From d845297892d7baecaa1c826b303ffe3b6137a4dd Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Sun, 3 Apr 2005 15:31:35 +0000 Subject: [PATCH] fix detect for k6 cpu's SVN revision: 14086 --- legacy/evas/src/lib/engines/common/evas_cpu.c | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/legacy/evas/src/lib/engines/common/evas_cpu.c b/legacy/evas/src/lib/engines/common/evas_cpu.c index f291ff363f..b5481f9d7d 100644 --- a/legacy/evas/src/lib/engines/common/evas_cpu.c +++ b/legacy/evas/src/lib/engines/common/evas_cpu.c @@ -7,19 +7,26 @@ #include #ifndef WIN32 -static sigjmp_buf detect_buf; +static sigjmp_buf detect_buf, detect_buf2; #endif static int cpu_feature_mask = 0; #ifndef WIN32 static void evas_common_cpu_catch_ill(int sig); +static void evas_common_cpu_catch_segv(int sig); static void evas_common_cpu_catch_ill(int sig) { siglongjmp(detect_buf, 1); } + +static void +evas_common_cpu_catch_segv(int sig) +{ + siglongjmp(detect_buf2, 1); +} #endif void @@ -76,7 +83,7 @@ evas_common_cpu_feature_test(void (*feature)(void)) { #ifndef WIN32 int enabled = 1; - struct sigaction act, oact; + struct sigaction act, oact, oact2; act.sa_handler = evas_common_cpu_catch_ill; act.sa_flags = SA_RESTART; @@ -87,8 +94,21 @@ evas_common_cpu_feature_test(void (*feature)(void)) sigaction(SIGILL, &oact, NULL); return 0; } + act.sa_handler = evas_common_cpu_catch_segv; + act.sa_flags = SA_RESTART; + sigemptyset(&act.sa_mask); + sigaction(SIGSEGV, &act, &oact2); + if (sigsetjmp(detect_buf2, 1)) + { + sigaction(SIGILL, &oact, NULL); + sigaction(SIGSEGV, &oact2, NULL); + return 0; + } + feature(); + sigaction(SIGILL, &oact, NULL); + sigaction(SIGSEGV, &oact2, NULL); return enabled; #else return 0;