-
Notifications
You must be signed in to change notification settings - Fork 2
/
acinclude.m4
107 lines (98 loc) · 2.55 KB
/
acinclude.m4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
dnl ------------------
dnl Check for properly working isblank()
dnl ------------------
AC_DEFUN([joe_ISBLANK],
[AC_CACHE_CHECK([whether isblank() works correctly with side effect expressions],
[joe_cv_isblank],
[AC_TRY_RUN([
#include <ctype.h>
int main() {
int a = 0;
isblank(a++);
return a != 1;
}
],
[joe_cv_isblank=yes],
[joe_cv_isblank=no],
[joe_cv_isblank=no])
])
if test "$joe_cv_isblank" = yes; then
AC_DEFINE([HAVE_WORKING_ISBLANK], 1, [Define if isblank() works with expressions with side effects])
fi
])
dnl ------------------
dnl Check if setpgrp must have two arguments
dnl autoconf-own macro is damaged for *BSD systems
dnl ------------------
AC_DEFUN([joe_SETPGRP],
[AC_CACHE_CHECK([whether setpgrp() takes no arguments],
[joe_cv_setpgrp_void],
[AC_TRY_RUN([
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
int main() {
/* exit succesfully if setpgrp() takes two args (*BSD systems) */
return setpgrp(0, 0) != 0;
}],
[joe_cv_setpgrp_void=no],
[joe_cv_setpgrp_void=yes],
[joe_cv_setpgrp_void=yes])
])
if test "$joe_cv_setpgrp_void" = yes; then
AC_DEFINE([SETPGRP_VOID], 1, [Define if setpgrp() takes no arguments])
fi
])
dnl ------------------
dnl Check to see if signal handlers must be reinstalled when invoked
dnl ------------------
AC_DEFUN([joe_REINSTALL_SIGHANDLERS],
[AC_CACHE_CHECK([whether sighandlers must be reinstalled],
[joe_cv_reinstall_sighandlers],
[AC_TRY_RUN([
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#if HAVE_SIGNAL_H
#include <signal.h>
#endif
#ifndef HAVE_SIGHANDLER_T
typedef RETSIGTYPE (*sighandler_t)(int);
#endif
int nsigint;
void set_signal(int signum, sighandler_t handler) {
#if HAVE_SIGACTION
struct sigaction sact;
sact.sa_handler = handler;
sact.sa_flags = 0;
sigemptyset(&sact.sa_mask);
sigaction(signum, &sact, NULL);
#elif HAVE_SIGVEC
struct sigvec svec;
svec.sv_handler = handler;
svec.sv_flags = 0;
sigemptyset(&svec.sv_mask);
sigvec(signum, &svec, NULL);
#else
signal(signum, handler);
#endif
}
RETSIGTYPE sigint(int s) {
nsigint++;
}
int main() {
nsigint = 0;
set_signal(SIGINT, sigint);
kill((int)getpid(), SIGINT);
kill((int)getpid(), SIGINT);
/* exit succesfully if don't have to reinstall sighandler when invoked */
return nsigint != 2;
}],
[joe_cv_reinstall_sighandlers=no],
[joe_cv_reinstall_sighandlers=yes],
[joe_cv_reinstall_sighandlers=yes])
])
if test "$joe_cv_reinstall_sighandlers" = yes; then
AC_DEFINE([NEED_TO_REINSTALL_SIGNAL], 1, [Define if we have to reinstall signal handler when invoked])
fi
])