From: Nicholas Clark Date: Fri, 23 Dec 2005 01:09:05 +0000 (+0000) Subject: SIGRTMAX, SIGRTMIN, LDBL_MAX, LDBL_MIN, LDBL_EPSILON and HUGE_VAL X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6800c0cf85ac0db6e97c99271c275fdcd4bf4200;p=p5sagit%2Fp5-mst-13.2.git SIGRTMAX, SIGRTMIN, LDBL_MAX, LDBL_MIN, LDBL_EPSILON and HUGE_VAL aren't constants on (at least some) Linux. And more evil than that, HUGE_VAL likes to use the C preprocessor in its value, necessitating use of a temporary. p4raw-id: //depot/perl@26464 --- diff --git a/ext/POSIX/Makefile.PL b/ext/POSIX/Makefile.PL index 8c871c1..1453b53 100644 --- a/ext/POSIX/Makefile.PL +++ b/ext/POSIX/Makefile.PL @@ -44,7 +44,7 @@ my @names = PARENB PARMRK PARODD PATH_MAX PIPE_BUF RAND_MAX R_OK SCHAR_MAX SCHAR_MIN SEEK_CUR SEEK_END SEEK_SET SHRT_MAX SHRT_MIN SIGABRT SIGALRM SIGCHLD SIGCONT SIGFPE SIGHUP SIGILL SIGINT SIGKILL SIGPIPE SIGQUIT - SIGRTMAX SIGRTMIN SIGSEGV SIGSTOP SIGTERM SIGTSTP SIGTTIN SIGTTOU + SIGSEGV SIGSTOP SIGTERM SIGTSTP SIGTTIN SIGTTOU SIGUSR1 SIGUSR2 SIG_BLOCK SIG_SETMASK SIG_UNBLOCK SSIZE_MAX STDERR_FILENO STDIN_FILENO STDOUT_FILENO STREAM_MAX S_IRGRP S_IROTH S_IRUSR S_IRWXG S_IRWXO S_IRWXU S_ISGID S_ISUID @@ -58,6 +58,8 @@ my @names = _SC_OPEN_MAX _SC_PAGESIZE _SC_SAVED_IDS _SC_STREAM_MAX _SC_TZNAME_MAX _SC_VERSION), {name=>"MB_CUR_MAX", not_constant=>1}, + {name=>"SIGRTMAX", not_constant=>1}, + {name=>"SIGRTMIN", not_constant=>1}, {name=>"EXIT_FAILURE", default=>["IV", "1"]}, {name=>"EXIT_SUCCESS", default=>["IV", "0"]}, {name=>"SIG_DFL", value=>"(IV)SIG_DFL"}, @@ -69,7 +71,7 @@ my @names = {name=>"_POSIX_JOB_CONTROL", type=>"YES", default=>["IV", "0"]}, {name=>"_POSIX_SAVED_IDS", type=>"YES", default=>["IV", "0"]}, {name=>'FLT_ROUNDS', type=>"NV", not_constant=>1}, - {name=>"HUGE_VAL", type=>"NV", + {name=>"HUGE_VAL", type=>"NV", not_constant=>1, macro=>[<<'END', "#endif\n"], #if (defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)) || defined(HUGE_VAL) /* HUGE_VALL is admittedly non-POSIX but if we are using long doubles @@ -86,13 +88,16 @@ END push @names, {name=>$_, type=>"UV"} foreach (qw(SA_NOCLDSTOP SA_NOCLDWAIT SA_NODEFER SA_ONSTACK SA_RESETHAND SA_RESTART SA_SIGINFO UCHAR_MAX UINT_MAX ULONG_MAX USHRT_MAX)); +push @names, {name=>$_, type=>"NV", not_constant=>1} + foreach (qw(LDBL_MAX LDBL_MIN LDBL_EPSILON)); + push @names, {name=>$_, type=>"NV"} foreach (qw(DBL_DIG DBL_EPSILON DBL_MANT_DIG DBL_MAX DBL_MAX_10_EXP DBL_MAX_EXP DBL_MIN DBL_MIN_10_EXP DBL_MIN_EXP FLT_DIG FLT_EPSILON FLT_MANT_DIG FLT_MAX FLT_MAX_10_EXP FLT_MAX_EXP FLT_MIN FLT_MIN_10_EXP FLT_MIN_EXP FLT_RADIX - LDBL_DIG LDBL_EPSILON LDBL_MANT_DIG LDBL_MAX LDBL_MAX_10_EXP - LDBL_MAX_EXP LDBL_MIN LDBL_MIN_10_EXP LDBL_MIN_EXP)); + LDBL_DIG LDBL_MANT_DIG LDBL_MAX_10_EXP + LDBL_MAX_EXP LDBL_MIN_10_EXP LDBL_MIN_EXP)); push @names, {name=>$_, type=>"IV", default=>["IV", "0"]} foreach (qw(_POSIX_ARG_MAX _POSIX_CHILD_MAX _POSIX_CHOWN_RESTRICTED diff --git a/lib/ExtUtils/Constant/ProxySubs.pm b/lib/ExtUtils/Constant/ProxySubs.pm index 116e2dc..9cc8815 100644 --- a/lib/ExtUtils/Constant/ProxySubs.pm +++ b/lib/ExtUtils/Constant/ProxySubs.pm @@ -2,7 +2,8 @@ package ExtUtils::Constant::ProxySubs; use strict; use vars qw($VERSION @ISA %type_to_struct %type_from_struct %type_to_sv - %type_to_C_value %type_is_a_problem %type_num_args); + %type_to_C_value %type_is_a_problem %type_num_args + %type_temporary); use Carp; require ExtUtils::Constant::XS; use ExtUtils::Constant::Utils qw(C_stringify); @@ -60,6 +61,8 @@ sub type_to_C_value { SV => 1, ); +$type_temporary{$_} = $_ foreach qw(IV UV NV SV); + while (my ($type, $value) = each %XS_TypeSet) { $type_num_args{$type} = defined $value ? ref $value ? scalar @$value : 1 : 0; @@ -280,9 +283,16 @@ EOBOOT die "Can't find generator code for type $type" unless defined $generator; - print $xs_fh " {\n"; + print $xs_fh <<"EOBOOT"; + { + $type_temporary{$type} temp; +EOBOOT print $xs_fh " $item->{pre}\n" if $item->{pre}; - printf $xs_fh <<"EOBOOT", $name, &$generator(&$type_to_value($value)); + # We need to use a temporary value because some really troublesome + # items use C pre processor directives in their values, and in turn + # these don't fit nicely in the macro-ised generator functions + printf $xs_fh <<"EOBOOT", &$type_to_value($value), $name, &$generator('temp'); + temp = %s; ${c_subname}_add_symbol($athx symbol_table, "%s", $namelen, %s); EOBOOT