[netbsd] Parrot on netbsd-alpha gets killed by SIGFPE when calculating Inf.
From: Mark Glines <mark@glines.org>
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
|
b
|
|
359 | 359 | config/gen/platform/generic/time.c [] |
360 | 360 | config/gen/platform/ia64/asm.s [] |
361 | 361 | config/gen/platform/netbsd/math.c [] |
| 362 | config/gen/platform/netbsd/misc.c [] |
| 363 | config/gen/platform/netbsd/misc.h [] |
362 | 364 | config/gen/platform/openbsd/math.c [] |
363 | 365 | config/gen/platform/openbsd/memexec.c [] |
364 | 366 | 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
a
|
b
|
|
| 1 | /* |
| 2 | * $Id$ |
| 3 | * Copyright (C) 2009, Parrot Foundation. |
| 4 | */ |
| 5 | |
| 6 | /* |
| 7 | |
| 8 | =head1 NAME |
| 9 | |
| 10 | config/gen/platform/netbsd/misc.c |
| 11 | |
| 12 | =head1 DESCRIPTION |
| 13 | |
| 14 | Miscellaneous helper functions that are specific to NetBSD. |
| 15 | |
| 16 | =head2 Functions |
| 17 | |
| 18 | =over 4 |
| 19 | |
| 20 | =cut |
| 21 | |
| 22 | */ |
| 23 | |
| 24 | /* |
| 25 | |
| 26 | =item C<void Parrot_platform_init_code(void)> |
| 27 | |
| 28 | Initialize Parrot for the NetBSD platform. |
| 29 | So far only turns off SIGFPE for Alpha. |
| 30 | |
| 31 | =cut |
| 32 | |
| 33 | */ |
| 34 | |
| 35 | #include <signal.h> |
| 36 | |
| 37 | void |
| 38 | Parrot_platform_init_code(void) |
| 39 | { |
| 40 | #if defined(__alpha__) |
| 41 | signal(SIGFPE, SIG_IGN); |
| 42 | #endif |
| 43 | } |
| 44 | |
| 45 | /* |
| 46 | |
| 47 | =back |
| 48 | |
| 49 | =cut |
| 50 | |
| 51 | */ |
| 52 | |
| 53 | /* |
| 54 | * Local variables: |
| 55 | * c-file-style: "parrot" |
| 56 | * End: |
| 57 | * vim: expandtab shiftwidth=4: |
| 58 | */ |
diff --git a/config/gen/platform/netbsd/misc.h b/config/gen/platform/netbsd/misc.h
new file mode 100644
index 0000000..2e38bd0
a
|
b
|
|
| 1 | /* |
| 2 | * $Id$ |
| 3 | * Copyright (C) 2009, Parrot Foundation. |
| 4 | */ |
| 5 | |
| 6 | #ifndef PARROT_PLATFORM_NETBSD_MISC_H_GUARD |
| 7 | # define PARROT_PLATFORM_NETBSD_MISC_H_GUARD |
| 8 | |
| 9 | # define PARROT_HAS_PLATFORM_INIT_CODE |
| 10 | void Parrot_platform_init_code(void); |
| 11 | |
| 12 | #endif /* PARROT_PLATFORM_NETBSD_MISC_H_GUARD */ |
| 13 | |
| 14 | /* |
| 15 | * Local variables: |
| 16 | * c-file-style: "parrot" |
| 17 | * End: |
| 18 | * vim: expandtab shiftwidth=4: |
| 19 | */ |
diff --git a/include/parrot/datatypes.h b/include/parrot/datatypes.h
index 737304f..3819a39 100644
a
|
b
|
|
123 | 123 | }; |
124 | 124 | #endif /* INSIDE_GLOBAL_SETUP */ |
125 | 125 | |
126 | | #define PARROT_FLOATVAL_INF_POSITIVE floatval_divide_by_zero(interp, 1.0) |
127 | | #define PARROT_FLOATVAL_INF_NEGATIVE floatval_divide_by_zero(interp, -1.0) |
128 | | #define PARROT_FLOATVAL_NAN_QUIET floatval_divide_by_zero(interp, 0.0) |
| 126 | #if defined(__NetBSD__) && defined(__alpha__) |
| 127 | # include <math.h> |
| 128 | # define PARROT_FLOATVAL_INF_POSITIVE INFINITY |
| 129 | # define PARROT_FLOATVAL_INF_NEGATIVE -INFINITY |
| 130 | # define PARROT_FLOATVAL_NAN_QUIET NAN |
| 131 | #else |
| 132 | # define PARROT_FLOATVAL_INF_POSITIVE floatval_divide_by_zero(interp, 1.0) |
| 133 | # define PARROT_FLOATVAL_INF_NEGATIVE floatval_divide_by_zero(interp, -1.0) |
| 134 | # define PARROT_FLOATVAL_NAN_QUIET floatval_divide_by_zero(interp, 0.0) |
| 135 | #endif |
129 | 136 | |
130 | 137 | #define PARROT_CSTRING_INF_POSITIVE "Inf" |
131 | 138 | #define PARROT_CSTRING_INF_NEGATIVE "-Inf" |
diff --git a/src/main.c b/src/main.c
index 92760ff..44b41f1 100644
a
|
b
|
|
20 | 20 | |
21 | 21 | #include <stdio.h> |
22 | 22 | #include <string.h> |
| 23 | #if defined(__NetBSD__) && defined(__alpha__) |
| 24 | # include <signal.h> |
| 25 | #endif |
23 | 26 | |
24 | 27 | #include "parrot/parrot.h" |
25 | 28 | #include "parrot/embed.h" |
… |
… |
|
42 | 45 | Interp *interp; |
43 | 46 | int status; |
44 | 47 | |
| 48 | #if defined(__NetBSD__) && defined(__alpha__) |
| 49 | signal(SIGFPE, SIG_IGN); /* ignore invalid operations/results */ |
| 50 | #endif |
| 51 | |
45 | 52 | /* internationalization setup */ |
46 | 53 | /* setlocale(LC_ALL, ""); */ |
47 | 54 | PARROT_BINDTEXTDOMAIN(PACKAGE, LOCALEDIR); |