Merge branch 'boehm-demers-weiser-gc' into bdw-gc-static-alloc
[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 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
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but 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 02110-1301 USA
21 */
22
23 \f
24
25 /**********************************************************************
26 This file is Guile's central private header.
27
28 When included by other files, this file should preceed any include
29 other than __scm.h. See __scm.h for details regarding the purpose of
30 and differences between _scm.h and __scm.h.
31 **********************************************************************/
32
33 #if defined(__ia64) && !defined(__ia64__)
34 # define __ia64__
35 #endif
36
37 #if HAVE_CONFIG_H
38 # include <config.h>
39 #endif
40
41 #include <errno.h>
42 #include "libguile/__scm.h"
43
44 /* Include headers for those files central to the implementation. The
45 rest should be explicitly #included in the C files themselves. */
46 #include "libguile/error.h" /* Everyone signals errors. */
47 #include "libguile/print.h" /* Everyone needs to print. */
48 #include "libguile/pairs.h" /* Everyone conses. */
49 #include "libguile/list.h" /* Everyone makes lists. */
50 #include "libguile/gc.h" /* Everyone allocates. */
51 #include "libguile/gsubr.h" /* Everyone defines global functions. */
52 #include "libguile/procs.h" /* Same. */
53 #include "libguile/numbers.h" /* Everyone deals with fixnums. */
54 #include "libguile/symbols.h" /* For length, chars, values, miscellany. */
55 #include "libguile/boolean.h" /* Everyone wonders about the truth. */
56 #include "libguile/threads.h" /* You are not alone. */
57 #include "libguile/snarf.h" /* Everyone snarfs. */
58 #include "libguile/variable.h"
59 #include "libguile/modules.h"
60 #include "libguile/inline.h"
61 #include "libguile/strings.h"
62
63 /* SCM_SYSCALL retries system calls that have been interrupted (EINTR).
64 However this can be avoided if the operating system can restart
65 system calls automatically. We assume this is the case if
66 sigaction is available and SA_RESTART is defined; they will be used
67 when installing signal handlers.
68 */
69
70 #ifdef HAVE_RESTARTABLE_SYSCALLS
71 #if ! SCM_USE_PTHREAD_THREADS /* However, don't assume SA_RESTART
72 works with pthreads... */
73 #define SCM_SYSCALL(line) line
74 #endif
75 #endif
76
77 #ifndef SCM_SYSCALL
78 #ifdef vms
79 # ifndef __GNUC__
80 # include <ssdef.h>
81 # define SCM_SYSCALL(line) do{errno = 0;line;} \
82 while(EVMSERR==errno && (vaxc$errno>>3)==(SS$_CONTROLC>>3))
83 # endif /* ndef __GNUC__ */
84 #endif /* def vms */
85 #endif /* ndef SCM_SYSCALL */
86
87 #ifndef SCM_SYSCALL
88 # ifdef EINTR
89 # if (EINTR > 0)
90 # define SCM_SYSCALL(line) do{errno = 0;line;}while(EINTR==errno)
91 # endif /* (EINTR > 0) */
92 # endif /* def EINTR */
93 #endif /* ndef SCM_SYSCALL */
94
95 #ifndef SCM_SYSCALL
96 # define SCM_SYSCALL(line) line;
97 #endif /* ndef SCM_SYSCALL */
98
99 \f
100
101 #ifndef min
102 #define min(A, B) ((A) <= (B) ? (A) : (B))
103 #endif
104 #ifndef max
105 #define max(A, B) ((A) >= (B) ? (A) : (B))
106 #endif
107
108
109
110 #if GUILE_USE_64_CALLS && HAVE_STAT64
111 #define CHOOSE_LARGEFILE(foo,foo64) foo64
112 #else
113 #define CHOOSE_LARGEFILE(foo,foo64) foo
114 #endif
115
116 /* These names are a bit long, but they make it clear what they represent. */
117 #if SCM_HAVE_STRUCT_DIRENT64 == 1
118 # define dirent_or_dirent64 CHOOSE_LARGEFILE(dirent,dirent64)
119 #else
120 # define dirent_or_dirent64 dirent
121 #endif
122 #define fstat_or_fstat64 CHOOSE_LARGEFILE(fstat,fstat64)
123 #define ftruncate_or_ftruncate64 CHOOSE_LARGEFILE(ftruncate,ftruncate64)
124 #define lseek_or_lseek64 CHOOSE_LARGEFILE(lseek,lseek64)
125 #define lstat_or_lstat64 CHOOSE_LARGEFILE(lstat,lstat64)
126 #define off_t_or_off64_t CHOOSE_LARGEFILE(off_t,off64_t)
127 #define open_or_open64 CHOOSE_LARGEFILE(open,open64)
128 #define readdir_or_readdir64 CHOOSE_LARGEFILE(readdir,readdir64)
129 #if SCM_HAVE_READDIR64_R == 1
130 # define readdir_r_or_readdir64_r CHOOSE_LARGEFILE(readdir_r,readdir64_r)
131 #else
132 # define readdir_r_or_readdir64_r readdir_r
133 #endif
134 #define stat_or_stat64 CHOOSE_LARGEFILE(stat,stat64)
135 #define truncate_or_truncate64 CHOOSE_LARGEFILE(truncate,truncate64)
136 #define scm_from_off_t_or_off64_t CHOOSE_LARGEFILE(scm_from_off_t,scm_from_int64)
137 #define scm_from_ino_t_or_ino64_t CHOOSE_LARGEFILE(scm_from_ulong,scm_from_uint64)
138 #define scm_from_blkcnt_t_or_blkcnt64_t CHOOSE_LARGEFILE(scm_from_ulong,scm_from_uint64)
139 #define scm_to_off_t_or_off64_t CHOOSE_LARGEFILE(scm_to_off_t,scm_to_int64)
140
141 #if SIZEOF_OFF_T == 4
142 # define scm_to_off_t scm_to_int32
143 # define scm_from_off_t scm_from_int32
144 #elif SIZEOF_OFF_T == 8
145 # define scm_to_off_t scm_to_int64
146 # define scm_from_off_t scm_from_int64
147 #else
148 # error sizeof(off_t) is not 4 or 8.
149 #endif
150 #define scm_to_off64_t scm_to_int64
151 #define scm_from_off64_t scm_from_int64
152
153
154 #endif /* SCM__SCM_H */
155
156 /*
157 Local Variables:
158 c-file-style: "gnu"
159 End:
160 */