source: project/chicken/trunk/chicken.h @ 15869

Last change on this file since 15869 was 15869, checked in by Kon Lovett, 10 years ago

library Added new dynamic library sys namespace procedures
runtime Added support for non-chicken dynload, "folded" 'C_dload2' into platform indep routine
chicken Added new dynload procs
eval Made dynload flags a parameter, added new dynload routines (only a subset is "public", i.e. non-sys namespace)

File size: 85.4 KB
Line 
1/* chicken.h - General headerfile for compiler generated executables
2;
3; Copyright (c) 2000-2007, Felix L. Winkelmann
4; Copyright (c) 2008-2009, The Chicken Team
5; All rights reserved.
6;
7; Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
8; conditions are met:
9;
10;   Redistributions of source code must retain the above copyright notice, this list of conditions and the following
11;     disclaimer.
12;   Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
13;     disclaimer in the documentation and/or other materials provided with the distribution.
14;   Neither the name of the author nor the names of its contributors may be used to endorse or promote
15;     products derived from this software without specific prior written permission.
16;
17; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
18; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
19; AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
20; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25; POSSIBILITY OF SUCH DAMAGE.
26*/
27
28/* Configuration: */
29
30/*
31 * The Watcom (__WATCOMC__), Metroworks (__MWERKS__), and Delorie (__DJGPP__)
32 * compilers are not currently supported but existing references remain,
33 * just in case.
34 */
35
36#ifndef ___CHICKEN
37#define ___CHICKEN
38
39#define C_MAJOR_VERSION       4
40
41/*
42 * N.B. This file MUST not rely upon "chicken-config.h"
43 */
44#if defined(HAVE_CONFIG_H) || defined(HAVE_CHICKEN_CONFIG_H)
45# include "chicken-config.h"
46#endif
47
48
49/* Kind of platform */
50
51#ifndef C_SIXTY_FOUR
52# if defined (__alpha__) || defined(__ia64__) || defined(__x86_64__) || defined(__LP64__) || defined(__powerpc64__)
53#   define C_SIXTY_FOUR
54# elif (defined(__sparc_v9__) || defined(__sparcv9)) && defined(__arch64__)
55#   define C_SIXTY_FOUR
56# elif defined(__mips64) && (!defined(__GNUC__) || _MIPS_SZPTR == 64)
57#   define C_SIXTY_FOUR
58# endif
59#endif
60
61#if defined(__APPLE__) && defined(__MACH__)
62# define C_MACOSX
63#endif
64
65#if defined(C_MACOSX) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
66# define C_XXXBSD
67#endif
68
69#if /*defined(__GNUC__) &&*/ (defined(__linux__) || defined(C_XXXBSD))
70# define C_GNU_ENV
71#endif
72
73#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__WATCOMC__) || defined(__MWERKS__) || defined(__DJGPP__)
74# define C_NONUNIX
75#endif
76
77
78/* Headers */
79
80#include <stdio.h>
81#include <stdlib.h>
82#include <stdarg.h>
83#include <ctype.h>
84#include <string.h>
85#include <setjmp.h>
86#include <limits.h>
87#include <time.h>
88
89#if !defined(C_NONUNIX) || defined(__MINGW32__) || defined(__WATCOMC__)
90# include <unistd.h>
91# include <inttypes.h>
92# include <sys/types.h>
93#endif
94
95/* Byteorder in machine word */
96
97#if defined(__MINGW32__)
98# include <sys/param.h>
99#elif defined(__CYGWIN__)
100# include <endian.h>
101#elif defined(__linux__)
102# include <endian.h>
103#elif defined(C_XXXBSD)
104# include <machine/endian.h>
105#elif defined(__hpux__)
106# include <arpa/nameser.h>
107#elif defined(_AIX)
108# include <sys/machine.h>
109#elif defined(__sun__)
110# include <sys/isa_defs.h>
111#elif defined(__svr4__)
112# include <sys/byteorder.h>
113#endif
114
115#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__WATCOMC__)
116# include <malloc.h>
117#endif
118
119#ifdef _MSC_VER
120# include <io.h>
121#endif
122
123/* Much better with stack allocation API */
124
125#if defined(_MSC_VER)
126# if HAVE_ALLOCA_H
127#  define alloca            _alloca
128# endif
129#elif !defined(__GNUC__) && !defined(__WATCOMC__)
130# if HAVE_ALLOCA_H
131#  include <alloca.h>
132# elif defined(_AIX)
133#   pragma alloca
134# elif !defined(alloca) /* predefined by HP cc +Olibcalls */
135    char *alloca ();
136# endif
137#elif (defined(__sun__) && defined(__svr4__)) || defined(__sgi__)
138# if HAVE_ALLOCA_H
139#  include <alloca.h>
140# endif
141#endif
142
143
144/* Chicken Core C API */
145
146#if defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN
147# define C_BIG_ENDIAN
148#elif defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
149# define C_BIG_ENDIAN
150#elif defined(__BIG_ENDIAN__)
151# define C_BIG_ENDIAN
152#elif defined(__sparc__) || defined(__POWERPC__) || defined(__MC68K__) || defined(__mips__)
153# define C_BIG_ENDIAN
154#endif
155
156#if defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN
157# define C_LITTLE_ENDIAN
158#elif defined(BYTE_ORDER) && defined(LITTLE_ENDIAN) && BYTE_ORDER == LITTLE_ENDIAN
159# define C_LITTLE_ENDIAN
160#elif defined(__LITTLE_ENDIAN__)
161# define C_LITTLE_ENDIAN
162#elif defined (__alpha__) || defined(_M_IX86) || defined(__i386__) || defined(__x86_64__) || defined(__ia64__)
163# define C_LITTLE_ENDIAN
164#endif
165
166/* Make sure some common C identifiers are availble w/ Windows */
167
168#ifdef _MSC_VER
169# define strncasecmp       strnicmp
170# define isatty            _isatty
171typedef __int8             int8_t;
172typedef unsigned __int8    uint8_t;
173typedef __int16            int16_t;
174typedef unsigned  __int16  uint16_t;
175typedef __int32            int32_t;
176typedef unsigned __int32   uint32_t;
177typedef __int64            int64_t;
178typedef unsigned __int64   uint64_t;
179# pragma warning(disable: 4101)
180#endif
181
182/* Could be used by C++ source */
183
184#ifdef __cplusplus
185# define C_extern                  extern "C"
186# define C_BEGIN_C_DECLS           extern "C" {
187# define C_END_C_DECLS             }
188#else
189# define C_extern                  extern
190# define C_BEGIN_C_DECLS
191# define C_END_C_DECLS
192#endif
193
194
195/* Function declaration modes */
196
197/* Visibility */
198#define C_varextern                C_extern
199#define C_fctimport
200#define C_fctexport
201#define C_externimport             C_extern
202#define C_externexport             C_extern
203#if defined(PIC)
204# if defined(__CYGWIN__) || defined(__MINGW32__)
205#  ifndef C_BUILDING_LIBCHICKEN
206#   undef  C_varextern
207#   define C_varextern             C_extern __declspec(dllimport)
208#  endif
209# elif defined(_MSC_VER)
210#  undef  C_fctimport
211#  define C_fctimport              __declspec(dllexport)
212#  undef  C_externimport
213#  undef  C_externexport
214#  define C_externexport           C_extern __declspec(dllexport)
215#  undef  C_varextern
216#  undef  C_fctexport
217#  ifdef C_BUILDING_LIBCHICKEN
218#   define C_varextern             C_extern __declspec(dllexport)
219#   define C_fctexport             __declspec(dllexport)
220#   define C_externimport          C_extern __declspec(dllexport)
221#  else
222#   define C_varextern             C_extern __declspec(dllimport)
223#   define C_fctexport             __declspec(dllimport)
224#   define C_externimport          C_extern __declspec(dllimport)
225#  endif
226# elif defined(__WATCOMC__)
227#  undef  C_fctimport
228#  define C_fctimport              __declspec(dllexport)
229#  undef  C_externimport
230#  undef  C_externexport
231#  define C_externexport           C_extern __declspec(dllexport)
232#  undef  C_varextern
233#  undef  C_fctexport
234#  ifdef C_BUILDING_LIBCHICKEN
235#   define C_varextern             C_extern __declspec(dllexport)
236#   define C_fctexport             __declspec(dllexport)
237#   define C_externimport          C_extern __declspec(dllexport)
238#  else
239#   define C_varextern             C_extern __declspec(dllimport)
240#   define C_fctexport             __declspec(dllimport)
241#   define C_externimport          C_extern __declspec(dllimport)
242#  endif
243# endif
244#endif
245
246/* Language specifics: */
247#if defined(__GNUC__) || defined(__INTEL_COMPILER)
248# ifndef __cplusplus
249#  define C_cblock                ({
250#  define C_cblockend             })
251#  define C_noret                 __attribute__ ((noreturn))
252#  define C_noret_decl(name)
253#  define C_aligned               __attribute__ ((aligned))
254# endif
255# ifdef __i386__
256#  define C_regparm               __attribute__ ((regparm(3)))
257# endif
258#elif defined(_MSC_VER)
259# define C_fcall                  __fastcall
260#elif defined(__WATCOMC__)
261# define C_ccall                  __cdecl
262#endif
263
264#ifndef C_cblock
265# define C_cblock                 do{
266# define C_cblockend              }while(0)
267# define C_noret
268# define C_noret_decl(name)
269#endif
270
271#ifndef C_regparm
272# define C_regparm
273#endif
274
275#ifndef C_fcall
276# define C_fcall
277#endif
278
279#ifndef C_ccall
280# define C_ccall
281#endif
282
283#ifndef C_aligned
284# define C_aligned
285#endif
286
287#define C_c_regparm
288
289/* Thread Local Stoarage */
290#ifdef C_ENABLE_TLS
291# if defined(__GNUC__)
292#  define C_TLS                    __thread
293# elif defined(_MSC_VER)
294#  define C_TLS                    __declspec(thread)
295# endif
296#endif
297
298#ifndef C_TLS
299# define C_TLS
300#endif
301
302
303/* Stack growth direction; used to compute stack addresses */
304
305#ifndef C_STACK_GROWS_DOWNWARD
306# define C_STACK_GROWS_DOWNWARD    -1
307#endif
308
309#if C_STACK_GROWS_DOWNWARD == -1
310# ifdef __hppa__
311#  undef C_STACK_GROWS_DOWNWARD
312#  define C_STACK_GROWS_DOWNWARD 0
313# else
314#  undef C_STACK_GROWS_DOWNWARD
315#  define C_STACK_GROWS_DOWNWARD 1
316# endif
317#endif
318
319/* Have a GUI? */
320
321#if defined(C_WINDOWS_GUI)
322# define C_MICROSOFT_WINDOWS
323# include <windows.h>
324# ifndef WINAPI
325#  define WINAPI
326# endif
327#else
328# define C_GENERIC_CONSOLE
329#endif
330
331/* Needed for pre-emptive threading */
332
333#define C_TIMER_INTERRUPTS
334
335/* For the easy FFI: */
336
337#define ___fixnum           int
338#define ___number           double
339#define ___bool             int
340#define ___byte             char
341#define ___scheme_value     C_word
342#define ___scheme_pointer   void *
343#define ___byte_vector      unsigned char *
344#define ___symbol           char *
345#define ___safe
346#define ___declare(x, y)
347#define ___specialize
348#define ___abstract
349#define ___discard
350#define ___in
351#define ___out
352#define ___inout
353#define ___mutable
354#define ___length(var)
355#define ___pointer
356#define ___u32              C_u32
357#define ___s32              C_s32
358#define ___u64              C_u64
359#define ___s64              C_s64
360
361
362/* Constants: */
363
364#define C_STACK_RESERVE                   4096
365#define C_DEFAULT_MAX_PENDING_FINALIZERS  2048
366
367#define C_IMMEDIATE_MARK_BITS     0x00000003
368#define C_IMMEDIATE_TYPE_BITS     0x0000000f
369
370#define C_BOOLEAN_BITS            0x00000006
371#define C_CHARACTER_BITS          0x0000000a
372#define C_SPECIAL_BITS            0x0000000e
373
374#define C_SCHEME_FALSE            ((C_word)(C_BOOLEAN_BITS | 0x00000000))
375#define C_SCHEME_TRUE             ((C_word)(C_BOOLEAN_BITS | 0x00000010))
376
377#define C_SCHEME_END_OF_LIST      ((C_word)(C_SPECIAL_BITS | 0x00000000))
378#define C_SCHEME_UNDEFINED        ((C_word)(C_SPECIAL_BITS | 0x00000010))
379#define C_SCHEME_UNBOUND          ((C_word)(C_SPECIAL_BITS | 0x00000020))
380#define C_SCHEME_END_OF_FILE      ((C_word)(C_SPECIAL_BITS | 0x00000030))
381
382#define C_FIXNUM_BIT              0x00000001
383#define C_FIXNUM_SHIFT            1
384
385/* Character range is that of a UTF-8 codepoint, not representable range */
386#define C_CHAR_BIT_MASK           0x1fffff
387#define C_CHAR_SHIFT              8
388
389#ifdef C_SIXTY_FOUR
390# define C_MOST_POSITIVE_FIXNUM   0x3fffffffffffffffL
391# define C_WORD_SIZE              64
392#else
393# define C_MOST_POSITIVE_FIXNUM   0x3fffffff
394# define C_WORD_SIZE              32
395#endif
396
397#define C_MOST_NEGATIVE_FIXNUM    (-C_MOST_POSITIVE_FIXNUM - 1)
398
399#ifdef C_SIXTY_FOUR
400# define C_INT_SIGN_BIT           0x8000000000000000L
401# define C_INT_TOP_BIT            0x4000000000000000L
402# define C_HEADER_BITS_MASK       0xff00000000000000L
403# define C_HEADER_TYPE_BITS       0x0f00000000000000L
404# define C_HEADER_SIZE_MASK       0x00ffffffffffffffL
405# define C_GC_FORWARDING_BIT      0x8000000000000000L   /* header contains forwarding pointer */
406# define C_BYTEBLOCK_BIT          0x4000000000000000L   /* block contains bytes instead of slots */
407# define C_SPECIALBLOCK_BIT       0x2000000000000000L   /* 1st item is a non-value */
408# define C_8ALIGN_BIT             0x1000000000000000L   /* data is aligned to 8-byte boundary */
409
410# define C_SYMBOL_TYPE            (0x0100000000000000L)
411# define C_STRING_TYPE            (0x0200000000000000L | C_BYTEBLOCK_BIT)
412# define C_PAIR_TYPE              (0x0300000000000000L)
413# define C_CLOSURE_TYPE           (0x0400000000000000L | C_SPECIALBLOCK_BIT)
414# define C_FLONUM_TYPE            (0x0500000000000000L | C_BYTEBLOCK_BIT | C_8ALIGN_BIT)
415/*       unused                   (0x0600000000000000L ...) */
416# define C_PORT_TYPE              (0x0700000000000000L | C_SPECIALBLOCK_BIT)
417# define C_STRUCTURE_TYPE         (0x0800000000000000L)
418# define C_POINTER_TYPE           (0x0900000000000000L | C_SPECIALBLOCK_BIT)
419# define C_LOCATIVE_TYPE          (0x0a00000000000000L | C_SPECIALBLOCK_BIT)
420# define C_TAGGED_POINTER_TYPE    (0x0b00000000000000L | C_SPECIALBLOCK_BIT)
421# define C_SWIG_POINTER_TYPE      (0x0c00000000000000L | C_SPECIALBLOCK_BIT)
422# define C_LAMBDA_INFO_TYPE       (0x0d00000000000000L | C_BYTEBLOCK_BIT)
423/*       unused                   (0x0e00000000000000L ...) */
424# define C_BUCKET_TYPE            (0x0f00000000000000L)
425#else
426# define C_INT_SIGN_BIT           0x80000000
427# define C_INT_TOP_BIT            0x40000000
428# define C_HEADER_BITS_MASK       0xff000000
429# define C_HEADER_TYPE_BITS       0x0f000000
430# define C_HEADER_SIZE_MASK       0x00ffffff
431# define C_GC_FORWARDING_BIT      0x80000000
432# define C_BYTEBLOCK_BIT          0x40000000
433# define C_SPECIALBLOCK_BIT       0x20000000
434# define C_8ALIGN_BIT             0x10000000
435
436# define C_SYMBOL_TYPE            (0x01000000)
437# define C_STRING_TYPE            (0x02000000 | C_BYTEBLOCK_BIT)
438# define C_PAIR_TYPE              (0x03000000)
439# define C_CLOSURE_TYPE           (0x04000000 | C_SPECIALBLOCK_BIT)
440# ifdef C_DOUBLE_IS_32_BITS
441#  define C_FLONUM_TYPE           (0x05000000 | C_BYTEBLOCK_BIT)
442# else
443#  define C_FLONUM_TYPE           (0x05000000 | C_BYTEBLOCK_BIT | C_8ALIGN_BIT)
444# endif
445/*       unused                   (0x06000000 ...) */
446# define C_PORT_TYPE              (0x07000000 | C_SPECIALBLOCK_BIT)
447# define C_STRUCTURE_TYPE         (0x08000000)
448# define C_POINTER_TYPE           (0x09000000 | C_SPECIALBLOCK_BIT)
449# define C_LOCATIVE_TYPE          (0x0a000000 | C_SPECIALBLOCK_BIT)
450# define C_TAGGED_POINTER_TYPE    (0x0b000000 | C_SPECIALBLOCK_BIT)
451# define C_SWIG_POINTER_TYPE      (0x0c000000 | C_SPECIALBLOCK_BIT)
452# define C_LAMBDA_INFO_TYPE       (0x0d000000 | C_BYTEBLOCK_BIT)
453/*       unused                   (0x0e000000 ...) */
454# define C_BUCKET_TYPE            (0x0f000000)
455#endif
456#define C_VECTOR_TYPE             0x00000000
457#define C_BYTEVECTOR_TYPE         (C_VECTOR_TYPE | C_BYTEBLOCK_BIT | C_8ALIGN_BIT)
458
459#define C_SIZEOF_LIST(n)          ((n) * 3 + 1)
460#define C_SIZEOF_PAIR             3
461#define C_SIZEOF_STRING(n)        (C_bytestowords(n) + 2)
462#define C_SIZEOF_SYMBOL           4
463#define C_SIZEOF_INTERNED_SYMBOL(n) (C_SIZEOF_SYMBOL + C_SIZEOF_BUCKET + C_SIZEOF_STRING(n))
464#ifdef C_DOUBLE_IS_32_BITS
465# define C_SIZEOF_FLONUM          2
466#else
467# define C_SIZEOF_FLONUM          4
468#endif
469#define C_SIZEOF_POINTER          2
470#define C_SIZEOF_TAGGED_POINTER   3
471#define C_SIZEOF_SWIG_POINTER     3
472#define C_SIZEOF_VECTOR(n)        ((n) + 1)
473#define C_SIZEOF_BUCKET           3
474#define C_SIZEOF_LOCATIVE         5
475#define C_SIZEOF_PORT             16
476
477/* Fixed size types have pre-computed header tags */
478#define C_PAIR_TAG                (C_PAIR_TYPE | (C_SIZEOF_PAIR - 1))
479#define C_POINTER_TAG             (C_POINTER_TYPE | (C_SIZEOF_POINTER - 1))
480#define C_LOCATIVE_TAG            (C_LOCATIVE_TYPE | (C_SIZEOF_LOCATIVE - 1))
481#define C_TAGGED_POINTER_TAG      (C_TAGGED_POINTER_TYPE | (C_SIZEOF_TAGGED_POINTER - 1))
482#define C_SWIG_POINTER_TAG        (C_SWIG_POINTER_TYPE | (C_wordstobytes(C_SIZEOF_SWIG_POINTER - 1)))
483#define C_SYMBOL_TAG              (C_SYMBOL_TYPE | (C_SIZEOF_SYMBOL - 1))
484#define C_FLONUM_TAG              (C_FLONUM_TYPE | sizeof(double))
485
486/* Locative subtypes */
487#define C_SLOT_LOCATIVE           0
488#define C_CHAR_LOCATIVE           1
489#define C_U8_LOCATIVE             2
490#define C_S8_LOCATIVE             3
491#define C_U16_LOCATIVE            4
492#define C_S16_LOCATIVE            5
493#define C_U32_LOCATIVE            6
494#define C_S32_LOCATIVE            7
495#define C_F32_LOCATIVE            8
496#define C_F64_LOCATIVE            9
497
498#ifdef C_SIXTY_FOUR
499# define C_word                   long
500# define C_u32                    uint32_t
501# define C_s32                    int32_t
502#else
503# define C_word                   int
504# define C_u32                    unsigned int
505# define C_s32                    int
506#endif
507
508#if defined(_MSC_VER) || defined (__MINGW32__)
509# define C_s64                    __int64
510#else
511# define C_s64                    int64_t
512#endif
513
514#define C_char                    char
515#define C_uchar                   unsigned C_char
516#define C_byte                    char
517#define C_uword                   unsigned C_word
518#define C_header                  C_uword
519#define C_text(x)                 x
520
521#define C_TIMER_INTERRUPT_NUMBER  255
522
523#define C_BAD_ARGUMENT_COUNT_ERROR                    1
524#define C_BAD_MINIMUM_ARGUMENT_COUNT_ERROR            2
525#define C_BAD_ARGUMENT_TYPE_ERROR                     3
526#define C_UNBOUND_VARIABLE_ERROR                      4
527#define C_TOO_MANY_PARAMETERS_ERROR                   5
528#define C_OUT_OF_MEMORY_ERROR                         6
529#define C_DIVISION_BY_ZERO_ERROR                      7
530#define C_OUT_OF_RANGE_ERROR                          8
531#define C_NOT_A_CLOSURE_ERROR                         9
532#define C_CONTINUATION_CANT_RECEIVE_VALUES_ERROR      10
533#define C_BAD_ARGUMENT_TYPE_CYCLIC_LIST_ERROR         11
534#define C_TOO_DEEP_RECURSION_ERROR                    12
535#define C_CANT_REPRESENT_INEXACT_ERROR                13
536#define C_NOT_A_PROPER_LIST_ERROR                     14
537#define C_BAD_ARGUMENT_TYPE_NO_FIXNUM_ERROR           15
538#define C_BAD_ARGUMENT_TYPE_NO_NUMBER_ERROR           16
539#define C_BAD_ARGUMENT_TYPE_NO_STRING_ERROR           17
540#define C_BAD_ARGUMENT_TYPE_NO_PAIR_ERROR             18
541#define C_BAD_ARGUMENT_TYPE_NO_LIST_ERROR             19
542#define C_BAD_ARGUMENT_TYPE_NO_CHAR_ERROR             20
543#define C_BAD_ARGUMENT_TYPE_NO_VECTOR_ERROR           21
544#define C_BAD_ARGUMENT_TYPE_NO_SYMBOL_ERROR           22
545#define C_STACK_OVERFLOW_ERROR                        23
546#define C_BAD_ARGUMENT_TYPE_BAD_STRUCT_ERROR          24
547#define C_BAD_ARGUMENT_TYPE_NO_BYTEVECTOR_ERROR       25
548#define C_LOST_LOCATIVE_ERROR                         26
549#define C_BAD_ARGUMENT_TYPE_NO_BLOCK_ERROR            27
550#define C_BAD_ARGUMENT_TYPE_NO_NUMBER_VECTOR_ERROR    28
551#define C_BAD_ARGUMENT_TYPE_NO_INTEGER_ERROR          29
552#define C_BAD_ARGUMENT_TYPE_NO_UINTEGER_ERROR         30
553#define C_BAD_ARGUMENT_TYPE_NO_POINTER_ERROR          31
554#define C_BAD_ARGUMENT_TYPE_NO_TAGGED_POINTER_ERROR   32
555#define C_RUNTIME_UNSAFE_DLOAD_SAFE_ERROR             33
556#define C_RUNTIME_SAFE_DLOAD_UNSAFE_ERROR             34
557#define C_BAD_ARGUMENT_TYPE_NO_FLONUM_ERROR           35
558#define C_BAD_ARGUMENT_TYPE_NO_CLOSURE_ERROR          36
559
560
561/* Platform information */
562#if defined(C_BIG_ENDIAN)
563# define C_MACHINE_BYTE_ORDER "big-endian"
564#elif defined(C_LITTLE_ENDIAN)
565# define C_MACHINE_BYTE_ORDER "little-endian"
566#endif
567
568#if defined(__alpha__)
569# define C_MACHINE_TYPE "alpha"
570#elif defined(__mips__)
571# define C_MACHINE_TYPE "mips"
572#elif defined(__hppa__)
573# define C_MACHINE_TYPE "hppa"
574#elif defined(__sparc_v9__) || defined(__sparcv9)
575# define C_MACHINE_TYPE "ultrasparc"
576#elif defined(__sparc__)
577# define C_MACHINE_TYPE "sparc"
578#elif defined(__powerpc64__)
579# define C_MACHINE_TYPE "ppc64"
580#elif defined(__ppc__) || defined(__powerpc__)
581# define C_MACHINE_TYPE "ppc"
582#elif defined(_M_IX86) || defined(__i386__)
583# define C_MACHINE_TYPE "x86"
584#elif defined(__ia64__)
585# define C_MACHINE_TYPE "ia64"
586#elif defined(__x86_64__)
587# define C_MACHINE_TYPE "x86-64"
588#elif defined(__arm__)
589# define C_MACHINE_TYPE "arm"
590#else
591# define C_MACHINE_TYPE "unknown"
592#endif
593
594#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(_WIN32) || defined(__WINNT__)
595# define C_SOFTWARE_TYPE "windows"
596#elif defined(__unix__) || defined(C_XXXBSD)
597# define C_SOFTWARE_TYPE "unix"
598#elif defined(ECOS)
599# define C_SOFTWARE_TYPE "ecos"
600#else
601# define C_SOFTWARE_TYPE "unknown"
602#endif
603
604#if defined(__CYGWIN__)
605# define C_BUILD_PLATFORM "cygwin"
606#elif defined(_MSC_VER)
607# define C_BUILD_PLATFORM "msvc"
608#elif defined(__SUNPRO_C)
609# define C_BUILD_PLATFORM "sun"
610#elif defined(__MINGW32__)
611# define C_BUILD_PLATFORM "mingw32"
612#elif defined(__GNUC__)
613# define C_BUILD_PLATFORM "gnu"
614#elif defined(__MWERKS__)
615# define C_BUILD_PLATFORM "metrowerks"
616#elif defined(__INTEL_COMPILER)
617# define C_BUILD_PLATFORM "intel"
618#elif defined(__WATCOMC__)
619# define C_BUILD_PLATFORM "watcom"
620#else
621# define C_BUILD_PLATFORM "unknown"
622#endif
623
624#if defined(_MSC_VER)
625# if defined(_DLL)
626#   define C_RUNTIME_VERSION "dynamic"
627# else
628#   define C_RUNTIME_VERSION "static"
629# endif
630#else
631# define C_RUNTIME_VERSION "unknown"
632#endif
633
634#if defined(__linux__)
635# define C_SOFTWARE_VERSION "linux"
636#elif defined(__FreeBSD__)
637# define C_SOFTWARE_VERSION "freebsd"
638#elif defined(__NetBSD__)
639# define C_SOFTWARE_VERSION "netbsd"
640#elif defined(__OpenBSD__)
641# define C_SOFTWARE_VERSION "openbsd"
642#elif defined(C_MACOSX)
643# define C_SOFTWARE_VERSION "macosx"
644#elif defined(__hpux__)
645# define C_SOFTWARE_VERSION "hpux"
646#elif defined(__DragonFly__)
647# define C_SOFTWARE_VERSION "dragonfly"
648#elif defined(__sun__)
649# if defined(__svr4__)
650#   define C_SOFTWARE_VERSION "solaris"
651# else
652#   define C_SOFTWARE_VERSION "sunos"
653# endif
654#else
655# define C_SOFTWARE_VERSION "unknown"
656#endif
657
658
659/* Types: */
660
661typedef struct C_block_struct
662{
663  C_header header;
664  C_word data[ 1 ];
665} C_SCHEME_BLOCK;
666
667typedef struct C_symbol_table_struct
668{
669  char *name;
670  unsigned int size;
671  C_word *table;
672  struct C_symbol_table_struct *next;
673} C_SYMBOL_TABLE;
674
675typedef struct C_gc_root_struct
676{
677  C_word value;
678  struct C_gc_root_struct *next, *prev;
679  int finalizable;
680} C_GC_ROOT;
681
682typedef struct C_ptable_entry_struct
683{
684  C_char *id;
685  void *ptr;
686} C_PTABLE_ENTRY;
687
688#ifdef __x86_64__
689# define C_AMD64_ABI_WEIRDNESS      , ...
690#else
691# define C_AMD64_ABI_WEIRDNESS
692#endif
693
694/* C_WORD_p<P>_<B>: List of ((2 ** P) * B) 'C_word' parameters */
695#define C_WORD_p0_0
696#define C_WORD_p1_0
697#define C_WORD_p2_0
698#define C_WORD_p3_0
699#define C_WORD_p4_0
700#define C_WORD_p5_0
701#define C_WORD_p6_0
702#define C_WORD_p7_0
703#define C_WORD_p0_1     C_word,
704#define C_WORD_p1_1     C_word, C_word,
705#define C_WORD_p2_1     C_WORD_p1_1 C_WORD_p1_1
706#define C_WORD_p3_1     C_WORD_p2_1 C_WORD_p2_1
707#define C_WORD_p4_1     C_WORD_p3_1 C_WORD_p3_1
708#define C_WORD_p5_1     C_WORD_p4_1 C_WORD_p4_1
709#define C_WORD_p6_1     C_WORD_p5_1 C_WORD_p5_1
710#define C_WORD_p7_1     C_WORD_p6_1 C_WORD_p6_1
711
712/* DECL_C_PROC_p0 (n0,  p7,p6,p5,p4,p3,p2,p1,p0):
713 *  declare function C_proc<n0>, which have <n0> 'C_word' parameters
714 *  (not counting last 'C_word C_AMD64_ABI_WEIRDNESS' one).
715 *  We must have:   n0 = SUM (i = 7 to 0, p<i> * (1 << i)).
716 * DECL_C_PROC_p<N+1> (...):
717 *  declare 2 as much functions as DECL_C_PROC_p<N>...
718 */
719#define DECL_C_PROC_p0( n0,  p7,p6,p5,p4,p3,p2,p1,p0) \
720    typedef void (C_ccall *C_proc##n0) (C_WORD_p7_##p7 C_WORD_p6_##p6 \
721                                        C_WORD_p5_##p5 C_WORD_p4_##p4 \
722                                        C_WORD_p3_##p3 C_WORD_p2_##p2 \
723                                        C_WORD_p1_##p1 C_WORD_p0_##p0 \
724                                        C_word C_AMD64_ABI_WEIRDNESS) C_noret;
725#define DECL_C_PROC_p1( n0,n1,  p7,p6,p5,p4,p3,p2,p1) \
726        DECL_C_PROC_p0 (n0,  p7,p6,p5,p4,p3,p2,p1,0) \
727        DECL_C_PROC_p0 (n1,  p7,p6,p5,p4,p3,p2,p1,1)
728#define DECL_C_PROC_p2( n0,n1,n2,n3,  p7,p6,p5,p4,p3,p2) \
729        DECL_C_PROC_p1 (n0,n1,  p7,p6,p5,p4,p3,p2,0) \
730        DECL_C_PROC_p1 (n2,n3,  p7,p6,p5,p4,p3,p2,1)
731#define DECL_C_PROC_p3( n0,n1,n2,n3,n4,n5,n6,n7,  p7,p6,p5,p4,p3) \
732        DECL_C_PROC_p2 (n0,n1,n2,n3,  p7,p6,p5,p4,p3,0) \
733        DECL_C_PROC_p2 (n4,n5,n6,n7,  p7,p6,p5,p4,p3,1)
734
735DECL_C_PROC_p1 (2,3,  0,0,0,0,0,0,1)
736DECL_C_PROC_p2 (4,5,6,7,  0,0,0,0,0,1)
737DECL_C_PROC_p3 (8,9,10,11,12,13,14,15,    0,0,0,0,1)
738DECL_C_PROC_p3 (16,17,18,19,20,21,22,23,  0,0,0,1,0)
739DECL_C_PROC_p3 (24,25,26,27,28,29,30,31,  0,0,0,1,1)
740DECL_C_PROC_p3 (32,33,34,35,36,37,38,39,  0,0,1,0,0)
741DECL_C_PROC_p3 (40,41,42,43,44,45,46,47,  0,0,1,0,1)
742DECL_C_PROC_p3 (48,49,50,51,52,53,54,55,  0,0,1,1,0)
743DECL_C_PROC_p3 (56,57,58,59,60,61,62,63,  0,0,1,1,1)
744DECL_C_PROC_p1 (64,65,  0,1,0,0,0,0,0)
745DECL_C_PROC_p0 (66,  0,1,0,0,0,0,1,0)
746DECL_C_PROC_p0 (67,  0,1,0,0,0,0,1,1)
747DECL_C_PROC_p2 (68,69,70,71,  0,1,0,0,0,1)
748DECL_C_PROC_p3 (72,73,74,75,76,77,78,79,  0,1,0,0,1)
749DECL_C_PROC_p3 (80,81,82,83,84,85,86,87,  0,1,0,1,0)
750DECL_C_PROC_p3 (88,89,90,91,92,93,94,95,  0,1,0,1,1)
751DECL_C_PROC_p3 (96,97,98,99,100,101,102,103,  0,1,1,0,0)
752DECL_C_PROC_p3 (104,105,106,107,108,109,110,111,  0,1,1,0,1)
753DECL_C_PROC_p3 (112,113,114,115,116,117,118,119,  0,1,1,1,0)
754DECL_C_PROC_p3 (120,121,122,123,124,125,126,127,  0,1,1,1,1)
755DECL_C_PROC_p0 (128,  1,0,0,0,0,0,0,0)
756
757
758/* Macros: */
759
760#define CHICKEN_gc_root_ref(root)      (((C_GC_ROOT *)(root))->value)
761#define CHICKEN_gc_root_set(root, x)   C_mutate(&((C_GC_ROOT *)(root))->value, (x))
762
763#define CHICKEN_global_ref(root)       C_u_i_car(((C_GC_ROOT *)(root))->value)
764#define CHICKEN_global_set(root, x)    C_mutate(&C_u_i_car(((C_GC_ROOT *)(root))->value), (x))
765
766#define CHICKEN_default_toplevel       ((void *)C_default_stub_toplevel)
767
768#define C_align4(n)                (((n) + 3) & ~3)
769#define C_align8(n)                (((n) + 7) & ~7)
770#define C_align16(n)               (((n) + 15) & ~15)
771
772/* This is word-size dependent: */
773#ifdef C_SIXTY_FOUR
774# define C_align(n)                C_align8(n)
775# define C_wordstobytes(n)         ((n) << 3)
776# define C_bytestowords(n)         (((n) + 7) >> 3)
777# define C_wordsperdouble(n)       (n)
778# define C_WORD_MIN                LONG_MIN
779# define C_WORD_MAX                LONG_MAX
780# define C_UWORD_MAX               ULONG_MAX
781#else
782# define C_align(n)                C_align4(n)
783# define C_wordstobytes(n)         ((n) << 2)
784# define C_bytestowords(n)         (((n) + 3) >> 2)
785# define C_wordsperdouble(n)       ((n) << 1)
786# define C_WORD_MIN                INT_MIN
787# define C_WORD_MAX                INT_MAX
788# define C_UWORD_MAX               UINT_MAX
789#endif
790
791#ifndef C_PROVIDE_LIBC_STUBS
792# define C_FILEPTR                  FILE *
793
794# define C_stdin                    stdin
795# define C_stdout                   stdout
796# define C_stderr                   stderr
797
798# define C_memcpy                   memcpy
799# define C_memcmp                   memcmp
800# define C_strcpy                   strcpy
801# define C_strncpy                  strncpy
802# define C_strcmp                   strcmp
803# define C_strncmp                  strncmp
804# define C_strlen                   strlen
805# define C_strcat                   strcat
806# define C_memset                   memset
807# define C_memmove                  memmove
808# define C_strncasecmp              strncasecmp
809# define C_malloc                   malloc
810# define C_calloc                   calloc
811# define C_free                     free
812# define C_strchr                   strchr
813# define C_realloc                  realloc
814# define C_strdup                   strdup
815# define C_strtol                   strtol
816# define C_strtod                   strtod
817# define C_strtoul                  strtoul
818# define C_fopen                    fopen
819# define C_fclose                   fclose
820# define C_strpbrk                  strpbrk
821# define C_gcvt                     gcvt
822# define C_sprintf                  sprintf
823# define C_snprintf                 snprintf
824# define C_printf                   printf
825# define C_fprintf                  fprintf
826# define C_fflush                   fflush
827# define C_getchar                  getchar
828# define C_exit                     exit
829# define C_dlopen                   dlopen
830# define C_dlclose                  dlclose
831# define C_dlsym                    dlsym
832# define C_fwrite                   fwrite
833# define C_fread                    fread
834# define C_fputs                    fputs
835# define C_fputc                    fputc
836# define C_putchar                  putchar
837# if (defined getc_unlocked || _POSIX_C_SOURCE >= 199506L)
838#  define C_getc                    getc_unlocked
839# else
840#  define C_getc                    getc
841# endif
842# define C_fgetc                    fgetc
843# define C_fgets                    fgets
844# define C_ungetc                   ungetc
845# define C_system                   system
846# define C_isatty                   isatty
847# define C_fileno                   fileno
848# define C_select                   select
849# define C_signal                   signal
850# define C_getrusage                getrusage
851# define C_tolower                  tolower
852# define C_toupper                  toupper
853# define C_gettimeofday             gettimeofday
854# define C_gmtime                   gmtime
855# define C_localtime                localtime
856# define C_setjmp                   setjmp
857# define C_longjmp                  longjmp
858# define C_alloca                   alloca
859# define C_strerror                 strerror
860# define C_isalpha                  isalpha
861# define C_isdigit                  isdigit
862# define C_isspace                  isspace
863# define C_islower                  islower
864# define C_isupper                  isupper
865#else
866# include "chicken-libc-stubs.h"
867#endif
868
869#define C_return(x)                return(x)
870#define C_resize_stack(n)          C_do_resize_stack(n)
871#define C_memcpy_slots(t, f, n)    C_memcpy((t), (f), (n) * sizeof(C_word))
872#define C_block_header(x)          (((C_SCHEME_BLOCK *)(x))->header)
873#define C_header_bits(x)           (C_block_header(x) & C_HEADER_BITS_MASK)
874#define C_header_size(x)           (C_block_header(x) & C_HEADER_SIZE_MASK)
875#define C_make_header(type, size)  ((C_header)(((type) & C_HEADER_BITS_MASK) | ((size) & C_HEADER_SIZE_MASK)))
876#define C_symbol_value(x)          (C_block_item(x, 0))
877#define C_block_item(x, i)         (((C_SCHEME_BLOCK *)(x))->data[ i ])
878#define C_set_block_item(x, i, y)  (C_block_item(x, i) = (y))
879#define C_save(x)                  (*(--C_temporary_stack) = (C_word)(x))
880#define C_adjust_stack(n)          (C_temporary_stack -= (n))
881#define C_rescue(x, i)             (C_temporary_stack[ i ] = (x))
882#define C_save_rest(s, c, n)       for(va_start(v, s); c-- > (n); C_save(va_arg(v, C_word)))
883#define C_rest_count(c)            ((C_temporary_stack_bottom - C_temporary_stack) - (c))
884#define C_restore                  (*(C_temporary_stack++))
885#define C_heaptop                  ((C_word **)(&C_fromspace_top))
886#define C_pick(n)                  (C_temporary_stack[ n ])
887#define C_drop(n)                  (C_temporary_stack += (n))
888#define C_alloc(n)                 ((C_word *)C_alloca((n) * sizeof(C_word)))
889#define C_stack_pointer            ((C_word *)C_alloca(0))
890#define C_stack_pointer_test       ((C_word *)C_alloca(1))
891#define C_demand_2(n)              (((C_word *)C_fromspace_top + (n)) < (C_word *)C_fromspace_limit)
892#define C_fix(n)                   (((C_word)(n) << C_FIXNUM_SHIFT) | C_FIXNUM_BIT)
893#define C_unfix(x)                 ((x) >> C_FIXNUM_SHIFT)
894#define C_make_character(c)        ((((c) & C_CHAR_BIT_MASK) << C_CHAR_SHIFT) | C_CHARACTER_BITS)
895#define C_character_code(x)        (((x) >> C_CHAR_SHIFT) & C_CHAR_BIT_MASK)
896#define C_flonum_magnitude(x)      (*((double *)(((C_SCHEME_BLOCK *)(x))->data)))
897#define C_c_string(x)              ((C_char *)(((C_SCHEME_BLOCK *)(x))->data))
898#define C_c_pointer(x)             ((void *)(x))
899#define C_c_pointer_nn(x)          ((void *)C_block_item(x, 0))
900#define C_truep(x)                 ((x) != C_SCHEME_FALSE)
901#define C_immediatep(x)            ((x) & C_IMMEDIATE_MARK_BITS)
902#define C_mk_bool(x)               ((x) ? C_SCHEME_TRUE : C_SCHEME_FALSE)
903#define C_mk_nbool(x)              ((x) ? C_SCHEME_FALSE : C_SCHEME_TRUE)
904#define C_port_file(p)             ((C_FILEPTR)C_block_item(p, 0))
905#define C_data_pointer(x)          ((void *)((C_SCHEME_BLOCK *)(x))->data)
906#define C_invert_flag(f)           (!(f))
907#define C_fitsinfixnump(n)         (((n) & C_INT_SIGN_BIT) == (((n) & C_INT_TOP_BIT) << 1))
908#define C_ufitsinfixnump(n)        (((n) & (C_INT_SIGN_BIT | (C_INT_SIGN_BIT >> 1))) == 0)
909#define C_quickflonumtruncate(n)   (C_fix((C_word)C_flonum_magnitude(n)))
910#define C_and(x, y)                (C_truep(x) ? (y) : C_SCHEME_FALSE)
911#define C_c_bytevector(x)          ((unsigned char *)C_data_pointer(x))
912#define C_c_bytevector_or_null(x)  ((unsigned char *)C_data_pointer_or_null(x))
913#define C_c_u8vector(x)            ((unsigned char *)C_data_pointer(C_u_i_cdr(x)))
914#define C_c_u8vector_or_null(x)    ((unsigned char *)C_srfi_4_vector_or_null(x))
915#define C_c_s8vector(x)            ((char *)C_data_pointer(C_u_i_cdr(x)))
916#define C_c_s8vector_or_null(x)    ((char *)C_srfi_4_vector_or_null(x))
917#define C_c_u16vector(x)           ((unsigned short *)C_data_pointer(C_u_i_cdr(x)))
918#define C_c_u16vector_or_null(x)   ((unsigned short *)C_srfi_4_vector_or_null(x))
919#define C_c_s16vector(x)           ((short *)C_data_pointer(C_u_i_cdr(x)))
920#define C_c_s16vector_or_null(x)   ((short *)C_srfi_4_vector_or_null(x))
921#define C_c_u32vector(x)           ((C_u32 *)C_data_pointer(C_u_i_cdr(x)))
922#define C_c_u32vector_or_null(x)   ((C_u32 *)C_srfi_4_vector_or_null(x))
923#define C_c_s32vector(x)           ((C_s32 *)C_data_pointer(C_u_i_cdr(x)))
924#define C_c_s32vector_or_null(x)   ((C_s32 *)C_srfi_4_vector_or_null(x))
925#define C_c_f32vector(x)           ((float *)C_data_pointer(C_u_i_cdr(x)))
926#define C_c_f32vector_or_null(x)   ((float *)C_srfi_4_vector_or_null(x))
927#define C_c_f64vector(x)           ((double *)C_data_pointer(C_u_i_cdr(x)))
928#define C_c_f64vector_or_null(x)   ((double *)C_srfi_4_vector_or_null(x))
929
930#ifdef C_STRESS_TEST
931# define C_STRESS_FAILURE          3
932# define C_stress                  (rand() % C_STRESS_FAILURE)
933#else
934# define C_stress                  1
935#endif
936
937#if C_STACK_GROWS_DOWNWARD
938# define C_demand(n)              (C_stress && ((C_word)(C_stack_pointer - C_stack_limit) > (n)))
939# define C_stack_probe(p)         (C_stress && ((C_word *)(p) >= C_stack_limit))
940# define C_stack_check            if(!C_disable_overflow_check && (C_byte*)(C_stack_pointer) + C_STACK_RESERVE < (C_byte *)C_stack_limit) C_stack_overflow()
941#else
942# define C_demand(n)              (C_stress && ((C_word)(C_stack_limit - C_stack_pointer) > (n)))
943# define C_stack_probe(p)         (C_stress && ((C_word *)(p) < C_stack_limit))
944# define C_stack_check            if(!C_disable_overflow_check && (C_byte*)(C_stack_pointer) - C_STACK_RESERVE > (C_byte *)C_stack_limit) C_stack_overflow()
945#endif
946
947#define C_zero_length_p(x)        C_mk_bool(C_header_size(x) == 0)
948#define C_boundp(x)               C_mk_bool(((C_SCHEME_BLOCK *)(x))->data[ 0 ] != C_SCHEME_UNBOUND)
949#define C_unboundvaluep(x)        C_mk_bool((x) == C_SCHEME_UNBOUND)
950#define C_blockp(x)               C_mk_bool(!C_immediatep(x))
951#define C_forwardedp(x)           C_mk_bool((C_block_header(x) & C_GC_FORWARDING_BIT) != 0)
952#define C_immp(x)                 C_mk_bool(C_immediatep(x))
953#define C_flonump(x)              C_mk_bool(C_block_header(x) == C_FLONUM_TAG)
954#define C_stringp(x)              C_mk_bool(C_header_bits(x) == C_STRING_TYPE)
955#define C_symbolp(x)              C_mk_bool(C_block_header(x) == C_SYMBOL_TAG)
956#define C_pairp(x)                C_mk_bool(C_block_header(x) == C_PAIR_TAG)
957#define C_closurep(x)             C_mk_bool(C_header_bits(x) == C_CLOSURE_TYPE)
958#define C_vectorp(x)              C_mk_bool(C_header_bits(x) == C_VECTOR_TYPE)
959#define C_bytevectorp(x)          C_mk_bool(C_header_bits(x) == C_BYTEVECTOR_TYPE)
960#define C_portp(x)                C_mk_bool(C_header_bits(x) == C_PORT_TYPE)
961#define C_structurep(x)           C_mk_bool(C_header_bits(x) == C_STRUCTURE_TYPE)
962#define C_locativep(x)            C_mk_bool(C_block_header(x) == C_LOCATIVE_TAG)
963#define C_charp(x)                C_mk_bool(((x) & C_IMMEDIATE_TYPE_BITS) == C_CHARACTER_BITS)
964#define C_booleanp(x)             C_mk_bool(((x) & C_IMMEDIATE_TYPE_BITS) == C_BOOLEAN_BITS)
965#define C_eofp(x)                 C_mk_bool((x) == C_SCHEME_END_OF_FILE)
966#define C_undefinedp(x)           C_mk_bool((x) == C_SCHEME_UNDEFINED)
967#define C_fixnump(x)              C_mk_bool((x) & C_FIXNUM_BIT)
968#define C_nfixnump(x)             C_mk_nbool((x) & C_FIXNUM_BIT)
969#define C_pointerp(x)             C_mk_bool(C_block_header(x) == C_POINTER_TAG)
970#define C_taggedpointerp(x)       C_mk_bool(C_block_header(x) == C_TAGGED_POINTER_TAG)
971#define C_swigpointerp(x)         C_mk_bool(C_block_header(x) == C_SWIG_POINTER_TAG)
972#define C_lambdainfop(x)          C_mk_bool(C_header_bits(x) == C_LAMBDA_INFO_TYPE)
973#define C_anypointerp(x)          C_mk_bool(C_block_header(x) == C_POINTER_TAG || C_block_header(x) == C_TAGGED_POINTER_TAG || C_block_header(x) == C_SWIG_POINTER_TAG)
974#define C_specialp(x)             C_mk_bool(C_header_bits(x) & C_SPECIALBLOCK_BIT)
975#define C_byteblockp(x)           C_mk_bool(C_header_bits(x) & C_BYTEBLOCK_BIT)
976#define C_anyp(x)                 C_SCHEME_TRUE
977#define C_eqp(x, y)               C_mk_bool((x) == (y))
978#define C_vemptyp(x)              C_mk_bool(C_header_size(x) == 0)
979#define C_notvemptyp(x)           C_mk_bool(C_header_size(x) > 0)
980#define C_slot(x, i)              (((C_SCHEME_BLOCK *)(x))->data[ C_unfix(i) ])
981#define C_slot0(x)                (((C_SCHEME_BLOCK *)(x))->data[ 0 ])
982#define C_subbyte(x, i)           C_fix(((C_byte *)((C_SCHEME_BLOCK *)(x))->data)[ C_unfix(i) ] & 0xff)
983#define C_subchar(x, i)           C_make_character(((C_uchar *)((C_SCHEME_BLOCK *)(x))->data)[ C_unfix(i) ])
984#define C_setbyte(x, i, n)        (((C_byte *)((C_SCHEME_BLOCK *)(x))->data)[ C_unfix(i) ] = C_unfix(n), C_SCHEME_UNDEFINED)
985#define C_setsubchar(x, i, n)     (((C_char *)((C_SCHEME_BLOCK *)(x))->data)[ C_unfix(i) ] = C_character_code(n), C_SCHEME_UNDEFINED)
986#define C_setsubbyte(x, i, n)     (((C_char *)((C_SCHEME_BLOCK *)(x))->data)[ C_unfix(i) ] = C_unfix(n), C_SCHEME_UNDEFINED)
987#define C_fixnum_times(n1, n2)          (C_fix(C_unfix(n1) * C_unfix(n2)))
988#define C_u_fixnum_plus(n1, n2)         (((n1) - C_FIXNUM_BIT) + (n2))
989#define C_fixnum_plus(n1, n2)           (C_u_fixnum_plus(n1, n2) | C_FIXNUM_BIT)
990#define C_u_fixnum_difference(n1, n2)   ((n1) - (n2) + C_FIXNUM_BIT)
991#define C_fixnum_difference(n1, n2)     (C_u_fixnum_difference(n1, n2) | C_FIXNUM_BIT)
992#define C_fixnum_divide(n1, n2)         (C_fix(C_unfix(n1) / C_unfix(n2)))
993#define C_fixnum_modulo(n1, n2)         (C_fix(C_unfix(n1) % C_unfix(n2)))
994#define C_u_fixnum_and(n1, n2)          ((n1) & (n2))
995#define C_fixnum_and(n1, n2)            (C_u_fixnum_and(n1, n2) | C_FIXNUM_BIT)
996#define C_u_fixnum_or(n1, n2)           ((n1) | (n2))
997#define C_fixnum_or(n1, n2)             (C_u_fixnum_or(n1, n2) | C_FIXNUM_BIT)
998#define C_fixnum_xor(n1, n2)            (((n1) ^ (n2)) | C_FIXNUM_BIT)
999#define C_fixnum_not(n)                 ((~(n)) | C_FIXNUM_BIT)
1000#define C_fixnum_shift_left(n1, n2)     (C_fix(C_unfix(n1) << C_unfix(n2)))
1001#define C_fixnum_shift_right(n1, n2)    (((n1) >> C_unfix(n2)) | C_FIXNUM_BIT)
1002#define C_u_fixnum_negate(n)            (-(n) + 2 * C_FIXNUM_BIT)
1003#define C_fixnum_negate(n)              (C_u_fixnum_negate(n) | C_FIXNUM_BIT)
1004#define C_fixnum_greaterp(n1, n2)       (C_mk_bool((C_word)(n1) > (C_word)(n2)))
1005#define C_fixnum_lessp(n1, n2)          (C_mk_bool((C_word)(n1) < (C_word)(n2)))
1006#define C_fixnum_greater_or_equal_p(n1, n2) (C_mk_bool((C_word)(n1) >= (C_word)(n2)))
1007#define C_fixnum_less_or_equal_p(n1, n2)(C_mk_bool((C_word)(n1) <= (C_word)(n2)))
1008#define C_u_fixnum_increase(n)          ((n) + (1 << C_FIXNUM_SHIFT))
1009#define C_fixnum_increase(n)            (C_u_fixnum_increase(n) | C_FIXNUM_BIT)
1010#define C_u_fixnum_decrease(n)          ((n) - (1 << C_FIXNUM_SHIFT))
1011#define C_fixnum_decrease(n)            (C_u_fixnum_decrease(n) | C_FIXNUM_BIT)
1012#define C_fixnum_abs(n)                 C_fix(abs(C_unfix(n)))
1013
1014#define C_flonum_equalp(n1, n2)         C_mk_bool(C_flonum_magnitude(n1) == C_flonum_magnitude(n2))
1015#define C_flonum_greaterp(n1, n2)       C_mk_bool(C_flonum_magnitude(n1) > C_flonum_magnitude(n2))
1016#define C_flonum_lessp(n1, n2)          C_mk_bool(C_flonum_magnitude(n1) < C_flonum_magnitude(n2))
1017#define C_flonum_greater_or_equal_p(n1, n2) C_mk_bool(C_flonum_magnitude(n1) >= C_flonum_magnitude(n2))
1018#define C_flonum_less_or_equal_p(n1, n2) C_mk_bool(C_flonum_magnitude(n1) <= C_flonum_magnitude(n2))
1019
1020#define C_display_fixnum(p, n)          (C_fprintf(C_port_file(p), C_text("%d"), C_unfix(n)), C_SCHEME_UNDEFINED)
1021#define C_display_char(p, c)            (C_fputc(C_character_code(c), C_port_file(p)), C_SCHEME_UNDEFINED)
1022#define C_display_string(p, s)          (C_fwrite(((C_SCHEME_BLOCK *)(s))->data, sizeof(C_char), C_header_size(s), \
1023                                         C_port_file(p)), C_SCHEME_UNDEFINED)
1024#define C_fix_to_char(x)                (C_make_character(C_unfix(x)))
1025#define C_char_to_fix(x)                (C_fix(C_character_code(x)))
1026#define C_math_result(x)                (C_temporary_flonum = (x), C_SCHEME_UNDEFINED)
1027#define C_substring_copy(s1, s2, start1, end1, start2) \
1028                                        (C_memcpy((C_char *)C_data_pointer(s2) + C_unfix(start2), \
1029                                                  (C_char *)C_data_pointer(s1) + C_unfix(start1), \
1030                                                  C_unfix(end1) - C_unfix(start1) ), C_SCHEME_UNDEFINED)
1031#define C_substring_compare(s1, s2, start1, start2, len) \
1032                                        C_mk_bool(C_memcmp((C_char *)C_data_pointer(s1) + C_unfix(start1), \
1033                                                           (C_char *)C_data_pointer(s2) + C_unfix(start2), \
1034                                                           C_unfix(len) ) == 0)
1035#define C_substring_compare_case_insensitive(s1, s2, start1, start2, len) \
1036                                        C_mk_bool(C_strncasecmp((C_char *)C_data_pointer(s1) + C_unfix(start1), \
1037                                                                (C_char *)C_data_pointer(s2) + C_unfix(start2), \
1038                                                                C_unfix(len) ) == 0)
1039#define C_subvector_copy(v1, v2, start1, end1, start2) \
1040                                        (C_memcpy_slots((C_char *)C_data_pointer(v2) + C_unfix(start2), \
1041                                                  (C_char *)C_data_pointer(v1) + C_unfix(start1), \
1042                                                  C_unfix(end1) - C_unfix(start1) ), C_SCHEME_UNDEFINED)
1043#define C_words(n)                      C_fix(C_bytestowords(C_unfix(n)))
1044#define C_bytes(n)                      C_fix(C_wordstobytes(C_unfix(n)))
1045#define C_random_fixnum(n)              C_fix((int)(((double)rand())/(RAND_MAX + 1.0) * C_unfix(n)))
1046#define C_randomize(n)                  (srand(C_unfix(n)), C_SCHEME_UNDEFINED)
1047#define C_block_size(x)                 C_fix(C_header_size(x))
1048#define C_pointer_address(x)            ((C_byte *)C_u_i_car(x))
1049#define C_block_address(ptr, n, x)      C_a_unsigned_int_to_num(ptr, n, x)
1050#define C_offset_pointer(x, y)          (C_pointer_address(x) + (y))
1051#define C_kontinue(k, r)                ((C_proc2)(void *)C_u_i_car(k))(2, (k), (r))
1052#define C_fetch_byte(x, p)              (((unsigned C_byte *)((C_SCHEME_BLOCK *)(x))->data)[ p ])
1053#define C_poke_integer(x, i, n)         (C_set_block_item(x, C_unfix(i), C_num_to_int(n)), C_SCHEME_UNDEFINED)
1054#define C_pointer_to_block(p, x)        (C_set_block_item(p, 0, (C_word)C_data_pointer(x)), C_SCHEME_UNDEFINED)
1055#define C_null_pointerp(x)              C_mk_bool((void *)C_u_i_car(x) == NULL)
1056#define C_update_pointer(p, ptr)        (C_set_block_item(ptr, 0, C_num_to_unsigned_int(p)), C_SCHEME_UNDEFINED)
1057#define C_copy_pointer(from, to)        (C_set_block_item(to, 0, C_u_i_car(from)), C_SCHEME_UNDEFINED)
1058#define C_pointer_to_object(ptr)        ((C_word*)C_block_item(ptr, 0))
1059
1060#define C_direct_return(dk, x)          (C_kontinue(dk, x), C_SCHEME_UNDEFINED)
1061
1062#ifdef C_SIXTY_FOUR
1063# define C_poke_integer_32(x, i, n)     (((C_s32 *)C_data_pointer(x))[ C_unfix(i) ] = C_unfix(n), C_SCHEME_UNDEFINED)
1064#else
1065# define C_poke_integer_32              C_poke_integer
1066#endif
1067
1068#define C_copy_memory(to, from, n)      (C_memcpy(C_data_pointer(to), C_data_pointer(from), C_unfix(n)), C_SCHEME_UNDEFINED)
1069#define C_set_memory(to, c, n)          (C_memset(C_data_pointer(to), C_character_code(c), C_unfix(n)), C_SCHEME_UNDEFINED)
1070#define C_string_compare(to, from, n)   C_fix(C_strncmp(C_c_string(to), C_c_string(from), C_unfix(n)))
1071#define C_string_compare_case_insensitive(from, to, n) \
1072                                        C_fix(C_strncasecmp(C_c_string(from), C_c_string(to), C_unfix(n)))
1073#define C_rename_file(old, new)         C_fix(rename(C_c_string(old), C_c_string(new)))
1074#define C_delete_file(fname)            C_fix(remove(C_c_string(fname)))
1075#define C_poke_double(b, i, n)          (((double *)C_data_pointer(b))[ C_unfix(i) ] = C_c_double(n), C_SCHEME_UNDEFINED)
1076#define C_poke_c_string(b, i, from)     (C_strcpy((char *)C_block_item(b, C_unfix(i)), C_data_pointer(from)), C_SCHEME_UNDEFINED)
1077#define C_peek_fixnum(b, i)             C_fix(C_block_item(b, C_unfix(i)))
1078#define C_peek_byte(ptr, i)             C_fix(((unsigned char *)C_u_i_car(ptr))[ C_unfix(i) ])
1079#define C_dupstr(s)                     C_strdup(C_data_pointer(s))
1080#define C_poke_pointer(b, i, x)         (C_set_block_item(b, C_unfix(i), (C_word)C_data_pointer(x)), C_SCHEME_UNDEFINED)
1081#define C_poke_pointer_or_null(b, i, x) (C_set_block_item(b, C_unfix(i), (C_word)C_data_pointer_or_null(x)), C_SCHEME_UNDEFINED)
1082#define C_qfree(ptr)                    (C_free(C_c_pointer_nn(ptr)), C_SCHEME_UNDEFINED)
1083
1084#define C_tty_portp(p)                 C_mk_bool(isatty(fileno(C_port_file(p))))
1085
1086#define C_emit_eval_trace_info(x, y, z) C_emit_trace_info2("<eval>", x, y, z)
1087#define C_emit_syntax_trace_info(x, y, z) C_emit_trace_info2("<syntax>", x, y, z)
1088
1089/* These expect C_VECTOR_TYPE to be 0: */
1090#define C_vector_to_structure(v)        (((C_SCHEME_BLOCK *)(v))->header |= C_STRUCTURE_TYPE, C_SCHEME_UNDEFINED)
1091#define C_vector_to_closure(v)          (((C_SCHEME_BLOCK *)(v))->header |= C_CLOSURE_TYPE, C_SCHEME_UNDEFINED)
1092#define C_string_to_bytevector(s)       (((C_SCHEME_BLOCK *)(s))->header = C_header_size(s) | C_BYTEVECTOR_TYPE, C_SCHEME_UNDEFINED)
1093#define C_string_to_lambdainfo(s)       (((C_SCHEME_BLOCK *)(s))->header = C_header_size(s) | C_LAMBDA_INFO_TYPE, C_SCHEME_UNDEFINED)
1094
1095#ifdef C_TIMER_INTERRUPTS
1096# ifdef PARANOIA
1097#  define C_check_for_interrupt         C_paranoid_check_for_interrupt()
1098# else
1099#  define C_check_for_interrupt         if(--C_timer_interrupt_counter <= 0) C_raise_interrupt(C_TIMER_INTERRUPT_NUMBER)
1100# endif
1101#else
1102# define C_check_for_interrupt
1103#endif
1104
1105#if defined(__GNUC__) || defined(__INTEL_COMPILER)
1106# define C_a_i(a, n)                    ({C_word *tmp = *a; *a += (n); tmp;})
1107# define C_a_i_cons(a, n, car, cdr)     ({C_word tmp = (C_word)(*a); (*a)[0] = C_PAIR_TYPE | 2; *a += 3; \
1108                                          C_set_block_item(tmp, 0, car); C_set_block_item(tmp, 1, cdr); tmp;})
1109#else
1110# define C_a_i_cons(a, n, car, cdr)     C_pair(a, car, cdr)
1111#endif /* __GNUC__ */
1112
1113#define C_a_i_data_mpointer(ptr, n, x)  C_mpointer(ptr, C_data_pointer(x))
1114#define C_a_int_to_num(ptr, n, i)       C_int_to_num(ptr, i)
1115#define C_a_unsigned_int_to_num(ptr, n, i)  C_unsigned_int_to_num(ptr, i)
1116#define C_a_double_to_num(ptr, n)       C_double_to_number(C_flonum(ptr, n))
1117#define C_a_i_vector                    C_vector
1118#define C_list                          C_a_i_list
1119#define C_i_setslot(x, i, y)            (C_mutate(&C_block_item(x, C_unfix(i)), y), C_SCHEME_UNDEFINED)
1120#define C_i_set_i_slot(x, i, y)         (C_set_block_item(x, C_unfix(i), y), C_SCHEME_UNDEFINED)
1121#define C_u_i_set_car(p, x)             (C_mutate(&C_u_i_car(p), x), C_SCHEME_UNDEFINED)
1122#define C_u_i_set_cdr(p, x)             (C_mutate(&C_u_i_cdr(p), x), C_SCHEME_UNDEFINED)
1123
1124#define C_i_not(x)                      (C_truep(x) ? C_SCHEME_FALSE : C_SCHEME_TRUE)
1125#define C_i_equalp(x, y)                C_mk_bool(C_equalp((x), (y)))
1126#define C_i_fixnumevenp(x)              C_mk_nbool((x) & 0x00000002)
1127#define C_i_fixnumoddp(x)               C_mk_bool((x) & 0x00000002)
1128#define C_i_nullp(x)                    C_mk_bool((x) == C_SCHEME_END_OF_LIST)
1129#define C_i_structurep(x, s)            C_mk_bool(!C_immediatep(x) && C_header_bits(x) == C_STRUCTURE_TYPE && C_block_item(x, 0) == (s))
1130
1131#define C_u_i_char_alphabeticp(x)       C_mk_bool(C_character_code(x) < 0x100 && C_isalpha(C_character_code(x)))
1132#define C_u_i_char_numericp(x)          C_mk_bool(C_character_code(x) < 0x100 && C_isdigit(C_character_code(x)))
1133#define C_u_i_char_whitespacep(x)       C_mk_bool(C_character_code(x) < 0x100 && C_isspace(C_character_code(x)))
1134#define C_u_i_char_upper_casep(x)       C_mk_bool(C_character_code(x) < 0x100 && C_isupper(C_character_code(x)))
1135#define C_u_i_char_lower_casep(x)       C_mk_bool(C_character_code(x) < 0x100 && C_islower(C_character_code(x)))
1136
1137#define C_u_i_char_upcase(x)            (C_character_code(x) < 0x100 ? C_make_character(C_toupper(C_character_code(x))) : (x))
1138#define C_u_i_char_downcase(x)          (C_character_code(x) < 0x100 ? C_make_character(C_tolower(C_character_code(x))) : (x))
1139
1140#define C_i_list_ref(lst, i)            C_i_car(C_i_list_tail(lst, i))
1141#define C_u_i_list_ref(lst, i)          C_u_i_car(C_i_list_tail(lst, i))
1142
1143#define C_u_i_car(x)                    C_block_item(x, 0)
1144#define C_u_i_cdr(x)                    C_block_item(x, 1)
1145#define C_u_i_caar(x)                   C_u_i_car( C_u_i_car( x ) )
1146#define C_u_i_cadr(x)                   C_u_i_car( C_u_i_cdr( x ) )
1147#define C_u_i_cdar(x)                   C_u_i_cdr( C_u_i_car( x ) )
1148#define C_u_i_cddr(x)                   C_u_i_cdr( C_u_i_cdr( x ) )
1149#define C_u_i_caaar(x)                  C_u_i_car( C_u_i_caar( x ) )
1150#define C_u_i_caadr(x)                  C_u_i_car( C_u_i_cadr( x ) )
1151#define C_u_i_cadar(x)                  C_u_i_car( C_u_i_cdar( x ) )
1152#define C_u_i_caddr(x)                  C_u_i_car( C_u_i_cddr( x ) )
1153#define C_u_i_cdaar(x)                  C_u_i_cdr( C_u_i_caar( x ) )
1154#define C_u_i_cdadr(x)                  C_u_i_cdr( C_u_i_cadr( x ) )
1155#define C_u_i_cddar(x)                  C_u_i_cdr( C_u_i_cdar( x ) )
1156#define C_u_i_cdddr(x)                  C_u_i_cdr( C_u_i_cddr( x ) )
1157#define C_u_i_caaaar(x)                 C_u_i_car( C_u_i_caaar( x ) )
1158#define C_u_i_caaadr(x)                 C_u_i_car( C_u_i_caadr( x ) )
1159#define C_u_i_caadar(x)                 C_u_i_car( C_u_i_cadar( x ) )
1160#define C_u_i_caaddr(x)                 C_u_i_car( C_u_i_caddr( x ) )
1161#define C_u_i_cadaar(x)                 C_u_i_car( C_u_i_cdaar( x ) )
1162#define C_u_i_cadadr(x)                 C_u_i_car( C_u_i_cdadr( x ) )
1163#define C_u_i_caddar(x)                 C_u_i_car( C_u_i_cddar( x ) )
1164#define C_u_i_cadddr(x)                 C_u_i_car( C_u_i_cdddr( x ) )
1165#define C_u_i_cdaaar(x)                 C_u_i_cdr( C_u_i_caaar( x ) )
1166#define C_u_i_cdaadr(x)                 C_u_i_cdr( C_u_i_caadr( x ) )
1167#define C_u_i_cdadar(x)                 C_u_i_cdr( C_u_i_cadar( x ) )
1168#define C_u_i_cdaddr(x)                 C_u_i_cdr( C_u_i_caddr( x ) )
1169#define C_u_i_cddaar(x)                 C_u_i_cdr( C_u_i_cdaar( x ) )
1170#define C_u_i_cddadr(x)                 C_u_i_cdr( C_u_i_cdadr( x ) )
1171#define C_u_i_cdddar(x)                 C_u_i_cdr( C_u_i_cddar( x ) )
1172#define C_u_i_cddddr(x)                 C_u_i_cdr( C_u_i_cdddr( x ) )
1173
1174#define C_a_i_times( ptr, n, x, y)      C_2_times( ptr, x, y)
1175#define C_a_i_plus(  ptr, n, x, y)      C_2_plus(  ptr, x, y)
1176#define C_a_i_minus( ptr, n, x, y)      C_2_minus( ptr, x, y)
1177#define C_a_i_divide(ptr, n, x, y)      C_2_divide(ptr, x, y)
1178
1179#if defined(__GNUC__) || defined(__INTEL_COMPILER)
1180# define C_i_not_pair_p(x)              ({C_word tmp = (x); C_mk_bool(C_immediatep(tmp) || C_block_header(tmp) != C_PAIR_TAG);})
1181#else
1182# define C_i_not_pair_p                 C_i_not_pair_p_2
1183#endif
1184
1185#define C_i_check_closure(x)            C_i_check_closure_2(x, C_SCHEME_FALSE)
1186#define C_i_check_exact(x)              C_i_check_exact_2(x, C_SCHEME_FALSE)
1187#define C_i_check_inexact(x)            C_i_check_inexact_2(x, C_SCHEME_FALSE)
1188#define C_i_check_number(x)             C_i_check_number_2(x, C_SCHEME_FALSE)
1189#define C_i_check_string(x)             C_i_check_string_2(x, C_SCHEME_FALSE)
1190#define C_i_check_bytevector(x)         C_i_check_bytevector_2(x, C_SCHEME_FALSE)
1191#define C_i_check_symbol(x)             C_i_check_symbol_2(x, C_SCHEME_FALSE)
1192#define C_i_check_list(x)               C_i_check_list_2(x, C_SCHEME_FALSE)
1193#define C_i_check_pair(x)               C_i_check_pair_2(x, C_SCHEME_FALSE)
1194#define C_i_check_vector(x)             C_i_check_vector_2(x, C_SCHEME_FALSE)
1195#define C_i_check_structure(x, st)      C_i_check_structure_2(x, (st), C_SCHEME_FALSE)
1196#define C_i_check_char(x)               C_i_check_char_2(x, C_SCHEME_FALSE)
1197
1198#define C_u_i_8vector_length(x)         C_fix(C_header_size(C_block_item(x, 1)))
1199#define C_u_i_16vector_length(x)        C_fix(C_header_size(C_block_item(x, 1)) >> 1)
1200#define C_u_i_32vector_length(x)        C_fix(C_header_size(C_block_item(x, 1)) >> 2)
1201#define C_u_i_64vector_length(x)        C_fix(C_header_size(C_block_item(x, 1)) >> 3)
1202
1203#define C_u_i_u8vector_ref(x, i)        C_fix(((unsigned char *)C_data_pointer(C_block_item((x), 1)))[ C_unfix(i) ])
1204#define C_u_i_s8vector_ref(x, i)        C_fix(((char *)C_data_pointer(C_block_item((x), 1)))[ C_unfix(i) ])
1205#define C_u_i_u16vector_ref(x, i)       C_fix(((unsigned short *)C_data_pointer(C_block_item((x), 1)))[ C_unfix(i) ])
1206#define C_u_i_s16vector_ref(x, i)       C_fix(((short *)C_data_pointer(C_block_item((x), 1)))[ C_unfix(i) ])
1207#define C_u_i_u32vector_ref(x, i)       C_fix(((C_u32 *)C_data_pointer(C_block_item((x), 1)))[ C_unfix(i) ])
1208#define C_u_i_s32vector_ref(x, i)       C_fix(((C_u32 *)C_data_pointer(C_block_item((x), 1)))[ C_unfix(i) ])
1209#define C_a_i_u32vector_ref(ptr, c, x, i)  C_unsigned_int_to_num(ptr, ((C_u32 *)C_data_pointer(C_block_item((x), 1)))[ C_unfix(i) ])
1210#define C_a_i_s32vector_ref(ptr, c, x, i)  C_int_to_num(ptr, ((C_s32 *)C_data_pointer(C_block_item((x), 1)))[ C_unfix(i) ])
1211
1212#define C_u_i_u8vector_set(x, i, v)     ((((unsigned char *)C_data_pointer(C_block_item((x), 1)))[ C_unfix(i) ] = C_unfix(v)), C_SCHEME_UNDEFINED)
1213#define C_u_i_s8vector_set(x, i, v)     ((((char *)C_data_pointer(C_block_item((x), 1)))[ C_unfix(i) ] = C_unfix(v)), C_SCHEME_UNDEFINED)
1214#define C_u_i_u16vector_set(x, i, v)    ((((unsigned short *)C_data_pointer(C_block_item((x), 1)))[ C_unfix(i) ] = C_unfix(v)), C_SCHEME_UNDEFINED)
1215#define C_u_i_s16vector_set(x, i, v)    ((((short *)C_data_pointer(C_block_item((x), 1)))[ C_unfix(i) ] = C_unfix(v)), C_SCHEME_UNDEFINED)
1216#define C_u_i_u32vector_set(x, i, v)    ((((C_u32 *)C_data_pointer(C_block_item((x), 1)))[ C_unfix(i) ] = C_num_to_unsigned_int(v)), C_SCHEME_UNDEFINED)
1217#define C_u_i_s32vector_set(x, i, v)    ((((C_s32 *)C_data_pointer(C_block_item((x), 1)))[ C_unfix(i) ] = C_num_to_int(v)), C_SCHEME_UNDEFINED)
1218
1219#define C_u_i_bit_setp(x, i)            C_mk_bool((C_unfix(x) & (1 << C_unfix(i))) != 0)
1220
1221#ifdef C_BIG_ENDIAN
1222# ifdef C_SIXTY_FOUR
1223#  define C_lihdr(x, y, z)              ((C_LAMBDA_INFO_TYPE >> 56) & 0xff), \
1224                                        0, 0, 0, 0, (x), (y), (z)
1225# else
1226#  define C_lihdr(x, y, z)              ((C_LAMBDA_INFO_TYPE >> 24) & 0xff), \
1227                                        (x), (y), (z)
1228# endif
1229#else
1230# ifdef C_SIXTY_FOUR
1231#  define C_lihdr(x, y, z)              (z), (y), (x), 0, 0, 0, 0, \
1232                                        ((C_LAMBDA_INFO_TYPE >> 56) & 0xff)
1233# else
1234#  define C_lihdr(x, y, z)              (z), (y), (x), \
1235                                        ((C_LAMBDA_INFO_TYPE >> 24) & 0xff)
1236# endif
1237#endif
1238
1239#define C_end_of_main
1240
1241#if !defined(C_EMBEDDED) && !defined(C_SHARED)
1242# ifndef C_WINDOWS_GUI
1243#  define C_main_entry_point            int main(int argc, char *argv[]) { return CHICKEN_main(argc, argv, (void*)C_toplevel); } C_end_of_main
1244# else
1245#  define C_main_entry_point            \
1246  int WINAPI WinMain(HINSTANCE me, HINSTANCE you, LPSTR cmdline, int show) \
1247  { return CHICKEN_main(0, NULL, (void *)C_toplevel); } C_end_of_main
1248# endif
1249#else
1250# define C_main_entry_point
1251#endif
1252
1253
1254/* Variables: */
1255
1256C_varextern C_TLS time_t C_startup_time_seconds;
1257C_varextern C_TLS C_word
1258  *C_temporary_stack,
1259  *C_temporary_stack_bottom,
1260  *C_stack_limit;
1261C_varextern C_TLS long
1262  C_timer_interrupt_counter,
1263  C_initial_timer_interrupt_period;
1264C_varextern C_TLS C_byte
1265  *C_fromspace_top,
1266  *C_fromspace_limit;
1267C_varextern C_TLS double C_temporary_flonum;
1268C_varextern C_TLS jmp_buf C_restart;
1269C_varextern C_TLS void *C_restart_address;
1270C_varextern C_TLS int C_entry_point_status;
1271
1272C_varextern C_TLS void (C_fcall *C_restart_trampoline)(void *proc) C_regparm C_noret;
1273C_varextern C_TLS void (*C_pre_gc_hook)(int mode);
1274C_varextern C_TLS void (*C_post_gc_hook)(int mode, long ms);
1275C_varextern C_TLS void (*C_panic_hook)(C_char *msg);
1276
1277C_varextern C_TLS int
1278  C_abort_on_thread_exceptions,
1279  C_interrupts_enabled,
1280  C_disable_overflow_check,
1281  C_enable_gcweak,
1282  C_heap_size_is_fixed,
1283  C_max_pending_finalizers,
1284  C_trace_buffer_size,
1285  C_main_argc;
1286C_varextern C_TLS C_uword
1287  C_heap_growth,
1288  C_heap_shrinkage;
1289C_varextern C_TLS char
1290  **C_main_argv,
1291  *C_dlerror;
1292C_varextern C_TLS C_uword C_maximal_heap_size;
1293C_varextern C_TLS int (*C_gc_mutation_hook)(C_word *slot, C_word val);
1294C_varextern C_TLS void (*C_gc_trace_hook)(C_word *var, int mode);
1295C_varextern C_TLS C_word (*C_get_unbound_variable_value_hook)(C_word sym);
1296
1297
1298/* Prototypes: */
1299
1300C_BEGIN_C_DECLS
1301
1302C_fctexport int CHICKEN_main(int argc, char *argv[], void *toplevel);
1303C_fctexport int CHICKEN_initialize(int heap, int stack, int symbols, void *toplevel);
1304C_fctexport C_word CHICKEN_run(void *toplevel);
1305C_fctexport C_word CHICKEN_continue(C_word k);
1306C_fctexport void *CHICKEN_new_gc_root();
1307C_fctexport void *CHICKEN_new_finalizable_gc_root();
1308C_fctexport void *CHICKEN_new_gc_root_2(int finalizable);
1309C_fctexport void CHICKEN_delete_gc_root(void *root);
1310C_fctexport void *CHICKEN_global_lookup(char *name);
1311C_fctexport int CHICKEN_is_running();
1312C_fctexport void CHICKEN_interrupt();
1313
1314C_fctexport void C_check_nursery_minimum(C_word size);
1315C_fctexport int C_fcall C_save_callback_continuation(C_word **ptr, C_word k);
1316C_fctexport C_word C_fcall C_restore_callback_continuation(void);
1317C_fctexport C_word C_fcall C_restore_callback_continuation2(int level);
1318C_fctexport C_word C_fcall C_callback(C_word closure, int argc);
1319C_fctexport C_word C_fcall C_callback_wrapper(void *proc, int argc);
1320C_fctexport void C_fcall C_callback_adjust_stack_limits(C_word *base); /* DEPRECATED */
1321C_fctexport void C_fcall C_callback_adjust_stack(C_word *base, int size);
1322C_fctexport void CHICKEN_parse_command_line(int argc, char *argv[], C_word *heap, C_word *stack, C_word *symbols);
1323C_fctexport void C_fcall C_toplevel_entry(C_char *name) C_regparm;
1324C_fctexport C_word C_fcall C_enable_interrupts(void) C_regparm;
1325C_fctexport C_word C_fcall C_disable_interrupts(void) C_regparm;
1326C_fctexport void C_fcall C_paranoid_check_for_interrupt(void) C_regparm;
1327C_fctexport double C_fcall C_c_double(C_word x) C_regparm;
1328C_fctexport C_word C_fcall C_num_to_int(C_word x) C_regparm;
1329C_fctexport C_s64 C_fcall C_num_to_int64(C_word x) C_regparm;
1330C_fctexport C_uword C_fcall C_num_to_unsigned_int(C_word x) C_regparm;
1331C_fctexport C_word C_fcall C_int_to_num(C_word **ptr, C_word n) C_regparm;
1332C_fctexport C_word C_fcall C_unsigned_int_to_num(C_word **ptr, C_uword n) C_regparm;
1333C_fctexport C_word C_fcall C_long_to_num(C_word **ptr, long n) C_regparm;
1334C_fctexport C_word C_fcall C_unsigned_long_to_num(C_word **ptr, unsigned long n) C_regparm;
1335C_fctexport long C_fcall C_num_to_long(C_word x) C_regparm;
1336C_fctexport unsigned long C_fcall C_num_to_unsigned_long(C_word x) C_regparm;
1337C_fctexport C_word C_fcall C_flonum_in_int_range_p(C_word n) C_regparm;
1338C_fctexport C_word C_fcall C_flonum_in_uint_range_p(C_word n) C_regparm;
1339C_fctexport C_word C_fcall C_double_to_number(C_word n) C_regparm;
1340C_fctexport char *C_fcall C_string_or_null(C_word x) C_regparm;
1341C_fctexport void *C_fcall C_data_pointer_or_null(C_word x) C_regparm;
1342C_fctexport void *C_fcall C_srfi_4_vector_or_null(C_word x) C_regparm;
1343C_fctexport void *C_fcall C_c_pointer_or_null(C_word x) C_regparm;
1344C_fctexport void *C_fcall C_scheme_or_c_pointer(C_word x) C_regparm;
1345C_fctexport C_word C_fcall C_flonum_in_fixnum_range_p(C_word n) C_regparm;
1346C_fctexport void C_zap_strings(C_word str);
1347C_fctexport void C_set_or_change_heap_size(C_word heap, int reintern);
1348C_fctexport void C_do_resize_stack(C_word stack);
1349C_fctexport C_word C_resize_pending_finalizers(C_word size);
1350C_fctexport void C_initialize_lf(C_word *lf, int count);
1351C_fctexport void *C_register_lf(C_word *lf, int count);
1352C_fctexport void *C_register_lf2(C_word *lf, int count, C_PTABLE_ENTRY *ptable);
1353C_fctexport void C_unregister_lf(void *handle);
1354C_fctexport C_char *C_dump_trace(int start);
1355C_fctexport void C_fcall C_clear_trace_buffer(void) C_regparm;
1356C_fctexport C_word C_fetch_trace(C_word start, C_word buffer);
1357C_fctexport C_word C_fcall C_string(C_word **ptr, int len, C_char *str) C_regparm;
1358C_fctexport C_word C_fcall C_static_string(C_word **ptr, int len, C_char *str) C_regparm;
1359C_fctexport C_word C_fcall C_static_lambda_info(C_word **ptr, int len, C_char *str) C_regparm;
1360C_fctexport C_word C_fcall C_bytevector(C_word **ptr, int len, C_char *str) C_regparm;
1361C_fctexport C_word C_fcall C_pbytevector(int len, C_char *str) C_regparm;
1362C_fctexport C_word C_fcall C_string_aligned8(C_word **ptr, int len, C_char *str) C_regparm;
1363C_fctexport C_word C_fcall C_string2(C_word **ptr, C_char *str) C_regparm;
1364C_fctexport C_word C_fcall C_string2_safe(C_word **ptr, int max, C_char *str) C_regparm;
1365C_fctexport C_word C_fcall C_intern(C_word **ptr, int len, C_char *str) C_regparm;
1366C_fctexport C_word C_fcall C_intern_in(C_word **ptr, int len, C_char *str, C_SYMBOL_TABLE *stable) C_regparm;
1367C_fctexport C_word C_fcall C_h_intern(C_word *slot, int len, C_char *str) C_regparm;
1368C_fctexport C_word C_fcall C_h_intern_in(C_word *slot, int len, C_char *str, C_SYMBOL_TABLE *stable) C_regparm;
1369C_fctexport C_word C_fcall C_intern2(C_word **ptr, C_char *str) C_regparm;
1370C_fctexport C_word C_fcall C_intern3(C_word **ptr, C_char *str, C_word value) C_regparm;
1371C_fctexport C_word C_fcall C_restore_rest(C_word *ptr, int num) C_regparm;
1372C_fctexport C_word C_fcall C_restore_rest_vector(C_word *ptr, int num) C_regparm;
1373C_fctexport void C_bad_memory(void) C_noret;
1374C_fctexport void C_bad_memory_2(void) C_noret;
1375C_fctexport void C_bad_argc(int c, int n) C_noret;
1376C_fctexport void C_bad_min_argc(int c, int n) C_noret;
1377C_fctexport void C_bad_argc_2(int c, int n, C_word closure) C_noret;
1378C_fctexport void C_bad_min_argc_2(int c, int n, C_word closure) C_noret;
1379C_fctexport void C_stack_overflow(void) C_noret;
1380C_fctexport void C_unbound_error(C_word sym) C_noret;
1381C_fctexport void C_no_closure_error(C_word x) C_noret;
1382C_fctexport C_word C_closure(C_word **ptr, int cells, C_word proc, ...);
1383C_fctexport C_word C_fcall C_pair(C_word **ptr, C_word car, C_word cdr) C_regparm;
1384C_fctexport C_word C_fcall C_h_pair(C_word car, C_word cdr) C_regparm;
1385C_fctexport C_word C_fcall C_flonum(C_word **ptr, double n) C_regparm;
1386C_fctexport C_word C_fcall C_number(C_word **ptr, double n) C_regparm;
1387C_fctexport C_word C_fcall C_mpointer(C_word **ptr, void *mp) C_regparm;
1388C_fctexport C_word C_fcall C_mpointer_or_false(C_word **ptr, void *mp) C_regparm;
1389C_fctexport C_word C_fcall C_mpointer(C_word **ptr, void *mp) C_regparm;
1390C_fctexport C_word C_fcall C_mpointer_or_false(C_word **ptr, void *mp) C_regparm;
1391C_fctexport C_word C_fcall C_taggedmpointer(C_word **ptr, C_word tag, void *mp) C_regparm;
1392C_fctexport C_word C_fcall C_taggedmpointer_or_false(C_word **ptr, C_word tag, void *mp) C_regparm;
1393C_fctexport C_word C_fcall C_swigmpointer(C_word **ptr, void *mp, void *sdata) C_regparm;
1394C_fctexport C_word C_vector(C_word **ptr, int n, ...);
1395C_fctexport C_word C_h_vector(int n, ...);
1396C_fctexport C_word C_structure(C_word **ptr, int n, ...);
1397C_fctexport C_word C_h_structure(int n, ...);
1398C_fctexport C_word C_fcall C_mutate(C_word *slot, C_word val) C_regparm;
1399C_fctexport void C_fcall C_reclaim(void *trampoline, void *proc) C_regparm C_noret;
1400C_fctexport void C_save_and_reclaim(void *trampoline, void *proc, int n, ...) C_noret;
1401C_fctexport void C_fcall C_rereclaim(long size) C_regparm; /* deprecated */
1402C_fctexport void C_fcall C_rereclaim2(C_uword size, int double_plus) C_regparm;
1403C_fctexport C_word C_fcall C_retrieve(C_word sym) C_regparm;
1404C_fctexport C_word C_fcall C_retrieve2(C_word val, char *name) C_regparm;
1405C_fctexport void *C_fcall C_retrieve_proc(C_word closure) C_regparm;
1406C_fctexport void *C_fcall C_retrieve_symbol_proc(C_word sym) C_regparm;
1407C_fctexport void *C_fcall C_retrieve2_symbol_proc(C_word val, char *name) C_regparm;
1408C_fctexport C_word C_fcall C_permanentp(C_word x) C_regparm;
1409C_fctexport int C_in_stackp(C_word x) C_regparm;
1410C_fctexport int C_fcall C_in_heapp(C_word x) C_regparm;
1411C_fctexport int C_fcall C_in_fromspacep(C_word x) C_regparm;
1412C_fctexport void C_fcall C_trace(C_char *name) C_regparm;
1413C_fctexport C_word C_fcall C_emit_trace_info(C_word x, C_word y, C_word t) C_regparm;
1414C_fctexport C_word C_fcall C_emit_trace_info2(char *raw, C_word x, C_word y, C_word t) C_regparm;
1415C_fctexport C_word C_fcall C_hash_string(C_word str) C_regparm;
1416C_fctexport C_word C_fcall C_hash_string_ci(C_word str) C_regparm;
1417C_fctexport C_word C_halt(C_word msg);
1418C_fctexport C_word C_message(C_word msg);
1419C_fctexport C_word C_fcall C_equalp(C_word x, C_word y) C_regparm;
1420C_fctexport C_word C_fcall C_set_gc_report(C_word flag) C_regparm;
1421C_fctexport C_word C_fcall C_start_timer(void) C_regparm;
1422C_fctexport C_word C_exit_runtime(C_word code);
1423C_fctexport C_word C_fcall C_display_flonum(C_word port, C_word n) C_regparm;
1424C_fctexport C_word C_fcall C_set_print_precision(C_word n) C_regparm;
1425C_fctexport C_word C_fcall C_get_print_precision(void) C_regparm;
1426C_fctexport C_word C_fcall C_read_char(C_word port) C_regparm;
1427C_fctexport C_word C_fcall C_peek_char(C_word port) C_regparm;
1428C_fctexport C_word C_fcall C_execute_shell_command(C_word string) C_regparm;
1429C_fctexport C_word C_fcall C_char_ready_p(C_word port) C_regparm;
1430C_fctexport C_word C_fcall C_flush_output(C_word port) C_regparm;
1431C_fctexport C_word C_fcall C_fudge(C_word fudge_factor) C_regparm;
1432C_fctexport void C_fcall C_raise_interrupt(int reason) C_regparm;
1433C_fctexport C_word C_fcall C_set_initial_timer_interrupt_period(C_word n) C_regparm;
1434C_fctexport C_word C_fcall C_establish_signal_handler(C_word signum, C_word reason) C_regparm;
1435C_fctexport C_word C_fcall C_fits_in_int_p(C_word x) C_regparm;
1436C_fctexport C_word C_fcall C_fits_in_unsigned_int_p(C_word x) C_regparm;
1437C_fctexport C_word C_fcall C_copy_block(C_word from, C_word to) C_regparm;
1438C_fctexport C_word C_fcall C_evict_block(C_word from, C_word ptr) C_regparm;
1439C_fctexport void C_fcall C_gc_protect(C_word **addr, int n) C_regparm;
1440C_fctexport void C_fcall C_gc_unprotect(int n) C_regparm;
1441C_fctexport C_SYMBOL_TABLE *C_new_symbol_table(char *name, unsigned int size) C_regparm;
1442C_fctexport void C_delete_symbol_table(C_SYMBOL_TABLE *st) C_regparm;
1443C_fctexport void C_set_symbol_table(C_SYMBOL_TABLE *st) C_regparm;
1444C_fctexport C_SYMBOL_TABLE *C_find_symbol_table(char *name) C_regparm;
1445C_fctexport C_word C_find_symbol(C_word str, C_SYMBOL_TABLE *stable) C_regparm;
1446C_fctexport C_word C_fcall C_lookup_symbol(C_word sym) C_regparm;
1447C_fctexport C_word C_enumerate_symbols(C_SYMBOL_TABLE *stable, C_word pos) C_regparm;
1448C_fctexport void C_do_register_finalizer(C_word x, C_word proc);
1449C_fctexport int C_do_unregister_finalizer(C_word x);
1450C_fctexport C_word C_dbg_hook(C_word x);
1451
1452C_fctimport void C_ccall C_toplevel(C_word c, C_word self, C_word k) C_noret;
1453C_fctexport void C_ccall C_stop_timer(C_word c, C_word closure, C_word k) C_noret;
1454C_fctexport void C_ccall C_apply(C_word c, C_word closure, C_word k, C_word fn, ...) C_noret;
1455C_fctexport void C_ccall C_do_apply(C_word n, C_word closure, C_word k) C_noret;
1456C_fctexport void C_ccall C_call_cc(C_word c, C_word closure, C_word k, C_word cont) C_noret;
1457C_fctexport void C_ccall C_continuation_graft(C_word c, C_word closure, C_word k, C_word kk, C_word proc) C_noret;
1458C_fctexport void C_ccall C_values(C_word c, C_word closure, C_word k, ...) C_noret;
1459C_fctexport void C_ccall C_apply_values(C_word c, C_word closure, C_word k, C_word lst) C_noret;
1460C_fctexport void C_ccall C_call_with_values(C_word c, C_word closure, C_word k, C_word thunk, C_word kont) C_noret;
1461C_fctexport void C_ccall C_u_call_with_values(C_word c, C_word closure, C_word k, C_word thunk, C_word kont) C_noret;
1462C_fctexport void C_ccall C_times(C_word c, C_word closure, C_word k, ...) C_noret;
1463C_fctexport void C_ccall C_plus(C_word c, C_word closure, C_word k, ...) C_noret;
1464C_fctexport void C_ccall C_minus(C_word c, C_word closure, C_word k, C_word n1, ...) C_noret;
1465C_fctexport void C_ccall C_divide(C_word c, C_word closure, C_word k, C_word n1, ...) C_noret;
1466C_fctexport void C_ccall C_nequalp(C_word c, C_word closure, C_word k, ...) C_noret;
1467C_fctexport void C_ccall C_greaterp(C_word c, C_word closure, C_word k, ...) C_noret;
1468C_fctexport void C_ccall C_lessp(C_word c, C_word closure, C_word k, ...) C_noret;
1469C_fctexport void C_ccall C_greater_or_equal_p(C_word c, C_word closure, C_word k, ...) C_noret;
1470C_fctexport void C_ccall C_less_or_equal_p(C_word c, C_word closure, C_word k, ...) C_noret;
1471C_fctexport void C_ccall C_expt(C_word c, C_word closure, C_word k, C_word n1, C_word n2) C_noret;
1472C_fctexport void C_ccall C_gc(C_word c, C_word closure, C_word k, ...) C_noret;
1473C_fctexport void C_ccall C_open_file_port(C_word c, C_word closure, C_word k, C_word port, C_word channel, C_word mode) C_noret;
1474C_fctexport void C_ccall C_allocate_vector(C_word c, C_word closure, C_word k, C_word size, C_word type, C_word init, C_word align8) C_noret;
1475C_fctexport void C_ccall C_string_to_symbol(C_word c, C_word closure, C_word k, C_word string) C_noret;
1476C_fctexport void C_ccall C_build_symbol(C_word c, C_word closure, C_word k, C_word string) C_noret;
1477C_fctexport void C_ccall C_cons_flonum(C_word c, C_word closure, C_word k) C_noret;
1478C_fctexport void C_ccall C_flonum_fraction(C_word c, C_word closure, C_word k, C_word n) C_noret;
1479C_fctexport void C_ccall C_exact_to_inexact(C_word c, C_word closure, C_word k, C_word n) C_noret;
1480C_fctexport void C_ccall C_flonum_floor(C_word c, C_word closure, C_word k, C_word n) C_noret;
1481C_fctexport void C_ccall C_flonum_ceiling(C_word c, C_word closure, C_word k, C_word n) C_noret;
1482C_fctexport void C_ccall C_flonum_truncate(C_word c, C_word closure, C_word k, C_word n) C_noret;
1483C_fctexport void C_ccall C_flonum_round(C_word c, C_word closure, C_word k, C_word n) C_noret;
1484C_fctexport void C_ccall C_quotient(C_word c, C_word closure, C_word k, C_word n1, C_word n2) C_noret;
1485C_fctexport void C_ccall C_string_to_number(C_word c, C_word closure, C_word k, C_word str, ...) C_noret;
1486C_fctexport void C_ccall C_number_to_string(C_word c, C_word closure, C_word k, C_word num, ...) C_noret;
1487C_fctexport void C_ccall C_get_argv(C_word c, C_word closure, C_word k) C_noret;
1488C_fctexport void C_ccall C_make_structure(C_word c, C_word closure, C_word k, C_word type, ...) C_noret;
1489C_fctexport void C_ccall C_make_symbol(C_word c, C_word closure, C_word k, C_word name) C_noret;
1490C_fctexport void C_ccall C_make_pointer(C_word c, C_word closure, C_word k) C_noret;
1491C_fctexport void C_ccall C_make_tagged_pointer(C_word c, C_word closure, C_word k, C_word tag) C_noret;
1492C_fctexport void C_ccall C_ensure_heap_reserve(C_word c, C_word closure, C_word k, C_word n) C_noret;
1493C_fctexport void C_ccall C_return_to_host(C_word c, C_word closure, C_word k) C_noret;
1494C_fctexport void C_ccall C_file_info(C_word c, C_word closure, C_word k, C_word port) C_noret;
1495C_fctexport void C_ccall C_get_environment_variable(C_word c, C_word closure, C_word k, C_word name) C_noret;
1496C_fctexport void C_ccall C_get_symbol_table_info(C_word c, C_word closure, C_word k) C_noret;
1497C_fctexport void C_ccall C_get_memory_info(C_word c, C_word closure, C_word k) C_noret;
1498C_fctexport void C_ccall C_context_switch(C_word c, C_word closure, C_word k, C_word state) C_noret;
1499C_fctexport void C_ccall C_peek_signed_integer(C_word c, C_word closure, C_word k, C_word v, C_word index) C_noret;
1500C_fctexport void C_ccall C_peek_unsigned_integer(C_word c, C_word closure, C_word k, C_word v, C_word index) C_noret;
1501C_fctexport void C_ccall C_decode_seconds(C_word c, C_word closure, C_word k, C_word secs, C_word mode) C_noret;
1502C_fctexport void C_ccall C_software_type(C_word c, C_word closure, C_word k) C_noret;
1503C_fctexport void C_ccall C_machine_type(C_word c, C_word closure, C_word k) C_noret;
1504C_fctexport void C_ccall C_machine_byte_order(C_word c, C_word closure, C_word k) C_noret;
1505C_fctexport void C_ccall C_software_version(C_word c, C_word closure, C_word k) C_noret;
1506C_fctexport void C_ccall C_build_platform(C_word c, C_word closure, C_word k) C_noret;
1507C_fctexport void C_ccall C_c_runtime(C_word c, C_word closure, C_word k) C_noret;
1508C_fctexport void C_ccall C_register_finalizer(C_word c, C_word closure, C_word k, C_word x, C_word proc) C_noret;
1509C_fctexport void C_ccall C_dlopen_flags(C_word c, C_word closure, C_word k) C_noret;
1510C_fctexport void C_ccall C_set_dlopen_flags(C_word c, C_word closure, C_word k, C_word now, C_word global) C_noret;
1511C_fctexport void C_ccall C_dload(C_word c, C_word closure, C_word k, C_word name, C_word entry, C_word reloadable) C_noret;
1512C_fctexport void C_ccall C_become(C_word c, C_word closure, C_word k, C_word table) C_noret;
1513C_fctexport void C_ccall C_cpu_time(C_word c, C_word closure, C_word k) C_noret;
1514C_fctexport void C_ccall C_locative_ref(C_word c, C_word closure, C_word k, C_word loc) C_noret;
1515C_fctexport void C_ccall C_call_with_cthulhu(C_word c, C_word self, C_word k, C_word proc) C_noret;
1516C_fctexport void C_ccall C_copy_closure(C_word c, C_word closure, C_word k, C_word proc) C_noret;
1517
1518C_fctexport void C_ccall C_dynamic_library_names(C_word c, C_word closure, C_word k) C_noret;
1519C_fctexport void C_ccall C_dynamic_library_data(C_word c, C_word closure, C_word k, C_word libnam) C_noret;
1520C_fctexport void C_ccall C_chicken_library_literal_frame(C_word c, C_word closure, C_word k, C_word lfnam, C_word lfhnd, C_word lfcnt) C_noret;
1521C_fctexport void C_ccall C_chicken_library_ptable(C_word c, C_word closure, C_word k, C_word lfnam, C_word lfhnd, C_word lfcnt, C_word inclptrs) C_noret;
1522
1523C_fctexport void C_ccall C_dynamic_library_load(C_word c, C_word closure, C_word k, C_word name) C_noret;
1524C_fctexport void C_ccall C_dynamic_library_unload(C_word c, C_word closure, C_word k, C_word name) C_noret;
1525
1526#if !defined(__GNUC__) && !defined(__INTEL_COMPILER)
1527C_fctexport C_word *C_a_i(C_word **a, int n);
1528#endif
1529
1530C_fctexport time_t C_fcall C_seconds(long *ms) C_regparm;
1531C_fctexport C_word C_a_i_list(C_word **a, int c, ...);
1532C_fctexport C_word C_h_list(int c, ...);
1533C_fctexport C_word C_a_i_string(C_word **a, int c, ...);
1534C_fctexport C_word C_a_i_record(C_word **a, int c, ...);
1535C_fctexport C_word C_a_i_port(C_word **a, int c);
1536C_fctexport C_word C_fcall C_a_i_bytevector(C_word **a, int c, C_word x) C_regparm;
1537C_fctexport C_word C_fcall C_i_eqvp(C_word x, C_word y) C_regparm;
1538C_fctexport C_word C_fcall C_i_symbolp(C_word x) C_regparm;
1539C_fctexport C_word C_fcall C_i_pairp(C_word x) C_regparm;
1540C_fctexport C_word C_fcall C_i_vectorp(C_word x) C_regparm;
1541C_fctexport C_word C_fcall C_i_closurep(C_word x) C_regparm;
1542C_fctexport C_word C_fcall C_i_portp(C_word x) C_regparm;
1543C_fctexport C_word C_fcall C_i_stringp(C_word x) C_regparm;
1544C_fctexport C_word C_fcall C_i_numberp(C_word x) C_regparm;
1545C_fctexport C_word C_fcall C_i_rationalp(C_word x) C_regparm;
1546C_fctexport C_word C_fcall C_i_integerp(C_word x) C_regparm;
1547C_fctexport C_word C_fcall C_i_flonump(C_word x) C_regparm;
1548C_fctexport C_word C_fcall C_i_finitep(C_word x) C_regparm;
1549C_fctexport C_word C_fcall C_i_locativep(C_word x) C_regparm;
1550C_fctexport C_word C_fcall C_i_fixnum_min(C_word x, C_word y) C_regparm;
1551C_fctexport C_word C_fcall C_i_fixnum_max(C_word x, C_word y) C_regparm;
1552C_fctexport C_word C_fcall C_i_flonum_min(C_word x, C_word y) C_regparm;
1553C_fctexport C_word C_fcall C_i_flonum_max(C_word x, C_word y) C_regparm;
1554C_fctexport C_word C_fcall C_a_i_abs(C_word **a, int c, C_word n) C_regparm;
1555C_fctexport C_word C_fcall C_i_listp(C_word x) C_regparm;
1556C_fctexport C_word C_fcall C_i_string_equal_p(C_word x, C_word y) C_regparm;
1557C_fctexport C_word C_fcall C_i_string_ci_equal_p(C_word x, C_word y) C_regparm;
1558C_fctexport C_word C_fcall C_u_i_string_equal_p(C_word x, C_word y) C_regparm;
1559C_fctexport C_word C_fcall C_i_set_car(C_word p, C_word x) C_regparm;
1560C_fctexport C_word C_fcall C_i_set_cdr(C_word p, C_word x) C_regparm;
1561C_fctexport C_word C_fcall C_i_vector_set(C_word v, C_word i, C_word x) C_regparm;
1562C_fctexport C_word C_fcall C_i_exactp(C_word x) C_regparm;
1563C_fctexport C_word C_fcall C_u_i_exactp(C_word x) C_regparm;
1564C_fctexport C_word C_fcall C_i_inexactp(C_word x) C_regparm;
1565C_fctexport C_word C_fcall C_u_i_inexactp(C_word x) C_regparm;
1566C_fctexport C_word C_fcall C_i_zerop(C_word x) C_regparm;
1567C_fctexport C_word C_fcall C_u_i_zerop(C_word x) C_regparm;
1568C_fctexport C_word C_fcall C_i_positivep(C_word x) C_regparm;
1569C_fctexport C_word C_fcall C_u_i_positivep(C_word x) C_regparm;
1570C_fctexport C_word C_fcall C_i_negativep(C_word x) C_regparm;
1571C_fctexport C_word C_fcall C_u_i_negativep(C_word x) C_regparm;
1572C_fctexport C_word C_fcall C_i_car(C_word x) C_regparm;
1573C_fctexport C_word C_fcall C_i_cdr(C_word x) C_regparm;
1574C_fctexport C_word C_fcall C_i_cadr(C_word x) C_regparm;
1575C_fctexport C_word C_fcall C_i_cddr(C_word x) C_regparm;
1576C_fctexport C_word C_fcall C_i_caddr(C_word x) C_regparm;
1577C_fctexport C_word C_fcall C_i_cdddr(C_word x) C_regparm;
1578C_fctexport C_word C_fcall C_i_cadddr(C_word x) C_regparm;
1579C_fctexport C_word C_fcall C_i_cddddr(C_word x) C_regparm;
1580C_fctexport C_word C_fcall C_i_list_tail(C_word lst, C_word i) C_regparm;
1581C_fctexport C_word C_fcall C_i_evenp(C_word x) C_regparm;
1582C_fctexport C_word C_fcall C_u_i_evenp(C_word x) C_regparm;
1583C_fctexport C_word C_fcall C_i_oddp(C_word x) C_regparm;
1584C_fctexport C_word C_fcall C_u_i_oddp(C_word x) C_regparm;
1585C_fctexport C_word C_fcall C_i_vector_ref(C_word v, C_word i) C_regparm;
1586C_fctexport C_word C_fcall C_i_block_ref(C_word x, C_word i) C_regparm;
1587C_fctexport C_word C_fcall C_i_string_set(C_word s, C_word i, C_word c) C_regparm;
1588C_fctexport C_word C_fcall C_i_string_ref(C_word s, C_word i) C_regparm;
1589C_fctexport C_word C_fcall C_i_vector_length(C_word v) C_regparm;
1590C_fctexport C_word C_fcall C_i_string_length(C_word s) C_regparm;
1591C_fctexport C_word C_fcall C_i_assq(C_word x, C_word lst) C_regparm;
1592C_fctexport C_word C_fcall C_u_i_assq(C_word x, C_word lst) C_regparm;
1593C_fctexport C_word C_fcall C_i_assv(C_word x, C_word lst) C_regparm;
1594C_fctexport C_word C_fcall C_i_assoc(C_word x, C_word lst) C_regparm;
1595C_fctexport C_word C_fcall C_i_memq(C_word x, C_word lst) C_regparm;
1596C_fctexport C_word C_fcall C_u_i_memq(C_word x, C_word lst) C_regparm;
1597C_fctexport C_word C_fcall C_i_memv(C_word x, C_word lst) C_regparm;
1598C_fctexport C_word C_fcall C_i_member(C_word x, C_word lst) C_regparm;
1599C_fctexport C_word C_fcall C_i_length(C_word lst) C_regparm;
1600C_fctexport C_word C_fcall C_u_i_length(C_word lst) C_regparm;
1601C_fctexport C_word C_fcall C_i_inexact_to_exact(C_word n) C_regparm;
1602C_fctexport C_word C_fcall C_i_check_closure_2(C_word x, C_word loc) C_regparm;
1603C_fctexport C_word C_fcall C_i_check_exact_2(C_word x, C_word loc) C_regparm;
1604C_fctexport C_word C_fcall C_i_check_inexact_2(C_word x, C_word loc) C_regparm;
1605C_fctexport C_word C_fcall C_i_check_number_2(C_word x, C_word loc) C_regparm;
1606C_fctexport C_word C_fcall C_i_check_string_2(C_word x, C_word loc) C_regparm;
1607C_fctexport C_word C_fcall C_i_check_bytevector_2(C_word x, C_word loc) C_regparm;
1608C_fctexport C_word C_fcall C_i_check_symbol_2(C_word x, C_word loc) C_regparm;
1609C_fctexport C_word C_fcall C_i_check_list_2(C_word x, C_word loc) C_regparm;
1610C_fctexport C_word C_fcall C_i_check_pair_2(C_word x, C_word loc) C_regparm;
1611C_fctexport C_word C_fcall C_i_check_vector_2(C_word x, C_word loc) C_regparm;
1612C_fctexport C_word C_fcall C_i_check_structure_2(C_word x, C_word st, C_word loc) C_regparm;
1613C_fctexport C_word C_fcall C_i_check_char_2(C_word x, C_word loc) C_regparm;
1614C_fctexport C_word C_fcall C_2_times(C_word **ptr, C_word x, C_word y) C_regparm;
1615C_fctexport C_word C_fcall C_2_plus(C_word **ptr, C_word x, C_word y) C_regparm;
1616C_fctexport C_word C_fcall C_2_minus(C_word **ptr, C_word x, C_word y) C_regparm;
1617C_fctexport C_word C_fcall C_2_divide(C_word **ptr, C_word x, C_word y) C_regparm;
1618C_fctexport C_word C_fcall C_i_nequalp(C_word x, C_word y) C_regparm;
1619C_fctexport C_word C_fcall C_i_greaterp(C_word x, C_word y) C_regparm;
1620C_fctexport C_word C_fcall C_i_lessp(C_word x, C_word y) C_regparm;
1621C_fctexport C_word C_fcall C_i_greater_or_equalp(C_word x, C_word y) C_regparm;
1622C_fctexport C_word C_fcall C_i_less_or_equalp(C_word x, C_word y) C_regparm;
1623C_fctexport C_word C_fcall C_i_not_pair_p_2(C_word x) C_regparm;
1624C_fctexport C_word C_fcall C_i_null_list_p(C_word x) C_regparm;
1625C_fctexport C_word C_fcall C_i_string_null_p(C_word x) C_regparm;
1626C_fctexport C_word C_fcall C_string_to_pbytevector(C_word x) C_regparm;
1627C_fctexport C_word C_fcall C_i_null_pointerp(C_word x) C_regparm;
1628C_fctexport C_word C_fcall C_i_fixnum_arithmetic_shift(C_word n, C_word c) C_regparm;
1629C_fctexport C_word C_fcall C_i_locative_set(C_word loc, C_word x) C_regparm;
1630C_fctexport C_word C_fcall C_i_locative_to_object(C_word loc) C_regparm;
1631C_fctexport C_word C_fcall C_a_i_make_locative(C_word **a, int c, C_word type, C_word object, C_word index, C_word weak) C_regparm;
1632C_fctexport C_word C_fcall C_a_i_flonum_plus(C_word **a, int c, C_word n1, C_word n2) C_regparm;
1633C_fctexport C_word C_fcall C_a_i_flonum_difference(C_word **a, int c, C_word n1, C_word n2) C_regparm;
1634C_fctexport C_word C_fcall C_a_i_flonum_times(C_word **a, int c, C_word n1, C_word n2) C_regparm;
1635C_fctexport C_word C_fcall C_a_i_flonum_quotient(C_word **a, int c, C_word n1, C_word n2) C_regparm;
1636C_fctexport C_word C_fcall C_a_i_flonum_negate(C_word **a, int c, C_word n1) C_regparm;
1637C_fctexport C_word C_fcall C_a_i_bitwise_and(C_word **a, int c, C_word n1, C_word n2) C_regparm;
1638C_fctexport C_word C_fcall C_a_i_bitwise_ior(C_word **a, int c, C_word n1, C_word n2) C_regparm;
1639C_fctexport C_word C_fcall C_a_i_bitwise_not(C_word **a, int c, C_word n1) C_regparm;
1640C_fctexport C_word C_fcall C_i_bit_setp(C_word n, C_word i) C_regparm;
1641C_fctexport C_word C_fcall C_a_i_bitwise_xor(C_word **a, int c, C_word n1, C_word n2) C_regparm;
1642C_fctexport C_word C_fcall C_a_i_arithmetic_shift(C_word **a, int c, C_word n1, C_word n2) C_regparm;
1643C_fctexport C_word C_fcall C_a_i_exp(C_word **a, int c, C_word n) C_regparm;
1644C_fctexport C_word C_fcall C_a_i_log(C_word **a, int c, C_word n) C_regparm;
1645C_fctexport C_word C_fcall C_a_i_sin(C_word **a, int c, C_word n) C_regparm;
1646C_fctexport C_word C_fcall C_a_i_cos(C_word **a, int c, C_word n) C_regparm;
1647C_fctexport C_word C_fcall C_a_i_tan(C_word **a, int c, C_word n) C_regparm;
1648C_fctexport C_word C_fcall C_a_i_asin(C_word **a, int c, C_word n) C_regparm;
1649C_fctexport C_word C_fcall C_a_i_acos(C_word **a, int c, C_word n) C_regparm;
1650C_fctexport C_word C_fcall C_a_i_atan(C_word **a, int c, C_word n) C_regparm;
1651C_fctexport C_word C_fcall C_a_i_atan2(C_word **a, int c, C_word n1, C_word n2) C_regparm;
1652C_fctexport C_word C_fcall C_a_i_sqrt(C_word **a, int c, C_word n) C_regparm;
1653C_fctexport C_word C_fcall C_i_o_fixnum_plus(C_word x, C_word y) C_regparm;
1654C_fctexport C_word C_fcall C_i_o_fixnum_difference(C_word x, C_word y) C_regparm;
1655C_fctexport C_word C_fcall C_i_o_fixnum_and(C_word x, C_word y) C_regparm;
1656C_fctexport C_word C_fcall C_i_o_fixnum_ior(C_word x, C_word y) C_regparm;
1657C_fctexport C_word C_fcall C_i_o_fixnum_xor(C_word x, C_word y) C_regparm;
1658
1659C_fctexport C_word C_fcall C_i_foreign_char_argumentp(C_word x) C_regparm;
1660C_fctexport C_word C_fcall C_i_foreign_fixnum_argumentp(C_word x) C_regparm;
1661C_fctexport C_word C_fcall C_i_foreign_flonum_argumentp(C_word x) C_regparm;
1662C_fctexport C_word C_fcall C_i_foreign_block_argumentp(C_word x) C_regparm;
1663C_fctexport C_word C_fcall C_i_foreign_number_vector_argumentp(C_word t, C_word x) C_regparm;
1664C_fctexport C_word C_fcall C_i_foreign_string_argumentp(C_word x) C_regparm;
1665C_fctexport C_word C_fcall C_i_foreign_symbol_argumentp(C_word x) C_regparm;
1666C_fctexport C_word C_fcall C_i_foreign_tagged_pointer_argumentp(C_word x, C_word t) C_regparm;
1667C_fctexport C_word C_fcall C_i_foreign_pointer_argumentp(C_word x) C_regparm;
1668C_fctexport C_word C_fcall C_i_foreign_scheme_or_c_pointer_argumentp(C_word x) C_regparm;
1669C_fctexport C_word C_fcall C_i_foreign_integer_argumentp(C_word x) C_regparm;
1670C_fctexport C_word C_fcall C_i_foreign_unsigned_integer_argumentp(C_word x) C_regparm;
1671
1672C_fctexport void * C_fcall C_dynamic_library_open(C_char *name) C_regparm;
1673C_fctexport void * C_fcall C_dynamic_library_procedure(void *handle, C_char *name) C_regparm;
1674C_fctexport void * C_fcall C_dynamic_library_procedure_exact(void *handle, C_char *name) C_regparm;
1675C_fctexport void * C_fcall C_dynamic_library_variable(void *handle, C_char *name) C_regparm;
1676C_fctexport void * C_fcall C_dynamic_library_variable_exact(void *handle, C_char *name) C_regparm;
1677C_fctexport int C_fcall C_dynamic_library_close(void *handle) C_regparm;
1678
1679C_fctexport void * C_fcall C_dynamic_library_symbol(C_word mname, C_word sname, C_word isprcsym) C_regparm;
1680
1681C_fctexport C_char * C_lookup_procedure_id(void *ptr);
1682C_fctexport void * C_lookup_procedure_ptr(C_char *id);
1683C_fctexport C_word C_ccall C_dunload(C_word name);
1684
1685#ifdef C_SIXTY_FOUR
1686C_fctexport void C_ccall C_peek_signed_integer_32(C_word c, C_word closure, C_word k, C_word v, C_word index) C_noret;
1687C_fctexport void C_ccall C_peek_unsigned_integer_32(C_word c, C_word closure, C_word k, C_word v, C_word index) C_noret;
1688#else
1689# define C_peek_signed_integer_32    C_peek_signed_integer
1690# define C_peek_unsigned_integer_32  C_peek_unsigned_integer
1691#endif
1692
1693C_fctexport C_word C_fcall C_decode_literal(C_word **ptr, C_char *str) C_regparm;
1694
1695/* defined in eval.scm: */
1696C_fctexport  void  CHICKEN_get_error_message(char *buf,int bufsize);
1697C_fctexport  int  CHICKEN_load(char * filename);
1698C_fctexport  int  CHICKEN_read(char * str,C_word *result);
1699C_fctexport  int  CHICKEN_apply_to_string(C_word func,C_word args,char *buf,int bufsize);
1700C_fctexport  int  CHICKEN_apply(C_word func,C_word args,C_word *result);
1701C_fctexport  int  CHICKEN_eval_string_to_string(char *str,char *buf,int bufsize);
1702C_fctexport  int  CHICKEN_eval_to_string(C_word exp,char *buf,int bufsize);
1703C_fctexport  int  CHICKEN_eval_string(char * str,C_word *result);
1704C_fctexport  int  CHICKEN_eval(C_word exp,C_word *result);
1705C_fctexport  int  CHICKEN_yield();
1706
1707C_fctexport void C_default_stub_toplevel(C_word c,C_word d,C_word k) C_noret;
1708
1709C_END_C_DECLS
1710
1711#endif /* ___CHICKEN */
Note: See TracBrowser for help on using the repository browser.