Ticket #574: netbsd-alpha-sigfpe.patch

File netbsd-alpha-sigfpe.patch, 4.5 KB (added by Infinoid, 6 years ago)

Here's the current patch, contains some redundant code and could use some cleanup.

  • MANIFEST

    [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  
    359359config/gen/platform/generic/time.c                          [] 
    360360config/gen/platform/ia64/asm.s                              [] 
    361361config/gen/platform/netbsd/math.c                           [] 
     362config/gen/platform/netbsd/misc.c                           [] 
     363config/gen/platform/netbsd/misc.h                           [] 
    362364config/gen/platform/openbsd/math.c                          [] 
    363365config/gen/platform/openbsd/memexec.c                       [] 
    364366config/gen/platform/openbsd/misc.h                          [] 
  • (a) /dev/null vs. (b) b/config/gen/platform/netbsd/misc.c

    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 
     10config/gen/platform/netbsd/misc.c 
     11 
     12=head1 DESCRIPTION 
     13 
     14Miscellaneous 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 
     28Initialize Parrot for the NetBSD platform. 
     29So far only turns off SIGFPE for Alpha. 
     30 
     31=cut 
     32 
     33*/ 
     34 
     35#include <signal.h> 
     36 
     37void 
     38Parrot_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 */ 
  • (a) /dev/null vs. (b) b/config/gen/platform/netbsd/misc.h

    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 
     10void 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 */ 
  • include/parrot/datatypes.h

    diff --git a/include/parrot/datatypes.h b/include/parrot/datatypes.h
    index 737304f..3819a39 100644
    a b  
    123123}; 
    124124#endif /* INSIDE_GLOBAL_SETUP */ 
    125125 
    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 
    129136 
    130137#define PARROT_CSTRING_INF_POSITIVE    "Inf" 
    131138#define PARROT_CSTRING_INF_NEGATIVE    "-Inf" 
  • src/main.c

    diff --git a/src/main.c b/src/main.c
    index 92760ff..44b41f1 100644
    a b  
    2020 
    2121#include <stdio.h> 
    2222#include <string.h> 
     23#if defined(__NetBSD__) && defined(__alpha__) 
     24#  include <signal.h> 
     25#endif 
    2326 
    2427#include "parrot/parrot.h" 
    2528#include "parrot/embed.h" 
     
    4245    Interp  *interp; 
    4346    int      status; 
    4447 
     48#if defined(__NetBSD__) && defined(__alpha__) 
     49    signal(SIGFPE, SIG_IGN); /* ignore invalid operations/results */ 
     50#endif 
     51 
    4552    /* internationalization setup */ 
    4653    /* setlocale(LC_ALL, ""); */ 
    4754    PARROT_BINDTEXTDOMAIN(PACKAGE, LOCALEDIR);