merge from 1.8 branch
[bpt/guile.git] / examples / compat / compat.h
1 /* classes: h_files */
2
3 #ifndef COMPATH
4 #define COMPATH
5 /* Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this software; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301 USA
21 *
22 * As a special exception, the Free Software Foundation gives permission
23 * for additional uses of the text contained in its release of GUILE.
24 *
25 * The exception is that, if you link the GUILE library with other files
26 * to produce an executable, this does not by itself cause the
27 * resulting executable to be covered by the GNU General Public License.
28 * Your use of that executable is in no way restricted on account of
29 * linking the GUILE library code into it.
30 *
31 * This exception does not however invalidate any other reasons why
32 * the executable file might be covered by the GNU General Public License.
33 *
34 * This exception applies only to the code released by the
35 * Free Software Foundation under the name GUILE. If you copy
36 * code from other Free Software Foundation releases into a copy of
37 * GUILE, as the General Public License permits, the exception does
38 * not apply to the code that you add in this way. To avoid misleading
39 * anyone as to the status of such modified files, you must delete
40 * this exception notice from them.
41 *
42 * If you write modifications of your own for GUILE, it is your choice
43 * whether to permit this exception to apply to your modifications.
44 * If you do not wish that, delete this exception notice. */
45 \f
46
47 #ifndef SCM_GC8MARKP
48 # define SCM_GC8MARKP(X) SCM_GC_MARK_P(X)
49 # define SCM_SETGC8MARK(X) SCM_SET_GC_MARK(X)
50 #endif
51
52 #ifndef SCM_GC_MARK_P
53 # define SCM_GC_MARK_P(X) SCM_GCMARKP(X)
54 # define SCM_SET_GC_MARK(X) SCM_SETGCMARK(X)
55 #endif
56
57 #ifndef SCM_ARRAY_FLAG_CONTIGUOUS
58 # define SCM_ARRAY_FLAG_CONTIGUOUS SCM_ARRAY_CONTIGUOUS
59 #endif
60
61 #ifndef HAVE_SCM_T_BITS
62 typedef scm_bits_t scm_t_bits;
63 typedef scm_array scm_t_array;
64 typedef scm_array_dim scm_t_array_dim;
65 typedef scm_mutex_t scm_t_mutex;
66 typedef scm_cond_t scm_t_cond;
67 typedef scm_key_t scm_t_key;
68 typedef scm_catch_body_t scm_t_catch_body;
69 typedef scm_catch_handler_t scm_t_catch_handler;
70 typedef scm_rstate scm_t_rstate;
71 typedef scm_port scm_t_port;
72 typedef scm_fport scm_t_fport;
73 #endif
74
75 #ifndef SCM_VALIDATE_DOUBLE_COPY
76 #define SCM_VALIDATE_DOUBLE_COPY SCM_VALIDATE_NUMBER_COPY
77 #endif
78
79 #ifndef HAVE_SCM_C_DEFINE_MODULE
80 #define scm_c_define_module(NAME,INIT,DATA) \
81 scm_make_module (scm_read_0str ("(" NAME ")"))
82 #endif
83
84 #ifndef SCM_MAKE_CHAR
85 #define SCM_MAKE_CHAR SCM_MAKICHR
86 #define SCM_CHAR SCM_ICHR
87 #define SCM_CHARP SCM_ICHRP
88 #endif
89
90 #ifndef SCM_ROSTRINGP
91 #define SCM_ROSTRINGP(x) (SCM_STRINGP (x) || SCM_SYMBOLP (x))
92 #define SCM_RWSTRINGP(x) SCM_STRINGP (x)
93 #define SCM_ROCHARS(x) \
94 (SCM_STRINGP (x) ? SCM_STRING_CHARS (x) : SCM_SYMBOL_CHARS (x))
95 #define SCM_ROLENGTH(x) \
96 (SCM_STRINGP (x) ? SCM_STRING_LENGTH (x) : SCM_SYMBOL_LENGTH (x))
97 #endif
98
99 #ifndef SCM_STRING_COERCE_0TERMINATION_X
100 #ifdef SCM_COERCE_SUBSTR
101 #define SCM_STRING_COERCE_0TERMINATION_X SCM_COERCE_SUBSTR
102 #else
103 #define SCM_STRING_COERCE_0TERMINATION_X(x) (x)
104 #endif
105 #endif
106
107 #ifndef HAVE_SCM_C_READ_STRING
108 #define scm_c_read_string scm_read_0str
109 #define scm_c_eval_string scm_eval_0str
110 #define scm_str2symbol(X) SCM_CAR (scm_intern0 (X))
111 #define scm_mem2string(X, Y) scm_makfromstr ((X), (Y), 0)
112 #endif
113
114 #ifndef HAVE_SCM_MAKE_REAL
115 #define scm_make_real(X) scm_makdbl ((X), 0.0)
116 #endif
117
118 #ifdef HAVE_SCM_NUM2DOUBLE
119 #define scm_real2double scm_num2double
120 #define SCM_REAL2DOUBLE SCM_NUM2DOUBLE
121 #else
122 #define scm_real2double(X, POS, WHERE) scm_num2dbl ((X), (WHERE))
123 #define SCM_REAL2DOUBLE(X, POS) scm_num2dbl ((X), FUNC_NAME)
124 #endif
125
126 #ifndef SCM_VALIDATE_DOUBLE_DEF_COPY
127 #define SCM_VALIDATE_DOUBLE_DEF_COPY SCM_VALIDATE_NUMBER_DEF_COPY
128 #endif
129
130 #ifndef HAVE_SCM_GC_PROTECT_OBJECT
131 #define scm_gc_protect_object scm_protect_object
132 #endif
133
134 #ifndef HAVE_SCM_C_DEFINE_GSUBR
135 #define scm_c_define_gsubr scm_make_gsubr
136 #endif
137
138 #ifndef SCM_STRING_CHARS
139 #define SCM_STRING_CHARS SCM_CHARS
140 #define SCM_STRING_UCHARS SCM_UCHARS
141 #define SCM_STRING_LENGTH SCM_LENGTH
142 #endif
143
144 #ifndef SCM_SUBSTRP
145 #define SCM_SUBSTRP(X) 0
146 #endif
147
148 #ifndef SCM_VECTOR_LENGTH
149 #define SCM_VECTOR_LENGTH SCM_LENGTH
150 #define SCM_UVECTOR_LENGTH SCM_LENGTH
151 #endif
152
153 #ifndef SCM_SET_VECTOR_LENGTH
154 #define SCM_SET_VECTOR_LENGTH SCM_SETLENGTH
155 #define SCM_SET_UVECTOR_LENGTH SCM_SETLENGTH
156 #endif
157
158 #ifndef SCM_VECTOR_BASE
159 #define SCM_VECTOR_BASE SCM_CHARS
160 #define SCM_UVECTOR_BASE SCM_CHARS
161 #endif
162
163 #ifndef SCM_SET_VECTOR_BASE
164 #define SCM_SET_VECTOR_BASE SCM_SETCHARS
165 #define SCM_SET_UVECTOR_BASE SCM_SETCHARS
166 #endif
167
168 #ifndef SCM_UVECTOR_MAX_LENGTH
169 #define SCM_UVECTOR_MAX_LENGTH SCM_LENGTH_MAX
170 #endif
171
172 #ifndef HAVE_SCM_LIST_1
173 #define scm_list_1 SCM_LIST1
174 #define scm_list_2 SCM_LIST2
175 #define scm_list_3 SCM_LIST3
176 #define scm_list_4 SCM_LIST4
177 #define scm_list_5 SCM_LIST5
178 #define scm_list_n scm_listify
179 #endif
180
181 #ifndef SCM_SYMBOL_CHARS
182 #define SCM_SYMBOL_CHARS SCM_CHARS
183 #endif
184
185 #endif /* COMPATH */