File: acinclude.m4

package info (click to toggle)
jupp 3.1.38-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 2,420 kB
  • sloc: ansic: 31,382; sh: 4,199; makefile: 431
file content (86 lines) | stat: -rw-r--r-- 2,149 bytes parent folder | download | duplicates (2)
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
dnl $MirOS: contrib/code/jupp/acinclude.m4,v 1.4 2018/02/01 02:36:51 tg Exp $

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) */
	exit(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 */
	exit(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
])