1 /***********************************************************************/
5 /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
7 /* Copyright 1996 Institut National de Recherche en Informatique et */
8 /* en Automatique. All rights reserved. This file is distributed */
9 /* under the terms of the GNU Library General Public License, with */
10 /* the special exception on linking described in file ../../LICENSE. */
12 /***********************************************************************/
14 /* $Id: align.c 4144 2001-12-07 13:41:02Z xleroy $ */
22 void access16(short int *p)
27 void access32(long int *p)
34 void sig_handler(int dummy)
39 int test(void (*fct) (/* ??? */), char *p)
43 signal(SIGSEGV, sig_handler);
44 signal(SIGBUS, sig_handler);
45 if(setjmp(failure) == 0) {
51 signal(SIGSEGV, SIG_DFL);
52 signal(SIGBUS, SIG_DFL);
58 void alarm_handler(int dummy)
68 int speedtest(char *p)
75 signal(SIGALRM, alarm_handler);
77 if (setjmp(timer) == 0) {
81 for (q = (int *) p, i = 1000; i > 0; q++, i--)
87 signal(SIGALRM, SIG_DFL);
94 int speed_aligned, speed_unaligned;
96 if (test(access16, (char *) n + 1)) exit(1);
97 if (test(access32, (char *) n + 1)) exit(1);
98 if (test(access32, (char *) n + 2)) exit(1);
99 speed_aligned = speedtest((char *) n);
100 speed_unaligned = speedtest((char *) n + 1);
101 if (speed_aligned >= 3 * speed_unaligned) exit(1);