Mon Jun 3 15:21:17 PDT 2002
[netwalk.git] / eiffel.h
blobf4d0b3c3bdb1913ab87248c3bbd60cc2e02cfeb5
1 /*
2 -- This file is free software, which comes along with SmallEiffel. This
3 -- software is distributed in the hope that it will be useful, but WITHOUT
4 -- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5 -- FITNESS FOR A PARTICULAR PURPOSE. You can modify it as you want, provided
6 -- this header is kept unaltered, and a notification of the changes is added.
7 -- You are allowed to redistribute it and sell it, alone or as a part of
8 -- another product.
9 -- Copyright (C) 1994-2002 LORIA - INRIA - U.H.P. Nancy 1 - FRANCE
10 -- Dominique COLNET and Suzanne COLLIN - SmallEiffel@loria.fr
11 -- http://SmallEiffel.loria.fr
15 This file (SmallEiffel/sys/runtime/base.h) contains all basic Eiffel
16 type definitions.
17 This file is automatically included in the header for all modes of
18 compilation: -boost, -no_check, -require_check, -ensure_check, ...
19 This file is also included in the header of any cecil file (when the
20 -cecil option is used).
21 This file is also included in the header file of C++ wrappers (when
22 using the external "C++" clause).
24 #include <stdio.h>
25 #include <string.h>
26 #include <math.h>
27 #include <stdlib.h>
28 #include <signal.h>
29 #include <stddef.h>
30 #include <stdarg.h>
31 #include <limits.h>
32 #include <float.h>
33 #include <setjmp.h>
34 #include <sys/types.h>
35 #include <sys/stat.h>
36 #include <fcntl.h>
37 #ifdef WIN32
38 #include <windows.h>
39 #else
40 #ifndef O_RDONLY
41 #include <sys/file.h>
42 #endif
43 #ifndef O_RDONLY
44 #define O_RDONLY 0000
45 #endif
46 #endif
48 /* Because ANSI C EXIT_* are not always defined: */
49 #ifndef EXIT_FAILURE
50 #define EXIT_FAILURE 1
51 #endif
52 #ifndef EXIT_SUCCESS
53 #define EXIT_SUCCESS 0
54 #endif
57 On Linux glibc systems, we need to use sig.* versions of jmp_buf,
58 setjmp and longjmp to preserve the signal handling context.
59 Currently, the way I figured to detect this is if _SIGSET_H_types has
60 been defined in /usr/include/setjmp.h.
62 #ifdef _SIGSET_H_types
63 #define JMP_BUF sigjmp_buf
64 #define SETJMP(x) sigsetjmp( (x), 1)
65 #define LONGJMP siglongjmp
66 #else
67 #define JMP_BUF jmp_buf
68 #define SETJMP(x) setjmp( (x) )
69 #define LONGJMP longjmp
70 #endif
73 Type to store reference objects Id:
75 typedef int Tid;
76 typedef struct S0 T0;
77 struct S0{Tid id;};
80 The default channel used to print runtime error messages:
82 #define SE_ERR stderr
85 Eiffel type INTEGER is #2:
87 typedef int T2;
88 #define EIF_INTEGER T2
89 #define M2 (0)
90 #define EIF_INTEGER_BITS (CHAR_BIT*sizeof(int))
91 #define EIF_MINIMUM_INTEGER (INT_MIN)
92 #define EIF_MAXIMUM_INTEGER (INT_MAX)
95 Eiffel type CHARACTER is #3:
97 typedef unsigned char T3;
98 #define EIF_CHARACTER T3
99 #define M3 (0)
100 #define EIF_CHARACTER_BITS (CHAR_BIT)
101 #define EIF_MINIMUM_CHARACTER_CODE (0)
102 #define EIF_MAXIMUM_CHARACTER_CODE (255)
103 #define T3code(x) ((T2)(x))
104 #define T3to_integer(x) ((T2)((char)(x)))
105 #define T3to_bit(x) (x)
108 Eiffel type REAL is #4:
110 typedef float T4;
111 #define EIF_REAL T4
112 #define M4 (0.0)
113 #define EIF_REAL_BITS (CHAR_BIT*sizeof(float))
114 #define EIF_MINIMUM_REAL (-(FLT_MAX))
115 #define EIF_MAXIMUM_REAL (FLT_MAX)
116 #define T2toT4(x) ((T4)(x))
119 Eiffel type DOUBLE is #5:
121 typedef double T5;
122 #define EIF_DOUBLE T5
123 #define M5 (0.0)
124 #define EIF_DOUBLE_BITS (CHAR_BIT*sizeof(double))
125 #define EIF_MINIMUM_DOUBLE (-(DBL_MAX))
126 #define EIF_MAXIMUM_DOUBLE (DBL_MAX)
127 #define T2toT5(x) ((T5)(x))
128 #define T4toT5(x) ((T5)(x))
131 Eiffel type BOOLEAN is #6:
133 typedef char T6;
134 #define EIF_BOOLEAN T6
135 #define M6 (0)
136 #define EIF_BOOLEAN_BITS (CHAR_BIT)
139 Eiffel type POINTER is #8:
141 typedef void* T8;
142 #define EIF_POINTER T8
143 #define M8 (NULL)
144 #define EIF_POINTER_BITS (CHAR_BIT*sizeof(void*))
147 To use type STRING on the C side:
149 #define EIF_STRING T7*
152 Some Other EIF_* defined in ETL:
154 #define eif_access(x) ((char*)(x))
155 #define EIF_REFERENCE T0*
156 #define EIF_OBJ T0*
157 #define EIF_OBJECT EIF_OBJ
160 Wrappers for `malloc' and `calloc':
162 void* se_malloc(size_t size);
163 void* se_calloc(size_t nmemb, size_t size);
164 extern void*eiffel_root_object;
166 typedef char* T9;
167 /* Available Eiffel routines via -cecil:
169 void* EVENTMAKER_make_quit(int C);
170 void* EVENTMAKER_make_mbdown(int C,T2 a1,T2 a2,T2 a3,T2 a4);
171 void* EVENTMAKER_make_keydown(int C,T2 a1,T2 a2);