X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdlib%2Fstrtoull.c;fp=functions%2Fstdlib%2Fstrtoull.c;h=a28bb45d5ef7c7fca86e85feae554d3e45a320b9;hb=164e8c095e19af2595865d2713dd4d3d893b71e0;hp=ca9dd1936ee2fb46c11dddfaf5f424aa5147e3bb;hpb=a0746ea9f2660205d2c885e34c515184442ddab1;p=pdclib diff --git a/functions/stdlib/strtoull.c b/functions/stdlib/strtoull.c index ca9dd19..a28bb45 100644 --- a/functions/stdlib/strtoull.c +++ b/functions/stdlib/strtoull.c @@ -76,14 +76,16 @@ int main( void ) TESTCASE( strtoull( overflow, &endptr, 0 ) == 0 ); TESTCASE( endptr == overflow ); errno = 0; -#if ULLONG_MAX == 0xffffffffffffffffLL +/* long long -> 64 bit */ +#if ULLONG_MAX >> 63 == 1 /* testing "even" overflow, i.e. base is power of two */ TESTCASE( strtoull( "18446744073709551615", NULL, 0 ) == ULLONG_MAX ); TESTCASE( errno == 0 ); TESTCASE( strtoull( "18446744073709551616", NULL, 0 ) == ULLONG_MAX ); TESTCASE( errno == ERANGE ); /* TODO: test "odd" overflow, i.e. base is not power of two */ -#elif ULLONG_MAX == 0xffffffffffffffffffffffffffffffffLL +/* long long -> 128 bit */ +#elif ULLONG_MAX >> 127 == 1 /* testing "even" overflow, i.e. base is power of two */ TESTCASE( strtoull( "340282366920938463463374607431768211455", NULL, 0 ) == ULLONG_MAX ); TESTCASE( errno == 0 );