/resources/smarteiffel-germ/compile_to_c.h

http://github.com/tybor/Liberty · C Header · 19784 lines · 19203 code · 99 blank · 482 comment · 113 complexity · dfed47b14d35501b06183c52b4ae3d17 MD5 · raw file

Large files are truncated click here to view the full file

  1. #ifdef __cplusplus
  2. extern "C" {
  3. #endif
  4. /*
  5. ANSI C code generated by
  6. Liberty Eiffel The GNU Eiffel Compiler, Eiffel tools and libraries
  7. release 2016.05 (Alexander Graham Bell)
  8. Copyright (C), 2011-2016 - C.ADRIAN, P.REDAELLI, R.MACK
  9. http://www.liberty-eiffel.org
  10. Original SmartEiffel code:
  11. Copyright (C), 1994-2002 - INRIA - LORIA - ESIAL UHP Nancy 1 - FRANCE
  12. Copyright (C), 2003-2005 - INRIA - LORIA - IUT Charlemagne Nancy 2 - FRANCE
  13. D.COLNET, P.RIBET, C.ADRIAN, V.CROIZIER, F.MERIZEN
  14. http://smarteiffel.loria.fr
  15. C Compiler options used: -pipe -O2
  16. */
  17. /*
  18. -- ------------------------------------------------------------------------------------------------------------
  19. -- Copyright notice below. Please read.
  20. --
  21. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  22. -- Copyright(C) 2003-2005: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  23. --
  24. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  25. --
  26. -- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
  27. -- documentation files (the "Software"), to deal in the Software without restriction, including without
  28. -- limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  29. -- the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
  30. -- conditions:
  31. --
  32. -- The above copyright notice and this permission notice shall be included in all copies or substantial
  33. -- portions of the Software.
  34. --
  35. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
  36. -- LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
  37. -- EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  38. -- AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
  39. -- OR OTHER DEALINGS IN THE SOFTWARE.
  40. --
  41. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  42. -- ------------------------------------------------------------------------------------------------------------
  43. */
  44. /*
  45. This file (Liberty/sys/runtime/base.h) contains all basic Eiffel
  46. type definitions.
  47. This file is automatically included in the header for all modes of
  48. compilation: -boost, -no_check, -require_check, -ensure_check, ...
  49. This file is also included in the header of any cecil file (when the
  50. -cecil option is used).
  51. This file is also included in the header file of C++ wrappers (when
  52. using the external "C++" clause).
  53. */
  54. #ifndef _BASE_H
  55. #define _BASE_H
  56. #if defined(_MSC_VER) && (_MSC_VER >= 1400) /* VC8+ */
  57. # ifndef _CRT_SECURE_NO_DEPRECATE
  58. # define _CRT_SECURE_NO_DEPRECATE
  59. # endif
  60. # ifndef _CRT_NONSTDC_NO_DEPRECATE
  61. # define _CRT_NONSTDC_NO_DEPRECATE
  62. # endif
  63. #endif /* VC8+ */
  64. #include <stdio.h>
  65. #include <string.h>
  66. #include <math.h>
  67. #include <stdlib.h>
  68. #include <signal.h>
  69. #include <stddef.h>
  70. #include <stdarg.h>
  71. #include <limits.h>
  72. #include <float.h>
  73. #include <setjmp.h>
  74. #include <sys/types.h>
  75. #include <sys/stat.h>
  76. #include <fcntl.h>
  77. #if defined __USE_POSIX || defined __unix__ || defined _POSIX_C_SOURCE
  78. # include <unistd.h>
  79. #endif
  80. #if !defined(WIN32) && \
  81. (defined(WINVER) || defined(_WIN32_WINNT) || defined(_WIN32) || \
  82. defined(__WIN32__) || defined(__TOS_WIN__) || defined(_MSC_VER))
  83. # define WIN32 1
  84. #endif
  85. #ifdef WIN32
  86. # include <windows.h>
  87. #endif
  88. #ifdef SE_THREAD
  89. #ifdef WIN32
  90. # define TLS(type) __declspec(thread) type
  91. #else
  92. # ifndef O_RDONLY
  93. # include <sys/file.h>
  94. # endif
  95. # ifndef O_RDONLY
  96. # define O_RDONLY 0000
  97. # endif
  98. # define TLS(type) __thread type
  99. #endif
  100. #else
  101. #define TLS(type) type
  102. #endif
  103. #if defined(_MSC_VER) && (_MSC_VER < 1600) /* MSVC older than v10 */
  104. typedef signed char int8_t;
  105. typedef signed short int16_t;
  106. typedef signed int int32_t;
  107. typedef signed __int64 int64_t;
  108. typedef unsigned char uint8_t;
  109. typedef unsigned short uint16_t;
  110. typedef unsigned int uint32_t;
  111. typedef unsigned __int64 uint64_t;
  112. # define PRId8 "d"
  113. # define PRId16 "d"
  114. # define PRId32 "d"
  115. # define PRId64 "I64d"
  116. # define INT8_C(c) c
  117. # define INT16_C(c) c
  118. # define INT32_C(c) c
  119. # define INT64_C(c) c ## i64
  120. # define UINT8_C(c) c ## u
  121. # define UINT16_C(c) c ## u
  122. # define UINT32_C(c) c ## u
  123. # define UINT64_C(c) c ## ui64
  124. #elif defined(__WATCOMC__) && (__WATCOMC__ <= 1220) /* WATCOM 12.2 or lower */
  125. typedef signed char int8_t;
  126. typedef signed short int16_t;
  127. typedef signed long int int32_t;
  128. typedef signed __int64 int64_t;
  129. typedef unsigned char uint8_t;
  130. typedef unsigned short uint16_t;
  131. typedef unsigned long int uint32_t;
  132. typedef unsigned __int64 uint64_t;
  133. # define PRId8 "d"
  134. # define PRId16 "d"
  135. # define PRId32 "d"
  136. # define PRId64 "Ld"
  137. # define INT8_C(c) c
  138. # define INT16_C(c) c
  139. # define INT32_C(c) c ## L
  140. # define INT64_C(c) c ## i64
  141. # define UINT8_C(c) c ## u
  142. # define UINT16_C(c) c ## u
  143. # define UINT32_C(c) c ## UL
  144. # define UINT64_C(c) c ## ui64
  145. #elif defined(__BORLANDC__) && (__BORLANDC__ < 0x600) /* Borland before 6.0 */
  146. typedef signed char int8_t;
  147. typedef signed short int16_t;
  148. typedef signed long int int32_t;
  149. typedef signed __int64 int64_t;
  150. typedef unsigned char uint8_t;
  151. typedef unsigned short uint16_t;
  152. typedef unsigned long int uint32_t;
  153. typedef unsigned __int64 uint64_t;
  154. # define PRId8 "d"
  155. # define PRId16 "d"
  156. # define PRId32 "ld"
  157. # define PRId64 "I64Ld"
  158. # define INT8_C(c) c
  159. # define INT16_C(c) c
  160. # define INT32_C(c) c ## L
  161. # define INT64_C(c) c ## i64
  162. # define UINT8_C(c) c ## u
  163. # define UINT16_C(c) c ## u
  164. # define UINT32_C(c) c ## UL
  165. # define UINT64_C(c) c ## ui64
  166. #elif defined(__FreeBSD__) && (__FreeBSD__ < 5) /* FreeBSD before 5.0 */ && !defined (_SYS_INTTYPES_H_)
  167. typedef signed char int8_t;
  168. typedef signed short int16_t;
  169. typedef signed long int int32_t;
  170. typedef signed long long int int64_t;
  171. typedef unsigned char uint8_t;
  172. typedef unsigned short uint16_t;
  173. typedef unsigned long int uint32_t;
  174. typedef unsigned long long int uint64_t;
  175. #elif defined(__CYGWIN__) && defined(__BIT_TYPES_DEFINED__) /* Cygwin defines intxx_t in sys/types.h instead of inttypes.h */
  176. # include <cygwin/version.h>
  177. # if defined(CYGWIN_VERSION_DLL_MAJOR) && (CYGWIN_VERSION_DLL_MAJOR<1005)
  178. typedef unsigned char uint8_t;
  179. typedef __uint16_t uint16_t;
  180. typedef __uint32_t uint32_t;
  181. typedef __uint64_t uint64_t;
  182. # endif
  183. #elif defined(SASC)
  184. # error("Too old SAS/C compiler, sorry.");
  185. #elif defined(__SASC__)
  186. # if (__SASC__ < 750 ) /* SAS/C before 7.50 */
  187. typedef signed char int8_t;
  188. typedef signed short int16_t;
  189. typedef signed long int int32_t;
  190. typedef signed long long int int64_t;
  191. typedef unsigned char uint8_t;
  192. typedef unsigned short uint16_t;
  193. typedef unsigned long int uint32_t;
  194. typedef unsigned long long int uint64_t;
  195. # endif
  196. #else
  197. # include <inttypes.h>
  198. # if !defined(INT8_MAX) && defined(INT16_MAX)
  199. /* int8_t is not mandatory */
  200. typedef int_least8_t int8_t;
  201. # endif
  202. #endif
  203. #if !defined(PRId16)
  204. # define PRId8 "d"
  205. # define PRId16 "d"
  206. # define PRId32 "ld"
  207. # define PRId64 "lld"
  208. #elif !defined(PRId8)
  209. # define PRId8 "d"
  210. #endif
  211. #if !defined(INT16_C)
  212. # define INT8_C(c) c
  213. # define INT16_C(c) c
  214. # define INT32_C(c) c ## L
  215. # define INT64_C(c) c ## LL
  216. # define UINT8_C(c) c ## u
  217. # define UINT16_C(c) c ## u
  218. # define UINT32_C(c) c ## UL
  219. # define UINT64_C(c) c ## ULL
  220. #elif !defined(INT8_C)
  221. # define INT8_C(c) c
  222. # define UINT8_C(c) c ## u
  223. #endif
  224. #if !defined(INT16_MIN)
  225. # define INT8_MIN (-INT8_C(127)-1)
  226. # define INT8_MAX (INT8_C(127))
  227. # define INT16_MIN (-INT16_C(32767)-1)
  228. # define INT16_MAX (INT16_C(32767))
  229. # define INT32_MIN (-INT32_C(2147483647)-1)
  230. # define INT32_MAX (INT32_C(2147483647))
  231. # define INT64_MIN (-INT64_C(9223372036854775807)-1)
  232. # define INT64_MAX (INT64_C(9223372036854775807))
  233. #elif !defined(INT8_MIN)
  234. # define INT8_MIN (-INT8_C(127)-1)
  235. #endif
  236. /*
  237. C compiler specific declaration for non-returning functions. Use
  238. NO_RETURN void foo(int bar);
  239. to declare a function prototype for function that doesn't return.
  240. */
  241. #if defined __GNUC__
  242. # define NO_RETURN __attribute__ ((noreturn))
  243. #elif defined __POCC__ || defined __BORLANDC__ || defined _MSC_VER
  244. # define NO_RETURN __declspec(noreturn)
  245. #else
  246. # define NO_RETURN
  247. /* maybe some warning occur unless NO_RETURN is defined for your compiler */
  248. #endif
  249. /*
  250. Endian stuff
  251. */
  252. #if defined(BSD) && (BSD >= 199103)
  253. # include <machine/endian.h>
  254. #elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA)
  255. /* bi-endian processor, current mode should be find in machine/endian.h file */
  256. # include <machine/endian.h>
  257. #elif defined(linux)
  258. # include <endian.h>
  259. #endif
  260. #if !defined(BYTE_ORDER) && defined(__BYTE_ORDER)
  261. # define BYTE_ORDER __BYTE_ORDER
  262. #endif
  263. #if !defined(LITTLE_ENDIAN) && defined(__LITTLE_ENDIAN)
  264. # define LITTLE_ENDIAN __LITTLE_ENDIAN
  265. #endif
  266. #if !defined(BIG_ENDIAN) && defined(__BIG_ENDIAN)
  267. # define BIG_ENDIAN __BIG_ENDIAN
  268. #endif
  269. #if !defined(LITTLE_ENDIAN)
  270. # define LITTLE_ENDIAN 1234 /* LSB first (vax, pc) */
  271. #endif
  272. #if !defined(BIG_ENDIAN)
  273. # define BIG_ENDIAN 4321 /* MSB first (IBM, net) */
  274. #endif
  275. #if !defined(PDP_ENDIAN)
  276. # define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */
  277. #endif
  278. #if !defined(BYTE_ORDER) && defined(BIT_ZERO_ON_RIGHT)
  279. # define BYTE_ORDER LITTLE_ENDIAN
  280. #elif !defined(BYTE_ORDER) && defined(BIT_ZERO_ON_LEFT)
  281. # define BYTE_ORDER BIG_ENDIAN
  282. #elif !defined(BYTE_ORDER)
  283. /* ARM */
  284. # if defined(__ARMEL__)
  285. # define BYTE_ORDER LITTLE_ENDIAN
  286. # elif defined(__ARMEB__)
  287. # define BYTE_ORDER BIG_ENDIAN
  288. # elif defined(__arm__)
  289. # error "ARMs are bi-endian processors. Endianness is unknown for this system, please drop an e-mail to liberty-eiffel@gnu.org"
  290. # endif
  291. /* HP RISC */
  292. # if defined(__hppa__) || defined(__hppa) || defined(__hp9000) || \
  293. defined(__hp9000s300) || defined(hp9000s300) || \
  294. defined(__hp9000s700) || defined(hp9000s700) || \
  295. defined(__hp9000s800) || defined(hp9000s800) || defined(hp9000s820)
  296. # define BYTE_ORDER BIG_ENDIAN
  297. # endif
  298. /* IBM */
  299. # if defined(ibm032) || defined(ibm370) || defined(_IBMR2) || \
  300. defined(IBM370) || defined(__MVS__)
  301. # define BYTE_ORDER BIG_ENDIAN
  302. # endif
  303. /* Intel x86 */
  304. # if defined(i386) || defined(__i386__) || defined(__i386) || \
  305. defined(_M_IX86) || defined(_X86_) || defined(__THW_INTEL) || \
  306. defined(sun386)
  307. # define BYTE_ORDER LITTLE_ENDIAN
  308. # endif
  309. /* Intel Itanium */
  310. # if defined(__ia64__) || defined(_IA64) || defined(__IA64__) || \
  311. defined(_M_IA64) || defined(_M_AMD64) || defined(_M_IX86) || defined(_AMD64_)
  312. # define BYTE_ORDER LITTLE_ENDIAN
  313. # endif
  314. /* Nationnal Semiconductor 32000 serie */
  315. # if defined(ns32000)
  316. # define BYTE_ORDER LITTLE_ENDIAN
  317. # endif
  318. /* Motorola 68000 */
  319. # if defined(mc68000) || defined(is68k) || defined(macII) || defined(m68k)
  320. # define BYTE_ORDER BIG_ENDIAN
  321. # endif
  322. /* MIPS */
  323. # if defined(MIPSEL) || defined(_MIPSEL)
  324. # define BYTE_ORDER LITTLE_ENDIAN
  325. # elif defined(MIPSEB) || defined(_MIPSEB)
  326. # define BYTE_ORDER BIG_ENDIAN
  327. # elif defined(__mips__) || defined(__mips) || defined(__MIPS__)
  328. # error "MIPS are bi-endian processors. Endianness is unknown for this system, please drop an e-mail to liberty-eiffel@gnu.org"
  329. # endif
  330. /* Power PC */
  331. /* this processor is bi-endian, how to know if little-endian is set? */
  332. # if defined(__powerpc) || defined(__powerpc__) || defined(__POWERPC__) || \
  333. defined(__ppc__) || defined(__ppc) || defined(_M_PPC) || \
  334. defined(__PPC) || defined(__PPC__)
  335. # define BYTE_ORDER BIG_ENDIAN
  336. # endif
  337. /* Pyramid 9810 */
  338. # if defined(pyr)
  339. # define BYTE_ORDER BIG_ENDIAN
  340. # endif
  341. /* RS/6000 */
  342. # if defined(__THW_RS6000) || defined(_IBMR2) || defined(_POWER) || \
  343. defined(_ARCH_PWR) || defined(_ARCH_PWR2)
  344. # define BYTE_ORDER BIG_ENDIAN
  345. # endif
  346. /* SPARC */
  347. # if defined(__sparc__) || defined(sparc) || defined(__sparc)
  348. # define BYTE_ORDER BIG_ENDIAN
  349. # endif
  350. /* CCI Tahoe */
  351. # if defined(tahoe)
  352. # define BYTE_ORDER BIG_ENDIAN
  353. # endif
  354. /* VAX */
  355. # if defined(vax) || defined(VAX) || defined(__vax__) || defined(_vax_) || \
  356. defined(__vax) || defined(__VAX)
  357. # define BYTE_ORDER LITTLE_ENDIAN
  358. # endif
  359. /* ELATE is a virtual OS with a little endian Virtual Processor */
  360. # if defined(__ELATE__)
  361. # define BYTE_ORDER LITTLE_ENDIAN
  362. # endif
  363. /* Miscellaneous little endian */
  364. # if defined(wrltitan)
  365. # define BYTE_ORDER LITTLE_ENDIAN
  366. # endif
  367. /* Miscellaneous big endian */
  368. # if defined(apollo) || defined(__convex__) || defined(_CRAY) || defined(sel)
  369. # define BYTE_ORDER BIG_ENDIAN
  370. # endif
  371. #endif
  372. #if !defined(BYTE_ORDER)
  373. # error "Unknown byte order. Add your system in above macros once you know your system type. Please drop an e-mail to liberty-eiffel@gnu.org"
  374. #endif
  375. #if (BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN)
  376. # error "Only little-endian and big-endian are valid at this time. Please drop an e-mail to liberty-eiffel@gnu.org"
  377. #endif
  378. /*
  379. Byte swapping stuff
  380. */
  381. extern void copy_swap_16(const uint16_t *src, uint16_t *dest, int count);
  382. /* Because ANSI C EXIT_* are not always defined: */
  383. #ifndef EXIT_FAILURE
  384. # define EXIT_FAILURE 1
  385. #endif
  386. #ifndef EXIT_SUCCESS
  387. # define EXIT_SUCCESS 0
  388. #endif
  389. /*
  390. On Linux glibc systems, we need to use sig.* versions of jmp_buf,
  391. setjmp and longjmp to preserve the signal handling context.
  392. Currently, the way I figured to detect this is if _SIGSET_H_types has
  393. been defined in /usr/include/setjmp.h.
  394. NOTE: with gcc, -ansi is used for SmartEiffel generated files EXCEPT in
  395. -no_split mode. ANSI only recognizes the non-sig versions.
  396. */
  397. #if (defined(_SIGSET_H_types) && !defined(__STRICT_ANSI__))
  398. # define JMP_BUF sigjmp_buf
  399. # define SETJMP(x) sigsetjmp( (x), 1)
  400. # define LONGJMP siglongjmp
  401. #else
  402. # define JMP_BUF jmp_buf
  403. # define SETJMP(x) setjmp( (x) )
  404. # define LONGJMP longjmp
  405. #endif
  406. /*
  407. Type to store reference objects Id:
  408. */
  409. typedef int Tid;
  410. typedef struct S0 T0;
  411. struct S0{Tid id;};
  412. /*
  413. The default channel used to print runtime error messages:
  414. */
  415. #define SE_ERR stderr
  416. /*
  417. Eiffel type INTEGER_8 is #1:
  418. */
  419. typedef int8_t T1;
  420. #define EIF_INTEGER_8 T1
  421. #define M1 (INT8_C(0))
  422. #define EIF_INTEGER_8_BITS (CHAR_BIT)
  423. #define EIF_MINIMUM_INTEGER_8 (INT8_MIN)
  424. #define EIF_MAXIMUM_INTEGER_8 (INT8_MAX)
  425. /*
  426. Eiffel type INTEGER_16 is #10:
  427. */
  428. typedef int16_t T10;
  429. #define EIF_INTEGER_16 T10
  430. #define M10 (INT16_C(0))
  431. #define EIF_INTEGER_16_BITS (CHAR_BIT*sizeof(T10t))
  432. #define EIF_MINIMUM_INTEGER_16 (INT16_MIN) /*-32768*/
  433. #define EIF_MAXIMUM_INTEGER_16 (INT16_MAX) /*+32767*/
  434. /*
  435. Eiffel type INTEGER or INTEGER_32 is #2:
  436. */
  437. typedef int32_t T2;
  438. #define EIF_INTEGER T2
  439. #define EIF_INTEGER_32 T2
  440. #define M2 (INT32_C(0))
  441. #define EIF_INTEGER_BITS ((T2)(CHAR_BIT*sizeof(T2)))
  442. #define EIF_INTEGER_32_BITS EIF_INTEGER_BITS
  443. #define EIF_MINIMUM_INTEGER (INT32_MIN)
  444. #define EIF_MAXIMUM_INTEGER (INT32_MAX)
  445. /*
  446. Eiffel type INTEGER_64 is #11:
  447. */
  448. typedef int64_t T11;
  449. #define EIF_INTEGER_64 T11
  450. #define M11 (INT64_C(0))
  451. #define EIF_INTEGER_64_BITS (CHAR_BIT*sizeof(T11))
  452. #define EIF_MINIMUM_INTEGER_64 (INT64_MIN)
  453. #define EIF_MAXIMUM_INTEGER_64 (INT64_MAX)
  454. /*
  455. Eiffel type CHARACTER is #3:
  456. */
  457. typedef unsigned char T3;
  458. #define EIF_CHARACTER T3
  459. #define M3 (0)
  460. #define EIF_CHARACTER_BITS (CHAR_BIT)
  461. #define EIF_MINIMUM_CHARACTER_CODE (0)
  462. #define EIF_MAXIMUM_CHARACTER_CODE (255)
  463. #define T3code(x) ((T10)(x))
  464. #define T3to_integer(x) ((signed char)(x))
  465. #define T3to_integer_8(x) ((signed char)(x))
  466. #define T3to_bit(x) (x)
  467. /*
  468. Eiffel type REAL_32 is #4:
  469. */
  470. typedef float T4;
  471. typedef T4 real32_t;
  472. #define EIF_REAL_32 T4
  473. #define M4 (0.0)
  474. #define EIF_MINIMUM_REAL_32 (-(FLT_MAX))
  475. #define EIF_MAXIMUM_REAL_32 (FLT_MAX)
  476. /*
  477. Eiffel type REAL or REAL_64 is #5:
  478. */
  479. typedef double T5;
  480. typedef T5 real64_t;
  481. #define EIF_REAL T5
  482. #define EIF_REAL_64 T5
  483. #define M5 (0.0)
  484. #define EIF_MINIMUM_REAL_64 (-(DBL_MAX))
  485. #define EIF_MINIMUM_REAL (EIF_MINIMUM_REAL_64)
  486. #define EIF_MAXIMUM_REAL_64 (DBL_MAX)
  487. #define EIF_MAXIMUM_REAL (EIF_MAXIMUM_REAL_64)
  488. /*
  489. Eiffel type REAL_EXTENDED is #12:
  490. */
  491. typedef long double T12;
  492. typedef T12 real_extended_t;
  493. #define EIF_REAL_EXTENDED T12
  494. #define EIF_REAL_128 T12
  495. #define M12 (0.0)
  496. #define EIF_MINIMUM_REAL_EXTENDED (-(DBL_MAX))
  497. #define EIF_MAXIMUM_REAL_EXTENDED (DBL_MAX)
  498. /*
  499. Eiffel type BOOLEAN is #6:
  500. */
  501. typedef char T6;
  502. #define EIF_BOOLEAN T6
  503. #define M6 (0)
  504. #define EIF_BOOLEAN_BITS (CHAR_BIT)
  505. /*
  506. Eiffel type POINTER is #8:
  507. */
  508. typedef void* T8;
  509. #define EIF_POINTER T8
  510. /* Sometimes, NULL is defined as 0 */
  511. #define M8 ((void*)NULL)
  512. #define EIF_POINTER_BITS (CHAR_BIT*sizeof(void*))
  513. /*
  514. To use type STRING on the C side:
  515. */
  516. #define EIF_STRING T7*
  517. /*
  518. Some Other EIF_* defined in ETL:
  519. */
  520. #define eif_access(x) ((char*)(x))
  521. #define EIF_REFERENCE T0*
  522. #define EIF_OBJ T0*
  523. #define EIF_OBJECT EIF_OBJ
  524. #define EIF_ANY EIF_OBJ
  525. /*
  526. Wrappers for `malloc' and `calloc':
  527. */
  528. void se_check_malloc(const void*result, const char*format, ...);
  529. void* se_malloc(size_t size);
  530. void* se_calloc(size_t nmemb, size_t size);
  531. void* se_realloc(void* src, size_t size);
  532. void* se_malloc_(size_t size, void*(*alloc)(size_t));
  533. void* se_calloc_(size_t nmemb, size_t size, void*(*alloc)(size_t,size_t));
  534. /*
  535. die method.
  536. */
  537. void se_die(int code);
  538. /*
  539. Runtime hooks. They allow different runtime modules to be quite independant. In time, they will also allow
  540. thread-safe operations.
  541. Currently known modules:
  542. - boost
  543. - no_check
  544. - sedb
  545. - gc
  546. - print stack
  547. - profile
  548. - plugins
  549. However, currently only profile uses this method. It will be extended to other modules later.
  550. The currently defined hooks are described in the enum below (the names should be self-explanatory).
  551. */
  552. typedef enum {
  553. SE_HANDLE_EXCEPTION_SET, /* called when an exception handler is set, prior to SETJMP */
  554. SE_HANDLE_EXCEPTION_CLEAR, /* called when a feature with an exception handler normally returns */
  555. SE_HANDLE_EXCEPTION_THROWN, /* called when an exception is thrown, prior to the LONGJMP */
  556. SE_HANDLE_ENTER_GC, /* called when gc_start() begins */
  557. SE_HANDLE_EXIT_GC, /* called when gc_start() ends */
  558. SE_HANDLE_ENTER_PRINT_STACK, /* called when se_print_run_time_stack() begins */
  559. SE_HANDLE_EXIT_PRINT_STACK, /* called when se_print_run_time_stack() ends */
  560. SE_HANDLE_NO_MORE_MEMORY, /* called by se_alloc() and co */
  561. SE_HANDLE_SEDB_BREAK, /* called when sedb stops the program */
  562. SE_HANDLE_SEDB_CONTINUE, /* called when sedb continues the program */
  563. SE_HANDLE_RUNTIME_ERROR, /* called when a runtime error is raised and not caught by an exception. Cannot be raised in boost mode. */
  564. SE_HANDLE_DIE_WITH_CODE, /* called when the program is stopped by the die_with_code feature. The data points to the int code. */
  565. SE_HANDLE_NORMAL_EXIT /* called when the program correctly terminates. The data is null. */
  566. } se_handler_action_t;
  567. extern int handlers_count;
  568. typedef void se_runtime_handler_t(se_handler_action_t action, void*data);
  569. void register_handler(se_runtime_handler_t*handler);
  570. void _handle(se_handler_action_t action, void*data);
  571. #define handle(action,data) do{if(handlers_count>0)_handle(action,data);}while(0)
  572. #endif /* #ifndef _BASE_H */
  573. #define SE_BOOST 1
  574. /*
  575. -- ------------------------------------------------------------------------------------------------------------
  576. -- Copyright notice below. Please read.
  577. --
  578. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  579. -- Copyright(C) 2003-2005: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  580. --
  581. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  582. --
  583. -- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
  584. -- documentation files (the "Software"), to deal in the Software without restriction, including without
  585. -- limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  586. -- the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
  587. -- conditions:
  588. --
  589. -- The above copyright notice and this permission notice shall be included in all copies or substantial
  590. -- portions of the Software.
  591. --
  592. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
  593. -- LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
  594. -- EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  595. -- AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
  596. -- OR OTHER DEALINGS IN THE SOFTWARE.
  597. --
  598. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  599. -- ------------------------------------------------------------------------------------------------------------
  600. */
  601. #ifndef WIN32
  602. # include <dirent.h>
  603. #endif
  604. #ifndef WIN32
  605. # include <unistd.h>
  606. #endif
  607. EIF_POINTER directory_open(EIF_POINTER path);
  608. EIF_POINTER directory_read_entry(EIF_POINTER dirstream);
  609. EIF_POINTER directory_get_entry_name(EIF_POINTER entry);
  610. EIF_BOOLEAN directory_close(EIF_POINTER dirstream);
  611. #define directory_current_working_directory (directory_cwd())
  612. EIF_POINTER directory_cwd(void);
  613. EIF_BOOLEAN directory_chdir(EIF_POINTER destination);
  614. EIF_BOOLEAN directory_mkdir(EIF_POINTER directory_path);
  615. EIF_BOOLEAN directory_rmdir(EIF_POINTER directory_path);
  616. /*
  617. -- ------------------------------------------------------------------------------------------------------------
  618. -- Copyright notice below. Please read.
  619. --
  620. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  621. -- Copyright(C) 2003-2005: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  622. --
  623. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  624. --
  625. -- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
  626. -- documentation files (the "Software"), to deal in the Software without restriction, including without
  627. -- limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  628. -- the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
  629. -- conditions:
  630. --
  631. -- The above copyright notice and this permission notice shall be included in all copies or substantial
  632. -- portions of the Software.
  633. --
  634. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
  635. -- LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
  636. -- EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  637. -- AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
  638. -- OR OTHER DEALINGS IN THE SOFTWARE.
  639. --
  640. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  641. -- ------------------------------------------------------------------------------------------------------------
  642. */
  643. #define basic_exec_system_none 0
  644. #define basic_exec_system_posix 1
  645. #define basic_exec_system_win32 2
  646. #include "eiffel_exec.h"
  647. /***************************
  648. * Common macros and types *
  649. * basic_exec_xxx *
  650. ***************************/
  651. #if defined __USE_POSIX || defined __unix__ || defined _POSIX_C_SOURCE || defined __APPLE__
  652. /*# include <unistd.h> done in base.h */
  653. /*# include <sys/types.h> done in base.h */
  654. #include <sys/wait.h>
  655. typedef struct se_exec_data se_exec_data_t;
  656. struct se_exec_data {
  657. pid_t id; /* the launched child process id */
  658. int running; /* true if the process is running */
  659. int child; /* true if the process is the child itself (useful for duplicate) */
  660. int status; /* the status of the child process if finished */
  661. };
  662. extern char** environ;
  663. #define basic_exec_id(data) (((se_exec_data_t*)data)->id)
  664. #define basic_exec_is_child(data) (((se_exec_data_t*)data)->child)
  665. #define basic_exec_status(data) (((se_exec_data_t*)data)->status)
  666. #define basic_exec_alloc_pipe() (calloc(2, sizeof(int)))
  667. #define basic_exec_free_pipe(p) (free(p))
  668. #define basic_exec_alloc_data() ((se_exec_data_t*)se_malloc(sizeof(se_exec_data_t)))
  669. #define basic_exec_free_data(p) (free(p))
  670. #define basic_exec_init_pipe(p) ((EIF_BOOLEAN)(pipe(p)>=0))
  671. #define basic_exec_system basic_exec_system_posix
  672. #elif defined WIN32
  673. /*# include <windows.h> done in base.h */
  674. typedef struct se_exec_data se_exec_data_t;
  675. struct se_exec_data {
  676. PROCESS_INFORMATION process_information;
  677. int running;
  678. DWORD status;
  679. };
  680. #define basic_exec_id(data) (((se_exec_data_t*)data)->process_information.dwProcessId)
  681. #define basic_exec_is_child(data) (0)
  682. #define basic_exec_status(data) (((se_exec_data_t*)data)->status)
  683. #define basic_exec_alloc_pipe() (calloc(2, sizeof(HANDLE)))
  684. #define basic_exec_free_pipe(p) (free(p))
  685. #define basic_exec_alloc_data() ((se_exec_data_t*)se_malloc(sizeof(se_exec_data_t)))
  686. #define basic_exec_free_data(p) (free(p))
  687. #define basic_exec_system basic_exec_system_win32
  688. extern EIF_BOOLEAN basic_exec_init_pipe(HANDLE*p);
  689. #else
  690. /* Dummy implementation that always reports an error back to the Eiffel side */
  691. typedef int se_exec_data_t;
  692. #define basic_exec_id(data) (-1)
  693. #define basic_exec_is_child(data) (0)
  694. #define basic_exec_status(data) (0)
  695. #define basic_exec_alloc_pipe() (NULL)
  696. #define basic_exec_free_pipe(p) /* dummy */
  697. #define basic_exec_alloc_data() ((se_exec_data_t*)NULL)
  698. #define basic_exec_free_data(p) /* dummy */
  699. #define basic_exec_init_pipe(p) ((EIF_BOOLEAN)0)
  700. #define basic_exec_system basic_exec_system_none
  701. #endif
  702. /***********************************
  703. * Prototypes for common functions *
  704. * basic_exec_xxx *
  705. ***********************************/
  706. extern EIF_BOOLEAN basic_exec_is_finished(se_exec_data_t*data);
  707. extern void basic_exec_wait(se_exec_data_t*data);
  708. extern void basic_exec_cleanup(se_exec_data_t*data, int status);
  709. /*************************************************
  710. * Posix-specific function prototypes and macros *
  711. * basic_exec_posix_xxx *
  712. *************************************************/
  713. extern EIF_BOOLEAN basic_exec_posix_execute(se_exec_data_t*data, char*prog, char**args, EIF_BOOLEAN keep_env, char**add_env, int*in_fd, int*out_fd, int*err_fd);
  714. extern EIF_INTEGER basic_exec_posix_get_character (EIF_INTEGER fd);
  715. extern void basic_exec_posix_put_character(EIF_INTEGER fd, EIF_CHARACTER c);
  716. extern void basic_exec_posix_wait_any(se_exec_data_t*data);
  717. extern void basic_exec_posix_any_finished(se_exec_data_t*data);
  718. #if basic_exec_system == basic_exec_system_posix
  719. #define basic_exec_posix_flush(fd) (fsync(fd))
  720. #define basic_exec_posix_close(fd) (close(fd))
  721. #define basic_exec_posix_kill(data, sig) (kill((data)->id, (sig)))
  722. #define basic_exec_posix_get_in_descriptor(pipe) (((int*)pipe)[0])
  723. #define basic_exec_posix_get_out_descriptor(pipe) (((int*)pipe)[1])
  724. #else
  725. #define basic_exec_posix_flush(fd) /* dummy */
  726. #define basic_exec_posix_close(fd) /* dummy */
  727. #define basic_exec_posix_kill(data, sig) /* dummy */
  728. #define basic_exec_posix_get_in_descriptor(pipe) 0
  729. #define basic_exec_posix_get_out_descriptor(pipe) 0
  730. #endif
  731. /*************************************************
  732. * Win32-specific function prototypes and macros *
  733. * basic_exec_win32_xxx *
  734. *************************************************/
  735. #if basic_exec_system == basic_exec_system_win32
  736. #define basic_exec_win32_flush(h) FlushFileBuffers((HANDLE)h)
  737. #define basic_exec_win32_close(h) CloseHandle((HANDLE)h)
  738. #define basic_exec_win32_handle(data) ((int)((se_exec_data_t*)data)->process_information.hProcess)
  739. #define basic_exec_win32_maximum_wait (MAXIMUM_WAIT_OBJECTS)
  740. extern EIF_BOOLEAN basic_exec_win32_execute(se_exec_data_t*data, char*args, EIF_BOOLEAN keep_env, char*add_env, HANDLE*in_h, HANDLE*out_h, HANDLE*err_h);
  741. extern EIF_BOOLEAN basic_exec_win32_wait_any(HANDLE*handles, DWORD count, se_exec_data_t*data);
  742. extern EIF_BOOLEAN basic_exec_win32_any_finished(HANDLE*handles, DWORD count, se_exec_data_t*data);
  743. extern void basic_exec_win32_put_character(HANDLE h, EIF_CHARACTER c);
  744. extern EIF_INTEGER basic_exec_win32_get_character (HANDLE h);
  745. #define basic_exec_win32_get_in_handle(pipe) (((HANDLE*)pipe)[0])
  746. #define basic_exec_win32_get_out_handle(pipe) (((HANDLE*)pipe)[1])
  747. #else
  748. #define basic_exec_win32_flush(h) /* dummy */
  749. #define basic_exec_win32_close(h) /* dummy */
  750. #define basic_exec_win32_handle(data) (0)
  751. #define basic_exec_win32_maximum_wait (0)
  752. extern EIF_BOOLEAN basic_exec_win32_execute(se_exec_data_t*data, char*args, EIF_BOOLEAN keep_env, char*add_env, void*in_h, void*out_h, void*err_h);
  753. extern EIF_BOOLEAN basic_exec_win32_wait_any(void*handles, int count, se_exec_data_t*data);
  754. extern EIF_BOOLEAN basic_exec_win32_any_finished(void*handles, int count, se_exec_data_t*data);
  755. extern void basic_exec_win32_put_character(void*h, EIF_CHARACTER c);
  756. extern EIF_INTEGER basic_exec_win32_get_character (void*h);
  757. #define basic_exec_win32_get_in_handle(pipe) NULL
  758. #define basic_exec_win32_get_out_handle(pipe) NULL
  759. #endif
  760. extern void basic_exec_waitpid_init(EIF_OBJECT);
  761. extern EIF_INTEGER basic_exec_waitpid_fd(void);
  762. extern EIF_INTEGER basic_exec_waitpid_read_buffer(void*);
  763. /*
  764. -- ------------------------------------------------------------------------------------------------------------
  765. -- Copyright notice below. Please read.
  766. --
  767. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  768. -- Copyright(C) 2003-2005: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  769. --
  770. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  771. --
  772. -- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
  773. -- documentation files (the "Software"), to deal in the Software without restriction, including without
  774. -- limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  775. -- the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
  776. -- conditions:
  777. --
  778. -- The above copyright notice and this permission notice shall be included in all copies or substantial
  779. -- portions of the Software.
  780. --
  781. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
  782. -- LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
  783. -- EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  784. -- AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
  785. -- OR OTHER DEALINGS IN THE SOFTWARE.
  786. --
  787. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  788. -- ------------------------------------------------------------------------------------------------------------
  789. */
  790. #define mbi_unsigned_32_to_integer_64(x) (((int64_t)((uint32_t)(x))))
  791. #define mbi_unsigned_less_than(a,b) ((((uint32_t)(a)) < ((uint32_t)(b))))
  792. #define mbi_unsigned_greater_than(a,b) ((((uint32_t)(a)) > ((uint32_t)(b))))
  793. #define mbi_unsigned_greater_or_equal(a,b) ((((uint32_t)(a)) >= ((uint32_t)(b))))
  794. #define mbi_storage_at(s, n) (((s)+(n)))
  795. EIF_BOOLEAN mbi_inc (int32_t *p);
  796. EIF_BOOLEAN mbi_add (int32_t a, int32_t b, int32_t *p);
  797. EIF_BOOLEAN mbi_add_with_inc (int32_t a, int32_t b, int32_t *p);
  798. EIF_BOOLEAN mbi_dec (int32_t *p);
  799. EIF_BOOLEAN mbi_subtract (int32_t a, int32_t b, int32_t *p);
  800. EIF_BOOLEAN mbi_subtract_with_dec (int32_t a, int32_t b, int32_t *p);
  801. EIF_INTEGER mbi_multiply (int32_t a, int32_t b, int32_t *p);
  802. EIF_INTEGER mbi_multiply_with_add (int32_t a, int32_t b, int32_t c, int32_t *p);
  803. EIF_INTEGER mbi_multiply_with_2_add (int32_t a, int32_t b, int32_t c, int32_t d, int32_t *p);
  804. EIF_INTEGER mbi_divide (int32_t a, int32_t b, int32_t d, int32_t *r);
  805. /*
  806. -- ------------------------------------------------------------------------------------------------------------
  807. -- Copyright notice below. Please read.
  808. --
  809. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  810. -- Copyright(C) 2003-2005: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  811. --
  812. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  813. --
  814. -- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
  815. -- documentation files (the "Software"), to deal in the Software without restriction, including without
  816. -- limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  817. -- the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
  818. -- conditions:
  819. --
  820. -- The above copyright notice and this permission notice shall be included in all copies or substantial
  821. -- portions of the Software.
  822. --
  823. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
  824. -- LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
  825. -- EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  826. -- AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
  827. -- OR OTHER DEALINGS IN THE SOFTWARE.
  828. --
  829. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  830. -- ------------------------------------------------------------------------------------------------------------
  831. */
  832. #define basic_getenv(v) (getenv((char*)v))
  833. /*
  834. -- ------------------------------------------------------------------------------------------------------------
  835. -- Copyright notice below. Please read.
  836. --
  837. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  838. -- Copyright(C) 2003-2005: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  839. --
  840. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  841. --
  842. -- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
  843. -- documentation files (the "Software"), to deal in the Software without restriction, including without
  844. -- limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  845. -- the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
  846. -- conditions:
  847. --
  848. -- The above copyright notice and this permission notice shall be included in all copies or substantial
  849. -- portions of the Software.
  850. --
  851. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
  852. -- LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
  853. -- EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  854. -- AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
  855. -- OR OTHER DEALINGS IN THE SOFTWARE.
  856. --
  857. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  858. -- ------------------------------------------------------------------------------------------------------------
  859. */
  860. EIF_INTEGER fstat_st_size(EIF_POINTER path);
  861. EIF_INTEGER_64 fstat_st_mtime(EIF_POINTER path);
  862. EIF_BOOLEAN fstat_st_is_file(EIF_POINTER path);
  863. EIF_BOOLEAN fstat_st_is_dir(EIF_POINTER path);
  864. /*
  865. -- ------------------------------------------------------------------------------------------------------------
  866. -- Copyright notice below. Please read.
  867. --
  868. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  869. -- Copyright(C) 2003-2005: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  870. --
  871. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  872. --
  873. -- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
  874. -- documentation files (the "Software"), to deal in the Software without restriction, including without
  875. -- limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  876. -- the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
  877. -- conditions:
  878. --
  879. -- The above copyright notice and this permission notice shall be included in all copies or substantial
  880. -- portions of the Software.
  881. --
  882. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
  883. -- LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
  884. -- EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  885. -- AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
  886. -- OR OTHER DEALINGS IN THE SOFTWARE.
  887. --
  888. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  889. -- ------------------------------------------------------------------------------------------------------------
  890. */
  891. #include <errno.h>
  892. #define text_file_read_open(p) (fopen(((char*)(p)),"r"))
  893. #define text_file_write_open(p) (fopen(((char*)(p)),"w"))
  894. #define text_file_write_append(p) (fopen(((char*)(p)),"a"))
  895. #define text_file_read_write_open(p) (fopen(((char*)(p)),"r+"))
  896. #define text_file_read_write_append(p) (fopen(((char*)(p)),"a+"))
  897. #define binary_file_read_open(p) (fopen(((char*)(p)),"rb"))
  898. #define binary_file_write_open(p) (fopen(((char*)(p)),"wb"))
  899. #define binary_file_write_append(p) (fopen(((char*)(p)),"ab"))
  900. #define io_fclose(p) (fclose((FILE*)(p)))
  901. #define io_flush(p) (fflush((FILE*)(p)))
  902. #define io_getc(f) (getc(((FILE*)(f))))
  903. #define io_putc(b, f) (putc((b),((FILE*)(f))))
  904. #define io_ungetc(b, f) (ungetc((b), (FILE*)(f)))
  905. #define io_fread(b, n, f) (fread((void *)(b),(size_t)(1), (size_t)(n),(FILE*)(f)))
  906. #define io_fwrite(b, n, f) (fwrite((void *)(b),(size_t)(1), (size_t)(n),(FILE*)(f)))
  907. #define io_feof(f) (feof(((FILE*)(f))))
  908. #define io_rename(o, n) (rename(((char*)(o)),((char*)(n))) == 0)
  909. #define io_remove(f) (remove(((char*)(f))) == 0)
  910. #define io_fseek(f, o) (fseek((FILE*)(f),(o),SEEK_SET))
  911. #define io_ftell(f) ((EIF_INTEGER_64)ftell((FILE*)(f)))
  912. #if defined __USE_POSIX || defined __unix__ || defined _POSIX_C_SOURCE
  913. # define read_stdin(b, s) (read(STDIN_FILENO, b, s))
  914. #else
  915. extern int read_stdin(EIF_CHARACTER *buffer, int size);
  916. #endif
  917. extern int io_copy(char*source, char*target);
  918. extern int io_file_exists(char*source);
  919. extern int io_same_physical_file(char*path1,char*path2);
  920. /*
  921. -- ------------------------------------------------------------------------------------------------------------
  922. -- Copyright notice below. Please read.
  923. --
  924. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  925. -- Copyright(C) 2003-2005: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  926. --
  927. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  928. --
  929. -- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
  930. -- documentation files (the "Software"), to deal in the Software without restriction, including without
  931. -- limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  932. -- the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
  933. -- conditions:
  934. --
  935. -- The above copyright notice and this permission notice shall be included in all copies or substantial
  936. -- portions of the Software.
  937. --
  938. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
  939. -- LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
  940. -- EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  941. -- AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
  942. -- OR OTHER DEALINGS IN THE SOFTWARE.
  943. --
  944. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  945. -- ------------------------------------------------------------------------------------------------------------
  946. */
  947. #define pointer_hash_code(p) (((unsigned int)(unsigned long)(p))>>1)
  948. #define pointer_to_natural_32(p) ((unsigned int) (p))
  949. #define pointer_to_any(p) ((T0*)(p))
  950. #define pointer_plus(p, o) (((char*)(p))+o)
  951. /*
  952. -- ------------------------------------------------------------------------------------------------------------
  953. -- Copyright notice below. Please read.
  954. --
  955. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  956. -- Copyright(C) 2003-2005: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  957. --
  958. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  959. --
  960. -- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
  961. -- documentation files (the "Software"), to deal in the Software without restriction, including without
  962. -- limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  963. -- the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
  964. -- conditions:
  965. --
  966. -- The above copyright notice and this permission notice shall be included in all copies or substantial
  967. -- portions of the Software.
  968. --
  969. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
  970. -- LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
  971. -- EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  972. -- AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
  973. -- OR OTHER DEALINGS IN THE SOFTWARE.
  974. --
  975. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  976. -- ------------------------------------------------------------------------------------------------------------
  977. */
  978. #ifdef WIN32
  979. # include <time.h>
  980. #else
  981. # include <sys/time.h>
  982. #endif
  983. extern EIF_INTEGER basic_microsecond_microsecond;
  984. extern EIF_INTEGER_64 basic_microsecond_time;
  985. #define basic_microsecond_update (_basic_microsecond_update())
  986. void _basic_microsecond_update(void);
  987. /*
  988. -- ------------------------------------------------------------------------------------------------------------
  989. -- Copyright notice below. Please read.
  990. --
  991. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  992. -- Copyright(C) 2003-2005: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  993. --
  994. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  995. --
  996. -- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
  997. -- documentation files (the "Software"), to deal in the Software without restriction, including without
  998. -- limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  999. -- the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
  1000. -- conditions:
  1001. --
  1002. -- The above copyright notice and this permission notice shall be included in all copies or substantial
  1003. -- portions of the Software.
  1004. --
  1005. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
  1006. -- LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
  1007. -- EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  1008. -- AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
  1009. -- OR OTHER DEALINGS IN THE SOFTWARE.
  1010. --
  1011. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  1012. -- ------------------------------------------------------------------------------------------------------------
  1013. */
  1014. #define sprintf_pointer(buffer, pointer) sprintf((char*)(buffer),"%p",pointer)
  1015. void sprintf_real_64(EIF_CHARACTER* b, EIF_CHARACTER m, int32_t f, real64_t r);
  1016. void sprintf_real_extended(EIF_CHARACTER* b, EIF_CHARACTER m, int32_t f, real_extended_t r);
  1017. /* C Header Pass 1: */
  1018. typedef union _se_agent se_agent;
  1019. typedef struct _se_agent0 se_agent0;
  1020. typedef struct S29 T29;
  1021. typedef int T296;
  1022. typedef struct S113 T113;
  1023. typedef struct S126 T126;
  1024. typedef void*T903;
  1025. typedef struct S104 T104;
  1026. typedef struct S283 T283;
  1027. typedef struct S117 T117;
  1028. typedef struct S111 T111;
  1029. typedef struct S291 T291;
  1030. typedef void*T281;
  1031. typedef int T297;
  1032. typedef struct S7 T7;
  1033. typedef struct S909 T909;
  1034. typedef struct S293 T293;
  1035. typedef struct S86 T86;
  1036. typedef struct S910 T910;
  1037. typedef struct S295 T295;
  1038. typedef int T554;
  1039. typedef struct S546 T546;
  1040. typedef struct S78 T78;
  1041. typedef struct S911 T911;
  1042. typedef struct S557 T557;
  1043. typedef struct S561 T561;
  1044. typedef struct S562 T562;
  1045. typedef struct S563 T563;
  1046. typedef struct S564 T564;
  1047. typedef struct S565 T565;
  1048. typedef struct S912 T912;
  1049. typedef struct S913 T913;
  1050. typedef struct S102 T102;
  1051. typedef struct S556 T556;
  1052. typedef int T545;
  1053. typedef struct S464 T464;
  1054. typedef struct S665 T665;
  1055. typedef struct S81 T81;
  1056. typedef struct S69 T69;
  1057. typedef struct S467 T467;
  1058. typedef struct S123 T123;
  1059. typedef struct S708 T708;
  1060. typedef struct S709 T709;
  1061. typedef struct S704 T704;
  1062. typedef struct S914 T914;
  1063. typedef struct S107 T107;
  1064. typedef struct S566 T566;
  1065. typedef struct S710 T710;
  1066. typedef struct S351 T351;
  1067. typedef struct S437 T437;
  1068. typedef struct S915 T915;
  1069. typedef struct S333 T333;
  1070. typedef struct S711 T711;
  1071. typedef struct S916 T916;
  1072. typedef struct S447 T447;
  1073. typedef struct S790 T790;
  1074. typedef struct S588 T588;
  1075. typedef struct S621 T621;
  1076. typedef struct S622 T622;
  1077. typedef struct S623 T623;
  1078. typedef struct S624 T624;
  1079. typedef struct S625 T625;
  1080. typedef struct S637 T637;
  1081. typedef struct S638 T638;
  1082. typedef struct S639 T639;
  1083. typedef struct S641 T641;
  1084. typedef struct S642 T642;
  1085. typedef struct S646 T646;
  1086. typedef struct S647 T647;
  1087. typedef struct S648 T648;
  1088. typedef struct S649 T649;
  1089. typedef struct S650 T650;
  1090. typedef struct S651 T651;
  1091. typedef struct S652 T652;
  1092. typedef struct S654 T654;
  1093. typedef struct S655 T655;
  1094. typedef struct S653 T653;
  1095. typedef struct S656 T656;
  1096. typedef struct S657 T657;
  1097. typedef struct S658 T658;
  1098. typedef struct S917 T917;
  1099. typedef struct S552 T552;
  1100. typedef struct S97 T97;
  1101. typedef struct S91 T91;
  1102. typedef struct S383 T383;
  1103. typedef void*T110;
  1104. typedef struct S95 T95;
  1105. typedef struct S286 T286;
  1106. typedef struct S89 T89;
  1107. typedef struct S919 T919;
  1108. typedef struct S920 T920;
  1109. typedef struct S921 T921;
  1110. typedef struct S306 T306;
  1111. typedef struct S108 T108;
  1112. typedef void*T116;
  1113. typedef void*T125;
  1114. typedef struct S124 T124;
  1115. typedef void*T127;
  1116. typedef struct S452 T452;
  1117. typedef struct S923 T923;
  1118. typedef struct S924 T924;
  1119. typedef struct S925 T925;
  1120. typedef struct S341 T341;
  1121. typedef struct S120 T120;
  1122. typedef struct S290 T290;
  1123. typedef struct S926 T926;
  1124. typedef struct S441 T441;
  1125. typedef struct S929 T929;
  1126. typedef int T587;
  1127. typedef struct S930 T930;
  1128. typedef struct S931 T931;
  1129. typedef struct S932 T932;
  1130. typedef struct S727 T727;
  1131. typedef struct S728 T728;
  1132. typedef struct S729 T729;
  1133. typedef struct S318 T318;
  1134. typedef struct S935 T935;
  1135. typedef struct S936 T936;
  1136. typedef struct S719 T719;
  1137. typedef struct S551 T551;
  1138. typedef struct S937 T937;
  1139. typedef struct S938 T938;
  1140. typedef struct S720 T720;
  1141. typedef struct S939 T939;
  1142. typedef int T940;
  1143. typedef struct S340 T340;
  1144. typedef struct S943 T943;
  1145. typedef int T807;
  1146. typedef struct S804 T804;
  1147. typedef struct S806 T806;
  1148. typedef int T944;
  1149. typedef struct S945 T945;
  1150. typedef struct S946 T946;
  1151. typedef struct S59 T59;
  1152. typedef struct S805 T805;
  1153. typedef struct S947 T947;
  1154. typedef struct S953 T953;
  1155. typedef struct S954 T954;
  1156. typedef int T80;
  1157. typedef struct S955 T955;
  1158. typedef int T957;
  1159. typedef struct S959 T959;
  1160. typedef struct S106 T106;
  1161. typedef struct S962 T962;
  1162. typedef struct S783 T783;
  1163. typedef struct S825 T825;
  1164. typedef struct S964 T964;
  1165. typedef struct S966 T966;
  1166. typedef struct S968 T968;
  1167. typedef struct S970 T970;
  1168. typedef struct S785 T785;
  1169. typedef struct S491 T491;
  1170. typedef struct S973 T973;
  1171. typedef struct S367 T367;
  1172. typedef struct S974 T974;
  1173. typedef struct S407 T407;
  1174. typedef struct S975 T975;
  1175. typedef struct S462 T462;
  1176. typedef struct S433 T433;
  1177. typedef struct S395 T395;
  1178. typedef struct S439 T439;
  1179. typedef struct S440 T440;
  1180. typedef struct S505 T505;
  1181. typedef struct S514 T514;
  1182. typedef struct S516 T516;
  1183. typedef struct S121 T121;
  1184. typedef struct S517 T517;
  1185. typedef struct S458 T458;
  1186. typedef struct S423 T423;
  1187. typedef struct S480 T480;
  1188. typedef struct S418 T418;
  1189. typedef struct S449 T449;
  1190. typedef struct S455 T455;
  1191. typedef struct S453 T453;
  1192. typedef struct S456 T456;
  1193. typedef struct S396 T396;
  1194. typedef struct S450 T450;
  1195. typedef struct S422 T422;
  1196. typedef struct S448 T448;
  1197. typedef struct S451 T451;
  1198. typedef struct S459 T459;
  1199. typedef struct S518 T518;
  1200. typedef struct S504 T504;
  1201. typedef struct S292 T292;
  1202. typedef struct S461 T461;
  1203. typedef struct S436 T436;
  1204. typedef struct S282