Add `struct-ref' and `struct-set' VM opcodes.
[bpt/guile.git] / libguile / _scm.h
1 /* classes: h_files */
2
3 #ifndef SCM__SCM_H
4 #define SCM__SCM_H
5
6 /* Copyright (C) 1995,1996,2000,2001, 2002, 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 3 of
11 * the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 */
23
24 \f
25
26 /**********************************************************************
27 This file is Guile's central private header.
28
29 When included by other files, this file should preceed any include
30 other than __scm.h. See __scm.h for details regarding the purpose of
31 and differences between _scm.h and __scm.h.
32 **********************************************************************/
33
34 #if defined(__ia64) && !defined(__ia64__)
35 # define __ia64__
36 #endif
37
38 #if HAVE_CONFIG_H
39 # include <config.h>
40 #endif
41
42 /* The size of `scm_t_bits'. */
43 #define SIZEOF_SCM_T_BITS SIZEOF_VOID_P
44
45 /* Undefine HAVE_STRUCT_TIMESPEC, because the libguile C code doesn't
46 need it anymore, and because on MinGW:
47
48 - the definition of struct timespec is provided (if at all) by
49 pthread.h
50
51 - pthread.h will _not_ define struct timespec if
52 HAVE_STRUCT_TIMESPEC is 1, because then it thinks that it doesn't
53 need to.
54
55 The libguile C code doesn't need HAVE_STRUCT_TIMESPEC anymore,
56 because the value of HAVE_STRUCT_TIMESPEC has already been
57 incorporated in how scm_t_timespec is defined (in scmconfig.h), and
58 the rest of the libguile C code now just uses scm_t_timespec.
59 */
60 #ifdef HAVE_STRUCT_TIMESPEC
61 #undef HAVE_STRUCT_TIMESPEC
62 #endif
63
64 #include <errno.h>
65 #include <verify.h>
66 #include "libguile/__scm.h"
67
68 /* Include headers for those files central to the implementation. The
69 rest should be explicitly #included in the C files themselves. */
70 #include "libguile/error.h" /* Everyone signals errors. */
71 #include "libguile/print.h" /* Everyone needs to print. */
72 #include "libguile/pairs.h" /* Everyone conses. */
73 #include "libguile/list.h" /* Everyone makes lists. */
74 #include "libguile/gc.h" /* Everyone allocates. */
75 #include "libguile/gsubr.h" /* Everyone defines global functions. */
76 #include "libguile/procs.h" /* Same. */
77 #include "libguile/numbers.h" /* Everyone deals with fixnums. */
78 #include "libguile/symbols.h" /* For length, chars, values, miscellany. */
79 #include "libguile/boolean.h" /* Everyone wonders about the truth. */
80 #include "libguile/threads.h" /* You are not alone. */
81 #include "libguile/snarf.h" /* Everyone snarfs. */
82 #include "libguile/foreign.h" /* Snarfing needs the foreign data structures. */
83 #include "libguile/programs.h" /* ... and program.h. */
84 #include "libguile/variable.h"
85 #include "libguile/modules.h"
86 #include "libguile/inline.h"
87 #include "libguile/strings.h"
88
89 #ifndef SCM_SYSCALL
90 #ifdef vms
91 # ifndef __GNUC__
92 # include <ssdef.h>
93 # define SCM_SYSCALL(line) do{errno = 0;line;} \
94 while(EVMSERR==errno && (vaxc$errno>>3)==(SS$_CONTROLC>>3))
95 # endif /* ndef __GNUC__ */
96 #endif /* def vms */
97 #endif /* ndef SCM_SYSCALL */
98
99 #ifndef SCM_SYSCALL
100 # ifdef EINTR
101 # if (EINTR > 0)
102 # define SCM_SYSCALL(line) do{errno = 0;line;}while(EINTR==errno)
103 # endif /* (EINTR > 0) */
104 # endif /* def EINTR */
105 #endif /* ndef SCM_SYSCALL */
106
107 #ifndef SCM_SYSCALL
108 # define SCM_SYSCALL(line) line;
109 #endif /* ndef SCM_SYSCALL */
110
111 \f
112
113 #ifndef min
114 #define min(A, B) ((A) <= (B) ? (A) : (B))
115 #endif
116 #ifndef max
117 #define max(A, B) ((A) >= (B) ? (A) : (B))
118 #endif
119
120
121
122 #if GUILE_USE_64_CALLS && HAVE_STAT64
123 #define CHOOSE_LARGEFILE(foo,foo64) foo64
124 #else
125 #define CHOOSE_LARGEFILE(foo,foo64) foo
126 #endif
127
128 /* These names are a bit long, but they make it clear what they represent. */
129 #if SCM_HAVE_STRUCT_DIRENT64 == 1
130 # define dirent_or_dirent64 CHOOSE_LARGEFILE(dirent,dirent64)
131 #else
132 # define dirent_or_dirent64 dirent
133 #endif
134 #define fstat_or_fstat64 CHOOSE_LARGEFILE(fstat,fstat64)
135 #define ftruncate_or_ftruncate64 CHOOSE_LARGEFILE(ftruncate,ftruncate64)
136 #define lseek_or_lseek64 CHOOSE_LARGEFILE(lseek,lseek64)
137 #define lstat_or_lstat64 CHOOSE_LARGEFILE(lstat,lstat64)
138 #define off_t_or_off64_t CHOOSE_LARGEFILE(off_t,off64_t)
139 #define open_or_open64 CHOOSE_LARGEFILE(open,open64)
140 #define readdir_or_readdir64 CHOOSE_LARGEFILE(readdir,readdir64)
141 #if SCM_HAVE_READDIR64_R == 1
142 # define readdir_r_or_readdir64_r CHOOSE_LARGEFILE(readdir_r,readdir64_r)
143 #else
144 # define readdir_r_or_readdir64_r readdir_r
145 #endif
146 #define stat_or_stat64 CHOOSE_LARGEFILE(stat,stat64)
147 #define truncate_or_truncate64 CHOOSE_LARGEFILE(truncate,truncate64)
148 #define scm_from_off_t_or_off64_t CHOOSE_LARGEFILE(scm_from_off_t,scm_from_int64)
149 #define scm_from_ino_t_or_ino64_t CHOOSE_LARGEFILE(scm_from_ulong,scm_from_uint64)
150 #define scm_from_blkcnt_t_or_blkcnt64_t CHOOSE_LARGEFILE(scm_from_ulong,scm_from_uint64)
151 #define scm_to_off_t_or_off64_t CHOOSE_LARGEFILE(scm_to_off_t,scm_to_int64)
152
153 #if SIZEOF_OFF_T == 4
154 # define scm_to_off_t scm_to_int32
155 # define scm_from_off_t scm_from_int32
156 #elif SIZEOF_OFF_T == 8
157 # define scm_to_off_t scm_to_int64
158 # define scm_from_off_t scm_from_int64
159 #else
160 # error sizeof(off_t) is not 4 or 8.
161 #endif
162 #define scm_to_off64_t scm_to_int64
163 #define scm_from_off64_t scm_from_int64
164
165
166 /* The endianness marker in objcode. */
167 #ifdef WORDS_BIGENDIAN
168 # define SCM_OBJCODE_ENDIANNESS "BE"
169 #else
170 # define SCM_OBJCODE_ENDIANNESS "LE"
171 #endif
172
173 #define _SCM_CPP_STRINGIFY(x) # x
174 #define SCM_CPP_STRINGIFY(x) _SCM_CPP_STRINGIFY (x)
175
176 /* The word size marker in objcode. */
177 #define SCM_OBJCODE_WORD_SIZE SCM_CPP_STRINGIFY (SIZEOF_VOID_P)
178
179 /* Major and minor versions must be single characters. */
180 #define SCM_OBJCODE_MAJOR_VERSION 0
181 #define SCM_OBJCODE_MINOR_VERSION O
182 #define SCM_OBJCODE_MAJOR_VERSION_STRING \
183 SCM_CPP_STRINGIFY(SCM_OBJCODE_MAJOR_VERSION)
184 #define SCM_OBJCODE_MINOR_VERSION_STRING \
185 SCM_CPP_STRINGIFY(SCM_OBJCODE_MINOR_VERSION)
186 #define SCM_OBJCODE_VERSION_STRING \
187 SCM_OBJCODE_MAJOR_VERSION_STRING "." SCM_OBJCODE_MINOR_VERSION_STRING
188 #define SCM_OBJCODE_MACHINE_VERSION_STRING \
189 SCM_OBJCODE_VERSION_STRING "-" SCM_OBJCODE_ENDIANNESS "-" SCM_OBJCODE_WORD_SIZE
190
191 /* The objcode magic header. */
192 #define SCM_OBJCODE_COOKIE \
193 "GOOF-" SCM_OBJCODE_MACHINE_VERSION_STRING "---"
194
195
196 #endif /* SCM__SCM_H */
197
198 /*
199 Local Variables:
200 c-file-style: "gnu"
201 End:
202 */