diff options
-rw-r--r-- | config/auto-aux/align.c | 96 | ||||
-rw-r--r-- | config/auto-aux/async_io.c | 44 | ||||
-rw-r--r-- | config/auto-aux/bytecopy.c | 19 | ||||
-rw-r--r-- | config/auto-aux/dblalign.c | 37 | ||||
-rw-r--r-- | config/auto-aux/endian.c | 26 | ||||
-rw-r--r-- | config/auto-aux/getgroups.c | 17 | ||||
-rwxr-xr-x | config/auto-aux/hasgot | 18 | ||||
-rwxr-xr-x | config/auto-aux/runtest | 3 | ||||
-rw-r--r-- | config/auto-aux/schar.c | 7 | ||||
-rw-r--r-- | config/auto-aux/schar2.c | 7 | ||||
-rw-r--r-- | config/auto-aux/setjmp.c | 12 | ||||
-rw-r--r-- | config/auto-aux/sighandler.c | 8 | ||||
-rw-r--r-- | config/auto-aux/signals.c | 58 | ||||
-rw-r--r-- | config/auto-aux/sizes.c | 7 |
14 files changed, 359 insertions, 0 deletions
diff --git a/config/auto-aux/align.c b/config/auto-aux/align.c new file mode 100644 index 000000000..15efbd4f7 --- /dev/null +++ b/config/auto-aux/align.c @@ -0,0 +1,96 @@ +#include <stdio.h> +#include <signal.h> +#include <setjmp.h> + +long foo; + +void access16(p) + short * p; +{ + foo = *p; +} + +void access32(p) + long * p; +{ + foo = *p; +} + +jmp_buf failure; + +void sig_handler(dummy) + int dummy; +{ + longjmp(failure, 1); +} + +int test(fct, p) + void (*fct)(); + char * p; +{ + int res; + + signal(SIGSEGV, sig_handler); + signal(SIGBUS, sig_handler); + if(setjmp(failure) == 0) { + fct(p); + res = 0; + } else { + res = 1; + } + signal(SIGSEGV, SIG_DFL); + signal(SIGBUS, SIG_DFL); + return res; +} + +jmp_buf timer; + +void alarm_handler(dummy) + int dummy; +{ + longjmp(timer, 1); +} + +void use(n) + int n; +{ + return; +} + +int speedtest(p) + char * p; +{ + int * q; + volatile int total; + int i; + volatile int sum; + + signal(SIGALRM, alarm_handler); + sum = 0; + if (setjmp(timer) == 0) { + alarm(1); + total = 0; + while(1) { + for (q = (int *) p, i = 1000; i > 0; q++, i--) + sum += *q; + total++; + } + } + use(sum); + signal(SIGALRM, SIG_DFL); + return total; +} + +main() +{ + long n[1001]; + int speed_aligned, speed_unaligned; + + if (test(access16, (char *) n + 1)) exit(1); + if (test(access32, (char *) n + 1)) exit(1); + if (test(access32, (char *) n + 2)) exit(1); + speed_aligned = speedtest((char *) n); + speed_unaligned = speedtest((char *) n + 1); + if (speed_aligned >= 3 * speed_unaligned) exit(1); + exit(0); +} diff --git a/config/auto-aux/async_io.c b/config/auto-aux/async_io.c new file mode 100644 index 000000000..2fb04a6c6 --- /dev/null +++ b/config/auto-aux/async_io.c @@ -0,0 +1,44 @@ +#include <stdio.h> +#include <fcntl.h> +#include <signal.h> +#include <errno.h> +#include "s.h" + +int signalled; + +void sigio_handler(arg) + int arg; +{ + signalled = 1; +} + +int main() +{ +#if defined(SIGIO) && defined(FASYNC) && defined(F_SETFL) && defined(F_SETOWN) + int p[2]; + int ret; +#define OUT 0 +#define IN 1 + if (pipe(p) == -1) return 1; + signalled = 0; + signal(SIGIO, sigio_handler); + ret = fcntl(p[OUT], F_GETFL, 0); + fcntl(p[OUT], F_SETFL, ret | FASYNC); + fcntl(p[OUT], F_SETOWN, getpid()); + switch(fork()) { + case -1: + return 1; + case 0: + close(p[OUT]); + write(p[IN], "x", 1); + sleep(1); + exit(0); + default: + close(p[IN]); + while(wait(NULL) == -1 && errno == EINTR) /*nothing*/; + } + if (signalled) return 0; else return 1; +#else + return 1; +#endif +} diff --git a/config/auto-aux/bytecopy.c b/config/auto-aux/bytecopy.c new file mode 100644 index 000000000..61fbb18d5 --- /dev/null +++ b/config/auto-aux/bytecopy.c @@ -0,0 +1,19 @@ +char buffer[27]; + +#ifdef reverse +#define cpy(s1,s2,n) copy(s2,s1,n) +#else +#define cpy copy +#endif + +main() +{ + cpy("abcdefghijklmnopqrstuvwxyz", buffer, 27); + if (strcmp(buffer, "abcdefghijklmnopqrstuvwxyz") != 0) exit(1); + cpy(buffer, buffer+3, 26-3); + if (strcmp(buffer, "abcabcdefghijklmnopqrstuvw") != 0) exit(1); + cpy("abcdefghijklmnopqrstuvwxyz", buffer, 27); + cpy(buffer+3, buffer, 26-3); + if (strcmp(buffer, "defghijklmnopqrstuvwxyzxyz") != 0) exit(1); + exit(0); +} diff --git a/config/auto-aux/dblalign.c b/config/auto-aux/dblalign.c new file mode 100644 index 000000000..dd3099ab6 --- /dev/null +++ b/config/auto-aux/dblalign.c @@ -0,0 +1,37 @@ +#include <stdio.h> +#include <signal.h> +#include <setjmp.h> + +double foo; + +void access_double(p) + double * p; +{ + foo = *p; +} + +jmp_buf failure; + +void sig_handler() +{ + longjmp(failure, 1); +} + +main() +{ + long n[10]; + int res; + signal(SIGSEGV, sig_handler); + signal(SIGBUS, sig_handler); + if(setjmp(failure) == 0) { + access_double((double *) n); + access_double((double *) (n+1)); + res = 0; + } else { + res = 1; + } + signal(SIGSEGV, SIG_DFL); + signal(SIGBUS, SIG_DFL); + exit(res); +} + diff --git a/config/auto-aux/endian.c b/config/auto-aux/endian.c new file mode 100644 index 000000000..776ab0483 --- /dev/null +++ b/config/auto-aux/endian.c @@ -0,0 +1,26 @@ +#include "m.h" + +#ifndef SIXTYFOUR +long intval = 0x41424344L; +char * bigendian = "ABCD"; +char * littleendian = "DCBA"; +#else +long intval = 0x4142434445464748L; +char * bigendian = "ABCDEFGH"; +char * littleendian = "HGFEDCBA"; +#endif + +main() +{ + long n[2]; + char * p; + + n[0] = intval; + n[1] = 0; + p = (char *) n; + if (strcmp(p, bigendian) == 0) + exit(0); + if (strcmp(p, littleendian) == 0) + exit(1); + exit(2); +} diff --git a/config/auto-aux/getgroups.c b/config/auto-aux/getgroups.c new file mode 100644 index 000000000..8520c5c67 --- /dev/null +++ b/config/auto-aux/getgroups.c @@ -0,0 +1,17 @@ +#include <sys/types.h> +#include <sys/param.h> + +#ifdef NGROUPS + +int main() +{ + int gidset[NGROUPS]; + if (getgroups(NGROUPS, gidset) == -1) return 1; + return 0; +} + +#else + +int main() { return 1; } + +#endif diff --git a/config/auto-aux/hasgot b/config/auto-aux/hasgot new file mode 100755 index 000000000..b87fdfc5c --- /dev/null +++ b/config/auto-aux/hasgot @@ -0,0 +1,18 @@ +#!/bin/sh + +ccopts="" +cclibs="" +rm -f hasgot.c +while : ; do + case "$1" in + -i) echo "#include <$2>" >> hasgot.c; shift;; + -l*) cclibs="$cclibs $1";; + -*) ccopts="$ccopts $1";; + *) break;; + esac + shift +done +(echo "main() {" + for f in $*; do echo " $f();"; done + echo "}") >> hasgot.c +exec $cc $ccopts -o tst hasgot.c $cclibs > /dev/null 2>/dev/null diff --git a/config/auto-aux/runtest b/config/auto-aux/runtest new file mode 100755 index 000000000..92c30362c --- /dev/null +++ b/config/auto-aux/runtest @@ -0,0 +1,3 @@ +#!/bin/sh +$cc -o tst $* || exit 100 +exec ./tst diff --git a/config/auto-aux/schar.c b/config/auto-aux/schar.c new file mode 100644 index 000000000..3890c495a --- /dev/null +++ b/config/auto-aux/schar.c @@ -0,0 +1,7 @@ +char foo[]="\377"; +main() +{ + int i; + i = foo[0]; + exit(i != -1); +} diff --git a/config/auto-aux/schar2.c b/config/auto-aux/schar2.c new file mode 100644 index 000000000..0c6a6ce4b --- /dev/null +++ b/config/auto-aux/schar2.c @@ -0,0 +1,7 @@ +signed char foo[]="\377"; +main() +{ + int i; + i = foo[0]; + exit(i != -1); +} diff --git a/config/auto-aux/setjmp.c b/config/auto-aux/setjmp.c new file mode 100644 index 000000000..0867e62bb --- /dev/null +++ b/config/auto-aux/setjmp.c @@ -0,0 +1,12 @@ +#include <setjmp.h> + +main() +{ + jmp_buf buf; + int i; + i = _setjmp(buf); + if (i == 0) { + _longjmp(buf, 12345); + } + exit (i != 12345); +} diff --git a/config/auto-aux/sighandler.c b/config/auto-aux/sighandler.c new file mode 100644 index 000000000..d8d2e5df4 --- /dev/null +++ b/config/auto-aux/sighandler.c @@ -0,0 +1,8 @@ +#include <signal.h> + +main() +{ + SIGRETURN (*old)(); + old = signal(SIGQUIT, SIG_DFL); + return 0; +} diff --git a/config/auto-aux/signals.c b/config/auto-aux/signals.c new file mode 100644 index 000000000..c355545d8 --- /dev/null +++ b/config/auto-aux/signals.c @@ -0,0 +1,58 @@ +/* To determine the semantics of signal handlers + (System V: signal is reset to default behavior on entrance to the handler + BSD: signal handler remains active). */ + +#include <stdio.h> +#include <signal.h> + +/* Find a signal that is ignored by default */ + +#ifdef SIGCHLD +#define IGNSIG SIGCHLD +#else +#ifdef SIGIO +#define IGNSIG SIGIO +#else +#ifdef SIGCLD +#define IGNSIG SIGCLD +#else +#ifdef SIGPWR +#define IGNSIG SIGPWR +#endif +#endif +#endif +#endif + +#ifdef IGNSIG + +int counter; + +void sig_handler(dummy) + int dummy; +{ + counter++; +} + +int main(argc, argv) + int argc; + char ** argv; +{ + signal(IGNSIG, sig_handler); + counter = 0; + kill(getpid(), IGNSIG); + kill(getpid(), IGNSIG); + return (counter == 2 ? 0 : 1); +} + +#else + +/* If no suitable signal was found, assume System V */ + +int main(argc, argv) + int argc; + char ** argv; +{ + return 1; +} + +#endif diff --git a/config/auto-aux/sizes.c b/config/auto-aux/sizes.c new file mode 100644 index 000000000..02ce67506 --- /dev/null +++ b/config/auto-aux/sizes.c @@ -0,0 +1,7 @@ +int main(argc, argv) + int argc; + char ** argv; +{ + printf("%d %d %d\n", sizeof(int), sizeof(long), sizeof(long *)); + return 0; +} |