pack_generic.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. /* Generic implementation of the PACK 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. /* PACK is specified as follows:
  23. 13.14.80 PACK (ARRAY, MASK, [VECTOR])
  24. Description: Pack an array into an array of rank one under the
  25. control of a mask.
  26. Class: Transformational function.
  27. Arguments:
  28. ARRAY may be of any type. It shall not be scalar.
  29. MASK shall be of type LOGICAL. It shall be conformable with ARRAY.
  30. VECTOR (optional) shall be of the same type and type parameters
  31. as ARRAY. VECTOR shall have at least as many elements as
  32. there are true elements in MASK. If MASK is a scalar
  33. with the value true, VECTOR shall have at least as many
  34. elements as there are in ARRAY.
  35. Result Characteristics: The result is an array of rank one with the
  36. same type and type parameters as ARRAY. If VECTOR is present, the
  37. result size is that of VECTOR; otherwise, the result size is the
  38. number /t/ of true elements in MASK unless MASK is scalar with the
  39. value true, in which case the result size is the size of ARRAY.
  40. Result Value: Element /i/ of the result is the element of ARRAY
  41. that corresponds to the /i/th true element of MASK, taking elements
  42. in array element order, for /i/ = 1, 2, ..., /t/. If VECTOR is
  43. present and has size /n/ > /t/, element /i/ of the result has the
  44. value VECTOR(/i/), for /i/ = /t/ + 1, ..., /n/.
  45. Examples: The nonzero elements of an array M with the value
  46. | 0 0 0 |
  47. | 9 0 0 | may be "gathered" by the function PACK. The result of
  48. | 0 0 7 |
  49. PACK (M, MASK = M.NE.0) is [9,7] and the result of PACK (M, M.NE.0,
  50. VECTOR = (/ 2,4,6,8,10,12 /)) is [9,7,6,8,10,12].
  51. There are two variants of the PACK intrinsic: one, where MASK is
  52. array valued, and the other one where MASK is scalar. */
  53. static void
  54. pack_internal (gfc_array_char *ret, const gfc_array_char *array,
  55. const gfc_array_l1 *mask, const gfc_array_char *vector,
  56. index_type size)
  57. {
  58. /* r.* indicates the return array. */
  59. index_type rstride0;
  60. char * restrict rptr;
  61. /* s.* indicates the source array. */
  62. index_type sstride[GFC_MAX_DIMENSIONS];
  63. index_type sstride0;
  64. const char *sptr;
  65. /* m.* indicates the mask array. */
  66. index_type mstride[GFC_MAX_DIMENSIONS];
  67. index_type mstride0;
  68. const GFC_LOGICAL_1 *mptr;
  69. index_type count[GFC_MAX_DIMENSIONS];
  70. index_type extent[GFC_MAX_DIMENSIONS];
  71. bool zero_sized;
  72. index_type n;
  73. index_type dim;
  74. index_type nelem;
  75. index_type total;
  76. int mask_kind;
  77. dim = GFC_DESCRIPTOR_RANK (array);
  78. sptr = array->base_addr;
  79. mptr = mask->base_addr;
  80. /* Use the same loop for all logical types, by using GFC_LOGICAL_1
  81. and using shifting to address size and endian issues. */
  82. mask_kind = GFC_DESCRIPTOR_SIZE (mask);
  83. if (mask_kind == 1 || mask_kind == 2 || mask_kind == 4 || mask_kind == 8
  84. #ifdef HAVE_GFC_LOGICAL_16
  85. || mask_kind == 16
  86. #endif
  87. )
  88. {
  89. /* Don't convert a NULL pointer as we use test for NULL below. */
  90. if (mptr)
  91. mptr = GFOR_POINTER_TO_L1 (mptr, mask_kind);
  92. }
  93. else
  94. runtime_error ("Funny sized logical array");
  95. zero_sized = false;
  96. for (n = 0; n < dim; n++)
  97. {
  98. count[n] = 0;
  99. extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
  100. if (extent[n] <= 0)
  101. zero_sized = true;
  102. sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n);
  103. mstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(mask,n);
  104. }
  105. if (sstride[0] == 0)
  106. sstride[0] = size;
  107. if (mstride[0] == 0)
  108. mstride[0] = mask_kind;
  109. if (zero_sized)
  110. sptr = NULL;
  111. else
  112. sptr = array->base_addr;
  113. if (ret->base_addr == NULL || unlikely (compile_options.bounds_check))
  114. {
  115. /* Count the elements, either for allocating memory or
  116. for bounds checking. */
  117. if (vector != NULL)
  118. {
  119. /* The return array will have as many
  120. elements as there are in VECTOR. */
  121. total = GFC_DESCRIPTOR_EXTENT(vector,0);
  122. }
  123. else
  124. {
  125. /* We have to count the true elements in MASK. */
  126. total = count_0 (mask);
  127. }
  128. if (ret->base_addr == NULL)
  129. {
  130. /* Setup the array descriptor. */
  131. GFC_DIMENSION_SET(ret->dim[0], 0, total-1, 1);
  132. ret->offset = 0;
  133. /* xmallocarray allocates a single byte for zero size. */
  134. ret->base_addr = xmallocarray (total, size);
  135. if (total == 0)
  136. return; /* In this case, nothing remains to be done. */
  137. }
  138. else
  139. {
  140. /* We come here because of range checking. */
  141. index_type ret_extent;
  142. ret_extent = GFC_DESCRIPTOR_EXTENT(ret,0);
  143. if (total != ret_extent)
  144. runtime_error ("Incorrect extent in return value of PACK intrinsic;"
  145. " is %ld, should be %ld", (long int) total,
  146. (long int) ret_extent);
  147. }
  148. }
  149. rstride0 = GFC_DESCRIPTOR_STRIDE_BYTES(ret,0);
  150. if (rstride0 == 0)
  151. rstride0 = size;
  152. sstride0 = sstride[0];
  153. mstride0 = mstride[0];
  154. rptr = ret->base_addr;
  155. while (sptr && mptr)
  156. {
  157. /* Test this element. */
  158. if (*mptr)
  159. {
  160. /* Add it. */
  161. memcpy (rptr, sptr, size);
  162. rptr += rstride0;
  163. }
  164. /* Advance to the next element. */
  165. sptr += sstride0;
  166. mptr += mstride0;
  167. count[0]++;
  168. n = 0;
  169. while (count[n] == extent[n])
  170. {
  171. /* When we get to the end of a dimension, reset it and increment
  172. the next dimension. */
  173. count[n] = 0;
  174. /* We could precalculate these products, but this is a less
  175. frequently used path so probably not worth it. */
  176. sptr -= sstride[n] * extent[n];
  177. mptr -= mstride[n] * extent[n];
  178. n++;
  179. if (n >= dim)
  180. {
  181. /* Break out of the loop. */
  182. sptr = NULL;
  183. break;
  184. }
  185. else
  186. {
  187. count[n]++;
  188. sptr += sstride[n];
  189. mptr += mstride[n];
  190. }
  191. }
  192. }
  193. /* Add any remaining elements from VECTOR. */
  194. if (vector)
  195. {
  196. n = GFC_DESCRIPTOR_EXTENT(vector,0);
  197. nelem = ((rptr - ret->base_addr) / rstride0);
  198. if (n > nelem)
  199. {
  200. sstride0 = GFC_DESCRIPTOR_STRIDE_BYTES(vector,0);
  201. if (sstride0 == 0)
  202. sstride0 = size;
  203. sptr = vector->base_addr + sstride0 * nelem;
  204. n -= nelem;
  205. while (n--)
  206. {
  207. memcpy (rptr, sptr, size);
  208. rptr += rstride0;
  209. sptr += sstride0;
  210. }
  211. }
  212. }
  213. }
  214. extern void pack (gfc_array_char *, const gfc_array_char *,
  215. const gfc_array_l1 *, const gfc_array_char *);
  216. export_proto(pack);
  217. void
  218. pack (gfc_array_char *ret, const gfc_array_char *array,
  219. const gfc_array_l1 *mask, const gfc_array_char *vector)
  220. {
  221. index_type type_size;
  222. index_type size;
  223. type_size = GFC_DTYPE_TYPE_SIZE(array);
  224. switch(type_size)
  225. {
  226. case GFC_DTYPE_LOGICAL_1:
  227. case GFC_DTYPE_INTEGER_1:
  228. pack_i1 ((gfc_array_i1 *) ret, (gfc_array_i1 *) array,
  229. (gfc_array_l1 *) mask, (gfc_array_i1 *) vector);
  230. return;
  231. case GFC_DTYPE_LOGICAL_2:
  232. case GFC_DTYPE_INTEGER_2:
  233. pack_i2 ((gfc_array_i2 *) ret, (gfc_array_i2 *) array,
  234. (gfc_array_l1 *) mask, (gfc_array_i2 *) vector);
  235. return;
  236. case GFC_DTYPE_LOGICAL_4:
  237. case GFC_DTYPE_INTEGER_4:
  238. pack_i4 ((gfc_array_i4 *) ret, (gfc_array_i4 *) array,
  239. (gfc_array_l1 *) mask, (gfc_array_i4 *) vector);
  240. return;
  241. case GFC_DTYPE_LOGICAL_8:
  242. case GFC_DTYPE_INTEGER_8:
  243. pack_i8 ((gfc_array_i8 *) ret, (gfc_array_i8 *) array,
  244. (gfc_array_l1 *) mask, (gfc_array_i8 *) vector);
  245. return;
  246. #ifdef HAVE_GFC_INTEGER_16
  247. case GFC_DTYPE_LOGICAL_16:
  248. case GFC_DTYPE_INTEGER_16:
  249. pack_i16 ((gfc_array_i16 *) ret, (gfc_array_i16 *) array,
  250. (gfc_array_l1 *) mask, (gfc_array_i16 *) vector);
  251. return;
  252. #endif
  253. case GFC_DTYPE_REAL_4:
  254. pack_r4 ((gfc_array_r4 *) ret, (gfc_array_r4 *) array,
  255. (gfc_array_l1 *) mask, (gfc_array_r4 *) vector);
  256. return;
  257. case GFC_DTYPE_REAL_8:
  258. pack_r8 ((gfc_array_r8 *) ret, (gfc_array_r8 *) array,
  259. (gfc_array_l1 *) mask, (gfc_array_r8 *) vector);
  260. return;
  261. /* FIXME: This here is a hack, which will have to be removed when
  262. the array descriptor is reworked. Currently, we don't store the
  263. kind value for the type, but only the size. Because on targets with
  264. __float128, we have sizeof(logn double) == sizeof(__float128),
  265. we cannot discriminate here and have to fall back to the generic
  266. handling (which is suboptimal). */
  267. #if !defined(GFC_REAL_16_IS_FLOAT128)
  268. # ifdef HAVE_GFC_REAL_10
  269. case GFC_DTYPE_REAL_10:
  270. pack_r10 ((gfc_array_r10 *) ret, (gfc_array_r10 *) array,
  271. (gfc_array_l1 *) mask, (gfc_array_r10 *) vector);
  272. return;
  273. # endif
  274. # ifdef HAVE_GFC_REAL_16
  275. case GFC_DTYPE_REAL_16:
  276. pack_r16 ((gfc_array_r16 *) ret, (gfc_array_r16 *) array,
  277. (gfc_array_l1 *) mask, (gfc_array_r16 *) vector);
  278. return;
  279. # endif
  280. #endif
  281. case GFC_DTYPE_COMPLEX_4:
  282. pack_c4 ((gfc_array_c4 *) ret, (gfc_array_c4 *) array,
  283. (gfc_array_l1 *) mask, (gfc_array_c4 *) vector);
  284. return;
  285. case GFC_DTYPE_COMPLEX_8:
  286. pack_c8 ((gfc_array_c8 *) ret, (gfc_array_c8 *) array,
  287. (gfc_array_l1 *) mask, (gfc_array_c8 *) vector);
  288. return;
  289. /* FIXME: This here is a hack, which will have to be removed when
  290. the array descriptor is reworked. Currently, we don't store the
  291. kind value for the type, but only the size. Because on targets with
  292. __float128, we have sizeof(logn double) == sizeof(__float128),
  293. we cannot discriminate here and have to fall back to the generic
  294. handling (which is suboptimal). */
  295. #if !defined(GFC_REAL_16_IS_FLOAT128)
  296. # ifdef HAVE_GFC_COMPLEX_10
  297. case GFC_DTYPE_COMPLEX_10:
  298. pack_c10 ((gfc_array_c10 *) ret, (gfc_array_c10 *) array,
  299. (gfc_array_l1 *) mask, (gfc_array_c10 *) vector);
  300. return;
  301. # endif
  302. # ifdef HAVE_GFC_COMPLEX_16
  303. case GFC_DTYPE_COMPLEX_16:
  304. pack_c16 ((gfc_array_c16 *) ret, (gfc_array_c16 *) array,
  305. (gfc_array_l1 *) mask, (gfc_array_c16 *) vector);
  306. return;
  307. # endif
  308. #endif
  309. }
  310. /* For other types, let's check the actual alignment of the data pointers.
  311. If they are aligned, we can safely call the unpack functions. */
  312. switch (GFC_DESCRIPTOR_SIZE (array))
  313. {
  314. case 1:
  315. pack_i1 ((gfc_array_i1 *) ret, (gfc_array_i1 *) array,
  316. (gfc_array_l1 *) mask, (gfc_array_i1 *) vector);
  317. return;
  318. case 2:
  319. if (GFC_UNALIGNED_2(ret->base_addr) || GFC_UNALIGNED_2(array->base_addr)
  320. || (vector && GFC_UNALIGNED_2(vector->base_addr)))
  321. break;
  322. else
  323. {
  324. pack_i2 ((gfc_array_i2 *) ret, (gfc_array_i2 *) array,
  325. (gfc_array_l1 *) mask, (gfc_array_i2 *) vector);
  326. return;
  327. }
  328. case 4:
  329. if (GFC_UNALIGNED_4(ret->base_addr) || GFC_UNALIGNED_4(array->base_addr)
  330. || (vector && GFC_UNALIGNED_4(vector->base_addr)))
  331. break;
  332. else
  333. {
  334. pack_i4 ((gfc_array_i4 *) ret, (gfc_array_i4 *) array,
  335. (gfc_array_l1 *) mask, (gfc_array_i4 *) vector);
  336. return;
  337. }
  338. case 8:
  339. if (GFC_UNALIGNED_8(ret->base_addr) || GFC_UNALIGNED_8(array->base_addr)
  340. || (vector && GFC_UNALIGNED_8(vector->base_addr)))
  341. break;
  342. else
  343. {
  344. pack_i8 ((gfc_array_i8 *) ret, (gfc_array_i8 *) array,
  345. (gfc_array_l1 *) mask, (gfc_array_i8 *) vector);
  346. return;
  347. }
  348. #ifdef HAVE_GFC_INTEGER_16
  349. case 16:
  350. if (GFC_UNALIGNED_16(ret->base_addr) || GFC_UNALIGNED_16(array->base_addr)
  351. || (vector && GFC_UNALIGNED_16(vector->base_addr)))
  352. break;
  353. else
  354. {
  355. pack_i16 ((gfc_array_i16 *) ret, (gfc_array_i16 *) array,
  356. (gfc_array_l1 *) mask, (gfc_array_i16 *) vector);
  357. return;
  358. }
  359. #endif
  360. default:
  361. break;
  362. }
  363. size = GFC_DESCRIPTOR_SIZE (array);
  364. pack_internal (ret, array, mask, vector, size);
  365. }
  366. extern void pack_char (gfc_array_char *, GFC_INTEGER_4, const gfc_array_char *,
  367. const gfc_array_l1 *, const gfc_array_char *,
  368. GFC_INTEGER_4, GFC_INTEGER_4);
  369. export_proto(pack_char);
  370. void
  371. pack_char (gfc_array_char *ret,
  372. GFC_INTEGER_4 ret_length __attribute__((unused)),
  373. const gfc_array_char *array, const gfc_array_l1 *mask,
  374. const gfc_array_char *vector, GFC_INTEGER_4 array_length,
  375. GFC_INTEGER_4 vector_length __attribute__((unused)))
  376. {
  377. pack_internal (ret, array, mask, vector, array_length);
  378. }
  379. extern void pack_char4 (gfc_array_char *, GFC_INTEGER_4, const gfc_array_char *,
  380. const gfc_array_l1 *, const gfc_array_char *,
  381. GFC_INTEGER_4, GFC_INTEGER_4);
  382. export_proto(pack_char4);
  383. void
  384. pack_char4 (gfc_array_char *ret,
  385. GFC_INTEGER_4 ret_length __attribute__((unused)),
  386. const gfc_array_char *array, const gfc_array_l1 *mask,
  387. const gfc_array_char *vector, GFC_INTEGER_4 array_length,
  388. GFC_INTEGER_4 vector_length __attribute__((unused)))
  389. {
  390. pack_internal (ret, array, mask, vector, array_length * sizeof (gfc_char4_t));
  391. }
  392. static void
  393. pack_s_internal (gfc_array_char *ret, const gfc_array_char *array,
  394. const GFC_LOGICAL_4 *mask, const gfc_array_char *vector,
  395. index_type size)
  396. {
  397. /* r.* indicates the return array. */
  398. index_type rstride0;
  399. char *rptr;
  400. /* s.* indicates the source array. */
  401. index_type sstride[GFC_MAX_DIMENSIONS];
  402. index_type sstride0;
  403. const char *sptr;
  404. index_type count[GFC_MAX_DIMENSIONS];
  405. index_type extent[GFC_MAX_DIMENSIONS];
  406. index_type n;
  407. index_type dim;
  408. index_type ssize;
  409. index_type nelem;
  410. index_type total;
  411. dim = GFC_DESCRIPTOR_RANK (array);
  412. /* Initialize sstride[0] to avoid -Wmaybe-uninitialized
  413. complaints. */
  414. sstride[0] = size;
  415. ssize = 1;
  416. for (n = 0; n < dim; n++)
  417. {
  418. count[n] = 0;
  419. extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
  420. if (extent[n] < 0)
  421. extent[n] = 0;
  422. sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n);
  423. ssize *= extent[n];
  424. }
  425. if (sstride[0] == 0)
  426. sstride[0] = size;
  427. sstride0 = sstride[0];
  428. if (ssize != 0)
  429. sptr = array->base_addr;
  430. else
  431. sptr = NULL;
  432. if (ret->base_addr == NULL)
  433. {
  434. /* Allocate the memory for the result. */
  435. if (vector != NULL)
  436. {
  437. /* The return array will have as many elements as there are
  438. in vector. */
  439. total = GFC_DESCRIPTOR_EXTENT(vector,0);
  440. if (total <= 0)
  441. {
  442. total = 0;
  443. vector = NULL;
  444. }
  445. }
  446. else
  447. {
  448. if (*mask)
  449. {
  450. /* The result array will have as many elements as the input
  451. array. */
  452. total = extent[0];
  453. for (n = 1; n < dim; n++)
  454. total *= extent[n];
  455. }
  456. else
  457. /* The result array will be empty. */
  458. total = 0;
  459. }
  460. /* Setup the array descriptor. */
  461. GFC_DIMENSION_SET(ret->dim[0],0,total-1,1);
  462. ret->offset = 0;
  463. ret->base_addr = xmallocarray (total, size);
  464. if (total == 0)
  465. return;
  466. }
  467. rstride0 = GFC_DESCRIPTOR_STRIDE_BYTES(ret,0);
  468. if (rstride0 == 0)
  469. rstride0 = size;
  470. rptr = ret->base_addr;
  471. /* The remaining possibilities are now:
  472. If MASK is .TRUE., we have to copy the source array into the
  473. result array. We then have to fill it up with elements from VECTOR.
  474. If MASK is .FALSE., we have to copy VECTOR into the result
  475. array. If VECTOR were not present we would have already returned. */
  476. if (*mask && ssize != 0)
  477. {
  478. while (sptr)
  479. {
  480. /* Add this element. */
  481. memcpy (rptr, sptr, size);
  482. rptr += rstride0;
  483. /* Advance to the next element. */
  484. sptr += sstride0;
  485. count[0]++;
  486. n = 0;
  487. while (count[n] == extent[n])
  488. {
  489. /* When we get to the end of a dimension, reset it and
  490. increment the next dimension. */
  491. count[n] = 0;
  492. /* We could precalculate these products, but this is a
  493. less frequently used path so probably not worth it. */
  494. sptr -= sstride[n] * extent[n];
  495. n++;
  496. if (n >= dim)
  497. {
  498. /* Break out of the loop. */
  499. sptr = NULL;
  500. break;
  501. }
  502. else
  503. {
  504. count[n]++;
  505. sptr += sstride[n];
  506. }
  507. }
  508. }
  509. }
  510. /* Add any remaining elements from VECTOR. */
  511. if (vector)
  512. {
  513. n = GFC_DESCRIPTOR_EXTENT(vector,0);
  514. nelem = ((rptr - ret->base_addr) / rstride0);
  515. if (n > nelem)
  516. {
  517. sstride0 = GFC_DESCRIPTOR_STRIDE_BYTES(vector,0);
  518. if (sstride0 == 0)
  519. sstride0 = size;
  520. sptr = vector->base_addr + sstride0 * nelem;
  521. n -= nelem;
  522. while (n--)
  523. {
  524. memcpy (rptr, sptr, size);
  525. rptr += rstride0;
  526. sptr += sstride0;
  527. }
  528. }
  529. }
  530. }
  531. extern void pack_s (gfc_array_char *ret, const gfc_array_char *array,
  532. const GFC_LOGICAL_4 *, const gfc_array_char *);
  533. export_proto(pack_s);
  534. void
  535. pack_s (gfc_array_char *ret, const gfc_array_char *array,
  536. const GFC_LOGICAL_4 *mask, const gfc_array_char *vector)
  537. {
  538. pack_s_internal (ret, array, mask, vector, GFC_DESCRIPTOR_SIZE (array));
  539. }
  540. extern void pack_s_char (gfc_array_char *ret, GFC_INTEGER_4,
  541. const gfc_array_char *array, const GFC_LOGICAL_4 *,
  542. const gfc_array_char *, GFC_INTEGER_4,
  543. GFC_INTEGER_4);
  544. export_proto(pack_s_char);
  545. void
  546. pack_s_char (gfc_array_char *ret,
  547. GFC_INTEGER_4 ret_length __attribute__((unused)),
  548. const gfc_array_char *array, const GFC_LOGICAL_4 *mask,
  549. const gfc_array_char *vector, GFC_INTEGER_4 array_length,
  550. GFC_INTEGER_4 vector_length __attribute__((unused)))
  551. {
  552. pack_s_internal (ret, array, mask, vector, array_length);
  553. }
  554. extern void pack_s_char4 (gfc_array_char *ret, GFC_INTEGER_4,
  555. const gfc_array_char *array, const GFC_LOGICAL_4 *,
  556. const gfc_array_char *, GFC_INTEGER_4,
  557. GFC_INTEGER_4);
  558. export_proto(pack_s_char4);
  559. void
  560. pack_s_char4 (gfc_array_char *ret,
  561. GFC_INTEGER_4 ret_length __attribute__((unused)),
  562. const gfc_array_char *array, const GFC_LOGICAL_4 *mask,
  563. const gfc_array_char *vector, GFC_INTEGER_4 array_length,
  564. GFC_INTEGER_4 vector_length __attribute__((unused)))
  565. {
  566. pack_s_internal (ret, array, mask, vector,
  567. array_length * sizeof (gfc_char4_t));
  568. }