Merge branch 'master' of git://git.savannah.gnu.org/guile into elisp
[bpt/guile.git] / examples / compat / compat.h
1 /* classes: h_files */
2
3 #ifndef COMPATH
4 #define COMPATH
5 /* Copyright (C) 2001, 2002, 2006, 2008 Free Software Foundation, Inc.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * as published by the Free Software Foundation; either version 3 of
10 * the License, or (at your option) any later version.
11 *
12 * This library 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 GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 */
22 \f
23
24 #ifndef SCM_GC8MARKP
25 # define SCM_GC8MARKP(X) SCM_GC_MARK_P(X)
26 # define SCM_SETGC8MARK(X) SCM_SET_GC_MARK(X)
27 #endif
28
29 #ifndef SCM_GC_MARK_P
30 # define SCM_GC_MARK_P(X) SCM_GCMARKP(X)
31 # define SCM_SET_GC_MARK(X) SCM_SETGCMARK(X)
32 #endif
33
34 #ifndef SCM_ARRAY_FLAG_CONTIGUOUS
35 # define SCM_ARRAY_FLAG_CONTIGUOUS SCM_ARRAY_CONTIGUOUS
36 #endif
37
38 #ifndef HAVE_SCM_T_BITS
39 typedef scm_bits_t scm_t_bits;
40 typedef scm_array scm_t_array;
41 typedef scm_array_dim scm_t_array_dim;
42 typedef scm_mutex_t scm_t_mutex;
43 typedef scm_cond_t scm_t_cond;
44 typedef scm_key_t scm_t_key;
45 typedef scm_catch_body_t scm_t_catch_body;
46 typedef scm_catch_handler_t scm_t_catch_handler;
47 typedef scm_rstate scm_t_rstate;
48 typedef scm_port scm_t_port;
49 typedef scm_fport scm_t_fport;
50 #endif
51
52 #ifndef SCM_VALIDATE_DOUBLE_COPY
53 #define SCM_VALIDATE_DOUBLE_COPY SCM_VALIDATE_NUMBER_COPY
54 #endif
55
56 #ifndef HAVE_SCM_C_DEFINE_MODULE
57 #define scm_c_define_module(NAME,INIT,DATA) \
58 scm_make_module (scm_read_0str ("(" NAME ")"))
59 #endif
60
61 #ifndef SCM_MAKE_CHAR
62 #define SCM_MAKE_CHAR SCM_MAKICHR
63 #define SCM_CHAR SCM_ICHR
64 #define SCM_CHARP SCM_ICHRP
65 #endif
66
67 #ifndef SCM_ROSTRINGP
68 #define SCM_ROSTRINGP(x) (SCM_STRINGP (x) || SCM_SYMBOLP (x))
69 #define SCM_RWSTRINGP(x) SCM_STRINGP (x)
70 #define SCM_ROCHARS(x) \
71 (SCM_STRINGP (x) ? SCM_STRING_CHARS (x) : SCM_SYMBOL_CHARS (x))
72 #define SCM_ROLENGTH(x) \
73 (SCM_STRINGP (x) ? SCM_STRING_LENGTH (x) : SCM_SYMBOL_LENGTH (x))
74 #endif
75
76 #ifndef SCM_STRING_COERCE_0TERMINATION_X
77 #ifdef SCM_COERCE_SUBSTR
78 #define SCM_STRING_COERCE_0TERMINATION_X SCM_COERCE_SUBSTR
79 #else
80 #define SCM_STRING_COERCE_0TERMINATION_X(x) (x)
81 #endif
82 #endif
83
84 #ifndef HAVE_SCM_C_READ_STRING
85 #define scm_c_read_string scm_read_0str
86 #define scm_c_eval_string scm_eval_0str
87 #define scm_str2symbol(X) SCM_CAR (scm_intern0 (X))
88 #define scm_mem2string(X, Y) scm_makfromstr ((X), (Y), 0)
89 #endif
90
91 #ifndef HAVE_SCM_MAKE_REAL
92 #define scm_make_real(X) scm_makdbl ((X), 0.0)
93 #endif
94
95 #ifdef HAVE_SCM_NUM2DOUBLE
96 #define scm_real2double scm_num2double
97 #define SCM_REAL2DOUBLE SCM_NUM2DOUBLE
98 #else
99 #define scm_real2double(X, POS, WHERE) scm_num2dbl ((X), (WHERE))
100 #define SCM_REAL2DOUBLE(X, POS) scm_num2dbl ((X), FUNC_NAME)
101 #endif
102
103 #ifndef SCM_VALIDATE_DOUBLE_DEF_COPY
104 #define SCM_VALIDATE_DOUBLE_DEF_COPY SCM_VALIDATE_NUMBER_DEF_COPY
105 #endif
106
107 #ifndef HAVE_SCM_GC_PROTECT_OBJECT
108 #define scm_gc_protect_object scm_protect_object
109 #endif
110
111 #ifndef HAVE_SCM_C_DEFINE_GSUBR
112 #define scm_c_define_gsubr scm_make_gsubr
113 #endif
114
115 #ifndef SCM_STRING_CHARS
116 #define SCM_STRING_CHARS SCM_CHARS
117 #define SCM_STRING_UCHARS SCM_UCHARS
118 #define SCM_STRING_LENGTH SCM_LENGTH
119 #endif
120
121 #ifndef SCM_SUBSTRP
122 #define SCM_SUBSTRP(X) 0
123 #endif
124
125 #ifndef SCM_VECTOR_LENGTH
126 #define SCM_VECTOR_LENGTH SCM_LENGTH
127 #define SCM_UVECTOR_LENGTH SCM_LENGTH
128 #endif
129
130 #ifndef SCM_SET_VECTOR_LENGTH
131 #define SCM_SET_VECTOR_LENGTH SCM_SETLENGTH
132 #define SCM_SET_UVECTOR_LENGTH SCM_SETLENGTH
133 #endif
134
135 #ifndef SCM_VECTOR_BASE
136 #define SCM_VECTOR_BASE SCM_CHARS
137 #define SCM_UVECTOR_BASE SCM_CHARS
138 #endif
139
140 #ifndef SCM_SET_VECTOR_BASE
141 #define SCM_SET_VECTOR_BASE SCM_SETCHARS
142 #define SCM_SET_UVECTOR_BASE SCM_SETCHARS
143 #endif
144
145 #ifndef SCM_UVECTOR_MAX_LENGTH
146 #define SCM_UVECTOR_MAX_LENGTH SCM_LENGTH_MAX
147 #endif
148
149 #ifndef HAVE_SCM_LIST_1
150 #define scm_list_1 SCM_LIST1
151 #define scm_list_2 SCM_LIST2
152 #define scm_list_3 SCM_LIST3
153 #define scm_list_4 SCM_LIST4
154 #define scm_list_5 SCM_LIST5
155 #define scm_list_n scm_listify
156 #endif
157
158 #ifndef SCM_SYMBOL_CHARS
159 #define SCM_SYMBOL_CHARS SCM_CHARS
160 #endif
161
162 #endif /* COMPATH */