int test_exception() { int errs = 0; printf("Checking that exceptional lib calls set errno\n"); errs += CHECK_TRIPPED_ERRNO(pow(-3, 4.4)); errs += CHECK_TRIPPED_ERRNO(log(-3.0)); errs += CHECK_TRIPPED_ERRNO(sqrt(-0.001)); errs += CHECK_TRIPPED_ERRNO(asin(1.0001)); /* Some versions of libc don't set errno =( * http://sourceware.org/bugzilla/show_bug.cgi?id=6780 * http://sourceware.org/bugzilla/show_bug.cgi?id=6781 errs += CHECK_TRIPPED_ERRNO(sin(INFINITY)); errs += CHECK_TRIPPED_ERRNO(cos(INFINITY)); */ errs += CHECK_TRIPPED_ERRNO(acosh(0.999)); errs += CHECK_TRIPPED_ERRNO(remainder(3.3, 0.0)); /* Some versions of libc don't set errno =( * http://sourceware.org/bugzilla/show_bug.cgi?id=6783 errs += CHECK_TRIPPED_ERRNO(remainder(INFINITY, 3.3)); */ return errs; }
int test_exception(void) { int errs = 0; /* * Attempt to prevent constant folding and optimization of library * function bodies (when statically linked). */ volatile double x; volatile double y; printf("Checking that exceptional lib calls set errno\n"); x = -3.0; y = 4.4; errs += CHECK_TRIPPED_ERRNO(pow(x, y)); errs += CHECK_TRIPPED_ERRNO(log(x)); x = -0.001; errs += CHECK_TRIPPED_ERRNO(sqrt(x)); x = 1.0001; errs += CHECK_TRIPPED_ERRNO(asin(x)); /* Some versions of libc don't set errno =( * http://sourceware.org/bugzilla/show_bug.cgi?id=6780 * http://sourceware.org/bugzilla/show_bug.cgi?id=6781 x = INFINITY; errs += CHECK_TRIPPED_ERRNO(sin(x)); errs += CHECK_TRIPPED_ERRNO(cos(x)); */ x = 0.999; errs += CHECK_TRIPPED_ERRNO(acosh(x)); x = 3.3; y = 0.0; errs += CHECK_TRIPPED_ERRNO(remainder(x, y)); /* Some versions of libc don't set errno =( * http://sourceware.org/bugzilla/show_bug.cgi?id=6783 x = INFINITY; y = 3.3; errs += CHECK_TRIPPED_ERRNO(remainder(x, y)); */ return errs; }