From 307fb64f8457cf3f711f2ceb93996722f8d6fa89 Mon Sep 17 00:00:00 2001 From: Abdulaziz Ghuloum Date: Mon, 3 Dec 2007 00:29:36 -0500 Subject: [PATCH] Fixes bug 173467. Ikarus now probes the cpuid for SSE2 support. --- scheme/last-revision | 2 +- src/Makefile.am | 2 +- src/Makefile.in | 5 +++-- src/cpu_has_sse2.s | 35 +++++++++++++++++++++++++++++++++++ src/ikarus-main.c | 9 +++++++++ 5 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 src/cpu_has_sse2.s diff --git a/scheme/last-revision b/scheme/last-revision index e7ff19b..1c509f5 100644 --- a/scheme/last-revision +++ b/scheme/last-revision @@ -1 +1 @@ -1174 +1175 diff --git a/src/Makefile.am b/src/Makefile.am index 0055207..7f9d633 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,7 +1,7 @@ bin_PROGRAMS = ikarus scheme-script -ikarus_SOURCES = ikarus-collect.c ikarus-exec.c ikarus-fasl.c ikarus-flonums.c ikarus-main.c ikarus-numerics.c ikarus-print.c ikarus-runtime.c ikarus-symbol-table.c ikarus-verify-integrity.c ikarus-weak-pairs.c ikarus-winmmap.c ikarus-data.h ikarus-winmmap.h ikarus-enter.s +ikarus_SOURCES = ikarus-collect.c ikarus-exec.c ikarus-fasl.c ikarus-flonums.c ikarus-main.c ikarus-numerics.c ikarus-print.c ikarus-runtime.c ikarus-symbol-table.c ikarus-verify-integrity.c ikarus-weak-pairs.c ikarus-winmmap.c ikarus-data.h ikarus-winmmap.h ikarus-enter.s cpu_has_sse2.s scheme_script_SOURCES = scheme-script.c diff --git a/src/Makefile.in b/src/Makefile.in index 49a3d79..6ba57f4 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -52,7 +52,8 @@ am_ikarus_OBJECTS = ikarus-collect.$(OBJEXT) ikarus-exec.$(OBJEXT) \ ikarus-print.$(OBJEXT) ikarus-runtime.$(OBJEXT) \ ikarus-symbol-table.$(OBJEXT) \ ikarus-verify-integrity.$(OBJEXT) ikarus-weak-pairs.$(OBJEXT) \ - ikarus-winmmap.$(OBJEXT) ikarus-enter.$(OBJEXT) + ikarus-winmmap.$(OBJEXT) ikarus-enter.$(OBJEXT) \ + cpu_has_sse2.$(OBJEXT) nodist_ikarus_OBJECTS = ikarus_OBJECTS = $(am_ikarus_OBJECTS) $(nodist_ikarus_OBJECTS) ikarus_LDADD = $(LDADD) @@ -173,7 +174,7 @@ target_os = @target_os@ target_vendor = @target_vendor@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -ikarus_SOURCES = ikarus-collect.c ikarus-exec.c ikarus-fasl.c ikarus-flonums.c ikarus-main.c ikarus-numerics.c ikarus-print.c ikarus-runtime.c ikarus-symbol-table.c ikarus-verify-integrity.c ikarus-weak-pairs.c ikarus-winmmap.c ikarus-data.h ikarus-winmmap.h ikarus-enter.s +ikarus_SOURCES = ikarus-collect.c ikarus-exec.c ikarus-fasl.c ikarus-flonums.c ikarus-main.c ikarus-numerics.c ikarus-print.c ikarus-runtime.c ikarus-symbol-table.c ikarus-verify-integrity.c ikarus-weak-pairs.c ikarus-winmmap.c ikarus-data.h ikarus-winmmap.h ikarus-enter.s cpu_has_sse2.s scheme_script_SOURCES = scheme-script.c nodist_ikarus_SOURCES = bootfileloc.h BUILT_SOURCES = bootfileloc.h diff --git a/src/cpu_has_sse2.s b/src/cpu_has_sse2.s new file mode 100644 index 0000000..f8e31b8 --- /dev/null +++ b/src/cpu_has_sse2.s @@ -0,0 +1,35 @@ +# Ikarus Scheme -- A compiler for R6RS Scheme. +# Copyright (C) 2006,2007 Abdulaziz Ghuloum +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +.text +.globl cpu_has_sse2 +.globl _cpu_has_sse2 + +.align 8 + +cpu_has_sse2: +_cpu_has_sse2: + # callee-save registers are $ebx, %esi, %edi, %esp, $ebp + # cpuid modifies %eax, %ebx, %ecx, %edx + # only %ebx needs to be saved/restored + push %ebx + movl $1, %eax + cpuid + movl %edx, %eax + sarl $26, %eax + andl $1, %eax + pop %ebx + ret diff --git a/src/ikarus-main.c b/src/ikarus-main.c index e885182..b60c771 100644 --- a/src/ikarus-main.c +++ b/src/ikarus-main.c @@ -127,7 +127,16 @@ file_exists(char* filename){ return (s == 0); } +extern int cpu_has_sse2(); + int main(int argc, char** argv){ + if(! cpu_has_sse2()){ + fprintf(stderr, "Ikarus Scheme cannot run on your computer because\n"); + fprintf(stderr, "your CPU does not support the SSE2 instruction set.\n"); + fprintf(stderr, "Refer to the Ikarus Scheme User's Guide for the\n"); + fprintf(stderr, "minimum hardware requirements.\n"); + exit(-1); + } if(get_option0("-h", argc, argv)){ ikarus_usage(); exit(0);