blob: db85f47eae1f4825dd3516d82559c1f4159de324 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
2
3AC_CHECK_TOOL(MIG, mig, MISSING)
4if test "x$MIG" = xMISSING; then
5 AC_MSG_ERROR([cannot find required build tool mig])
6fi
7LIBC_CONFIG_VAR([MIG], [$MIG])
8
9### Sanity checks for Mach header installation
10AC_CHECK_HEADER(mach/mach_types.h,,
11 [AC_MSG_ERROR([cannot find Mach headers])], -)
12AC_CHECK_HEADER(mach/mach_types.defs,, [dnl
13AC_MSG_ERROR([cannot find Mach .defs files])], -)
14
15dnl
16dnl mach_TYPE_CHECK(foo_t, bar_t)
17dnl
18dnl Check if foo_t is defined by <mach/mach_types.h>.
19dnl If not, compile with -Dfoo_t=bar_t.
20dnl
21AC_DEFUN([mach_TYPE_CHECK], [dnl
22AC_CACHE_CHECK(for $1 in mach/mach_types.h, libc_cv_mach_$1,
23AC_TRY_COMPILE([#include <mach/mach_types.h>], [extern $1 foo;],
24libc_cv_mach_$1=$1, libc_cv_mach_$1=$2))
25if test [$]libc_cv_mach_$1 != $1; then
26 DEFINES="$DEFINES -D$1=$2"
27fi])
28
29dnl
30dnl OSF Mach has renamed these typedefs for some reason.
31dnl
32mach_TYPE_CHECK(task_t, task_port_t)
33mach_TYPE_CHECK(thread_t, thread_port_t)
34
35dnl
36dnl The creation_time field is a GNU Mach addition the other variants lack.
37dnl
38AC_CACHE_CHECK(for creation_time in task_basic_info,
39 libc_cv_mach_task_creation_time, [dnl
40AC_TRY_COMPILE([#include <mach/task_info.h>], [
41extern struct task_basic_info *i;
42long s = i->creation_time.seconds;
43], libc_cv_mach_task_creation_time=yes, libc_cv_mach_task_creation_time=no)])
44if test $libc_cv_mach_task_creation_time = no; then
45 AC_MSG_ERROR([you need Mach headers supporting task_info.creation_time])
46fi
47
48dnl
49dnl The Darwin variant no longer has <mach/mach.defs>
50dnl but instead has several constituent .defs files.
51dnl In this scenario we will presume there is a <mach/mach_interface.h>
52dnl that contains an #include for each constituent header file,
53dnl but we don't do a check for that here because in a bare
54dnl environment the compile against those headers will fail.
55dnl
56mach_interface_list=
57for ifc in mach mach4 \
58 clock clock_priv host_priv host_security ledger lock_set \
59 processor processor_set task thread_act vm_map \
60 memory_object memory_object_default default_pager \
61 i386/mach_i386 \
62 ; do
63 AC_CHECK_HEADER(mach/${ifc}.defs, [dnl
64 mach_interface_list="$mach_interface_list $ifc"],, -)
65done
66if test "x$mach_interface_list" = x; then
67 AC_MSG_ERROR([what manner of Mach is this?])
68fi
69
70AC_CACHE_CHECK(for host_page_size in mach_host.defs,
71 libc_cv_mach_host_page_size, [dnl
72AC_EGREP_HEADER(host_page_size, mach/mach_host.defs,
73 libc_cv_mach_host_page_size=yes,
74 libc_cv_mach_host_page_size=no)])
75if test $libc_cv_mach_host_page_size = yes; then
76 AC_DEFINE([HAVE_HOST_PAGE_SIZE])
77fi
78
79AC_CHECK_HEADER(mach/machine/ndr_def.h, [dnl
80 DEFINES="$DEFINES -DNDR_DEF_HEADER='<mach/machine/ndr_def.h>'"], [dnl
81AC_CHECK_HEADER(machine/ndr_def.h, [dnl
82 DEFINES="$DEFINES -DNDR_DEF_HEADER='<machine/ndr_def.h>'"],, -)], -)
83
84AC_CACHE_CHECK(for i386_io_perm_modify in mach_i386.defs,
85 libc_cv_mach_i386_ioports, [dnl
86AC_EGREP_HEADER(i386_io_perm_modify, mach/i386/mach_i386.defs,
87 libc_cv_mach_i386_ioports=yes,
88 libc_cv_mach_i386_ioports=no)])
89if test $libc_cv_mach_i386_ioports = yes; then
90 AC_DEFINE([HAVE_I386_IO_PERM_MODIFY])
91fi
92
93AC_CACHE_CHECK(for i386_set_gdt in mach_i386.defs,
94 libc_cv_mach_i386_gdt, [dnl
95AC_EGREP_HEADER(i386_set_gdt, mach/i386/mach_i386.defs,
96 libc_cv_mach_i386_gdt=yes,
97 libc_cv_mach_i386_gdt=no)])
98if test $libc_cv_mach_i386_gdt = yes; then
99 AC_DEFINE([HAVE_I386_SET_GDT])
100fi
101
102dnl Swiped from hurd/aclocal.m4
103AC_DEFUN([hurd_MIG_RETCODE], [dnl
104# See if mig groks `retcode'.
105AC_CACHE_CHECK(whether $MIG supports the retcode keyword, hurd_cv_mig_retcode,
106[cat > conftest.defs <<\EOF
107#include <mach/std_types.defs>
108#include <mach/mach_types.defs>
109subsystem foobar 1000;
110type reply_port_t = polymorphic | MACH_MSG_TYPE_PORT_SEND_ONCE
111 ctype: mach_port_t;
112simpleroutine foobar_reply (
113 reply_port: reply_port_t;
114 err: kern_return_t, RetCode);
115EOF
116if AC_TRY_COMMAND([CC="${CC}" ${MIG-false} -n conftest.defs 1>&AS_MESSAGE_LOG_FD]); then
117 hurd_cv_mig_retcode=yes
118else
119 hurd_cv_mig_retcode=no
120fi
121rm -f conftest*])
122if test $hurd_cv_mig_retcode = yes; then
123 AC_DEFINE(HAVE_MIG_RETCODE)
124fi])
125
126hurd_MIG_RETCODE