_scm.h 6.7 KB

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