spread_generic.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. /* Generic implementation of the SPREAD intrinsic
  2. Copyright (C) 2002-2022 Free Software Foundation, Inc.
  3. Contributed by Paul Brook <paul@nowt.org>
  4. This file is part of the GNU Fortran runtime library (libgfortran).
  5. Libgfortran is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public
  7. License as published by the Free Software Foundation; either
  8. version 3 of the License, or (at your option) any later version.
  9. Ligbfortran is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. Under Section 7 of GPL version 3, you are granted additional
  14. permissions described in the GCC Runtime Library Exception, version
  15. 3.1, as published by the Free Software Foundation.
  16. You should have received a copy of the GNU General Public License and
  17. a copy of the GCC Runtime Library Exception along with this program;
  18. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  19. <http://www.gnu.org/licenses/>. */
  20. #include "libgfortran.h"
  21. #include <string.h>
  22. static void
  23. spread_internal (gfc_array_char *ret, const gfc_array_char *source,
  24. const index_type *along, const index_type *pncopies)
  25. {
  26. /* r.* indicates the return array. */
  27. index_type rstride[GFC_MAX_DIMENSIONS];
  28. index_type rstride0;
  29. index_type rdelta = 0;
  30. index_type rrank;
  31. index_type rs;
  32. char *rptr;
  33. char *dest;
  34. /* s.* indicates the source array. */
  35. index_type sstride[GFC_MAX_DIMENSIONS];
  36. index_type sstride0;
  37. index_type srank;
  38. const char *sptr;
  39. index_type count[GFC_MAX_DIMENSIONS];
  40. index_type extent[GFC_MAX_DIMENSIONS];
  41. index_type n;
  42. index_type dim;
  43. index_type ncopies;
  44. index_type size;
  45. size = GFC_DESCRIPTOR_SIZE(source);
  46. srank = GFC_DESCRIPTOR_RANK(source);
  47. rrank = srank + 1;
  48. if (rrank > GFC_MAX_DIMENSIONS)
  49. runtime_error ("return rank too large in spread()");
  50. if (*along > rrank)
  51. runtime_error ("dim outside of rank in spread()");
  52. ncopies = *pncopies;
  53. if (ret->base_addr == NULL)
  54. {
  55. /* The front end has signalled that we need to populate the
  56. return array descriptor. */
  57. size_t ub, stride;
  58. ret->dtype.rank = rrank;
  59. dim = 0;
  60. rs = 1;
  61. for (n = 0; n < rrank; n++)
  62. {
  63. stride = rs;
  64. if (n == *along - 1)
  65. {
  66. ub = ncopies - 1;
  67. rdelta = rs * size;
  68. rs *= ncopies;
  69. }
  70. else
  71. {
  72. count[dim] = 0;
  73. extent[dim] = GFC_DESCRIPTOR_EXTENT(source,dim);
  74. sstride[dim] = GFC_DESCRIPTOR_STRIDE_BYTES(source,dim);
  75. rstride[dim] = rs * size;
  76. ub = extent[dim]-1;
  77. rs *= extent[dim];
  78. dim++;
  79. }
  80. GFC_DIMENSION_SET(ret->dim[n], 0, ub, stride);
  81. }
  82. ret->offset = 0;
  83. ret->base_addr = xmallocarray (rs, size);
  84. if (rs <= 0)
  85. return;
  86. }
  87. else
  88. {
  89. int zero_sized;
  90. zero_sized = 0;
  91. dim = 0;
  92. if (GFC_DESCRIPTOR_RANK(ret) != rrank)
  93. runtime_error ("rank mismatch in spread()");
  94. if (compile_options.bounds_check)
  95. {
  96. for (n = 0; n < rrank; n++)
  97. {
  98. index_type ret_extent;
  99. ret_extent = GFC_DESCRIPTOR_EXTENT(ret,n);
  100. if (n == *along - 1)
  101. {
  102. rdelta = GFC_DESCRIPTOR_STRIDE_BYTES(ret,n);
  103. if (ret_extent != ncopies)
  104. runtime_error("Incorrect extent in return value of SPREAD"
  105. " intrinsic in dimension %ld: is %ld,"
  106. " should be %ld", (long int) n+1,
  107. (long int) ret_extent, (long int) ncopies);
  108. }
  109. else
  110. {
  111. count[dim] = 0;
  112. extent[dim] = GFC_DESCRIPTOR_EXTENT(source,dim);
  113. if (ret_extent != extent[dim])
  114. runtime_error("Incorrect extent in return value of SPREAD"
  115. " intrinsic in dimension %ld: is %ld,"
  116. " should be %ld", (long int) n+1,
  117. (long int) ret_extent,
  118. (long int) extent[dim]);
  119. if (extent[dim] <= 0)
  120. zero_sized = 1;
  121. sstride[dim] = GFC_DESCRIPTOR_STRIDE_BYTES(source,dim);
  122. rstride[dim] = GFC_DESCRIPTOR_STRIDE_BYTES(ret,n);
  123. dim++;
  124. }
  125. }
  126. }
  127. else
  128. {
  129. for (n = 0; n < rrank; n++)
  130. {
  131. if (n == *along - 1)
  132. {
  133. rdelta = GFC_DESCRIPTOR_STRIDE_BYTES(ret,n);
  134. }
  135. else
  136. {
  137. count[dim] = 0;
  138. extent[dim] = GFC_DESCRIPTOR_EXTENT(source,dim);
  139. if (extent[dim] <= 0)
  140. zero_sized = 1;
  141. sstride[dim] = GFC_DESCRIPTOR_STRIDE_BYTES(source,dim);
  142. rstride[dim] = GFC_DESCRIPTOR_STRIDE_BYTES(ret,n);
  143. dim++;
  144. }
  145. }
  146. }
  147. if (zero_sized)
  148. return;
  149. if (sstride[0] == 0)
  150. sstride[0] = size;
  151. }
  152. sstride0 = sstride[0];
  153. rstride0 = rstride[0];
  154. rptr = ret->base_addr;
  155. sptr = source->base_addr;
  156. while (sptr)
  157. {
  158. /* Spread this element. */
  159. dest = rptr;
  160. for (n = 0; n < ncopies; n++)
  161. {
  162. memcpy (dest, sptr, size);
  163. dest += rdelta;
  164. }
  165. /* Advance to the next element. */
  166. sptr += sstride0;
  167. rptr += rstride0;
  168. count[0]++;
  169. n = 0;
  170. while (count[n] == extent[n])
  171. {
  172. /* When we get to the end of a dimension, reset it and increment
  173. the next dimension. */
  174. count[n] = 0;
  175. /* We could precalculate these products, but this is a less
  176. frequently used path so probably not worth it. */
  177. sptr -= sstride[n] * extent[n];
  178. rptr -= rstride[n] * extent[n];
  179. n++;
  180. if (n >= srank)
  181. {
  182. /* Break out of the loop. */
  183. sptr = NULL;
  184. break;
  185. }
  186. else
  187. {
  188. count[n]++;
  189. sptr += sstride[n];
  190. rptr += rstride[n];
  191. }
  192. }
  193. }
  194. }
  195. /* This version of spread_internal treats the special case of a scalar
  196. source. This is much simpler than the more general case above. */
  197. static void
  198. spread_internal_scalar (gfc_array_char *ret, const char *source,
  199. const index_type *along, const index_type *pncopies)
  200. {
  201. int n;
  202. int ncopies = *pncopies;
  203. char * dest;
  204. size_t size;
  205. size = GFC_DESCRIPTOR_SIZE(ret);
  206. if (GFC_DESCRIPTOR_RANK (ret) != 1)
  207. runtime_error ("incorrect destination rank in spread()");
  208. if (*along > 1)
  209. runtime_error ("dim outside of rank in spread()");
  210. if (ret->base_addr == NULL)
  211. {
  212. ret->base_addr = xmallocarray (ncopies, size);
  213. ret->offset = 0;
  214. GFC_DIMENSION_SET(ret->dim[0], 0, ncopies - 1, 1);
  215. }
  216. else
  217. {
  218. if (ncopies - 1 > (GFC_DESCRIPTOR_EXTENT(ret,0) - 1)
  219. / GFC_DESCRIPTOR_STRIDE(ret,0))
  220. runtime_error ("dim too large in spread()");
  221. }
  222. for (n = 0; n < ncopies; n++)
  223. {
  224. dest = (char*)(ret->base_addr + n * GFC_DESCRIPTOR_STRIDE_BYTES(ret,0));
  225. memcpy (dest , source, size);
  226. }
  227. }
  228. extern void spread (gfc_array_char *, const gfc_array_char *,
  229. const index_type *, const index_type *);
  230. export_proto(spread);
  231. void
  232. spread (gfc_array_char *ret, const gfc_array_char *source,
  233. const index_type *along, const index_type *pncopies)
  234. {
  235. index_type type_size;
  236. type_size = GFC_DTYPE_TYPE_SIZE(ret);
  237. switch(type_size)
  238. {
  239. case GFC_DTYPE_LOGICAL_1:
  240. case GFC_DTYPE_INTEGER_1:
  241. spread_i1 ((gfc_array_i1 *) ret, (gfc_array_i1 *) source,
  242. *along, *pncopies);
  243. return;
  244. case GFC_DTYPE_LOGICAL_2:
  245. case GFC_DTYPE_INTEGER_2:
  246. spread_i2 ((gfc_array_i2 *) ret, (gfc_array_i2 *) source,
  247. *along, *pncopies);
  248. return;
  249. case GFC_DTYPE_LOGICAL_4:
  250. case GFC_DTYPE_INTEGER_4:
  251. spread_i4 ((gfc_array_i4 *) ret, (gfc_array_i4 *) source,
  252. *along, *pncopies);
  253. return;
  254. case GFC_DTYPE_LOGICAL_8:
  255. case GFC_DTYPE_INTEGER_8:
  256. spread_i8 ((gfc_array_i8 *) ret, (gfc_array_i8 *) source,
  257. *along, *pncopies);
  258. return;
  259. #ifdef HAVE_GFC_INTEGER_16
  260. case GFC_DTYPE_LOGICAL_16:
  261. case GFC_DTYPE_INTEGER_16:
  262. spread_i16 ((gfc_array_i16 *) ret, (gfc_array_i16 *) source,
  263. *along, *pncopies);
  264. return;
  265. #endif
  266. case GFC_DTYPE_REAL_4:
  267. spread_r4 ((gfc_array_r4 *) ret, (gfc_array_r4 *) source,
  268. *along, *pncopies);
  269. return;
  270. case GFC_DTYPE_REAL_8:
  271. spread_r8 ((gfc_array_r8 *) ret, (gfc_array_r8 *) source,
  272. *along, *pncopies);
  273. return;
  274. /* FIXME: This here is a hack, which will have to be removed when
  275. the array descriptor is reworked. Currently, we don't store the
  276. kind value for the type, but only the size. Because on targets with
  277. __float128, we have sizeof(logn double) == sizeof(__float128),
  278. we cannot discriminate here and have to fall back to the generic
  279. handling (which is suboptimal). */
  280. #if !defined(GFC_REAL_16_IS_FLOAT128)
  281. # ifdef GFC_HAVE_REAL_10
  282. case GFC_DTYPE_REAL_10:
  283. spread_r10 ((gfc_array_r10 *) ret, (gfc_array_r10 *) source,
  284. *along, *pncopies);
  285. return;
  286. # endif
  287. # ifdef GFC_HAVE_REAL_16
  288. case GFC_DTYPE_REAL_16:
  289. spread_r16 ((gfc_array_r16 *) ret, (gfc_array_r16 *) source,
  290. *along, *pncopies);
  291. return;
  292. # endif
  293. #endif
  294. case GFC_DTYPE_COMPLEX_4:
  295. spread_c4 ((gfc_array_c4 *) ret, (gfc_array_c4 *) source,
  296. *along, *pncopies);
  297. return;
  298. case GFC_DTYPE_COMPLEX_8:
  299. spread_c8 ((gfc_array_c8 *) ret, (gfc_array_c8 *) source,
  300. *along, *pncopies);
  301. return;
  302. /* FIXME: This here is a hack, which will have to be removed when
  303. the array descriptor is reworked. Currently, we don't store the
  304. kind value for the type, but only the size. Because on targets with
  305. __float128, we have sizeof(logn double) == sizeof(__float128),
  306. we cannot discriminate here and have to fall back to the generic
  307. handling (which is suboptimal). */
  308. #if !defined(GFC_REAL_16_IS_FLOAT128)
  309. # ifdef GFC_HAVE_COMPLEX_10
  310. case GFC_DTYPE_COMPLEX_10:
  311. spread_c10 ((gfc_array_c10 *) ret, (gfc_array_c10 *) source,
  312. *along, *pncopies);
  313. return;
  314. # endif
  315. # ifdef GFC_HAVE_COMPLEX_16
  316. case GFC_DTYPE_COMPLEX_16:
  317. spread_c16 ((gfc_array_c16 *) ret, (gfc_array_c16 *) source,
  318. *along, *pncopies);
  319. return;
  320. # endif
  321. #endif
  322. }
  323. switch (GFC_DESCRIPTOR_SIZE (ret))
  324. {
  325. case 1:
  326. spread_i1 ((gfc_array_i1 *) ret, (gfc_array_i1 *) source,
  327. *along, *pncopies);
  328. return;
  329. case 2:
  330. if (GFC_UNALIGNED_2(ret->base_addr) || GFC_UNALIGNED_2(source->base_addr))
  331. break;
  332. else
  333. {
  334. spread_i2 ((gfc_array_i2 *) ret, (gfc_array_i2 *) source,
  335. *along, *pncopies);
  336. return;
  337. }
  338. case 4:
  339. if (GFC_UNALIGNED_4(ret->base_addr) || GFC_UNALIGNED_4(source->base_addr))
  340. break;
  341. else
  342. {
  343. spread_i4 ((gfc_array_i4 *) ret, (gfc_array_i4 *) source,
  344. *along, *pncopies);
  345. return;
  346. }
  347. case 8:
  348. if (GFC_UNALIGNED_8(ret->base_addr) || GFC_UNALIGNED_8(source->base_addr))
  349. break;
  350. else
  351. {
  352. spread_i8 ((gfc_array_i8 *) ret, (gfc_array_i8 *) source,
  353. *along, *pncopies);
  354. return;
  355. }
  356. #ifdef HAVE_GFC_INTEGER_16
  357. case 16:
  358. if (GFC_UNALIGNED_16(ret->base_addr)
  359. || GFC_UNALIGNED_16(source->base_addr))
  360. break;
  361. else
  362. {
  363. spread_i16 ((gfc_array_i16 *) ret, (gfc_array_i16 *) source,
  364. *along, *pncopies);
  365. return;
  366. }
  367. #endif
  368. }
  369. spread_internal (ret, source, along, pncopies);
  370. }
  371. extern void spread_char (gfc_array_char *, GFC_INTEGER_4,
  372. const gfc_array_char *, const index_type *,
  373. const index_type *, GFC_INTEGER_4);
  374. export_proto(spread_char);
  375. void
  376. spread_char (gfc_array_char *ret,
  377. GFC_INTEGER_4 ret_length __attribute__((unused)),
  378. const gfc_array_char *source, const index_type *along,
  379. const index_type *pncopies,
  380. GFC_INTEGER_4 source_length __attribute__((unused)))
  381. {
  382. spread_internal (ret, source, along, pncopies);
  383. }
  384. extern void spread_char4 (gfc_array_char *, GFC_INTEGER_4,
  385. const gfc_array_char *, const index_type *,
  386. const index_type *, GFC_INTEGER_4);
  387. export_proto(spread_char4);
  388. void
  389. spread_char4 (gfc_array_char *ret,
  390. GFC_INTEGER_4 ret_length __attribute__((unused)),
  391. const gfc_array_char *source, const index_type *along,
  392. const index_type *pncopies,
  393. GFC_INTEGER_4 source_length __attribute__((unused)))
  394. {
  395. spread_internal (ret, source, along, pncopies);
  396. }
  397. /* The following are the prototypes for the versions of spread with a
  398. scalar source. */
  399. extern void spread_scalar (gfc_array_char *, const char *,
  400. const index_type *, const index_type *);
  401. export_proto(spread_scalar);
  402. void
  403. spread_scalar (gfc_array_char *ret, const char *source,
  404. const index_type *along, const index_type *pncopies)
  405. {
  406. index_type type_size;
  407. if (GFC_DTYPE_IS_UNSET(ret))
  408. runtime_error ("return array missing descriptor in spread()");
  409. type_size = GFC_DTYPE_TYPE_SIZE(ret);
  410. switch(type_size)
  411. {
  412. case GFC_DTYPE_LOGICAL_1:
  413. case GFC_DTYPE_INTEGER_1:
  414. spread_scalar_i1 ((gfc_array_i1 *) ret, (GFC_INTEGER_1 *) source,
  415. *along, *pncopies);
  416. return;
  417. case GFC_DTYPE_LOGICAL_2:
  418. case GFC_DTYPE_INTEGER_2:
  419. spread_scalar_i2 ((gfc_array_i2 *) ret, (GFC_INTEGER_2 *) source,
  420. *along, *pncopies);
  421. return;
  422. case GFC_DTYPE_LOGICAL_4:
  423. case GFC_DTYPE_INTEGER_4:
  424. spread_scalar_i4 ((gfc_array_i4 *) ret, (GFC_INTEGER_4 *) source,
  425. *along, *pncopies);
  426. return;
  427. case GFC_DTYPE_LOGICAL_8:
  428. case GFC_DTYPE_INTEGER_8:
  429. spread_scalar_i8 ((gfc_array_i8 *) ret, (GFC_INTEGER_8 *) source,
  430. *along, *pncopies);
  431. return;
  432. #ifdef HAVE_GFC_INTEGER_16
  433. case GFC_DTYPE_LOGICAL_16:
  434. case GFC_DTYPE_INTEGER_16:
  435. spread_scalar_i16 ((gfc_array_i16 *) ret, (GFC_INTEGER_16 *) source,
  436. *along, *pncopies);
  437. return;
  438. #endif
  439. case GFC_DTYPE_REAL_4:
  440. spread_scalar_r4 ((gfc_array_r4 *) ret, (GFC_REAL_4 *) source,
  441. *along, *pncopies);
  442. return;
  443. case GFC_DTYPE_REAL_8:
  444. spread_scalar_r8 ((gfc_array_r8 *) ret, (GFC_REAL_8 *) source,
  445. *along, *pncopies);
  446. return;
  447. /* FIXME: This here is a hack, which will have to be removed when
  448. the array descriptor is reworked. Currently, we don't store the
  449. kind value for the type, but only the size. Because on targets with
  450. __float128, we have sizeof(logn double) == sizeof(__float128),
  451. we cannot discriminate here and have to fall back to the generic
  452. handling (which is suboptimal). */
  453. #if !defined(GFC_REAL_16_IS_FLOAT128)
  454. # ifdef HAVE_GFC_REAL_10
  455. case GFC_DTYPE_REAL_10:
  456. spread_scalar_r10 ((gfc_array_r10 *) ret, (GFC_REAL_10 *) source,
  457. *along, *pncopies);
  458. return;
  459. # endif
  460. # ifdef HAVE_GFC_REAL_16
  461. case GFC_DTYPE_REAL_16:
  462. spread_scalar_r16 ((gfc_array_r16 *) ret, (GFC_REAL_16 *) source,
  463. *along, *pncopies);
  464. return;
  465. # endif
  466. #endif
  467. case GFC_DTYPE_COMPLEX_4:
  468. spread_scalar_c4 ((gfc_array_c4 *) ret, (GFC_COMPLEX_4 *) source,
  469. *along, *pncopies);
  470. return;
  471. case GFC_DTYPE_COMPLEX_8:
  472. spread_scalar_c8 ((gfc_array_c8 *) ret, (GFC_COMPLEX_8 *) source,
  473. *along, *pncopies);
  474. return;
  475. /* FIXME: This here is a hack, which will have to be removed when
  476. the array descriptor is reworked. Currently, we don't store the
  477. kind value for the type, but only the size. Because on targets with
  478. __float128, we have sizeof(logn double) == sizeof(__float128),
  479. we cannot discriminate here and have to fall back to the generic
  480. handling (which is suboptimal). */
  481. #if !defined(GFC_REAL_16_IS_FLOAT128)
  482. # ifdef HAVE_GFC_COMPLEX_10
  483. case GFC_DTYPE_COMPLEX_10:
  484. spread_scalar_c10 ((gfc_array_c10 *) ret, (GFC_COMPLEX_10 *) source,
  485. *along, *pncopies);
  486. return;
  487. # endif
  488. # ifdef HAVE_GFC_COMPLEX_16
  489. case GFC_DTYPE_COMPLEX_16:
  490. spread_scalar_c16 ((gfc_array_c16 *) ret, (GFC_COMPLEX_16 *) source,
  491. *along, *pncopies);
  492. return;
  493. # endif
  494. #endif
  495. }
  496. switch (GFC_DESCRIPTOR_SIZE(ret))
  497. {
  498. case 1:
  499. spread_scalar_i1 ((gfc_array_i1 *) ret, (GFC_INTEGER_1 *) source,
  500. *along, *pncopies);
  501. return;
  502. case 2:
  503. if (GFC_UNALIGNED_2(ret->base_addr) || GFC_UNALIGNED_2(source))
  504. break;
  505. else
  506. {
  507. spread_scalar_i2 ((gfc_array_i2 *) ret, (GFC_INTEGER_2 *) source,
  508. *along, *pncopies);
  509. return;
  510. }
  511. case 4:
  512. if (GFC_UNALIGNED_4(ret->base_addr) || GFC_UNALIGNED_4(source))
  513. break;
  514. else
  515. {
  516. spread_scalar_i4 ((gfc_array_i4 *) ret, (GFC_INTEGER_4 *) source,
  517. *along, *pncopies);
  518. return;
  519. }
  520. case 8:
  521. if (GFC_UNALIGNED_8(ret->base_addr) || GFC_UNALIGNED_8(source))
  522. break;
  523. else
  524. {
  525. spread_scalar_i8 ((gfc_array_i8 *) ret, (GFC_INTEGER_8 *) source,
  526. *along, *pncopies);
  527. return;
  528. }
  529. #ifdef HAVE_GFC_INTEGER_16
  530. case 16:
  531. if (GFC_UNALIGNED_16(ret->base_addr) || GFC_UNALIGNED_16(source))
  532. break;
  533. else
  534. {
  535. spread_scalar_i16 ((gfc_array_i16 *) ret, (GFC_INTEGER_16 *) source,
  536. *along, *pncopies);
  537. return;
  538. }
  539. #endif
  540. default:
  541. break;
  542. }
  543. spread_internal_scalar (ret, source, along, pncopies);
  544. }
  545. extern void spread_char_scalar (gfc_array_char *, GFC_INTEGER_4,
  546. const char *, const index_type *,
  547. const index_type *, GFC_INTEGER_4);
  548. export_proto(spread_char_scalar);
  549. void
  550. spread_char_scalar (gfc_array_char *ret,
  551. GFC_INTEGER_4 ret_length __attribute__((unused)),
  552. const char *source, const index_type *along,
  553. const index_type *pncopies,
  554. GFC_INTEGER_4 source_length __attribute__((unused)))
  555. {
  556. if (GFC_DTYPE_IS_UNSET(ret))
  557. runtime_error ("return array missing descriptor in spread()");
  558. spread_internal_scalar (ret, source, along, pncopies);
  559. }
  560. extern void spread_char4_scalar (gfc_array_char *, GFC_INTEGER_4,
  561. const char *, const index_type *,
  562. const index_type *, GFC_INTEGER_4);
  563. export_proto(spread_char4_scalar);
  564. void
  565. spread_char4_scalar (gfc_array_char *ret,
  566. GFC_INTEGER_4 ret_length __attribute__((unused)),
  567. const char *source, const index_type *along,
  568. const index_type *pncopies,
  569. GFC_INTEGER_4 source_length __attribute__((unused)))
  570. {
  571. if (GFC_DTYPE_IS_UNSET(ret))
  572. runtime_error ("return array missing descriptor in spread()");
  573. spread_internal_scalar (ret, source, along, pncopies);
  574. }