Date: Thu, 29 Jun 2000 20:28:50 -0700 (PDT) From: John Polstra <jdp@polstra.com> To: hackers@freebsd.org Subject: Please run this test on an 80386 Message-ID: <XFMail.000629202850.jdp@polstra.com>
next in thread | raw e-mail | index | archive | help
This message is in MIME format --_=XFMail.1.3.p0.FreeBSD:000629202850:24129=_ Content-Type: text/plain; charset=us-ascii I am making some changes to FreeBSD's dynamic linker which require the ability to find out whether the CPU running the program supports the cmpxchg instruction. This instruction was introduced with the 80486; it did not exist on the 80386. The attached program attempts to determine whether the cmpxchg instruction is supported. Unfortunately, I don't have an 80386 to test it on. I would appreciate it if somebody with FreeBSD running on an 80386 would compile the program, run it, and send me the output. To compile it, just type: cc -o sigill sigill.c and then run it with ./sigill On an 80386 it should print out This CPU does not support the cmpxchg instruction Thanks in advance! John -- John Polstra jdp@polstra.com John D. Polstra & Co., Inc. Seattle, Washington USA "Disappointment is a good sign of basic intelligence." -- Chögyam Trungpa --_=XFMail.1.3.p0.FreeBSD:000629202850:24129=_ Content-Disposition: attachment; filename="sigill.c" Content-Transfer-Encoding: 7bit Content-Description: sigill.c Content-Type: text/plain; charset=us-ascii; name=sigill.c; SizeOnDisk=1194 #include <err.h> #include <setjmp.h> #include <signal.h> #include <stdio.h> #include <string.h> #ifdef TEST #define cmpxchgl(old, new, m) ({ \ __asm volatile (".byte 0x0f; .byte 0x0f"); \ 0; }) #else #define cmpxchgl(old, new, m) ({ \ unsigned int __eax; \ __asm volatile ("lock; cmpxchgl %2, %0" \ : "=m"(m), "=a"(__eax) \ : "r"(new), "0"(m), "1"(old) \ : "cc"); \ (__eax); }) #endif static jmp_buf sigill_env; static void sigill(int sig) { longjmp(sigill_env, 1); } static int cpu_supports_cmpxchg(void) { struct sigaction act, oact; int result = 1; int lock = 0; memset(&act, 0, sizeof act); act.sa_handler = sigill; sigemptyset(&act.sa_mask); act.sa_flags = 0; if (sigaction(SIGILL, &act, &oact) == -1) err(1, "sigaction failed"); if (setjmp(sigill_env) == 0) cmpxchgl(0, 1, lock); else result = 0; if (sigaction(SIGILL, &oact, NULL) == -1) err(1, "sigaction failed"); return result; } int main(int argc, char *argv[]) { if (cpu_supports_cmpxchg()) printf("This CPU supports the cmpxchg instruction\n"); else printf("This CPU does not support the cmpxchg instruction\n"); return 0; } --_=XFMail.1.3.p0.FreeBSD:000629202850:24129=_-- End of MIME message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.000629202850.jdp>