[netbsd] Parrot on netbsd-alpha gets killed by SIGFPE when calculating Inf. From: Mark Glines he> Non-portable: #define PARROT_FLOATVAL_INF_POSITIVE floatval_divide_by_zero(interp, 1.0) he> On alpha, doing that will land you a SIGFPE. he++ provided this patch which allows parrot to pass "make test". --- MANIFEST | 2 + config/gen/platform/netbsd/misc.c | 58 +++++++++++++++++++++++++++++++++++++ config/gen/platform/netbsd/misc.h | 19 ++++++++++++ include/parrot/datatypes.h | 13 ++++++-- src/main.c | 7 ++++ 5 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 config/gen/platform/netbsd/misc.c create mode 100644 config/gen/platform/netbsd/misc.h diff --git a/MANIFEST b/MANIFEST index 5de2d66..b29f0ed 100644 --- a/MANIFEST +++ b/MANIFEST @@ -359,6 +359,8 @@ config/gen/platform/generic/threads.h [] config/gen/platform/generic/time.c [] config/gen/platform/ia64/asm.s [] config/gen/platform/netbsd/math.c [] +config/gen/platform/netbsd/misc.c [] +config/gen/platform/netbsd/misc.h [] config/gen/platform/openbsd/math.c [] config/gen/platform/openbsd/memexec.c [] config/gen/platform/openbsd/misc.h [] diff --git a/config/gen/platform/netbsd/misc.c b/config/gen/platform/netbsd/misc.c new file mode 100644 index 0000000..877a7a0 --- /dev/null +++ b/config/gen/platform/netbsd/misc.c @@ -0,0 +1,58 @@ +/* + * $Id$ + * Copyright (C) 2009, Parrot Foundation. + */ + +/* + +=head1 NAME + +config/gen/platform/netbsd/misc.c + +=head1 DESCRIPTION + +Miscellaneous helper functions that are specific to NetBSD. + +=head2 Functions + +=over 4 + +=cut + +*/ + +/* + +=item C + +Initialize Parrot for the NetBSD platform. +So far only turns off SIGFPE for Alpha. + +=cut + +*/ + +#include + +void +Parrot_platform_init_code(void) +{ +#if defined(__alpha__) + signal(SIGFPE, SIG_IGN); +#endif +} + +/* + +=back + +=cut + +*/ + +/* + * Local variables: + * c-file-style: "parrot" + * End: + * vim: expandtab shiftwidth=4: + */ diff --git a/config/gen/platform/netbsd/misc.h b/config/gen/platform/netbsd/misc.h new file mode 100644 index 0000000..2e38bd0 --- /dev/null +++ b/config/gen/platform/netbsd/misc.h @@ -0,0 +1,19 @@ +/* + * $Id$ + * Copyright (C) 2009, Parrot Foundation. + */ + +#ifndef PARROT_PLATFORM_NETBSD_MISC_H_GUARD +# define PARROT_PLATFORM_NETBSD_MISC_H_GUARD + +# define PARROT_HAS_PLATFORM_INIT_CODE +void Parrot_platform_init_code(void); + +#endif /* PARROT_PLATFORM_NETBSD_MISC_H_GUARD */ + +/* + * Local variables: + * c-file-style: "parrot" + * End: + * vim: expandtab shiftwidth=4: + */ diff --git a/include/parrot/datatypes.h b/include/parrot/datatypes.h index 737304f..3819a39 100644 --- a/include/parrot/datatypes.h +++ b/include/parrot/datatypes.h @@ -123,9 +123,16 @@ const struct _data_types data_types[] = { }; #endif /* INSIDE_GLOBAL_SETUP */ -#define PARROT_FLOATVAL_INF_POSITIVE floatval_divide_by_zero(interp, 1.0) -#define PARROT_FLOATVAL_INF_NEGATIVE floatval_divide_by_zero(interp, -1.0) -#define PARROT_FLOATVAL_NAN_QUIET floatval_divide_by_zero(interp, 0.0) +#if defined(__NetBSD__) && defined(__alpha__) +# include +# define PARROT_FLOATVAL_INF_POSITIVE INFINITY +# define PARROT_FLOATVAL_INF_NEGATIVE -INFINITY +# define PARROT_FLOATVAL_NAN_QUIET NAN +#else +# define PARROT_FLOATVAL_INF_POSITIVE floatval_divide_by_zero(interp, 1.0) +# define PARROT_FLOATVAL_INF_NEGATIVE floatval_divide_by_zero(interp, -1.0) +# define PARROT_FLOATVAL_NAN_QUIET floatval_divide_by_zero(interp, 0.0) +#endif #define PARROT_CSTRING_INF_POSITIVE "Inf" #define PARROT_CSTRING_INF_NEGATIVE "-Inf" diff --git a/src/main.c b/src/main.c index 92760ff..44b41f1 100644 --- a/src/main.c +++ b/src/main.c @@ -20,6 +20,9 @@ Start Parrot #include #include +#if defined(__NetBSD__) && defined(__alpha__) +# include +#endif #include "parrot/parrot.h" #include "parrot/embed.h" @@ -42,6 +45,10 @@ main(int argc, char * argv[]) Interp *interp; int status; +#if defined(__NetBSD__) && defined(__alpha__) + signal(SIGFPE, SIG_IGN); /* ignore invalid operations/results */ +#endif + /* internationalization setup */ /* setlocale(LC_ALL, ""); */ PARROT_BINDTEXTDOMAIN(PACKAGE, LOCALEDIR);