?RCS: $Id: d_castneg.U,v 3.0.1.2 1995/05/12 12:11:21 ram Exp $
?RCS:
?RCS: Copyright (c) 1991-1993, Raphael Manfredi
-?RCS:
-?RCS: You may redistribute only under the terms of the Artistic Licence,
+?RCS:
+?RCS: You may redistribute only under the terms of the Artistic License,
?RCS: as specified in the README file that comes with the distribution.
?RCS: You may reuse parts of this distribution only within the terms of
-?RCS: that same Artistic Licence; a copy of which may be found at the root
+?RCS: that same Artistic License; a copy of which may be found at the root
?RCS: of the source tree for dist 3.0.
?RCS:
?RCS: $Log: d_castneg.U,v $
?X:
?X: Can the compiler cast negative / odd floats to unsigned values.
?X:
-?MAKE:d_castneg castflags: cat Compile rm Setvar signal_t run
+?MAKE:d_castneg castflags: cat Compile rm_try Setvar signal_t run i_stdlib
?MAKE: -pick add $@ %<
?S:d_castneg:
?S: This variable conditionally defines CASTNEG, which indicates
-?S: wether the C compiler can cast negative float to unsigned.
+?S: whether the C compiler can cast negative float to unsigned.
?S:.
?S:castflags:
?S: This variable contains a flag that precise difficulties the
?H:#$d_castneg CASTNEGFLOAT /**/
?H:#define CASTFLAGS $castflags /**/
?H:.
+?F:!try
?LINT:set d_castneg
: check for ability to cast negative floats to unsigned
echo " "
echo 'Checking whether your C compiler can cast negative float to unsigned.' >&4
$cat >try.c <<EOCP
#include <stdio.h>
+#$i_stdlib I_STDLIB
+#ifdef I_STDLIB
+#include <stdlib.h>
+#endif
#include <sys/types.h>
#include <signal.h>
-$signal_t blech(s) int s; { exit(7); }
-$signal_t blech_in_list(s) int s; { exit(4); }
-unsigned long dummy_long(p) unsigned long p; { return p; }
-unsigned int dummy_int(p) unsigned int p; { return p; }
-unsigned short dummy_short(p) unsigned short p; { return p; }
+$signal_t blech(int s) { exit(7); }
+$signal_t blech_in_list(int s) { exit(4); }
+unsigned long dummy_long(unsigned long p) { return p; }
+unsigned int dummy_int(unsigned int p) { return p; }
+unsigned short dummy_short(unsigned short p) { return p; }
int main()
{
double f;
unsigned short ashort;
int result = 0;
char str[16];
-
+
/* Frustrate gcc-2.7.2's optimizer which failed this test with
a direct f = -123. assignment. gcc-2.8.0 reportedly
optimized the whole file away
*/
- /* Store the number in a writable string for gcc to pass to
- sscanf under HP/UX.
+ /* Store the number in a writable string for gcc to pass to
+ sscanf under HP-UX.
*/
sprintf(str, "-123");
sscanf(str, "%lf", &f); /* f = -123.; */
esac
set d_castneg
eval $setvar
-$rm -f try.*
+$rm_try