* srfi-39.scm: Update copyright statement to LGPL.
[bpt/guile.git] / libguile / _scm.h
CommitLineData
0f2d19dd
JB
1/* classes: h_files */
2
0527e687
DH
3#ifndef SCM__SCM_H
4#define SCM__SCM_H
5
d3cf93bc 6/* Copyright (C) 1995,1996,2000,2001, 2002, 2006, 2008 Free Software Foundation, Inc.
0527e687 7 *
d3cf93bc
NJ
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.
0527e687 12 *
d3cf93bc 13 * This library is distributed in the hope that it will be useful,
0f2d19dd 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d3cf93bc
NJ
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
0527e687 17 *
d3cf93bc
NJ
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 */
0527e687 22
0f2d19dd
JB
23\f
24
b49ed9c9
RB
25/**********************************************************************
26 This file is Guile's central private header.
20e6290e 27
b49ed9c9
RB
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 **********************************************************************/
176067df 32
9a5fa6e9
NJ
33#if defined(__ia64) && !defined(__ia64__)
34# define __ia64__
35#endif
176067df 36
b49ed9c9
RB
37#if HAVE_CONFIG_H
38# include <config.h>
39#endif
176067df 40
b49ed9c9
RB
41#include <errno.h>
42#include "libguile/__scm.h"
462a6f1f 43
20e6290e
JB
44/* Include headers for those files central to the implementation. The
45 rest should be explicitly #included in the C files themselves. */
a0599745
MD
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. */
3d7f708f 56#include "libguile/threads.h" /* You are not alone. */
a0599745 57#include "libguile/snarf.h" /* Everyone snarfs. */
86d31dfe
MV
58#include "libguile/variable.h"
59#include "libguile/modules.h"
0f633e66 60#include "libguile/inline.h"
0f2d19dd 61
e1a191a8
GH
62/* SCM_SYSCALL retries system calls that have been interrupted (EINTR).
63 However this can be avoided if the operating system can restart
64 system calls automatically. We assume this is the case if
65 sigaction is available and SA_RESTART is defined; they will be used
66 when installing signal handlers.
67 */
68
08b8c694 69#ifdef HAVE_RESTARTABLE_SYSCALLS
17403ebc
RB
70#if ! SCM_USE_PTHREAD_THREADS /* However, don't assume SA_RESTART
71 works with pthreads... */
e1a191a8
GH
72#define SCM_SYSCALL(line) line
73#endif
845944c3 74#endif
e1a191a8
GH
75
76#ifndef SCM_SYSCALL
0f2d19dd
JB
77#ifdef vms
78# ifndef __GNUC__
79# include <ssdef.h>
80# define SCM_SYSCALL(line) do{errno = 0;line;} \
81 while(EVMSERR==errno && (vaxc$errno>>3)==(SS$_CONTROLC>>3))
82# endif /* ndef __GNUC__ */
83#endif /* def vms */
e1a191a8 84#endif /* ndef SCM_SYSCALL */
0f2d19dd
JB
85
86#ifndef SCM_SYSCALL
87# ifdef EINTR
88# if (EINTR > 0)
89# define SCM_SYSCALL(line) do{errno = 0;line;}while(EINTR==errno)
90# endif /* (EINTR > 0) */
91# endif /* def EINTR */
92#endif /* ndef SCM_SYSCALL */
93
94#ifndef SCM_SYSCALL
e1a191a8 95# define SCM_SYSCALL(line) line;
0f2d19dd
JB
96#endif /* ndef SCM_SYSCALL */
97
82893676 98#if !defined (MSDOS) && !defined (__MINGW32__)
0f2d19dd
JB
99# ifdef ARM_ULIB
100 extern volatile int errno;
101# else
102 extern int errno;
103# endif /* def ARM_ULIB */
82893676 104#endif /* ndef MSDOS && ndef __MINGW32__*/
0f2d19dd
JB
105
106\f
107
e412e180 108#ifndef min
34d19ef6 109#define min(A, B) ((A) <= (B) ? (A) : (B))
e412e180
MD
110#endif
111#ifndef max
34d19ef6 112#define max(A, B) ((A) >= (B) ? (A) : (B))
e412e180 113#endif
462a6f1f 114
2b829bbb
KR
115
116
117#if HAVE_STAT64
118#define CHOOSE_LARGEFILE(foo,foo64) foo64
119#else
120#define CHOOSE_LARGEFILE(foo,foo64) foo
121#endif
122
123/* These names are a bit long, but they make it clear what they represent. */
124#define dirent_or_dirent64 CHOOSE_LARGEFILE(dirent,dirent64)
125#define fstat_or_fstat64 CHOOSE_LARGEFILE(fstat,fstat64)
126#define ftruncate_or_ftruncate64 CHOOSE_LARGEFILE(ftruncate,ftruncate64)
22acb298 127#define lseek_or_lseek64 CHOOSE_LARGEFILE(lseek,lseek64)
2b829bbb
KR
128#define lstat_or_lstat64 CHOOSE_LARGEFILE(lstat,lstat64)
129#define off_t_or_off64_t CHOOSE_LARGEFILE(off_t,off64_t)
130#define open_or_open64 CHOOSE_LARGEFILE(open,open64)
131#define readdir_or_readdir64 CHOOSE_LARGEFILE(readdir,readdir64)
132#define readdir_r_or_readdir64_r CHOOSE_LARGEFILE(readdir_r,readdir64_r)
133#define stat_or_stat64 CHOOSE_LARGEFILE(stat,stat64)
134#define truncate_or_truncate64 CHOOSE_LARGEFILE(truncate,truncate64)
135#define scm_from_off_t_or_off64_t CHOOSE_LARGEFILE(scm_from_off_t,scm_from_int64)
136#define scm_from_ino_t_or_ino64_t CHOOSE_LARGEFILE(scm_from_ulong,scm_from_uint64)
137#define scm_from_blkcnt_t_or_blkcnt64_t CHOOSE_LARGEFILE(scm_from_ulong,scm_from_uint64)
138#define scm_to_off_t_or_off64_t CHOOSE_LARGEFILE(scm_to_off_t,scm_to_int64)
139
140#if SIZEOF_OFF_T == 4
22acb298
KR
141# define scm_to_off_t scm_to_int32
142# define scm_from_off_t scm_from_int32
143#elif SIZEOF_OFF_T == 8
144# define scm_to_off_t scm_to_int64
145# define scm_from_off_t scm_from_int64
146#else
147# error sizeof(off_t) is not 4 or 8.
2b829bbb 148#endif
8ab3d8a0
KR
149#define scm_to_off64_t scm_to_int64
150#define scm_from_off64_t scm_from_int64
2b829bbb
KR
151
152
0527e687 153#endif /* SCM__SCM_H */
89e00824
ML
154
155/*
156 Local Variables:
157 c-file-style: "gnu"
158 End:
159*/