libgfortran.h 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423
  1. /* Common declarations for all of libgfortran.
  2. Copyright (C) 2002-2015 Free Software Foundation, Inc.
  3. Contributed by Paul Brook <paul@nowt.org>, and
  4. Andy Vaught <andy@xena.eas.asu.edu>
  5. This file is part of the GNU Fortran runtime library (libgfortran).
  6. Libgfortran is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 3, or (at your option)
  9. any later version.
  10. Libgfortran is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. Under Section 7 of GPL version 3, you are granted additional
  15. permissions described in the GCC Runtime Library Exception, version
  16. 3.1, as published by the Free Software Foundation.
  17. You should have received a copy of the GNU General Public License and
  18. a copy of the GCC Runtime Library Exception along with this program;
  19. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  20. <http://www.gnu.org/licenses/>. */
  21. #ifndef LIBGFOR_H
  22. #define LIBGFOR_H
  23. /* Ensure that ANSI conform stdio is used. This needs to be set before
  24. any system header file is included. */
  25. #if defined __MINGW32__
  26. # define _POSIX 1
  27. # define gfc_printf gnu_printf
  28. #else
  29. # define gfc_printf __printf__
  30. #endif
  31. /* config.h MUST be first because it can affect system headers. */
  32. #include "config.h"
  33. #include <stdio.h>
  34. #include <stddef.h>
  35. #include <float.h>
  36. #include <stdarg.h>
  37. #include <stdbool.h>
  38. #if HAVE_COMPLEX_H
  39. /* Must appear before math.h on VMS systems. */
  40. # include <complex.h>
  41. #else
  42. #define complex __complex__
  43. #endif
  44. #include <math.h>
  45. /* If we're support quad-precision floating-point type, include the
  46. header to our support library. */
  47. #ifdef HAVE_FLOAT128
  48. # include "quadmath_weak.h"
  49. #endif
  50. #ifdef __MINGW32__
  51. extern float __strtof (const char *, char **);
  52. #define gfc_strtof __strtof
  53. extern double __strtod (const char *, char **);
  54. #define gfc_strtod __strtod
  55. extern long double __strtold (const char *, char **);
  56. #define gfc_strtold __strtold
  57. #else
  58. #define gfc_strtof strtof
  59. #define gfc_strtod strtod
  60. #define gfc_strtold strtold
  61. #endif
  62. #include "../gcc/fortran/libgfortran.h"
  63. #include "c99_protos.h"
  64. #if HAVE_IEEEFP_H
  65. #include <ieeefp.h>
  66. #endif
  67. #include "gstdint.h"
  68. #if HAVE_SYS_TYPES_H
  69. #include <sys/types.h>
  70. #endif
  71. #ifdef __MINGW32__
  72. typedef off64_t gfc_offset;
  73. #else
  74. typedef off_t gfc_offset;
  75. #endif
  76. #ifndef NULL
  77. #define NULL (void *) 0
  78. #endif
  79. /* The following macros can be used to annotate conditions which are likely or
  80. unlikely to be true. Avoid using them when a condition is only slightly
  81. more likely/less unlikely than average to avoid the performance penalties of
  82. branch misprediction. In addition, as __builtin_expect overrides the compiler
  83. heuristic, do not use in conditions where one of the branches ends with a
  84. call to a function with __attribute__((noreturn)): the compiler internal
  85. heuristic will mark this branch as much less likely as unlikely() would
  86. do. */
  87. #define likely(x) __builtin_expect(!!(x), 1)
  88. #define unlikely(x) __builtin_expect(!!(x), 0)
  89. /* Make sure we have ptrdiff_t. */
  90. #ifndef HAVE_PTRDIFF_T
  91. typedef intptr_t ptrdiff_t;
  92. #endif
  93. /* On mingw, work around the buggy Windows snprintf() by using the one
  94. mingw provides, __mingw_snprintf(). We also provide a prototype for
  95. __mingw_snprintf(), because the mingw headers currently don't have one. */
  96. #if HAVE_MINGW_SNPRINTF
  97. extern int __mingw_snprintf (char *, size_t, const char *, ...)
  98. __attribute__ ((format (gnu_printf, 3, 4)));
  99. #undef snprintf
  100. #define snprintf __mingw_snprintf
  101. /* Fallback to sprintf if target does not have snprintf. */
  102. #elif !defined(HAVE_SNPRINTF)
  103. #undef snprintf
  104. #define snprintf(str, size, ...) sprintf (str, __VA_ARGS__)
  105. #endif
  106. /* For a library, a standard prefix is a requirement in order to partition
  107. the namespace. IPREFIX is for symbols intended to be internal to the
  108. library. */
  109. #define PREFIX(x) _gfortran_ ## x
  110. #define IPREFIX(x) _gfortrani_ ## x
  111. /* Magic to rename a symbol at the compiler level. You continue to refer
  112. to the symbol as OLD in the source, but it'll be named NEW in the asm. */
  113. #define sym_rename(old, new) sym_rename1(old, __USER_LABEL_PREFIX__, new)
  114. #define sym_rename1(old, ulp, new) sym_rename2(old, ulp, new)
  115. #define sym_rename2(old, ulp, new) extern __typeof(old) old __asm__(#ulp #new)
  116. /* There are several classifications of routines:
  117. (1) Symbols used only within the library,
  118. (2) Symbols to be exported from the library,
  119. (3) Symbols to be exported from the library, but
  120. also used inside the library.
  121. By telling the compiler about these different classifications we can
  122. tightly control the interface seen by the user, and get better code
  123. from the compiler at the same time.
  124. One of the following should be used immediately after the declaration
  125. of each symbol:
  126. internal_proto Marks a symbol used only within the library,
  127. and adds IPREFIX to the assembly-level symbol
  128. name. The later is important for maintaining
  129. the namespace partition for the static library.
  130. export_proto Marks a symbol to be exported, and adds PREFIX
  131. to the assembly-level symbol name.
  132. export_proto_np Marks a symbol to be exported without adding PREFIX.
  133. iexport_proto Marks a function to be exported, but with the
  134. understanding that it can be used inside as well.
  135. iexport_data_proto Similarly, marks a data symbol to be exported.
  136. Unfortunately, some systems can't play the hidden
  137. symbol renaming trick on data symbols, thanks to
  138. the horribleness of COPY relocations.
  139. If iexport_proto or iexport_data_proto is used, you must also use
  140. iexport or iexport_data after the *definition* of the symbol. */
  141. #if defined(HAVE_ATTRIBUTE_VISIBILITY)
  142. # define internal_proto(x) \
  143. sym_rename(x, IPREFIX (x)) __attribute__((__visibility__("hidden")))
  144. #else
  145. # define internal_proto(x) sym_rename(x, IPREFIX(x))
  146. #endif
  147. #if defined(HAVE_ATTRIBUTE_VISIBILITY) && defined(HAVE_ATTRIBUTE_ALIAS)
  148. # define export_proto(x) sym_rename(x, PREFIX(x))
  149. # define export_proto_np(x) extern char swallow_semicolon
  150. # define iexport_proto(x) internal_proto(x)
  151. # define iexport(x) iexport1(x, IPREFIX(x))
  152. # define iexport1(x,y) iexport2(x,y)
  153. # define iexport2(x,y) \
  154. extern __typeof(x) PREFIX(x) __attribute__((__alias__(#y)))
  155. #else
  156. # define export_proto(x) sym_rename(x, PREFIX(x))
  157. # define export_proto_np(x) extern char swallow_semicolon
  158. # define iexport_proto(x) export_proto(x)
  159. # define iexport(x) extern char swallow_semicolon
  160. #endif
  161. /* TODO: detect the case when we *can* hide the symbol. */
  162. #define iexport_data_proto(x) export_proto(x)
  163. #define iexport_data(x) extern char swallow_semicolon
  164. /* The only reliable way to get the offset of a field in a struct
  165. in a system independent way is via this macro. */
  166. #ifndef offsetof
  167. #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER)
  168. #endif
  169. /* The C99 classification macros isfinite, isinf, isnan, isnormal
  170. and signbit are broken or inconsistent on quite a few targets.
  171. So, we use GCC's builtins instead.
  172. Another advantage for GCC's builtins for these type-generic macros
  173. is that it handles floating-point types that the system headers
  174. may not support (like __float128). */
  175. #undef isnan
  176. #define isnan(x) __builtin_isnan(x)
  177. #undef isfinite
  178. #define isfinite(x) __builtin_isfinite(x)
  179. #undef isinf
  180. #define isinf(x) __builtin_isinf(x)
  181. #undef isnormal
  182. #define isnormal(x) __builtin_isnormal(x)
  183. #undef signbit
  184. #define signbit(x) __builtin_signbit(x)
  185. #include "kinds.h"
  186. /* Define the type used for the current record number for large file I/O.
  187. The size must be consistent with the size defined on the compiler side. */
  188. #ifdef HAVE_GFC_INTEGER_8
  189. typedef GFC_INTEGER_8 GFC_IO_INT;
  190. #else
  191. #ifdef HAVE_GFC_INTEGER_4
  192. typedef GFC_INTEGER_4 GFC_IO_INT;
  193. #else
  194. #error "GFC_INTEGER_4 should be available for the library to compile".
  195. #endif
  196. #endif
  197. /* The following two definitions must be consistent with the types used
  198. by the compiler. */
  199. /* The type used of array indices, amongst other things. */
  200. typedef ptrdiff_t index_type;
  201. /* The type used for the lengths of character variables. */
  202. typedef GFC_INTEGER_4 gfc_charlen_type;
  203. /* Definitions of CHARACTER data types:
  204. - CHARACTER(KIND=1) corresponds to the C char type,
  205. - CHARACTER(KIND=4) corresponds to an unsigned 32-bit integer. */
  206. typedef GFC_UINTEGER_4 gfc_char4_t;
  207. /* Byte size of character kinds. For the kinds currently supported, it's
  208. simply equal to the kind parameter itself. */
  209. #define GFC_SIZE_OF_CHAR_KIND(kind) (kind)
  210. /* This will be 0 on little-endian machines and one on big-endian machines. */
  211. extern int big_endian;
  212. internal_proto(big_endian);
  213. #define GFOR_POINTER_TO_L1(p, kind) \
  214. (big_endian * (kind - 1) + (GFC_LOGICAL_1 *)(p))
  215. #define GFC_INTEGER_1_HUGE \
  216. (GFC_INTEGER_1)((((GFC_UINTEGER_1)1) << 7) - 1)
  217. #define GFC_INTEGER_2_HUGE \
  218. (GFC_INTEGER_2)((((GFC_UINTEGER_2)1) << 15) - 1)
  219. #define GFC_INTEGER_4_HUGE \
  220. (GFC_INTEGER_4)((((GFC_UINTEGER_4)1) << 31) - 1)
  221. #define GFC_INTEGER_8_HUGE \
  222. (GFC_INTEGER_8)((((GFC_UINTEGER_8)1) << 63) - 1)
  223. #ifdef HAVE_GFC_INTEGER_16
  224. #define GFC_INTEGER_16_HUGE \
  225. (GFC_INTEGER_16)((((GFC_UINTEGER_16)1) << 127) - 1)
  226. #endif
  227. /* M{IN,AX}{LOC,VAL} need also infinities and NaNs if supported. */
  228. #ifdef __FLT_HAS_INFINITY__
  229. # define GFC_REAL_4_INFINITY __builtin_inff ()
  230. #endif
  231. #ifdef __DBL_HAS_INFINITY__
  232. # define GFC_REAL_8_INFINITY __builtin_inf ()
  233. #endif
  234. #ifdef __LDBL_HAS_INFINITY__
  235. # ifdef HAVE_GFC_REAL_10
  236. # define GFC_REAL_10_INFINITY __builtin_infl ()
  237. # endif
  238. # ifdef HAVE_GFC_REAL_16
  239. # ifdef GFC_REAL_16_IS_LONG_DOUBLE
  240. # define GFC_REAL_16_INFINITY __builtin_infl ()
  241. # else
  242. # define GFC_REAL_16_INFINITY __builtin_infq ()
  243. # endif
  244. # endif
  245. #endif
  246. #ifdef __FLT_HAS_QUIET_NAN__
  247. # define GFC_REAL_4_QUIET_NAN __builtin_nanf ("")
  248. #endif
  249. #ifdef __DBL_HAS_QUIET_NAN__
  250. # define GFC_REAL_8_QUIET_NAN __builtin_nan ("")
  251. #endif
  252. #ifdef __LDBL_HAS_QUIET_NAN__
  253. # ifdef HAVE_GFC_REAL_10
  254. # define GFC_REAL_10_QUIET_NAN __builtin_nanl ("")
  255. # endif
  256. # ifdef HAVE_GFC_REAL_16
  257. # ifdef GFC_REAL_16_IS_LONG_DOUBLE
  258. # define GFC_REAL_16_QUIET_NAN __builtin_nanl ("")
  259. # else
  260. # define GFC_REAL_16_QUIET_NAN nanq ("")
  261. # endif
  262. # endif
  263. #endif
  264. typedef struct descriptor_dimension
  265. {
  266. index_type _stride;
  267. index_type lower_bound;
  268. index_type _ubound;
  269. }
  270. descriptor_dimension;
  271. #define GFC_ARRAY_DESCRIPTOR(r, type) \
  272. struct {\
  273. type *base_addr;\
  274. size_t offset;\
  275. index_type dtype;\
  276. descriptor_dimension dim[r];\
  277. }
  278. /* Commonly used array descriptor types. */
  279. typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, void) gfc_array_void;
  280. typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, char) gfc_array_char;
  281. typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_1) gfc_array_i1;
  282. typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_2) gfc_array_i2;
  283. typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_4) gfc_array_i4;
  284. typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_8) gfc_array_i8;
  285. #ifdef HAVE_GFC_INTEGER_16
  286. typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_16) gfc_array_i16;
  287. #endif
  288. typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_4) gfc_array_r4;
  289. typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_8) gfc_array_r8;
  290. #ifdef HAVE_GFC_REAL_10
  291. typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_10) gfc_array_r10;
  292. #endif
  293. #ifdef HAVE_GFC_REAL_16
  294. typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_16) gfc_array_r16;
  295. #endif
  296. typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_4) gfc_array_c4;
  297. typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_8) gfc_array_c8;
  298. #ifdef HAVE_GFC_COMPLEX_10
  299. typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_10) gfc_array_c10;
  300. #endif
  301. #ifdef HAVE_GFC_COMPLEX_16
  302. typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_16) gfc_array_c16;
  303. #endif
  304. typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_1) gfc_array_l1;
  305. typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_2) gfc_array_l2;
  306. typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_4) gfc_array_l4;
  307. typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_8) gfc_array_l8;
  308. #ifdef HAVE_GFC_LOGICAL_16
  309. typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_16) gfc_array_l16;
  310. #endif
  311. #define GFC_DESCRIPTOR_RANK(desc) ((desc)->dtype & GFC_DTYPE_RANK_MASK)
  312. #define GFC_DESCRIPTOR_TYPE(desc) (((desc)->dtype & GFC_DTYPE_TYPE_MASK) \
  313. >> GFC_DTYPE_TYPE_SHIFT)
  314. #define GFC_DESCRIPTOR_SIZE(desc) ((desc)->dtype >> GFC_DTYPE_SIZE_SHIFT)
  315. #define GFC_DESCRIPTOR_DATA(desc) ((desc)->base_addr)
  316. #define GFC_DESCRIPTOR_DTYPE(desc) ((desc)->dtype)
  317. #define GFC_DIMENSION_LBOUND(dim) ((dim).lower_bound)
  318. #define GFC_DIMENSION_UBOUND(dim) ((dim)._ubound)
  319. #define GFC_DIMENSION_STRIDE(dim) ((dim)._stride)
  320. #define GFC_DIMENSION_EXTENT(dim) ((dim)._ubound + 1 - (dim).lower_bound)
  321. #define GFC_DIMENSION_SET(dim,lb,ub,str) \
  322. do \
  323. { \
  324. (dim).lower_bound = lb; \
  325. (dim)._ubound = ub; \
  326. (dim)._stride = str; \
  327. } while (0)
  328. #define GFC_DESCRIPTOR_LBOUND(desc,i) ((desc)->dim[i].lower_bound)
  329. #define GFC_DESCRIPTOR_UBOUND(desc,i) ((desc)->dim[i]._ubound)
  330. #define GFC_DESCRIPTOR_EXTENT(desc,i) ((desc)->dim[i]._ubound + 1 \
  331. - (desc)->dim[i].lower_bound)
  332. #define GFC_DESCRIPTOR_EXTENT_BYTES(desc,i) \
  333. (GFC_DESCRIPTOR_EXTENT(desc,i) * GFC_DESCRIPTOR_SIZE(desc))
  334. #define GFC_DESCRIPTOR_STRIDE(desc,i) ((desc)->dim[i]._stride)
  335. #define GFC_DESCRIPTOR_STRIDE_BYTES(desc,i) \
  336. (GFC_DESCRIPTOR_STRIDE(desc,i) * GFC_DESCRIPTOR_SIZE(desc))
  337. /* Macros to get both the size and the type with a single masking operation */
  338. #define GFC_DTYPE_SIZE_MASK \
  339. ((~((index_type) 0) >> GFC_DTYPE_SIZE_SHIFT) << GFC_DTYPE_SIZE_SHIFT)
  340. #define GFC_DTYPE_TYPE_SIZE_MASK (GFC_DTYPE_SIZE_MASK | GFC_DTYPE_TYPE_MASK)
  341. #define GFC_DTYPE_TYPE_SIZE(desc) ((desc)->dtype & GFC_DTYPE_TYPE_SIZE_MASK)
  342. #define GFC_DTYPE_INTEGER_1 ((BT_INTEGER << GFC_DTYPE_TYPE_SHIFT) \
  343. | (sizeof(GFC_INTEGER_1) << GFC_DTYPE_SIZE_SHIFT))
  344. #define GFC_DTYPE_INTEGER_2 ((BT_INTEGER << GFC_DTYPE_TYPE_SHIFT) \
  345. | (sizeof(GFC_INTEGER_2) << GFC_DTYPE_SIZE_SHIFT))
  346. #define GFC_DTYPE_INTEGER_4 ((BT_INTEGER << GFC_DTYPE_TYPE_SHIFT) \
  347. | (sizeof(GFC_INTEGER_4) << GFC_DTYPE_SIZE_SHIFT))
  348. #define GFC_DTYPE_INTEGER_8 ((BT_INTEGER << GFC_DTYPE_TYPE_SHIFT) \
  349. | (sizeof(GFC_INTEGER_8) << GFC_DTYPE_SIZE_SHIFT))
  350. #ifdef HAVE_GFC_INTEGER_16
  351. #define GFC_DTYPE_INTEGER_16 ((BT_INTEGER << GFC_DTYPE_TYPE_SHIFT) \
  352. | (sizeof(GFC_INTEGER_16) << GFC_DTYPE_SIZE_SHIFT))
  353. #endif
  354. #define GFC_DTYPE_LOGICAL_1 ((BT_LOGICAL << GFC_DTYPE_TYPE_SHIFT) \
  355. | (sizeof(GFC_LOGICAL_1) << GFC_DTYPE_SIZE_SHIFT))
  356. #define GFC_DTYPE_LOGICAL_2 ((BT_LOGICAL << GFC_DTYPE_TYPE_SHIFT) \
  357. | (sizeof(GFC_LOGICAL_2) << GFC_DTYPE_SIZE_SHIFT))
  358. #define GFC_DTYPE_LOGICAL_4 ((BT_LOGICAL << GFC_DTYPE_TYPE_SHIFT) \
  359. | (sizeof(GFC_LOGICAL_4) << GFC_DTYPE_SIZE_SHIFT))
  360. #define GFC_DTYPE_LOGICAL_8 ((BT_LOGICAL << GFC_DTYPE_TYPE_SHIFT) \
  361. | (sizeof(GFC_LOGICAL_8) << GFC_DTYPE_SIZE_SHIFT))
  362. #ifdef HAVE_GFC_LOGICAL_16
  363. #define GFC_DTYPE_LOGICAL_16 ((BT_LOGICAL << GFC_DTYPE_TYPE_SHIFT) \
  364. | (sizeof(GFC_LOGICAL_16) << GFC_DTYPE_SIZE_SHIFT))
  365. #endif
  366. #define GFC_DTYPE_REAL_4 ((BT_REAL << GFC_DTYPE_TYPE_SHIFT) \
  367. | (sizeof(GFC_REAL_4) << GFC_DTYPE_SIZE_SHIFT))
  368. #define GFC_DTYPE_REAL_8 ((BT_REAL << GFC_DTYPE_TYPE_SHIFT) \
  369. | (sizeof(GFC_REAL_8) << GFC_DTYPE_SIZE_SHIFT))
  370. #ifdef HAVE_GFC_REAL_10
  371. #define GFC_DTYPE_REAL_10 ((BT_REAL << GFC_DTYPE_TYPE_SHIFT) \
  372. | (sizeof(GFC_REAL_10) << GFC_DTYPE_SIZE_SHIFT))
  373. #endif
  374. #ifdef HAVE_GFC_REAL_16
  375. #define GFC_DTYPE_REAL_16 ((BT_REAL << GFC_DTYPE_TYPE_SHIFT) \
  376. | (sizeof(GFC_REAL_16) << GFC_DTYPE_SIZE_SHIFT))
  377. #endif
  378. #define GFC_DTYPE_COMPLEX_4 ((BT_COMPLEX << GFC_DTYPE_TYPE_SHIFT) \
  379. | (sizeof(GFC_COMPLEX_4) << GFC_DTYPE_SIZE_SHIFT))
  380. #define GFC_DTYPE_COMPLEX_8 ((BT_COMPLEX << GFC_DTYPE_TYPE_SHIFT) \
  381. | (sizeof(GFC_COMPLEX_8) << GFC_DTYPE_SIZE_SHIFT))
  382. #ifdef HAVE_GFC_COMPLEX_10
  383. #define GFC_DTYPE_COMPLEX_10 ((BT_COMPLEX << GFC_DTYPE_TYPE_SHIFT) \
  384. | (sizeof(GFC_COMPLEX_10) << GFC_DTYPE_SIZE_SHIFT))
  385. #endif
  386. #ifdef HAVE_GFC_COMPLEX_16
  387. #define GFC_DTYPE_COMPLEX_16 ((BT_COMPLEX << GFC_DTYPE_TYPE_SHIFT) \
  388. | (sizeof(GFC_COMPLEX_16) << GFC_DTYPE_SIZE_SHIFT))
  389. #endif
  390. #define GFC_DTYPE_DERIVED_1 ((BT_DERIVED << GFC_DTYPE_TYPE_SHIFT) \
  391. | (sizeof(GFC_INTEGER_1) << GFC_DTYPE_SIZE_SHIFT))
  392. #define GFC_DTYPE_DERIVED_2 ((BT_DERIVED << GFC_DTYPE_TYPE_SHIFT) \
  393. | (sizeof(GFC_INTEGER_2) << GFC_DTYPE_SIZE_SHIFT))
  394. #define GFC_DTYPE_DERIVED_4 ((BT_DERIVED << GFC_DTYPE_TYPE_SHIFT) \
  395. | (sizeof(GFC_INTEGER_4) << GFC_DTYPE_SIZE_SHIFT))
  396. #define GFC_DTYPE_DERIVED_8 ((BT_DERIVED << GFC_DTYPE_TYPE_SHIFT) \
  397. | (sizeof(GFC_INTEGER_8) << GFC_DTYPE_SIZE_SHIFT))
  398. #ifdef HAVE_GFC_INTEGER_16
  399. #define GFC_DTYPE_DERIVED_16 ((BT_DERIVED << GFC_DTYPE_TYPE_SHIFT) \
  400. | (sizeof(GFC_INTEGER_16) << GFC_DTYPE_SIZE_SHIFT))
  401. #endif
  402. /* Macros to determine the alignment of pointers. */
  403. #define GFC_UNALIGNED_2(x) (((uintptr_t)(x)) & \
  404. (__alignof__(GFC_INTEGER_2) - 1))
  405. #define GFC_UNALIGNED_4(x) (((uintptr_t)(x)) & \
  406. (__alignof__(GFC_INTEGER_4) - 1))
  407. #define GFC_UNALIGNED_8(x) (((uintptr_t)(x)) & \
  408. (__alignof__(GFC_INTEGER_8) - 1))
  409. #ifdef HAVE_GFC_INTEGER_16
  410. #define GFC_UNALIGNED_16(x) (((uintptr_t)(x)) & \
  411. (__alignof__(GFC_INTEGER_16) - 1))
  412. #endif
  413. #define GFC_UNALIGNED_C4(x) (((uintptr_t)(x)) & \
  414. (__alignof__(GFC_COMPLEX_4) - 1))
  415. #define GFC_UNALIGNED_C8(x) (((uintptr_t)(x)) & \
  416. (__alignof__(GFC_COMPLEX_8) - 1))
  417. /* Runtime library include. */
  418. #define stringize(x) expand_macro(x)
  419. #define expand_macro(x) # x
  420. /* Runtime options structure. */
  421. typedef struct
  422. {
  423. int stdin_unit, stdout_unit, stderr_unit, optional_plus;
  424. int locus;
  425. int separator_len;
  426. const char *separator;
  427. int all_unbuffered, unbuffered_preconnected, default_recl;
  428. int fpe, backtrace;
  429. }
  430. options_t;
  431. extern options_t options;
  432. internal_proto(options);
  433. extern void backtrace_handler (int);
  434. internal_proto(backtrace_handler);
  435. /* Compile-time options that will influence the library. */
  436. typedef struct
  437. {
  438. int warn_std;
  439. int allow_std;
  440. int pedantic;
  441. int convert;
  442. int backtrace;
  443. int sign_zero;
  444. size_t record_marker;
  445. int max_subrecord_length;
  446. int bounds_check;
  447. int fpe_summary;
  448. }
  449. compile_options_t;
  450. extern compile_options_t compile_options;
  451. internal_proto(compile_options);
  452. extern void init_compile_options (void);
  453. internal_proto(init_compile_options);
  454. #define GFC_MAX_SUBRECORD_LENGTH 2147483639 /* 2**31 - 9 */
  455. /* Structure for statement options. */
  456. typedef struct
  457. {
  458. const char *name;
  459. int value;
  460. }
  461. st_option;
  462. /* This is returned by notification_std to know if, given the flags
  463. that were given (-std=, -pedantic) we should issue an error, a warning
  464. or nothing. */
  465. typedef enum
  466. { NOTIFICATION_SILENT, NOTIFICATION_WARNING, NOTIFICATION_ERROR }
  467. notification;
  468. /* The filename and line number don't go inside the globals structure.
  469. They are set by the rest of the program and must be linked to. */
  470. /* Location of the current library call (optional). */
  471. extern unsigned line;
  472. iexport_data_proto(line);
  473. extern char *filename;
  474. iexport_data_proto(filename);
  475. /* The default value of record length for preconnected units is defined
  476. here. This value can be overriden by an environment variable.
  477. Default value is 1 Gb. */
  478. #define DEFAULT_RECL 1073741824
  479. #define CHARACTER2(name) \
  480. gfc_charlen_type name ## _len; \
  481. char * name
  482. typedef struct st_parameter_common
  483. {
  484. GFC_INTEGER_4 flags;
  485. GFC_INTEGER_4 unit;
  486. const char *filename;
  487. GFC_INTEGER_4 line;
  488. CHARACTER2 (iomsg);
  489. GFC_INTEGER_4 *iostat;
  490. }
  491. st_parameter_common;
  492. #undef CHARACTER2
  493. #define IOPARM_LIBRETURN_MASK (3 << 0)
  494. #define IOPARM_LIBRETURN_OK (0 << 0)
  495. #define IOPARM_LIBRETURN_ERROR (1 << 0)
  496. #define IOPARM_LIBRETURN_END (2 << 0)
  497. #define IOPARM_LIBRETURN_EOR (3 << 0)
  498. #define IOPARM_ERR (1 << 2)
  499. #define IOPARM_END (1 << 3)
  500. #define IOPARM_EOR (1 << 4)
  501. #define IOPARM_HAS_IOSTAT (1 << 5)
  502. #define IOPARM_HAS_IOMSG (1 << 6)
  503. #define IOPARM_COMMON_MASK ((1 << 7) - 1)
  504. #define IOPARM_OPEN_HAS_RECL_IN (1 << 7)
  505. #define IOPARM_OPEN_HAS_FILE (1 << 8)
  506. #define IOPARM_OPEN_HAS_STATUS (1 << 9)
  507. #define IOPARM_OPEN_HAS_ACCESS (1 << 10)
  508. #define IOPARM_OPEN_HAS_FORM (1 << 11)
  509. #define IOPARM_OPEN_HAS_BLANK (1 << 12)
  510. #define IOPARM_OPEN_HAS_POSITION (1 << 13)
  511. #define IOPARM_OPEN_HAS_ACTION (1 << 14)
  512. #define IOPARM_OPEN_HAS_DELIM (1 << 15)
  513. #define IOPARM_OPEN_HAS_PAD (1 << 16)
  514. #define IOPARM_OPEN_HAS_CONVERT (1 << 17)
  515. #define IOPARM_OPEN_HAS_DECIMAL (1 << 18)
  516. #define IOPARM_OPEN_HAS_ENCODING (1 << 19)
  517. #define IOPARM_OPEN_HAS_ROUND (1 << 20)
  518. #define IOPARM_OPEN_HAS_SIGN (1 << 21)
  519. #define IOPARM_OPEN_HAS_ASYNCHRONOUS (1 << 22)
  520. #define IOPARM_OPEN_HAS_NEWUNIT (1 << 23)
  521. /* library start function and end macro. These can be expanded if needed
  522. in the future. cmp is st_parameter_common *cmp */
  523. extern void library_start (st_parameter_common *);
  524. internal_proto(library_start);
  525. #define library_end()
  526. /* main.c */
  527. extern void stupid_function_name_for_static_linking (void);
  528. internal_proto(stupid_function_name_for_static_linking);
  529. extern void set_args (int, char **);
  530. iexport_proto(set_args);
  531. extern void get_args (int *, char ***);
  532. internal_proto(get_args);
  533. extern void store_exe_path (const char *);
  534. export_proto(store_exe_path);
  535. extern char * full_exe_path (void);
  536. internal_proto(full_exe_path);
  537. extern void find_addr2line (void);
  538. internal_proto(find_addr2line);
  539. /* backtrace.c */
  540. extern void backtrace (void);
  541. iexport_proto(backtrace);
  542. /* error.c */
  543. #if defined(HAVE_GFC_REAL_16)
  544. #define GFC_LARGEST_BUF (sizeof (GFC_REAL_16))
  545. #elif defined(HAVE_GFC_INTEGER_16)
  546. #define GFC_LARGEST_BUF (sizeof (GFC_INTEGER_LARGEST))
  547. #elif defined(HAVE_GFC_REAL_10)
  548. #define GFC_LARGEST_BUF (sizeof (GFC_REAL_10))
  549. #else
  550. #define GFC_LARGEST_BUF (sizeof (GFC_INTEGER_LARGEST))
  551. #endif
  552. #define GFC_ITOA_BUF_SIZE (sizeof (GFC_INTEGER_LARGEST) * 3 + 2)
  553. #define GFC_XTOA_BUF_SIZE (GFC_LARGEST_BUF * 2 + 1)
  554. #define GFC_OTOA_BUF_SIZE (GFC_LARGEST_BUF * 3 + 1)
  555. #define GFC_BTOA_BUF_SIZE (GFC_LARGEST_BUF * 8 + 1)
  556. extern _Noreturn void sys_abort (void);
  557. internal_proto(sys_abort);
  558. extern ssize_t estr_write (const char *);
  559. internal_proto(estr_write);
  560. extern int st_vprintf (const char *, va_list);
  561. internal_proto(st_vprintf);
  562. extern int st_printf (const char *, ...)
  563. __attribute__((format (gfc_printf, 1, 2)));
  564. internal_proto(st_printf);
  565. extern const char *gfc_xtoa (GFC_UINTEGER_LARGEST, char *, size_t);
  566. internal_proto(gfc_xtoa);
  567. extern _Noreturn void os_error (const char *);
  568. iexport_proto(os_error);
  569. extern void show_locus (st_parameter_common *);
  570. internal_proto(show_locus);
  571. extern _Noreturn void runtime_error (const char *, ...)
  572. __attribute__ ((format (gfc_printf, 1, 2)));
  573. iexport_proto(runtime_error);
  574. extern _Noreturn void runtime_error_at (const char *, const char *, ...)
  575. __attribute__ ((format (gfc_printf, 2, 3)));
  576. iexport_proto(runtime_error_at);
  577. extern void runtime_warning_at (const char *, const char *, ...)
  578. __attribute__ ((format (gfc_printf, 2, 3)));
  579. iexport_proto(runtime_warning_at);
  580. extern _Noreturn void internal_error (st_parameter_common *, const char *);
  581. internal_proto(internal_error);
  582. extern const char *translate_error (int);
  583. internal_proto(translate_error);
  584. extern void generate_error (st_parameter_common *, int, const char *);
  585. iexport_proto(generate_error);
  586. extern void generate_warning (st_parameter_common *, const char *);
  587. internal_proto(generate_warning);
  588. extern bool notify_std (st_parameter_common *, int, const char *);
  589. internal_proto(notify_std);
  590. extern notification notification_std(int);
  591. internal_proto(notification_std);
  592. extern char *gf_strerror (int, char *, size_t);
  593. internal_proto(gf_strerror);
  594. /* fpu.c */
  595. extern void set_fpu (void);
  596. internal_proto(set_fpu);
  597. extern int get_fpu_trap_exceptions (void);
  598. internal_proto(get_fpu_trap_exceptions);
  599. extern void set_fpu_trap_exceptions (int, int);
  600. internal_proto(set_fpu_trap_exceptions);
  601. extern int support_fpu_trap (int);
  602. internal_proto(support_fpu_trap);
  603. extern int get_fpu_except_flags (void);
  604. internal_proto(get_fpu_except_flags);
  605. extern void set_fpu_except_flags (int, int);
  606. internal_proto(set_fpu_except_flags);
  607. extern int support_fpu_flag (int);
  608. internal_proto(support_fpu_flag);
  609. extern void set_fpu_rounding_mode (int);
  610. internal_proto(set_fpu_rounding_mode);
  611. extern int get_fpu_rounding_mode (void);
  612. internal_proto(get_fpu_rounding_mode);
  613. extern int support_fpu_rounding_mode (int);
  614. internal_proto(support_fpu_rounding_mode);
  615. extern void get_fpu_state (void *);
  616. internal_proto(get_fpu_state);
  617. extern void set_fpu_state (void *);
  618. internal_proto(set_fpu_state);
  619. extern int get_fpu_underflow_mode (void);
  620. internal_proto(get_fpu_underflow_mode);
  621. extern void set_fpu_underflow_mode (int);
  622. internal_proto(set_fpu_underflow_mode);
  623. extern int support_fpu_underflow_control (int);
  624. internal_proto(support_fpu_underflow_control);
  625. /* memory.c */
  626. extern void *xmalloc (size_t) __attribute__ ((malloc));
  627. internal_proto(xmalloc);
  628. extern void *xmallocarray (size_t, size_t) __attribute__ ((malloc));
  629. internal_proto(xmallocarray);
  630. extern void *xcalloc (size_t, size_t) __attribute__ ((malloc));
  631. internal_proto(xcalloc);
  632. extern void *xrealloc (void *, size_t);
  633. internal_proto(xrealloc);
  634. /* environ.c */
  635. extern int check_buffered (int);
  636. internal_proto(check_buffered);
  637. extern void init_variables (void);
  638. internal_proto(init_variables);
  639. extern void show_variables (void);
  640. internal_proto(show_variables);
  641. unit_convert get_unformatted_convert (int);
  642. internal_proto(get_unformatted_convert);
  643. /* Secure getenv() which returns NULL if running as SUID/SGID. */
  644. #ifndef HAVE_SECURE_GETENV
  645. #ifdef HAVE___SECURE_GETENV
  646. #define secure_getenv __secure_getenv
  647. #elif defined(HAVE_GETUID) && defined(HAVE_GETEUID) \
  648. && defined(HAVE_GETGID) && defined(HAVE_GETEGID)
  649. #define FALLBACK_SECURE_GETENV
  650. extern char *secure_getenv (const char *);
  651. internal_proto(secure_getenv);
  652. #else
  653. #define secure_getenv getenv
  654. #endif
  655. #endif
  656. /* string.c */
  657. extern int find_option (st_parameter_common *, const char *, gfc_charlen_type,
  658. const st_option *, const char *);
  659. internal_proto(find_option);
  660. extern gfc_charlen_type fstrlen (const char *, gfc_charlen_type);
  661. internal_proto(fstrlen);
  662. extern gfc_charlen_type fstrcpy (char *, gfc_charlen_type, const char *, gfc_charlen_type);
  663. internal_proto(fstrcpy);
  664. extern gfc_charlen_type cf_strcpy (char *, gfc_charlen_type, const char *);
  665. internal_proto(cf_strcpy);
  666. extern gfc_charlen_type string_len_trim (gfc_charlen_type, const char *);
  667. export_proto(string_len_trim);
  668. extern gfc_charlen_type string_len_trim_char4 (gfc_charlen_type,
  669. const gfc_char4_t *);
  670. export_proto(string_len_trim_char4);
  671. extern char *fc_strdup(const char *, gfc_charlen_type);
  672. internal_proto(fc_strdup);
  673. extern char *fc_strdup_notrim(const char *, gfc_charlen_type);
  674. internal_proto(fc_strdup_notrim);
  675. /* io/intrinsics.c */
  676. extern void flush_all_units (void);
  677. internal_proto(flush_all_units);
  678. /* io.c */
  679. extern void init_units (void);
  680. internal_proto(init_units);
  681. extern void close_units (void);
  682. internal_proto(close_units);
  683. extern int unit_to_fd (int);
  684. internal_proto(unit_to_fd);
  685. extern char * filename_from_unit (int);
  686. internal_proto(filename_from_unit);
  687. /* stop.c */
  688. extern _Noreturn void stop_string (const char *, GFC_INTEGER_4);
  689. export_proto(stop_string);
  690. /* reshape_packed.c */
  691. extern void reshape_packed (char *, index_type, const char *, index_type,
  692. const char *, index_type);
  693. internal_proto(reshape_packed);
  694. /* Repacking functions. These are called internally by internal_pack
  695. and internal_unpack. */
  696. GFC_INTEGER_1 *internal_pack_1 (gfc_array_i1 *);
  697. internal_proto(internal_pack_1);
  698. GFC_INTEGER_2 *internal_pack_2 (gfc_array_i2 *);
  699. internal_proto(internal_pack_2);
  700. GFC_INTEGER_4 *internal_pack_4 (gfc_array_i4 *);
  701. internal_proto(internal_pack_4);
  702. GFC_INTEGER_8 *internal_pack_8 (gfc_array_i8 *);
  703. internal_proto(internal_pack_8);
  704. #if defined HAVE_GFC_INTEGER_16
  705. GFC_INTEGER_16 *internal_pack_16 (gfc_array_i16 *);
  706. internal_proto(internal_pack_16);
  707. #endif
  708. GFC_REAL_4 *internal_pack_r4 (gfc_array_r4 *);
  709. internal_proto(internal_pack_r4);
  710. GFC_REAL_8 *internal_pack_r8 (gfc_array_r8 *);
  711. internal_proto(internal_pack_r8);
  712. #if defined HAVE_GFC_REAL_10
  713. GFC_REAL_10 *internal_pack_r10 (gfc_array_r10 *);
  714. internal_proto(internal_pack_r10);
  715. #endif
  716. #if defined HAVE_GFC_REAL_16
  717. GFC_REAL_16 *internal_pack_r16 (gfc_array_r16 *);
  718. internal_proto(internal_pack_r16);
  719. #endif
  720. GFC_COMPLEX_4 *internal_pack_c4 (gfc_array_c4 *);
  721. internal_proto(internal_pack_c4);
  722. GFC_COMPLEX_8 *internal_pack_c8 (gfc_array_c8 *);
  723. internal_proto(internal_pack_c8);
  724. #if defined HAVE_GFC_COMPLEX_10
  725. GFC_COMPLEX_10 *internal_pack_c10 (gfc_array_c10 *);
  726. internal_proto(internal_pack_c10);
  727. #endif
  728. #if defined HAVE_GFC_COMPLEX_16
  729. GFC_COMPLEX_16 *internal_pack_c16 (gfc_array_c16 *);
  730. internal_proto(internal_pack_c16);
  731. #endif
  732. extern void internal_unpack_1 (gfc_array_i1 *, const GFC_INTEGER_1 *);
  733. internal_proto(internal_unpack_1);
  734. extern void internal_unpack_2 (gfc_array_i2 *, const GFC_INTEGER_2 *);
  735. internal_proto(internal_unpack_2);
  736. extern void internal_unpack_4 (gfc_array_i4 *, const GFC_INTEGER_4 *);
  737. internal_proto(internal_unpack_4);
  738. extern void internal_unpack_8 (gfc_array_i8 *, const GFC_INTEGER_8 *);
  739. internal_proto(internal_unpack_8);
  740. #if defined HAVE_GFC_INTEGER_16
  741. extern void internal_unpack_16 (gfc_array_i16 *, const GFC_INTEGER_16 *);
  742. internal_proto(internal_unpack_16);
  743. #endif
  744. extern void internal_unpack_r4 (gfc_array_r4 *, const GFC_REAL_4 *);
  745. internal_proto(internal_unpack_r4);
  746. extern void internal_unpack_r8 (gfc_array_r8 *, const GFC_REAL_8 *);
  747. internal_proto(internal_unpack_r8);
  748. #if defined HAVE_GFC_REAL_10
  749. extern void internal_unpack_r10 (gfc_array_r10 *, const GFC_REAL_10 *);
  750. internal_proto(internal_unpack_r10);
  751. #endif
  752. #if defined HAVE_GFC_REAL_16
  753. extern void internal_unpack_r16 (gfc_array_r16 *, const GFC_REAL_16 *);
  754. internal_proto(internal_unpack_r16);
  755. #endif
  756. extern void internal_unpack_c4 (gfc_array_c4 *, const GFC_COMPLEX_4 *);
  757. internal_proto(internal_unpack_c4);
  758. extern void internal_unpack_c8 (gfc_array_c8 *, const GFC_COMPLEX_8 *);
  759. internal_proto(internal_unpack_c8);
  760. #if defined HAVE_GFC_COMPLEX_10
  761. extern void internal_unpack_c10 (gfc_array_c10 *, const GFC_COMPLEX_10 *);
  762. internal_proto(internal_unpack_c10);
  763. #endif
  764. #if defined HAVE_GFC_COMPLEX_16
  765. extern void internal_unpack_c16 (gfc_array_c16 *, const GFC_COMPLEX_16 *);
  766. internal_proto(internal_unpack_c16);
  767. #endif
  768. /* Internal auxiliary functions for the pack intrinsic. */
  769. extern void pack_i1 (gfc_array_i1 *, const gfc_array_i1 *,
  770. const gfc_array_l1 *, const gfc_array_i1 *);
  771. internal_proto(pack_i1);
  772. extern void pack_i2 (gfc_array_i2 *, const gfc_array_i2 *,
  773. const gfc_array_l1 *, const gfc_array_i2 *);
  774. internal_proto(pack_i2);
  775. extern void pack_i4 (gfc_array_i4 *, const gfc_array_i4 *,
  776. const gfc_array_l1 *, const gfc_array_i4 *);
  777. internal_proto(pack_i4);
  778. extern void pack_i8 (gfc_array_i8 *, const gfc_array_i8 *,
  779. const gfc_array_l1 *, const gfc_array_i8 *);
  780. internal_proto(pack_i8);
  781. #ifdef HAVE_GFC_INTEGER_16
  782. extern void pack_i16 (gfc_array_i16 *, const gfc_array_i16 *,
  783. const gfc_array_l1 *, const gfc_array_i16 *);
  784. internal_proto(pack_i16);
  785. #endif
  786. extern void pack_r4 (gfc_array_r4 *, const gfc_array_r4 *,
  787. const gfc_array_l1 *, const gfc_array_r4 *);
  788. internal_proto(pack_r4);
  789. extern void pack_r8 (gfc_array_r8 *, const gfc_array_r8 *,
  790. const gfc_array_l1 *, const gfc_array_r8 *);
  791. internal_proto(pack_r8);
  792. #ifdef HAVE_GFC_REAL_10
  793. extern void pack_r10 (gfc_array_r10 *, const gfc_array_r10 *,
  794. const gfc_array_l1 *, const gfc_array_r10 *);
  795. internal_proto(pack_r10);
  796. #endif
  797. #ifdef HAVE_GFC_REAL_16
  798. extern void pack_r16 (gfc_array_r16 *, const gfc_array_r16 *,
  799. const gfc_array_l1 *, const gfc_array_r16 *);
  800. internal_proto(pack_r16);
  801. #endif
  802. extern void pack_c4 (gfc_array_c4 *, const gfc_array_c4 *,
  803. const gfc_array_l1 *, const gfc_array_c4 *);
  804. internal_proto(pack_c4);
  805. extern void pack_c8 (gfc_array_c8 *, const gfc_array_c8 *,
  806. const gfc_array_l1 *, const gfc_array_c8 *);
  807. internal_proto(pack_c8);
  808. #ifdef HAVE_GFC_REAL_10
  809. extern void pack_c10 (gfc_array_c10 *, const gfc_array_c10 *,
  810. const gfc_array_l1 *, const gfc_array_c10 *);
  811. internal_proto(pack_c10);
  812. #endif
  813. #ifdef HAVE_GFC_REAL_16
  814. extern void pack_c16 (gfc_array_c16 *, const gfc_array_c16 *,
  815. const gfc_array_l1 *, const gfc_array_c16 *);
  816. internal_proto(pack_c16);
  817. #endif
  818. /* Internal auxiliary functions for the unpack intrinsic. */
  819. extern void unpack0_i1 (gfc_array_i1 *, const gfc_array_i1 *,
  820. const gfc_array_l1 *, const GFC_INTEGER_1 *);
  821. internal_proto(unpack0_i1);
  822. extern void unpack0_i2 (gfc_array_i2 *, const gfc_array_i2 *,
  823. const gfc_array_l1 *, const GFC_INTEGER_2 *);
  824. internal_proto(unpack0_i2);
  825. extern void unpack0_i4 (gfc_array_i4 *, const gfc_array_i4 *,
  826. const gfc_array_l1 *, const GFC_INTEGER_4 *);
  827. internal_proto(unpack0_i4);
  828. extern void unpack0_i8 (gfc_array_i8 *, const gfc_array_i8 *,
  829. const gfc_array_l1 *, const GFC_INTEGER_8 *);
  830. internal_proto(unpack0_i8);
  831. #ifdef HAVE_GFC_INTEGER_16
  832. extern void unpack0_i16 (gfc_array_i16 *, const gfc_array_i16 *,
  833. const gfc_array_l1 *, const GFC_INTEGER_16 *);
  834. internal_proto(unpack0_i16);
  835. #endif
  836. extern void unpack0_r4 (gfc_array_r4 *, const gfc_array_r4 *,
  837. const gfc_array_l1 *, const GFC_REAL_4 *);
  838. internal_proto(unpack0_r4);
  839. extern void unpack0_r8 (gfc_array_r8 *, const gfc_array_r8 *,
  840. const gfc_array_l1 *, const GFC_REAL_8 *);
  841. internal_proto(unpack0_r8);
  842. #ifdef HAVE_GFC_REAL_10
  843. extern void unpack0_r10 (gfc_array_r10 *, const gfc_array_r10 *,
  844. const gfc_array_l1 *, const GFC_REAL_10 *);
  845. internal_proto(unpack0_r10);
  846. #endif
  847. #ifdef HAVE_GFC_REAL_16
  848. extern void unpack0_r16 (gfc_array_r16 *, const gfc_array_r16 *,
  849. const gfc_array_l1 *, const GFC_REAL_16 *);
  850. internal_proto(unpack0_r16);
  851. #endif
  852. extern void unpack0_c4 (gfc_array_c4 *, const gfc_array_c4 *,
  853. const gfc_array_l1 *, const GFC_COMPLEX_4 *);
  854. internal_proto(unpack0_c4);
  855. extern void unpack0_c8 (gfc_array_c8 *, const gfc_array_c8 *,
  856. const gfc_array_l1 *, const GFC_COMPLEX_8 *);
  857. internal_proto(unpack0_c8);
  858. #ifdef HAVE_GFC_COMPLEX_10
  859. extern void unpack0_c10 (gfc_array_c10 *, const gfc_array_c10 *,
  860. const gfc_array_l1 *mask, const GFC_COMPLEX_10 *);
  861. internal_proto(unpack0_c10);
  862. #endif
  863. #ifdef HAVE_GFC_COMPLEX_16
  864. extern void unpack0_c16 (gfc_array_c16 *, const gfc_array_c16 *,
  865. const gfc_array_l1 *, const GFC_COMPLEX_16 *);
  866. internal_proto(unpack0_c16);
  867. #endif
  868. extern void unpack1_i1 (gfc_array_i1 *, const gfc_array_i1 *,
  869. const gfc_array_l1 *, const gfc_array_i1 *);
  870. internal_proto(unpack1_i1);
  871. extern void unpack1_i2 (gfc_array_i2 *, const gfc_array_i2 *,
  872. const gfc_array_l1 *, const gfc_array_i2 *);
  873. internal_proto(unpack1_i2);
  874. extern void unpack1_i4 (gfc_array_i4 *, const gfc_array_i4 *,
  875. const gfc_array_l1 *, const gfc_array_i4 *);
  876. internal_proto(unpack1_i4);
  877. extern void unpack1_i8 (gfc_array_i8 *, const gfc_array_i8 *,
  878. const gfc_array_l1 *, const gfc_array_i8 *);
  879. internal_proto(unpack1_i8);
  880. #ifdef HAVE_GFC_INTEGER_16
  881. extern void unpack1_i16 (gfc_array_i16 *, const gfc_array_i16 *,
  882. const gfc_array_l1 *, const gfc_array_i16 *);
  883. internal_proto(unpack1_i16);
  884. #endif
  885. extern void unpack1_r4 (gfc_array_r4 *, const gfc_array_r4 *,
  886. const gfc_array_l1 *, const gfc_array_r4 *);
  887. internal_proto(unpack1_r4);
  888. extern void unpack1_r8 (gfc_array_r8 *, const gfc_array_r8 *,
  889. const gfc_array_l1 *, const gfc_array_r8 *);
  890. internal_proto(unpack1_r8);
  891. #ifdef HAVE_GFC_REAL_10
  892. extern void unpack1_r10 (gfc_array_r10 *, const gfc_array_r10 *,
  893. const gfc_array_l1 *, const gfc_array_r10 *);
  894. internal_proto(unpack1_r10);
  895. #endif
  896. #ifdef HAVE_GFC_REAL_16
  897. extern void unpack1_r16 (gfc_array_r16 *, const gfc_array_r16 *,
  898. const gfc_array_l1 *, const gfc_array_r16 *);
  899. internal_proto(unpack1_r16);
  900. #endif
  901. extern void unpack1_c4 (gfc_array_c4 *, const gfc_array_c4 *,
  902. const gfc_array_l1 *, const gfc_array_c4 *);
  903. internal_proto(unpack1_c4);
  904. extern void unpack1_c8 (gfc_array_c8 *, const gfc_array_c8 *,
  905. const gfc_array_l1 *, const gfc_array_c8 *);
  906. internal_proto(unpack1_c8);
  907. #ifdef HAVE_GFC_COMPLEX_10
  908. extern void unpack1_c10 (gfc_array_c10 *, const gfc_array_c10 *,
  909. const gfc_array_l1 *, const gfc_array_c10 *);
  910. internal_proto(unpack1_c10);
  911. #endif
  912. #ifdef HAVE_GFC_COMPLEX_16
  913. extern void unpack1_c16 (gfc_array_c16 *, const gfc_array_c16 *,
  914. const gfc_array_l1 *, const gfc_array_c16 *);
  915. internal_proto(unpack1_c16);
  916. #endif
  917. /* Helper functions for spread. */
  918. extern void spread_i1 (gfc_array_i1 *, const gfc_array_i1 *,
  919. const index_type, const index_type);
  920. internal_proto(spread_i1);
  921. extern void spread_i2 (gfc_array_i2 *, const gfc_array_i2 *,
  922. const index_type, const index_type);
  923. internal_proto(spread_i2);
  924. extern void spread_i4 (gfc_array_i4 *, const gfc_array_i4 *,
  925. const index_type, const index_type);
  926. internal_proto(spread_i4);
  927. extern void spread_i8 (gfc_array_i8 *, const gfc_array_i8 *,
  928. const index_type, const index_type);
  929. internal_proto(spread_i8);
  930. #ifdef HAVE_GFC_INTEGER_16
  931. extern void spread_i16 (gfc_array_i16 *, const gfc_array_i16 *,
  932. const index_type, const index_type);
  933. internal_proto(spread_i16);
  934. #endif
  935. extern void spread_r4 (gfc_array_r4 *, const gfc_array_r4 *,
  936. const index_type, const index_type);
  937. internal_proto(spread_r4);
  938. extern void spread_r8 (gfc_array_r8 *, const gfc_array_r8 *,
  939. const index_type, const index_type);
  940. internal_proto(spread_r8);
  941. #ifdef HAVE_GFC_REAL_10
  942. extern void spread_r10 (gfc_array_r10 *, const gfc_array_r10 *,
  943. const index_type, const index_type);
  944. internal_proto(spread_r10);
  945. #endif
  946. #ifdef HAVE_GFC_REAL_16
  947. extern void spread_r16 (gfc_array_r16 *, const gfc_array_r16 *,
  948. const index_type, const index_type);
  949. internal_proto(spread_r16);
  950. #endif
  951. extern void spread_c4 (gfc_array_c4 *, const gfc_array_c4 *,
  952. const index_type, const index_type);
  953. internal_proto(spread_c4);
  954. extern void spread_c8 (gfc_array_c8 *, const gfc_array_c8 *,
  955. const index_type, const index_type);
  956. internal_proto(spread_c8);
  957. #ifdef HAVE_GFC_COMPLEX_10
  958. extern void spread_c10 (gfc_array_c10 *, const gfc_array_c10 *,
  959. const index_type, const index_type);
  960. internal_proto(spread_c10);
  961. #endif
  962. #ifdef HAVE_GFC_COMPLEX_16
  963. extern void spread_c16 (gfc_array_c16 *, const gfc_array_c16 *,
  964. const index_type, const index_type);
  965. internal_proto(spread_c16);
  966. #endif
  967. extern void spread_scalar_i1 (gfc_array_i1 *, const GFC_INTEGER_1 *,
  968. const index_type, const index_type);
  969. internal_proto(spread_scalar_i1);
  970. extern void spread_scalar_i2 (gfc_array_i2 *, const GFC_INTEGER_2 *,
  971. const index_type, const index_type);
  972. internal_proto(spread_scalar_i2);
  973. extern void spread_scalar_i4 (gfc_array_i4 *, const GFC_INTEGER_4 *,
  974. const index_type, const index_type);
  975. internal_proto(spread_scalar_i4);
  976. extern void spread_scalar_i8 (gfc_array_i8 *, const GFC_INTEGER_8 *,
  977. const index_type, const index_type);
  978. internal_proto(spread_scalar_i8);
  979. #ifdef HAVE_GFC_INTEGER_16
  980. extern void spread_scalar_i16 (gfc_array_i16 *, const GFC_INTEGER_16 *,
  981. const index_type, const index_type);
  982. internal_proto(spread_scalar_i16);
  983. #endif
  984. extern void spread_scalar_r4 (gfc_array_r4 *, const GFC_REAL_4 *,
  985. const index_type, const index_type);
  986. internal_proto(spread_scalar_r4);
  987. extern void spread_scalar_r8 (gfc_array_r8 *, const GFC_REAL_8 *,
  988. const index_type, const index_type);
  989. internal_proto(spread_scalar_r8);
  990. #ifdef HAVE_GFC_REAL_10
  991. extern void spread_scalar_r10 (gfc_array_r10 *, const GFC_REAL_10 *,
  992. const index_type, const index_type);
  993. internal_proto(spread_scalar_r10);
  994. #endif
  995. #ifdef HAVE_GFC_REAL_16
  996. extern void spread_scalar_r16 (gfc_array_r16 *, const GFC_REAL_16 *,
  997. const index_type, const index_type);
  998. internal_proto(spread_scalar_r16);
  999. #endif
  1000. extern void spread_scalar_c4 (gfc_array_c4 *, const GFC_COMPLEX_4 *,
  1001. const index_type, const index_type);
  1002. internal_proto(spread_scalar_c4);
  1003. extern void spread_scalar_c8 (gfc_array_c8 *, const GFC_COMPLEX_8 *,
  1004. const index_type, const index_type);
  1005. internal_proto(spread_scalar_c8);
  1006. #ifdef HAVE_GFC_COMPLEX_10
  1007. extern void spread_scalar_c10 (gfc_array_c10 *, const GFC_COMPLEX_10 *,
  1008. const index_type, const index_type);
  1009. internal_proto(spread_scalar_c10);
  1010. #endif
  1011. #ifdef HAVE_GFC_COMPLEX_16
  1012. extern void spread_scalar_c16 (gfc_array_c16 *, const GFC_COMPLEX_16 *,
  1013. const index_type, const index_type);
  1014. internal_proto(spread_scalar_c16);
  1015. #endif
  1016. /* string_intrinsics.c */
  1017. extern int compare_string (gfc_charlen_type, const char *,
  1018. gfc_charlen_type, const char *);
  1019. iexport_proto(compare_string);
  1020. extern int compare_string_char4 (gfc_charlen_type, const gfc_char4_t *,
  1021. gfc_charlen_type, const gfc_char4_t *);
  1022. iexport_proto(compare_string_char4);
  1023. extern int memcmp_char4 (const void *, const void *, size_t);
  1024. internal_proto(memcmp_char4);
  1025. /* random.c */
  1026. extern void random_seed_i4 (GFC_INTEGER_4 * size, gfc_array_i4 * put,
  1027. gfc_array_i4 * get);
  1028. iexport_proto(random_seed_i4);
  1029. extern void random_seed_i8 (GFC_INTEGER_8 * size, gfc_array_i8 * put,
  1030. gfc_array_i8 * get);
  1031. iexport_proto(random_seed_i8);
  1032. /* size.c */
  1033. typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, void) array_t;
  1034. extern index_type size0 (const array_t * array);
  1035. iexport_proto(size0);
  1036. /* bounds.c */
  1037. extern void bounds_equal_extents (array_t *, array_t *, const char *,
  1038. const char *);
  1039. internal_proto(bounds_equal_extents);
  1040. extern void bounds_reduced_extents (array_t *, array_t *, int, const char *,
  1041. const char *intrinsic);
  1042. internal_proto(bounds_reduced_extents);
  1043. extern void bounds_iforeach_return (array_t *, array_t *, const char *);
  1044. internal_proto(bounds_iforeach_return);
  1045. extern void bounds_ifunction_return (array_t *, const index_type *,
  1046. const char *, const char *);
  1047. internal_proto(bounds_ifunction_return);
  1048. extern index_type count_0 (const gfc_array_l1 *);
  1049. internal_proto(count_0);
  1050. /* Internal auxiliary functions for cshift */
  1051. void cshift0_i1 (gfc_array_i1 *, const gfc_array_i1 *, ptrdiff_t, int);
  1052. internal_proto(cshift0_i1);
  1053. void cshift0_i2 (gfc_array_i2 *, const gfc_array_i2 *, ptrdiff_t, int);
  1054. internal_proto(cshift0_i2);
  1055. void cshift0_i4 (gfc_array_i4 *, const gfc_array_i4 *, ptrdiff_t, int);
  1056. internal_proto(cshift0_i4);
  1057. void cshift0_i8 (gfc_array_i8 *, const gfc_array_i8 *, ptrdiff_t, int);
  1058. internal_proto(cshift0_i8);
  1059. #ifdef HAVE_GFC_INTEGER_16
  1060. void cshift0_i16 (gfc_array_i16 *, const gfc_array_i16 *, ptrdiff_t, int);
  1061. internal_proto(cshift0_i16);
  1062. #endif
  1063. void cshift0_r4 (gfc_array_r4 *, const gfc_array_r4 *, ptrdiff_t, int);
  1064. internal_proto(cshift0_r4);
  1065. void cshift0_r8 (gfc_array_r8 *, const gfc_array_r8 *, ptrdiff_t, int);
  1066. internal_proto(cshift0_r8);
  1067. #ifdef HAVE_GFC_REAL_10
  1068. void cshift0_r10 (gfc_array_r10 *, const gfc_array_r10 *, ptrdiff_t, int);
  1069. internal_proto(cshift0_r10);
  1070. #endif
  1071. #ifdef HAVE_GFC_REAL_16
  1072. void cshift0_r16 (gfc_array_r16 *, const gfc_array_r16 *, ptrdiff_t, int);
  1073. internal_proto(cshift0_r16);
  1074. #endif
  1075. void cshift0_c4 (gfc_array_c4 *, const gfc_array_c4 *, ptrdiff_t, int);
  1076. internal_proto(cshift0_c4);
  1077. void cshift0_c8 (gfc_array_c8 *, const gfc_array_c8 *, ptrdiff_t, int);
  1078. internal_proto(cshift0_c8);
  1079. #ifdef HAVE_GFC_COMPLEX_10
  1080. void cshift0_c10 (gfc_array_c10 *, const gfc_array_c10 *, ptrdiff_t, int);
  1081. internal_proto(cshift0_c10);
  1082. #endif
  1083. #ifdef HAVE_GFC_COMPLEX_16
  1084. void cshift0_c16 (gfc_array_c16 *, const gfc_array_c16 *, ptrdiff_t, int);
  1085. internal_proto(cshift0_c16);
  1086. #endif
  1087. #endif /* LIBGFOR_H */