X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdlib%2Fstrtoul.c;fp=functions%2Fstdlib%2Fstrtoul.c;h=4b2fd3d208ec56c49f0e5ef4553992184c37125c;hb=5bd2bbfe899293f748cd092d613340417af487f2;hp=568029756b69af9267be04b790ad5a086f0ba4bc;hpb=dce3890032b066679d21ef55d00b505f90176a8b;p=pdclib.old diff --git a/functions/stdlib/strtoul.c b/functions/stdlib/strtoul.c index 5680297..4b2fd3d 100644 --- a/functions/stdlib/strtoul.c +++ b/functions/stdlib/strtoul.c @@ -79,7 +79,8 @@ int main( void ) /* for one-complement and signed magnitude just as well. Anyone having */ /* a platform to test this on? */ errno = 0; -#if ULONG_MAX == 0xffffffffL +/* long -> 32 bit */ +#if ULONG_MAX >> 31 == 1 /* testing "even" overflow, i.e. base is power of two */ TESTCASE( strtoul( "4294967295", NULL, 0 ) == ULONG_MAX ); TESTCASE( errno == 0 ); @@ -87,7 +88,8 @@ int main( void ) TESTCASE( strtoul( "4294967296", NULL, 0 ) == ULONG_MAX ); TESTCASE( errno == ERANGE ); /* TODO: test "odd" overflow, i.e. base is not power of two */ -#elif ULONG_MAX == 0xffffffffffffffffL +/* long -> 64 bit */ +#elif ULONG_MAX >> 63 == 1 /* testing "even" overflow, i.e. base is power of two */ TESTCASE( strtoul( "18446744073709551615", NULL, 0 ) == ULONG_MAX ); TESTCASE( errno == 0 );