| 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 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 | /* Undefine HAVE_STRUCT_TIMESPEC, because the libguile C code doesn't |
| 43 | need it anymore, and because on MinGW: |
| 44 | |
| 45 | - the definition of struct timespec is provided (if at all) by |
| 46 | pthread.h |
| 47 | |
| 48 | - pthread.h will _not_ define struct timespec if |
| 49 | HAVE_STRUCT_TIMESPEC is 1, because then it thinks that it doesn't |
| 50 | need to. |
| 51 | |
| 52 | The libguile C code doesn't need HAVE_STRUCT_TIMESPEC anymore, |
| 53 | because the value of HAVE_STRUCT_TIMESPEC has already been |
| 54 | incorporated in how scm_t_timespec is defined (in scmconfig.h), and |
| 55 | the rest of the libguile C code now just uses scm_t_timespec. |
| 56 | */ |
| 57 | #ifdef HAVE_STRUCT_TIMESPEC |
| 58 | #undef HAVE_STRUCT_TIMESPEC |
| 59 | #endif |
| 60 | |
| 61 | #include <errno.h> |
| 62 | #include "libguile/__scm.h" |
| 63 | |
| 64 | /* Include headers for those files central to the implementation. The |
| 65 | rest should be explicitly #included in the C files themselves. */ |
| 66 | #include "libguile/error.h" /* Everyone signals errors. */ |
| 67 | #include "libguile/print.h" /* Everyone needs to print. */ |
| 68 | #include "libguile/pairs.h" /* Everyone conses. */ |
| 69 | #include "libguile/list.h" /* Everyone makes lists. */ |
| 70 | #include "libguile/gc.h" /* Everyone allocates. */ |
| 71 | #include "libguile/gsubr.h" /* Everyone defines global functions. */ |
| 72 | #include "libguile/procs.h" /* Same. */ |
| 73 | #include "libguile/numbers.h" /* Everyone deals with fixnums. */ |
| 74 | #include "libguile/symbols.h" /* For length, chars, values, miscellany. */ |
| 75 | #include "libguile/boolean.h" /* Everyone wonders about the truth. */ |
| 76 | #include "libguile/threads.h" /* You are not alone. */ |
| 77 | #include "libguile/snarf.h" /* Everyone snarfs. */ |
| 78 | #include "libguile/variable.h" |
| 79 | #include "libguile/modules.h" |
| 80 | #include "libguile/inline.h" |
| 81 | |
| 82 | #ifndef SCM_SYSCALL |
| 83 | #ifdef vms |
| 84 | # ifndef __GNUC__ |
| 85 | # include <ssdef.h> |
| 86 | # define SCM_SYSCALL(line) do{errno = 0;line;} \ |
| 87 | while(EVMSERR==errno && (vaxc$errno>>3)==(SS$_CONTROLC>>3)) |
| 88 | # endif /* ndef __GNUC__ */ |
| 89 | #endif /* def vms */ |
| 90 | #endif /* ndef SCM_SYSCALL */ |
| 91 | |
| 92 | #ifndef SCM_SYSCALL |
| 93 | # ifdef EINTR |
| 94 | # if (EINTR > 0) |
| 95 | # define SCM_SYSCALL(line) do{errno = 0;line;}while(EINTR==errno) |
| 96 | # endif /* (EINTR > 0) */ |
| 97 | # endif /* def EINTR */ |
| 98 | #endif /* ndef SCM_SYSCALL */ |
| 99 | |
| 100 | #ifndef SCM_SYSCALL |
| 101 | # define SCM_SYSCALL(line) line; |
| 102 | #endif /* ndef SCM_SYSCALL */ |
| 103 | |
| 104 | \f |
| 105 | |
| 106 | #ifndef min |
| 107 | #define min(A, B) ((A) <= (B) ? (A) : (B)) |
| 108 | #endif |
| 109 | #ifndef max |
| 110 | #define max(A, B) ((A) >= (B) ? (A) : (B)) |
| 111 | #endif |
| 112 | |
| 113 | |
| 114 | |
| 115 | #if GUILE_USE_64_CALLS && HAVE_STAT64 |
| 116 | #define CHOOSE_LARGEFILE(foo,foo64) foo64 |
| 117 | #else |
| 118 | #define CHOOSE_LARGEFILE(foo,foo64) foo |
| 119 | #endif |
| 120 | |
| 121 | /* These names are a bit long, but they make it clear what they represent. */ |
| 122 | #if SCM_HAVE_STRUCT_DIRENT64 == 1 |
| 123 | # define dirent_or_dirent64 CHOOSE_LARGEFILE(dirent,dirent64) |
| 124 | #else |
| 125 | # define dirent_or_dirent64 dirent |
| 126 | #endif |
| 127 | #define fstat_or_fstat64 CHOOSE_LARGEFILE(fstat,fstat64) |
| 128 | #define ftruncate_or_ftruncate64 CHOOSE_LARGEFILE(ftruncate,ftruncate64) |
| 129 | #define lseek_or_lseek64 CHOOSE_LARGEFILE(lseek,lseek64) |
| 130 | #define lstat_or_lstat64 CHOOSE_LARGEFILE(lstat,lstat64) |
| 131 | #define off_t_or_off64_t CHOOSE_LARGEFILE(off_t,off64_t) |
| 132 | #define open_or_open64 CHOOSE_LARGEFILE(open,open64) |
| 133 | #define readdir_or_readdir64 CHOOSE_LARGEFILE(readdir,readdir64) |
| 134 | #if SCM_HAVE_READDIR64_R == 1 |
| 135 | # define readdir_r_or_readdir64_r CHOOSE_LARGEFILE(readdir_r,readdir64_r) |
| 136 | #else |
| 137 | # define readdir_r_or_readdir64_r readdir_r |
| 138 | #endif |
| 139 | #define stat_or_stat64 CHOOSE_LARGEFILE(stat,stat64) |
| 140 | #define truncate_or_truncate64 CHOOSE_LARGEFILE(truncate,truncate64) |
| 141 | #define scm_from_off_t_or_off64_t CHOOSE_LARGEFILE(scm_from_off_t,scm_from_int64) |
| 142 | #define scm_from_ino_t_or_ino64_t CHOOSE_LARGEFILE(scm_from_ulong,scm_from_uint64) |
| 143 | #define scm_from_blkcnt_t_or_blkcnt64_t CHOOSE_LARGEFILE(scm_from_ulong,scm_from_uint64) |
| 144 | #define scm_to_off_t_or_off64_t CHOOSE_LARGEFILE(scm_to_off_t,scm_to_int64) |
| 145 | |
| 146 | #if SIZEOF_OFF_T == 4 |
| 147 | # define scm_to_off_t scm_to_int32 |
| 148 | # define scm_from_off_t scm_from_int32 |
| 149 | #elif SIZEOF_OFF_T == 8 |
| 150 | # define scm_to_off_t scm_to_int64 |
| 151 | # define scm_from_off_t scm_from_int64 |
| 152 | #else |
| 153 | # error sizeof(off_t) is not 4 or 8. |
| 154 | #endif |
| 155 | #define scm_to_off64_t scm_to_int64 |
| 156 | #define scm_from_off64_t scm_from_int64 |
| 157 | |
| 158 | |
| 159 | #endif /* SCM__SCM_H */ |
| 160 | |
| 161 | /* |
| 162 | Local Variables: |
| 163 | c-file-style: "gnu" |
| 164 | End: |
| 165 | */ |