1995-08-09 08:06:35 -07:00
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
1996-04-30 07:53:58 -07:00
|
|
|
/* Objective Caml */
|
1995-08-09 08:06:35 -07:00
|
|
|
/* */
|
|
|
|
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
|
|
|
|
/* */
|
1996-04-30 07:53:58 -07:00
|
|
|
/* Copyright 1996 Institut National de Recherche en Informatique et */
|
1999-11-17 10:59:06 -08:00
|
|
|
/* en Automatique. All rights reserved. This file is distributed */
|
2001-12-07 05:41:02 -08:00
|
|
|
/* under the terms of the GNU Library General Public License, with */
|
|
|
|
/* the special exception on linking described in file ../../LICENSE. */
|
1995-08-09 08:06:35 -07:00
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
1995-05-09 02:36:12 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <setjmp.h>
|
|
|
|
|
|
|
|
long foo;
|
|
|
|
|
1997-09-02 05:55:01 -07:00
|
|
|
void access16(short int *p)
|
1995-05-09 02:36:12 -07:00
|
|
|
{
|
|
|
|
foo = *p;
|
|
|
|
}
|
|
|
|
|
1997-09-02 05:55:01 -07:00
|
|
|
void access32(long int *p)
|
1995-05-09 02:36:12 -07:00
|
|
|
{
|
|
|
|
foo = *p;
|
|
|
|
}
|
|
|
|
|
|
|
|
jmp_buf failure;
|
|
|
|
|
1997-09-02 05:55:01 -07:00
|
|
|
void sig_handler(int dummy)
|
1995-05-09 02:36:12 -07:00
|
|
|
{
|
|
|
|
longjmp(failure, 1);
|
|
|
|
}
|
|
|
|
|
1997-09-02 05:55:01 -07:00
|
|
|
int test(void (*fct) (/* ??? */), char *p)
|
1995-05-09 02:36:12 -07:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
1997-09-02 05:55:01 -07:00
|
|
|
void alarm_handler(int dummy)
|
1995-05-09 02:36:12 -07:00
|
|
|
{
|
|
|
|
longjmp(timer, 1);
|
|
|
|
}
|
|
|
|
|
1997-09-02 05:55:01 -07:00
|
|
|
void use(int n)
|
1995-05-09 02:36:12 -07:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1997-09-02 05:55:01 -07:00
|
|
|
int speedtest(char *p)
|
1995-05-09 02:36:12 -07:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1997-09-02 05:55:01 -07:00
|
|
|
main(void)
|
1995-05-09 02:36:12 -07:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|