diff options
author | Kevin Ryde <user42@zip.com.au> | 2002-03-23 23:05:02 +0100 |
---|---|---|
committer | Kevin Ryde <user42@zip.com.au> | 2002-03-23 23:05:02 +0100 |
commit | aa65403bd87dc6b16a301a5e9d86b041563d32b9 (patch) | |
tree | 12ccc6a8e7022f25a977916fb485c77593242a89 /demos | |
parent | c97eda1c7ef748cda5bb6639b9f42f1b017f3812 (diff) | |
download | gmp-aa65403bd87dc6b16a301a5e9d86b041563d32b9.tar.gz |
* demos/pexpr.c (setup_error_handler): Corrections to sigstack code.
Diffstat (limited to 'demos')
-rw-r--r-- | demos/pexpr.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/demos/pexpr.c b/demos/pexpr.c index 4b2f20b4e..16d0e8ec4 100644 --- a/demos/pexpr.c +++ b/demos/pexpr.c @@ -59,6 +59,11 @@ Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "gmp.h" +/* SunOS 4 doesn't define a canonical SIGSTKSZ, provide a default. */ +#ifndef SIGSTKSZ +#define SIGSTKSZ 4096 +#endif + #define TIME(t,func) \ do { int __t0, __times, __t, __tmp; \ @@ -171,6 +176,20 @@ cputime (void) #endif +int +stack_downwards_helper (char *xp) +{ + char y; + return &y < xp; +} +int +stack_downwards_p (void) +{ + char x; + return stack_downwards_helper (&x); +} + + void setup_error_handler (void) { @@ -190,7 +209,8 @@ setup_error_handler (void) overflown stack. */ #if HAVE_SIGALTSTACK { - /* AIX uses stack_t, MacOS uses struct sigaltstack. */ + /* AIX uses stack_t, MacOS uses struct sigaltstack, various other + systems have both. */ #if HAVE_STACK_T stack_t s; #else @@ -206,8 +226,10 @@ setup_error_handler (void) #else #if HAVE_SIGSTACK { - struct sigstack sigstk; + struct sigstack s; s.ss_sp = malloc (SIGSTKSZ); + if (stack_downwards_p ()) + s.ss_sp += SIGSTKSZ; s.ss_onstack = 0; if (sigstack (&s, NULL) != 0) perror("sigstack"); |