cleanup
[m6w6/ext-psi] / config.m4
1 PHP_ARG_ENABLE(psi, whether to enable PHP System Interface support,
2 [ --enable-psi Enable PHP System Interface support])
3 PHP_ARG_WITH(psi-libjit, where to find libjit,
4 [ --with-psi-libjit=DIR PSI: path to libjit], [], no)
5 PHP_ARG_WITH(psi-libffi, where to find libjit,
6 [ --with-psi-libffi=DIR PSI: path to libffi], [], no)
7
8 if test "$PHP_PSI" != "no"; then
9 AC_ARG_VAR(LEMON, The lemon parser generator of the SQLite project)
10 AC_PATH_PROG(LEMON, lemon, ./lemon)
11 PHP_SUBST(LEMON)
12
13 if test -z "$PKG_CONFIG"
14 then
15 AC_PATH_PROG(PKG_CONFIG, pkg-config, false)
16 fi
17
18 export PKG_CONFIG_PATH="$PHP_PSI_LIBFFI/lib/pkgconfig:$PHP_PSI_LIBJIT/lib/pkgconfig:$PKG_CONFIG_PATH"
19
20 AC_CACHE_CHECK(for libffi through pkg-config, PSI_cv_LIBFFI, [
21 if $PKG_CONFIG --exists libffi
22 then
23 PSI_cv_LIBFFI=true
24 else
25 PSI_cv_LIBFFI=false
26 fi])
27 if $PSI_cv_LIBFFI
28 then
29 AC_MSG_CHECKING(for libffi)
30 PSI_cv_LIBFFI_DIR=`$PKG_CONFIG --variable=prefix libffi`
31 AC_MSG_RESULT($PSI_cv_LIBFFI_DIR)
32 PHP_EVAL_INCLINE(`$PKG_CONFIG --cflags libffi`)
33 PHP_EVAL_LIBLINE(`$PKG_CONFIG --libs libffi`, PSI_SHARED_LIBADD)
34 AC_DEFINE(HAVE_LIBFFI, 1, Have libffi)
35 else
36 AC_CACHE_CHECK(for libffi, PSI_cv_LIBFFI_DIR, [
37 for PSI_cv_LIBFFI_DIR in $PHP_PSI_LIBFFI {/usr{,/local},/opt}{,/libffi}
38 do
39 if test -e $PSI_cv_LIBFFI_DIR/include/ffi/ffi.h
40 then
41 break
42 fi
43 PSI_cv_LIBFFI_DIR=
44 done])
45 if test -n "$PSI_cv_LIBFFI_DIR"
46 then
47 PHP_ADD_INCLUDE($PSI_cv_LIBFFI_DIR/include/ffi)
48 PHP_ADD_LIBRARY_WITH_PATH(ffi, $PSI_cv_LIBFFI_DIR/$PHP_LIBDIR, PSI_SHARED_LIBADD)
49 AC_DEFINE(HAVE_LIBFFI, 1, Have libffi)
50 else
51 AC_MSG_WARN([Could not find libffi, please provide the base install path])
52 fi
53 fi
54 PHP_CHECK_LIBRARY(ffi, ffi_closure_alloc, [
55 PHP_CHECK_LIBRARY(ffi, ffi_prep_closure_loc, [
56 AC_DEFINE(PSI_HAVE_FFI_PREP_CLOSURE_LOC, 1, [ ])
57 ], [], -L$PSI_cv_LIBFFI_DIR/$PHP_LIBDIR)
58 AC_DEFINE(PSI_HAVE_FFI_CLOSURE_ALLOC, 1, [ ])
59 ], [
60 PHP_CHECK_LIBRARY(ffi, ffi_prep_closure, [
61 AC_CHECK_HEADERS(sys/mman.h)
62 PHP_CHECK_FUNC(mmap)
63 AC_DEFINE(PSI_HAVE_FFI_PREP_CLOSURE, 1, [ ])
64 ], [
65 ], -L$PSI_cv_LIBFFI_DIR/$PHP_LIBDIR)
66 ], -L$PSI_cv_LIBFFI_DIR/$PHP_LIBDIR)
67
68 AC_CACHE_CHECK(for libjit, PSI_cv_LIBJIT_DIR, [
69 for PSI_cv_LIBJIT_DIR in $PHP_PSI_LIBJIT {/usr{,/local},/opt}{,/libjit}
70 do
71 if test -e $PSI_cv_LIBJIT_DIR/include/jit/jit.h
72 then
73 break
74 fi
75 PSI_cv_LIBJIT_DIR=
76 done])
77 if test -n "$PSI_cv_LIBJIT_DIR"
78 then
79 PHP_ADD_INCLUDE($PSI_cv_LIBJIT_DIR/include)
80 PHP_ADD_LIBRARY_WITH_PATH(jit, $PSI_cv_LIBJIT_DIR/$PHP_LIBDIR, PSI_SHARED_LIBADD)
81 AC_DEFINE(HAVE_LIBJIT, 1, Have libjit)
82 else
83 AC_MSG_WARN([Could not find libjit, please provide the base install path])
84 fi
85
86 PHP_SUBST(PSI_SHARED_LIBADD)
87
88 dnl PSI_INCLUDES_DEFAULT(include, defines)
89 AC_DEFUN(PSI_INCLUDES_DEFAULT, [
90 AC_INCLUDES_DEFAULT()
91 $2
92 m4_ifnblank($1,
93 m4_expand([#include <]$1[>])
94 )
95 ])
96
97 psi_type_pair() { # (type, size)
98 local psi_type_name=`tr -cd A-Za-z <<<$1`
99 local psi_type_lower=`tr A-Z a-z <<<$psi_type_name`
100 case $psi_type_lower in
101 int*|uint*)
102 local psi_type_upper=`tr a-z A-Z <<<$1`
103 local psi_type_bits=`expr $2 \* 8`
104 echo "PSI_T_${psi_type_upper}${psi_type_bits}, \"${psi_type_lower}${psi_type_bits}_t\""
105 ;;
106 struct*)
107 echo "PSI_T_STRUCT, \"$2\""
108 ;;
109 *)
110 echo "PSI_T_NAME, \"$psi_type_name\""
111 ;;
112 esac
113 }
114
115 PSI_TYPES=""
116 dnl PSI_TYPE(type name, basic type, includes)
117 AC_DEFUN(PSI_TYPE, [
118 ifdef(AC_TYPE_[]patsubst(translit($1,a-z,A-Z),\W,_),AC_TYPE_[]patsubst(translit($1,a-z,A-Z),\W,_))
119 AC_CHECK_SIZEOF($1, [], PSI_INCLUDES_DEFAULT($3))
120 if test "$2" && test "$ac_cv_sizeof_[]$1" -gt 0; then
121 PSI_TYPES="{`psi_type_pair $2 $ac_cv_sizeof_[]$1`, \""$1"\"}, $PSI_TYPES"
122 fi
123 ])
124
125
126 dnl PSI_COMPUTE_STR(variable, string or expression, includes)
127 AC_DEFUN(PSI_COMPUTE_STR, [
128 AC_TRY_RUN([
129 $3
130 int main() {
131 return EOF == fputs($2, fopen("conftest.out", "w"));
132 }
133 ], [
134 eval $1=\\\"`cat conftest.out`\\\"
135 ])
136 ])
137
138 PSI_CONSTS=""
139 dnl PSI_CONST(const name, type, headers to include)
140 AC_DEFUN(PSI_CONST, [
141 AC_CACHE_CHECK(value of $1, psi_cv_const_$1, [
142 psi_const_val=
143 case $2 in
144 str*|quoted_str*)
145 if test "$cross_compiling" = "yes"
146 then
147 AC_TRY_CPP(PSI_INCLUDES_DEFAULT($3)$1, psi_const_val=`eval "$ac_try|tail -n1"`, psi_const_val=)
148 else
149 PSI_COMPUTE_STR(psi_const_val, $1, PSI_INCLUDES_DEFAULT($3))
150 fi
151 ;;
152 *)
153 AC_COMPUTE_INT(psi_const_val, $1, PSI_INCLUDES_DEFAULT($3))
154 ;;
155 esac
156 psi_cv_const_$1=$psi_const_val
157 ])
158 if test "$psi_cv_const_$1"
159 then
160 case $2 in
161 str*|quoted_str*)
162 PSI_CONSTS="{PSI_T_STRING, \"string\", \"psi\\\\$1\", $psi_cv_const_$1, PSI_T_QUOTED_STRING}, $PSI_CONSTS"
163 ;;
164 *)
165 PSI_CONSTS="{PSI_T_INT, \"int\", \"psi\\\\$1\", \"$psi_cv_const_$1\", PSI_T_NUMBER}, $PSI_CONSTS"
166 ;;
167 esac
168 fi
169 ])
170
171 AC_DEFUN([AX_CHECK_SIGN], [
172 typename=`echo $1 | sed "s/@<:@^a-zA-Z0-9_@:>@/_/g"`
173 AC_CACHE_CHECK([whether $1 is signed], ax_cv_decl_${typename}_signed, [
174 AC_TRY_COMPILE([$4],
175 [ int foo @<:@ 1 - 2 * !((($1) -1) < 0) @:>@ ],
176 [ eval "ax_cv_decl_${typename}_signed=\"yes\"" ],
177 [ eval "ax_cv_decl_${typename}_signed=\"no\"" ])])
178 symbolname=`echo $1 | sed "s/@<:@^a-zA-Z0-9_@:>@/_/g" | tr "a-z" "A-Z"`
179 if eval "test \"\${ax_cv_decl_${typename}_signed}\" = \"yes\""; then
180 $2
181 elif eval "test \"\${ax_cv_decl_${typename}_signed}\" = \"no\""; then
182 $3
183 fi
184 ])
185 dnl PSI_CHECK_OFFSETOF(struct, member, include)
186 dnl[AS_LITERAL_IF([$1], [], [m4_fatal([$0: requires literal arguments])])]dnl
187 dnl[AS_LITERAL_IF([$2], [], [m4_fatal([$0: requires literal arguments])])]dnl
188 AC_DEFUN(PSI_CHECK_OFFSETOF, [
189 _AC_CACHE_CHECK_INT(
190 [offset of $2 in $1],
191 [AS_TR_SH([ac_cv_offsetof_$1_$2])],
192 [(long int) (offsetof ($1, $2))],
193 [AC_INCLUDES_DEFAULT([$3])],
194 [AC_MSG_FAILURE([cannot compute offsetof ($1, $2)])]
195 )
196 AC_DEFINE_UNQUOTED(
197 AS_TR_CPP(offsetof_$1_$2),
198 $AS_TR_SH([ac_cv_offsetof_$1_$2]),
199 [The offset of `$2' in `$1', as computed by offsetof.]
200 )
201 ])
202
203 dnl PSI_STRUCT(struct name, members, member type cases, includes)
204 PSI_STRUCTS=
205 AC_DEFUN(PSI_STRUCT, [
206 AC_CHECK_SIZEOF($1, [], PSI_INCLUDES_DEFAULT($4))
207 psi_struct_name=`echo $1 | cut -d" " -f2`
208 psi_struct_size=$AS_TR_SH(ac_cv_sizeof_$1)
209 psi_struct_members=
210 m4_foreach(member, [$2], [
211 AC_CHECK_MEMBER($1.member, [
212 psi_member_name=member
213 AC_CHECK_SIZEOF(AS_TR_SH($1)[_]member, [], PSI_INCLUDES_DEFAULT($4,
214 [#define ]AS_TR_SH($1)[_]member (($1 *)0)->member
215 ))
216 psi_member_size=$AS_TR_SH(ac_cv_sizeof_$1[]_[]member)
217 PSI_CHECK_OFFSETOF($1, member, PSI_INCLUDES_DEFAULT($4))
218 psi_member_offset=$AS_TR_SH(ac_cv_offsetof_$1[]_[]member)
219 # type
220 case member in
221 $3
222 *) psi_member_type=int ;;
223 esac
224 # pointer level
225 psi_struct_member_pl=`echo $psi_member_type | tr -cd '*' | wc -c`
226 # array size
227 psi_struct_member_as=`echo $psi_member_type | $AWK -F'@<:@@:>@@<:@@:>@' 'END {if(!found)print 0} /\@<:@@<:@@<:@:digit:@:>@@:>@+\@:>@/ {found=1; print$[]2}'`
228 if test $psi_struct_member_as -gt 0
229 then
230 psi_struct_member_pl=`expr $psi_struct_member_pl + 1`
231 fi
232 psi_struct_member="{`psi_type_pair $psi_member_type $psi_member_size`, \"$psi_member_name\", $psi_member_offset, $psi_member_size, $psi_struct_member_pl, $psi_struct_member_as}"
233 if test "$psi_struct_members"
234 then
235 psi_struct_members="$psi_struct_members, $psi_struct_member"
236 else
237 psi_struct_members="$psi_struct_member"
238 fi
239 ], [], PSI_INCLUDES_DEFAULT($4))
240 ])
241 if test "$1" != "$psi_struct_name"
242 then
243 PSI_TYPES="{PSI_T_STRUCT, \"$psi_struct_name\", \"$psi_struct_name\"}, $PSI_TYPES"
244 fi
245 PSI_STRUCTS="{\"$psi_struct_name\", $psi_struct_size, {$psi_struct_members}}, $PSI_STRUCTS"
246 ])
247
248 PSI_INCLUDES=
249 AC_PROG_NM
250 AC_PROG_AWK
251 PSI_FUNCS=
252 dnl PSI_FUNC(fn)
253 AC_DEFUN(PSI_FUNC, [
254 psi_symbol=$1
255 AC_CACHE_CHECK(for $1, psi_cv_fn_$1, [
256 psi_symbol_redirect=
257 AC_TRY_LINK_FUNC($1, [
258 psi_symbol_redirect=`$NM -g conftest$ac_exeext | $AWK -F" *|@" '/ U .*$1.*/ {print$[]3}'`
259 ])
260 case "$psi_symbol_redirect" in
261 "_$psi_symbol"|"$psi_symbol"|"")
262 psi_cv_fn_$1=$psi_symbol
263 ;;
264 *)
265 psi_cv_fn_$1=$psi_symbol_redirect
266 ;;
267 esac
268 ])
269 if test "$psi_cv_fn_$1" != "$psi_symbol"
270 then
271 PSI_FUNCS="{\"$psi_symbol\", (void *) $psi_symbol}, $PSI_FUNCS"
272 fi
273 ])
274
275 PSI_MACROS=
276 dnl PSI_MACRO(macro, return type, decl args, call args, include)
277 AC_DEFUN(PSI_MACRO, [
278 AC_CHECK_DECL($1$3, [
279 PSI_MACROS="static $2 psi_macro_$1$3 {return $1$4;} $PSI_MACROS"
280 PSI_FUNCS="{\"$1\", (void *) psi_macro_$1}, $PSI_FUNCS"
281 ], [], PSI_INCLUDES_DEFAULT($5))
282 ])
283
284 AC_TYPE_INT8_T
285 AC_CHECK_ALIGNOF(int8_t)
286 AC_TYPE_UINT8_T
287 AC_CHECK_ALIGNOF(uint8_t)
288 AC_TYPE_INT16_T
289 AC_CHECK_ALIGNOF(int16_t)
290 AC_TYPE_UINT16_T
291 AC_CHECK_ALIGNOF(uint16_t)
292 AC_TYPE_INT32_T
293 AC_CHECK_ALIGNOF(int32_t)
294 AC_TYPE_UINT32_T
295 AC_CHECK_ALIGNOF(uint32_t)
296 AC_TYPE_INT64_T
297 AC_CHECK_ALIGNOF(int64_t)
298 AC_TYPE_UINT64_T
299 AC_CHECK_ALIGNOF(uint64_t)
300
301 PSI_TYPE(char, int)
302 PSI_TYPE(short, int)
303 PSI_TYPE(int, int)
304 PSI_TYPE(long, int)
305 PSI_TYPE(float)
306 PSI_TYPE(double)
307 PSI_TYPE(void *)
308
309 dnl errno.h
310 PSI_MACRO(errno, int, [()], [], errno.h)
311 PSI_CONST(E2BIG, int, errno.h)
312 PSI_CONST(EACCES, int, errno.h)
313 PSI_CONST(EADDRINUSE, int, errno.h)
314 PSI_CONST(EADDRNOTAVAIL, int, errno.h)
315 PSI_CONST(EAFNOSUPPORT, int, errno.h)
316 PSI_CONST(EAGAIN, int, errno.h)
317 PSI_CONST(EALREADY, int, errno.h)
318 PSI_CONST(EBADF, int, errno.h)
319 PSI_CONST(EBADMSG, int, errno.h)
320 PSI_CONST(EBUSY, int, errno.h)
321 PSI_CONST(ECANCELED, int, errno.h)
322 PSI_CONST(ECHILD, int, errno.h)
323 PSI_CONST(ECONNABORTED, int, errno.h)
324 PSI_CONST(ECONNREFUSED, int, errno.h)
325 PSI_CONST(ECONNRESET, int, errno.h)
326 PSI_CONST(EDEADLK, int, errno.h)
327 PSI_CONST(EDESTADDRREQ, int, errno.h)
328 PSI_CONST(EDOM, int, errno.h)
329 PSI_CONST(EDQUOT, int, errno.h)
330 PSI_CONST(EEXIST, int, errno.h)
331 PSI_CONST(EFAULT, int, errno.h)
332 PSI_CONST(EFBIG, int, errno.h)
333 PSI_CONST(EHOSTUNREACH, int, errno.h)
334 PSI_CONST(EIDRM, int, errno.h)
335 PSI_CONST(EILSEQ, int, errno.h)
336 PSI_CONST(EINPROGRESS, int, errno.h)
337 PSI_CONST(EINTR, int, errno.h)
338 PSI_CONST(EINVAL, int, errno.h)
339 PSI_CONST(EIO, int, errno.h)
340 PSI_CONST(EISCONN, int, errno.h)
341 PSI_CONST(EISDIR, int, errno.h)
342 PSI_CONST(ELOOP, int, errno.h)
343 PSI_CONST(EMFILE, int, errno.h)
344 PSI_CONST(EMLINK, int, errno.h)
345 PSI_CONST(EMSGSIZE, int, errno.h)
346 PSI_CONST(EMULTIHOP, int, errno.h)
347 PSI_CONST(ENAMETOOLONG, int, errno.h)
348 PSI_CONST(ENETDOWN, int, errno.h)
349 PSI_CONST(ENETRESET, int, errno.h)
350 PSI_CONST(ENETUNREACH, int, errno.h)
351 PSI_CONST(ENFILE, int, errno.h)
352 PSI_CONST(ENOBUFS, int, errno.h)
353 PSI_CONST(ENODATA, int, errno.h)
354 PSI_CONST(ENODEV, int, errno.h)
355 PSI_CONST(ENOENT, int, errno.h)
356 PSI_CONST(ENOEXEC, int, errno.h)
357 PSI_CONST(ENOLCK, int, errno.h)
358 PSI_CONST(ENOLINK, int, errno.h)
359 PSI_CONST(ENOMEM, int, errno.h)
360 PSI_CONST(ENOMSG, int, errno.h)
361 PSI_CONST(ENOPROTOOPT, int, errno.h)
362 PSI_CONST(ENOSPC, int, errno.h)
363 PSI_CONST(ENOSR, int, errno.h)
364 PSI_CONST(ENOSTR, int, errno.h)
365 PSI_CONST(ENOSYS, int, errno.h)
366 PSI_CONST(ENOTCONN, int, errno.h)
367 PSI_CONST(ENOTDIR, int, errno.h)
368 PSI_CONST(ENOTEMPTY, int, errno.h)
369 PSI_CONST(ENOTRECOVERABLE, int, errno.h)
370 PSI_CONST(ENOTSOCK, int, errno.h)
371 PSI_CONST(ENOTSUP, int, errno.h)
372 PSI_CONST(ENOTTY, int, errno.h)
373 PSI_CONST(ENXIO, int, errno.h)
374 PSI_CONST(EOPNOTSUPP, int, errno.h)
375 PSI_CONST(EOVERFLOW, int, errno.h)
376 PSI_CONST(EOWNERDEAD, int, errno.h)
377 PSI_CONST(EPERM, int, errno.h)
378 PSI_CONST(EPIPE, int, errno.h)
379 PSI_CONST(EPROTO, int, errno.h)
380 PSI_CONST(EPROTONOSUPPORT, int, errno.h)
381 PSI_CONST(EPROTOTYPE, int, errno.h)
382 PSI_CONST(ERANGE, int, errno.h)
383 PSI_CONST(EROFS, int, errno.h)
384 PSI_CONST(ESPIPE, int, errno.h)
385 PSI_CONST(ESRCH, int, errno.h)
386 PSI_CONST(ESTALE, int, errno.h)
387 PSI_CONST(ETIME, int, errno.h)
388 PSI_CONST(ETIMEDOUT, int, errno.h)
389 PSI_CONST(ETXTBSY, int, errno.h)
390 PSI_CONST(EWOULDBLOCK, int, errno.h)
391 PSI_CONST(EXDEV, int, errno.h)
392
393 dnl glob.h
394 PSI_FUNC(glob)
395 PSI_FUNC(globfree)
396 PSI_STRUCT(glob_t, [
397 [gl_pathc], [gl_matchc],
398 [gl_pathv],
399 [gl_offs],
400 [gl_flags]], [
401 gl_pathc|gloffs) psi_member_type=uint ;;
402 gl_pathv) psi_member_type="char**" ;;
403 ], glob.h)
404 PSI_CONST(GLOB_APPEND, int, glob.h)
405 PSI_CONST(GLOB_DOOFFS, int, glob.h)
406 PSI_CONST(GLOB_ERR, int, glob.h)
407 PSI_CONST(GLOB_MARK, int, glob.h)
408 PSI_CONST(GLOB_NOCHECK, int, glob.h)
409 PSI_CONST(GLOB_NOESCAPE, int, glob.h)
410 PSI_CONST(GLOB_NOSORT, int, glob.h)
411 PSI_CONST(GLOB_ABORTED, int, glob.h)
412 PSI_CONST(GLOB_NOMATCH, int, glob.h)
413 PSI_CONST(GLOB_NOSPACE, int, glob.h)
414
415 dnl stdint.h
416 PSI_TYPE(int_least8_t, int)
417 PSI_TYPE(int_least16_t, int)
418 PSI_TYPE(int_least32_t, int)
419 PSI_TYPE(int_least64_t, int)
420 PSI_TYPE(uint_least8_t, uint)
421 PSI_TYPE(uint_least16_t, uint)
422 PSI_TYPE(uint_least32_t, uint)
423 PSI_TYPE(uint_least64_t, uint)
424 PSI_TYPE(int_fast8_t, int)
425 PSI_TYPE(int_fast16_t, int)
426 PSI_TYPE(int_fast32_t, int)
427 PSI_TYPE(int_fast64_t, int)
428 PSI_TYPE(uint_fast8_t, uint)
429 PSI_TYPE(uint_fast16_t, uint)
430 PSI_TYPE(uint_fast32_t, uint)
431 PSI_TYPE(uint_fast64_t, uint)
432 PSI_TYPE(intptr_t, int)
433 PSI_TYPE(uintptr_t, uint)
434 PSI_TYPE(intmax_t, int)
435 PSI_TYPE(uintmax_t, uint)
436
437 PSI_CONST(INT8_MIN, int)
438 PSI_CONST(INT8_MAX, int)
439 PSI_CONST(UINT8_MAX, int)
440 PSI_CONST(INT16_MIN, int)
441 PSI_CONST(INT16_MAX, int)
442 PSI_CONST(UINT16_MAX, int)
443 PSI_CONST(INT32_MIN, int)
444 PSI_CONST(INT32_MAX, int)
445 PSI_CONST(UINT32_MAX, int)
446 PSI_CONST(INT64_MIN, int)
447 PSI_CONST(INT64_MAX, int)
448 PSI_CONST(UINT64_MAX, int)
449
450 PSI_CONST(INT_LEAST8_MIN, int)
451 PSI_CONST(INT_LEAST8_MAX, int)
452 PSI_CONST(UINT_LEAST8_MAX, int)
453 PSI_CONST(INT_LEAST16_MIN, int)
454 PSI_CONST(INT_LEAST16_MAX, int)
455 PSI_CONST(UINT_LEAST16_MAX, int)
456 PSI_CONST(INT_LEAST32_MIN, int)
457 PSI_CONST(INT_LEAST32_MAX, int)
458 PSI_CONST(UINT_LEAST32_MAX, int)
459 PSI_CONST(INT_LEAST64_MIN, int)
460 PSI_CONST(INT_LEAST64_MAX, int)
461 PSI_CONST(UINT_LEAST64_MAX, int)
462
463 PSI_CONST(INT_FAST8_MIN, int)
464 PSI_CONST(INT_FAST8_MAX, int)
465 PSI_CONST(UINT_FAST8_MAX, int)
466 PSI_CONST(INT_FAST16_MIN, int)
467 PSI_CONST(INT_FAST16_MAX, int)
468 PSI_CONST(UINT_FAST16_MAX, int)
469 PSI_CONST(INT_FAST32_MIN, int)
470 PSI_CONST(INT_FAST32_MAX, int)
471 PSI_CONST(UINT_FAST32_MAX, int)
472 PSI_CONST(INT_FAST64_MIN, int)
473 PSI_CONST(INT_FAST64_MAX, int)
474 PSI_CONST(UINT_FAST64_MAX, int)
475
476 PSI_CONST(INTPTR_MIN, int)
477 PSI_CONST(INTPTR_MAX, int)
478 PSI_CONST(UINTPTR_MAX, int)
479 PSI_CONST(INTMAX_MIN, int)
480 PSI_CONST(INTMAX_MAX, int)
481 PSI_CONST(UINTMAX_MAX, int)
482
483 dnl stddef.h
484 PSI_TYPE(ptrdiff_t, int)
485 PSI_CONST(PTRDIFF_MIN, int)
486 PSI_CONST(PTRDIFF_MAX, int)
487 PSI_TYPE(size_t, uint)
488 PSI_CONST(SIZE_MAX, int)
489 AC_CHECK_TYPE(wchar_t, [
490 AX_CHECK_SIGN(wchar_t, psi_wchar_t=int, psi_wchar_t=uint)
491 PSI_TYPE(wchar_t, $psi_wchar_t)
492 PSI_CONST(WCHAR_MIN, int)
493 PSI_CONST(WCHAR_MAX, int)
494 ])
495
496 dnl stdio.h
497 PSI_CONST(BUFSIZ, int)
498 PSI_CONST(_IOFBF, int)
499 PSI_CONST(_IOLBF, int)
500 PSI_CONST(_IONBF, int)
501 PSI_CONST(SEEK_CUR, int)
502 PSI_CONST(SEEK_END, int)
503 PSI_CONST(SEEK_SET, int)
504 PSI_CONST(FILENAME_MAX, int)
505 PSI_CONST(FOPEN_MAX, int)
506 PSI_CONST(TMP_MAX, int)
507 PSI_CONST(EOF, int)
508 PSI_CONST(P_tmpdir, string)
509 PSI_CONST(L_ctermid, int)
510 PSI_CONST(L_tmpnam, int)
511 PSI_FUNC(clearerr)
512 PSI_FUNC(ctermid)
513 PSI_FUNC(dprintf)
514 PSI_FUNC(fclose)
515 PSI_FUNC(fdopen)
516 PSI_FUNC(feof)
517 PSI_FUNC(ferror)
518 PSI_FUNC(fflush)
519 PSI_FUNC(fgetc)
520 PSI_FUNC(fgetpos)
521 PSI_FUNC(fgets)
522 PSI_FUNC(fileno)
523 PSI_FUNC(flockfile)
524 PSI_FUNC(fmemopen)
525 PSI_FUNC(fopen)
526 PSI_FUNC(fprintf)
527 PSI_FUNC(fputc)
528 PSI_FUNC(fputs)
529 PSI_FUNC(fread)
530 PSI_FUNC(freopen)
531 PSI_FUNC(fscanf)
532 PSI_FUNC(fseek)
533 PSI_FUNC(fseeko)
534 PSI_FUNC(fsetpos)
535 PSI_FUNC(ftell)
536 PSI_FUNC(ftello)
537 PSI_FUNC(ftrylockfile)
538 PSI_FUNC(funlockfile)
539 PSI_FUNC(fwrite)
540 PSI_FUNC(getc)
541 PSI_FUNC(getchar)
542 PSI_FUNC(getc_unlocked)
543 PSI_FUNC(getchar_unlocked)
544 PSI_FUNC(getdelim)
545 PSI_FUNC(getline)
546 PSI_FUNC(gets)
547 PSI_FUNC(open_memstream)
548 PSI_FUNC(pclose)
549 PSI_FUNC(perror)
550 PSI_FUNC(popen)
551 PSI_FUNC(printf)
552 PSI_FUNC(putc)
553 PSI_FUNC(putchar)
554 PSI_FUNC(putc_unlocked)
555 PSI_FUNC(putchar_unlocked)
556 PSI_FUNC(puts)
557 PSI_FUNC(remove)
558 PSI_FUNC(rename)
559 PSI_FUNC(renameat)
560 PSI_FUNC(rewind)
561 PSI_FUNC(scanf)
562 PSI_FUNC(setbuf)
563 PSI_FUNC(setvbuf)
564 PSI_FUNC(snprintf)
565 PSI_FUNC(sprintf)
566 PSI_FUNC(sscanf)
567 PSI_FUNC(tempnam)
568 PSI_FUNC(tmpfile)
569 PSI_FUNC(tmpnam)
570 PSI_FUNC(ungetc)
571 PSI_FUNC(vdprintf)
572 PSI_FUNC(vfprintf)
573 PSI_FUNC(vfscanf)
574 PSI_FUNC(vprintf)
575 PSI_FUNC(vscanf)
576 PSI_FUNC(vsnprintf)
577 PSI_FUNC(vsprintf)
578 PSI_FUNC(vsscanf)
579
580 dnl stdlib.h
581 PSI_FUNC(free)
582 PSI_CONST(EXIT_FAILURE, int)
583 PSI_CONST(EXIT_SUCCESS, int)
584 PSI_CONST(RAND_MAX, int)
585 PSI_CONST(MB_CUR_MAX, int)
586
587 dnl sys/stat.h
588 PSI_FUNC(chmod)
589 PSI_FUNC(fchmod)
590 PSI_FUNC(fchmodat)
591 PSI_FUNC(fstat)
592 PSI_FUNC(fstatat)
593 PSI_FUNC(futimens)
594 PSI_FUNC(lstat)
595 PSI_FUNC(mkdir)
596 PSI_FUNC(mkdirat)
597 PSI_FUNC(mkfifo)
598 PSI_FUNC(mkfifoat)
599 PSI_FUNC(mknod)
600 PSI_FUNC(mknodat)
601 PSI_FUNC(stat)
602 PSI_FUNC(umask)
603 PSI_FUNC(utimensat)
604 PSI_STRUCT(struct stat, [
605 [st_dev],
606 [st_ino],
607 [st_mode],
608 [st_nlink],
609 [st_uid],
610 [st_gid],
611 [st_rdev],
612 [st_size],
613 [st_atim], [st_atimespec],
614 [st_mtim], [st_mtimespec],
615 [st_ctim], [st_ctimespec],
616 [st_birthtimespec],
617 [st_blksize],
618 [st_blocks],
619 [st_flags],
620 [st_gen]], [
621 st_?tim) psi_member_type="struct timespec" ;;
622 st_*timespec) psi_member_type="struct timespec" ;;
623 ], sys/stat.h)
624 PSI_CONST(S_IFMT, int, sys/stat.h)
625 PSI_CONST(S_IFBLK, int, sys/stat.h)
626 PSI_CONST(S_IFCHR, int, sys/stat.h)
627 PSI_CONST(S_IFIFO, int, sys/stat.h)
628 PSI_CONST(S_IFREG, int, sys/stat.h)
629 PSI_CONST(S_IFDIR, int, sys/stat.h)
630 PSI_CONST(S_IFLNK, int, sys/stat.h)
631 PSI_CONST(S_IFSOCK, int, sys/stat.h)
632 PSI_CONST(S_IRWXU, int, sys/stat.h)
633 PSI_CONST(S_IRUSR, int, sys/stat.h)
634 PSI_CONST(S_IWUSR, int, sys/stat.h)
635 PSI_CONST(S_IXUSR, int, sys/stat.h)
636 PSI_CONST(S_IRWXG, int, sys/stat.h)
637 PSI_CONST(S_IRGRP, int, sys/stat.h)
638 PSI_CONST(S_IWGRP, int, sys/stat.h)
639 PSI_CONST(S_IXGRP, int, sys/stat.h)
640 PSI_CONST(S_IRWXO, int, sys/stat.h)
641 PSI_CONST(S_IROTH, int, sys/stat.h)
642 PSI_CONST(S_IWOTH, int, sys/stat.h)
643 PSI_CONST(S_IXOTH, int, sys/stat.h)
644 PSI_CONST(S_ISUID, int, sys/stat.h)
645 PSI_CONST(S_ISGID, int, sys/stat.h)
646 PSI_CONST(UTIME_NOW, int, sys/stat.h)
647 PSI_CONST(UTIME_OMIT, int, sys/stat.h)
648 PSI_MACRO(S_ISBLK, int, [(mode_t m)], [(m)], sys/stat.h)
649 PSI_MACRO(S_ISCHR, int, [(mode_t m)], [(m)], sys/stat.h)
650 PSI_MACRO(S_ISDIR, int, [(mode_t m)], [(m)], sys/stat.h)
651 PSI_MACRO(S_ISFIFO, int, [(mode_t m)], [(m)], sys/stat.h)
652 PSI_MACRO(S_ISREG, int, [(mode_t m)], [(m)], sys/stat.h)
653 PSI_MACRO(S_ISLNK, int, [(mode_t m)], [(m)], sys/stat.h)
654 PSI_MACRO(S_ISSOCK, int, [(mode_t m)], [(m)], sys/stat.h)
655 PSI_MACRO(S_TYPEISMQ, int, [(struct stat *s)], [(s)], sys/stat.h)
656 PSI_MACRO(S_TYPEISSEM, int, [(struct stat *s)], [(s)], sys/stat.h)
657 PSI_MACRO(S_TYPEISSHM, int, [(struct stat *s)], [(s)], sys/stat.h)
658 PSI_MACRO(S_TYPEISTMO, int, [(struct stat *s)], [(s)], sys/stat.h)
659 dnl sys/time.h
660 PSI_STRUCT(struct timeval, [
661 [tv_sec],
662 [tv_usec]], [
663 ], sys/time.h)
664 PSI_STRUCT(struct itimerval, [
665 [it_interval],
666 [it_value]], [
667 it_*) psi_member_type="struct timeval" ;;
668 ], sys/time.h)
669 PSI_STRUCT(struct timezone, [
670 [tz_minuteswest],
671 [tz_dsttime]], [
672 ], sys/time.h)
673 PSI_CONST(ITIMER_REAL, int, sys/time.h)
674 PSI_CONST(ITIMER_VIRTUAL, int, sys/time.h)
675 PSI_CONST(ITIMER_PROF, int, sys/time.h)
676 dnl sys/times.h
677 PSI_FUNC(times)
678 PSI_STRUCT(struct tms, [
679 [tms_utime],
680 [tms_stime],
681 [tms_cutime],
682 [tms_cstime]], [
683 ], sys/times.h)
684 dnl sys/types.h
685 PSI_TYPE(blkcnt_t, int)
686 PSI_TYPE(blksize_t, int)
687 PSI_TYPE(clock_t, int)
688 PSI_TYPE(clockid_t, int)
689 PSI_TYPE(dev_t, int)
690 PSI_TYPE(fsblkcnt_t, uint)
691 PSI_TYPE(fsfilcnt_t, uint)
692 PSI_TYPE(gid_t, int)
693 PSI_TYPE(id_t, int)
694 PSI_TYPE(ino_t, uint)
695 PSI_TYPE(key_t, int)
696 PSI_TYPE(mode_t, int)
697 PSI_TYPE(nlink_t, int)
698 PSI_TYPE(off_t, int)
699 PSI_TYPE(pid_t, int)
700 PSI_TYPE(ssize_t, int)
701 PSI_TYPE(suseconds_t, int)
702 PSI_TYPE(time_t, int)
703 PSI_TYPE(timer_t, int)
704 PSI_TYPE(uid_t)
705 dnl sys/utsname.h
706 PSI_FUNC(uname)
707 PSI_STRUCT(struct utsname, [
708 [sysname],
709 [nodename],
710 [release],
711 [version],
712 [machine],
713 [domainname]], [
714 *) psi_member_type="char@<:@$psi_member_size@:>@" ;;
715 ], sys/utsname.h)
716 dnl time.h
717 PSI_STRUCT(struct tm, [
718 [tm_sec],
719 [tm_min],
720 [tm_hour],
721 [tm_mday],
722 [tm_mon],
723 [tm_year],
724 [tm_wday],
725 [tm_yday],
726 [tm_isdst]], [
727 ], time.h)
728 PSI_STRUCT(struct timespec, [
729 [tv_sec],
730 [tv_nsec]], [
731 ], time.h)
732 PSI_CONST(CLOCKS_PER_SEC, int, time.h)
733 PSI_CONST(CLOCK_MONOTONIC, int, time.h)
734 PSI_CONST(CLOCK_PROCESS_CPUTIME_ID, int, time.h)
735 PSI_CONST(CLOCK_REALTIME, int, time.h)
736 PSI_CONST(CLOCK_THREAD_CPUTIME_ID, int, time.h)
737 PSI_CONST(TIMER_ABSTIME, int, time.h)
738 dnl wchar.h
739 AC_CHECK_TYPE(wint_t, [
740 AX_CHECK_SIGN(wint_t, psi_wint_t=int, psi_wint_t=uint)
741 PSI_TYPE(wint_t, $psi_wint_t, wchar.h)
742 PSI_CONST(WINT_MIN, int, wchar.h)
743 PSI_CONST(WINT_MAX, int, wchar.h)
744 PSI_CONST(WEOF, int, wchar.h)
745 ], [], [
746 AC_INCLUDES_DEFAULT()
747 #include <wchar.h>
748 ])
749
750
751 AC_DEFINE_UNQUOTED(PHP_PSI_FUNCS, $PSI_FUNCS, Redirected functions)
752 AC_DEFINE_UNQUOTED(PHP_PSI_MACROS, $PSI_MACROS, Exported macros)
753 AC_DEFINE_UNQUOTED(PHP_PSI_TYPES, $PSI_TYPES, Predefined types)
754 AC_DEFINE_UNQUOTED(PHP_PSI_CONSTS, $PSI_CONSTS, Predefined constants)
755 AC_DEFINE_UNQUOTED(PHP_PSI_STRUCTS, $PSI_STRUCTS, Predefined structs)
756
757 AC_DEFINE_UNQUOTED(PHP_PSI_SHLIB_SUFFIX, ["]$SHLIB_SUFFIX_NAME["], DL suffix)
758
759 PHP_PSI_SRCDIR=PHP_EXT_SRCDIR(psi)
760 PHP_PSI_BUILDDIR=PHP_EXT_BUILDDIR(psi)
761
762 PHP_ADD_INCLUDE($PHP_PSI_SRCDIR/src)
763 PHP_ADD_BUILD_DIR($PHP_PSI_BUILDDIR/src)
764
765 PHP_PSI_HEADERS=`(cd $PHP_PSI_SRCDIR/src && echo *.h)`
766 PHP_PSI_SOURCES="src/parser_proc.c src/parser.c src/module.c src/context.c"
767 PHP_PSI_SOURCES="$PHP_PSI_SOURCES src/libjit.c src/libffi.c"
768
769 PHP_NEW_EXTENSION(psi, $PHP_PSI_SOURCES, $ext_shared)
770 PHP_INSTALL_HEADERS(ext/psi, php_psi.h $PHP_PSI_HEADERS)
771
772 PHP_SUBST(PHP_PSI_HEADERS)
773 PHP_SUBST(PHP_PSI_SOURCES)
774
775 PHP_SUBST(PHP_PSI_SRCDIR)
776 PHP_SUBST(PHP_PSI_BUILDDIR)
777
778 PHP_ADD_MAKEFILE_FRAGMENT
779 fi