Embedded Artistry Framework
Embedded Systems C++ Framework
Macros | Functions | Variables
libm-test.c File Reference
#include "libm-test-ulps.h"
#include <float.h>
#include <openlibm.h>
#include <limits.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
Include dependency graph for libm-test.c:
This graph shows which files directly or indirectly include this file:

Macros

#define _GNU_SOURCE
 
#define NO_EXCEPTION   0x0
 
#define INVALID_EXCEPTION   0x1
 
#define DIVIDE_BY_ZERO_EXCEPTION   0x2
 
#define INVALID_EXCEPTION_OK   0x4
 
#define DIVIDE_BY_ZERO_EXCEPTION_OK   0x8
 
#define EXCEPTIONS_OK   INVALID_EXCEPTION_OK+DIVIDE_BY_ZERO_EXCEPTION_OK
 
#define IGNORE_ZERO_INF_SIGN   0x10
 
#define M_PI_6l   .52359877559829887307710723054658383L
 
#define M_E2l   7.389056098930650227230427460575008L
 
#define M_E3l   20.085536923187667740928529654581719L
 
#define M_2_SQRT_PIl   3.5449077018110320545963349666822903L /* 2 sqrt (M_PIl) */
 
#define M_SQRT_PIl   1.7724538509055160272981674833411451L /* sqrt (M_PIl) */
 
#define M_LOG_SQRT_PIl   0.57236494292470008707171367567652933L /* log(sqrt(M_PIl)) */
 
#define M_LOG_2_SQRT_PIl   1.265512123484645396488945797134706L /* log(2*sqrt(M_PIl)) */
 
#define M_PI_34l   (M_PIl - M_PI_4l) /* 3*pi/4 */
 
#define M_PI_34_LOG10El   (M_PIl - M_PI_4l) * M_LOG10El
 
#define M_PI2_LOG10El   M_PI_2l * M_LOG10El
 
#define M_PI4_LOG10El   M_PI_4l * M_LOG10El
 
#define M_PI_LOG10El   M_PIl * M_LOG10El
 
#define M_El   2.7182818284590452353602874713526625L /* e */
 
#define M_LOG2El   1.4426950408889634073599246810018922L /* log_2 e */
 
#define M_LOG10El   0.4342944819032518276511289189166051L /* log_10 e */
 
#define M_LN2l   0.6931471805599453094172321214581766L /* log_e 2 */
 
#define M_LN10l   2.3025850929940456840179914546843642L /* log_e 10 */
 
#define M_PIl   3.1415926535897932384626433832795029L /* pi */
 
#define M_PI_2l   1.5707963267948966192313216916397514L /* pi/2 */
 
#define M_PI_4l   0.7853981633974483096156608458198757L /* pi/4 */
 
#define M_1_PIl   0.3183098861837906715377675267450287L /* 1/pi */
 
#define M_2_PIl   0.6366197723675813430755350534900574L /* 2/pi */
 
#define M_2_SQRTPIl   1.1283791670955125738961589031215452L /* 2/sqrt(pi) */
 
#define M_SQRT2l   1.4142135623730950488016887242096981L /* sqrt(2) */
 
#define M_SQRT1_2l   0.7071067811865475244008443621048490L /* 1/sqrt(2) */
 
#define MANT_DIG
 
#define gamma   lgamma /* XXX scp XXX */
 
#define gammaf   lgammaf /* XXX scp XXX */
 

Functions

void FUNC() sincos (FLOAT x, FLOAT *s, FLOAT *c)
 
static void init_max_error (void)
 
static void set_max_error (FLOAT current, FLOAT *curr_max_error)
 
static int print_screen (int ok, int xfail)
 
static int print_screen_max_error (int ok, int xfail)
 
static void update_stats (int ok, int xfail)
 
static void print_ulps (const char *test_name, FLOAT ulp)
 
static void print_function_ulps (const char *function_name, FLOAT ulp)
 
static void print_max_error (const char *func_name, FLOAT allowed, int xfail)
 
static void test_single_exception (const char *test_name, int exception, int exc_flag, int fe_flag, const char *flag_name)
 
static void test_exceptions (const char *test_name, int exception)
 
static void check_float_internal (const char *test_name, FLOAT computed, FLOAT expected, FLOAT max_ulp, int xfail, int exceptions, FLOAT *curr_max_error)
 
static void check_float (const char *test_name, FLOAT computed, FLOAT expected, FLOAT max_ulp, int xfail, int exceptions)
 
static void check_int (const char *test_name, int computed, int expected, int max_ulp, int xfail, int exceptions)
 
static void check_long (const char *test_name, long int computed, long int expected, long int max_ulp, int xfail, int exceptions)
 
static void check_bool (const char *test_name, int computed, int expected, long int max_ulp, int xfail, int exceptions)
 
static void check_longlong (const char *test_name, long long int computed, long long int expected, long long int max_ulp, int xfail, int exceptions)
 
static void acos_test (void)
 
static void acosh_test (void)
 
static void asin_test (void)
 
static void asinh_test (void)
 
static void atan_test (void)
 
static void atanh_test (void)
 
static void atan2_test (void)
 
static void cbrt_test (void)
 
static void ceil_test (void)
 
static void copysign_test (void)
 
static void cos_test (void)
 
static void cosh_test (void)
 
static void erf_test (void)
 
static void erfc_test (void)
 
static void exp_test (void)
 
static void exp2_test (void)
 
static void expm1_test (void)
 
static void fabs_test (void)
 
static void fdim_test (void)
 
static void floor_test (void)
 
static void fma_test (void)
 
static void fmax_test (void)
 
static void fmin_test (void)
 
static void fmod_test (void)
 
static void fpclassify_test (void)
 
static void frexp_test (void)
 
static void gamma_test (void)
 
static void hypot_test (void)
 
static void ilogb_test (void)
 
static void isfinite_test (void)
 
static void isnormal_test (void)
 
static void j0_test (void)
 
static void j1_test (void)
 
static void jn_test (void)
 
static void ldexp_test (void)
 
static void lgamma_test (void)
 
static void lrint_test (void)
 
static void llrint_test (void)
 
static void log_test (void)
 
static void log10_test (void)
 
static void log1p_test (void)
 
static void log2_test (void)
 
static void logb_test (void)
 
static void lround_test (void)
 
static void llround_test (void)
 
static void modf_test (void)
 
static void nearbyint_test (void)
 
static void nextafter_test (void)
 
static void pow_test (void)
 
static void remainder_test (void)
 
static void remquo_test (void)
 
static void rint_test (void)
 
static void round_test (void)
 
static void scalbn_test (void)
 
static void scalbln_test (void)
 
static void signbit_test (void)
 
static void sin_test (void)
 
static void sincos_test (void)
 
static void sinh_test (void)
 
static void sqrt_test (void)
 
static void tan_test (void)
 
static void tanh_test (void)
 
static void tgamma_test (void)
 
static void trunc_test (void)
 
static void y0_test (void)
 
static void y1_test (void)
 
static void yn_test (void)
 
static void initialize (void)
 
int main (int argc, char **argv)
 

Variables

static FILEulps_file
 
static int output_ulps
 
static int noErrors
 
static int noTests
 
static int noExcTests
 
static int noXFails
 
static int noXPasses
 
static int verbose
 
static int output_max_error
 
static int output_points
 
static int ignore_max_ulp
 
static FLOAT minus_zero
 
static FLOAT plus_zero
 
static FLOAT plus_infty
 
static FLOAT minus_infty
 
static FLOAT nan_value
 
static FLOAT max_error
 
static FLOAT real_max_error
 
static FLOAT imag_max_error
 

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

◆ DIVIDE_BY_ZERO_EXCEPTION

#define DIVIDE_BY_ZERO_EXCEPTION   0x2

◆ DIVIDE_BY_ZERO_EXCEPTION_OK

#define DIVIDE_BY_ZERO_EXCEPTION_OK   0x8

◆ EXCEPTIONS_OK

◆ gamma

#define gamma   lgamma /* XXX scp XXX */

◆ gammaf

#define gammaf   lgammaf /* XXX scp XXX */

◆ IGNORE_ZERO_INF_SIGN

#define IGNORE_ZERO_INF_SIGN   0x10

◆ INVALID_EXCEPTION

#define INVALID_EXCEPTION   0x1

◆ INVALID_EXCEPTION_OK

#define INVALID_EXCEPTION_OK   0x4

◆ M_1_PIl

#define M_1_PIl   0.3183098861837906715377675267450287L /* 1/pi */

◆ M_2_PIl

#define M_2_PIl   0.6366197723675813430755350534900574L /* 2/pi */

◆ M_2_SQRT_PIl

#define M_2_SQRT_PIl   3.5449077018110320545963349666822903L /* 2 sqrt (M_PIl) */

◆ M_2_SQRTPIl

#define M_2_SQRTPIl   1.1283791670955125738961589031215452L /* 2/sqrt(pi) */

◆ M_E2l

#define M_E2l   7.389056098930650227230427460575008L

◆ M_E3l

#define M_E3l   20.085536923187667740928529654581719L

◆ M_El

#define M_El   2.7182818284590452353602874713526625L /* e */

◆ M_LN10l

#define M_LN10l   2.3025850929940456840179914546843642L /* log_e 10 */

◆ M_LN2l

#define M_LN2l   0.6931471805599453094172321214581766L /* log_e 2 */

◆ M_LOG10El

#define M_LOG10El   0.4342944819032518276511289189166051L /* log_10 e */

◆ M_LOG2El

#define M_LOG2El   1.4426950408889634073599246810018922L /* log_2 e */

◆ M_LOG_2_SQRT_PIl

#define M_LOG_2_SQRT_PIl   1.265512123484645396488945797134706L /* log(2*sqrt(M_PIl)) */

◆ M_LOG_SQRT_PIl

#define M_LOG_SQRT_PIl   0.57236494292470008707171367567652933L /* log(sqrt(M_PIl)) */

◆ M_PI2_LOG10El

#define M_PI2_LOG10El   M_PI_2l * M_LOG10El

◆ M_PI4_LOG10El

#define M_PI4_LOG10El   M_PI_4l * M_LOG10El

◆ M_PI_2l

#define M_PI_2l   1.5707963267948966192313216916397514L /* pi/2 */

◆ M_PI_34_LOG10El

#define M_PI_34_LOG10El   (M_PIl - M_PI_4l) * M_LOG10El

◆ M_PI_34l

#define M_PI_34l   (M_PIl - M_PI_4l) /* 3*pi/4 */

◆ M_PI_4l

#define M_PI_4l   0.7853981633974483096156608458198757L /* pi/4 */

◆ M_PI_6l

#define M_PI_6l   .52359877559829887307710723054658383L

◆ M_PI_LOG10El

#define M_PI_LOG10El   M_PIl * M_LOG10El

◆ M_PIl

#define M_PIl   3.1415926535897932384626433832795029L /* pi */

◆ M_SQRT1_2l

#define M_SQRT1_2l   0.7071067811865475244008443621048490L /* 1/sqrt(2) */

◆ M_SQRT2l

#define M_SQRT2l   1.4142135623730950488016887242096981L /* sqrt(2) */

◆ M_SQRT_PIl

#define M_SQRT_PIl   1.7724538509055160272981674833411451L /* sqrt (M_PIl) */

◆ MANT_DIG

#define MANT_DIG
Value:
#define CHOOSE(Clongdouble, Cdouble, Cfloat, Cinlinelongdouble, Cinlinedouble, Cinlinefloat)
Definition: test-double.c:24
#define DBL_MANT_DIG
Definition: test_suite.cpp:41
#define FLT_MANT_DIG
Definition: test_suite.cpp:26
#define LDBL_MANT_DIG
Definition: _float.h:15

◆ NO_EXCEPTION

#define NO_EXCEPTION   0x0

Function Documentation

◆ acos_test()

static void acos_test ( void  )
static

◆ acosh_test()

static void acosh_test ( void  )
static

◆ asin_test()

static void asin_test ( void  )
static

◆ asinh_test()

static void asinh_test ( void  )
static

◆ atan2_test()

static void atan2_test ( void  )
static

◆ atan_test()

static void atan_test ( void  )
static

◆ atanh_test()

static void atanh_test ( void  )
static

◆ cbrt_test()

static void cbrt_test ( void  )
static

◆ ceil_test()

static void ceil_test ( void  )
static

◆ check_bool()

static void check_bool ( const char *  test_name,
int  computed,
int  expected,
long int  max_ulp,
int  xfail,
int  exceptions 
)
static

◆ check_float()

static void check_float ( const char *  test_name,
FLOAT  computed,
FLOAT  expected,
FLOAT  max_ulp,
int  xfail,
int  exceptions 
)
static

◆ check_float_internal()

static void check_float_internal ( const char *  test_name,
FLOAT  computed,
FLOAT  expected,
FLOAT  max_ulp,
int  xfail,
int  exceptions,
FLOAT curr_max_error 
)
static

◆ check_int()

static void check_int ( const char *  test_name,
int  computed,
int  expected,
int  max_ulp,
int  xfail,
int  exceptions 
)
static

◆ check_long()

static void check_long ( const char *  test_name,
long int  computed,
long int  expected,
long int  max_ulp,
int  xfail,
int  exceptions 
)
static

◆ check_longlong()

static void check_longlong ( const char *  test_name,
long long int  computed,
long long int  expected,
long long int  max_ulp,
int  xfail,
int  exceptions 
)
static

◆ copysign_test()

static void copysign_test ( void  )
static

◆ cos_test()

static void cos_test ( void  )
static

◆ cosh_test()

static void cosh_test ( void  )
static

◆ erf_test()

static void erf_test ( void  )
static

◆ erfc_test()

static void erfc_test ( void  )
static

◆ exp2_test()

static void exp2_test ( void  )
static

◆ exp_test()

static void exp_test ( void  )
static

◆ expm1_test()

static void expm1_test ( void  )
static

◆ fabs_test()

static void fabs_test ( void  )
static

◆ fdim_test()

static void fdim_test ( void  )
static

◆ floor_test()

static void floor_test ( void  )
static

◆ fma_test()

static void fma_test ( void  )
static

◆ fmax_test()

static void fmax_test ( void  )
static

◆ fmin_test()

static void fmin_test ( void  )
static

◆ fmod_test()

static void fmod_test ( void  )
static

◆ fpclassify_test()

static void fpclassify_test ( void  )
static

◆ frexp_test()

static void frexp_test ( void  )
static

◆ gamma_test()

static void gamma_test ( void  )
static

◆ hypot_test()

static void hypot_test ( void  )
static

◆ ilogb_test()

static void ilogb_test ( void  )
static

◆ init_max_error()

static void init_max_error ( void  )
static

◆ initialize()

static void initialize ( void  )
static

◆ isfinite_test()

static void isfinite_test ( void  )
static

◆ isnormal_test()

static void isnormal_test ( void  )
static

◆ j0_test()

static void j0_test ( void  )
static

◆ j1_test()

static void j1_test ( void  )
static

◆ jn_test()

static void jn_test ( void  )
static

◆ ldexp_test()

static void ldexp_test ( void  )
static

◆ lgamma_test()

static void lgamma_test ( void  )
static

◆ llrint_test()

static void llrint_test ( void  )
static

◆ llround_test()

static void llround_test ( void  )
static

◆ log10_test()

static void log10_test ( void  )
static

◆ log1p_test()

static void log1p_test ( void  )
static

◆ log2_test()

static void log2_test ( void  )
static

◆ log_test()

static void log_test ( void  )
static

◆ logb_test()

static void logb_test ( void  )
static

◆ lrint_test()

static void lrint_test ( void  )
static

◆ lround_test()

static void lround_test ( void  )
static

◆ main()

int main ( int  argc,
char **  argv 
)

◆ modf_test()

static void modf_test ( void  )
static

◆ nearbyint_test()

static void nearbyint_test ( void  )
static

◆ nextafter_test()

static void nextafter_test ( void  )
static

◆ pow_test()

static void pow_test ( void  )
static

◆ print_function_ulps()

static void print_function_ulps ( const char *  function_name,
FLOAT  ulp 
)
static

◆ print_max_error()

static void print_max_error ( const char *  func_name,
FLOAT  allowed,
int  xfail 
)
static

◆ print_screen()

static int print_screen ( int  ok,
int  xfail 
)
static

◆ print_screen_max_error()

static int print_screen_max_error ( int  ok,
int  xfail 
)
static

References output_max_error, and verbose.

Referenced by print_max_error().

◆ print_ulps()

static void print_ulps ( const char *  test_name,
FLOAT  ulp 
)
static

◆ remainder_test()

static void remainder_test ( void  )
static

◆ remquo_test()

static void remquo_test ( void  )
static

◆ rint_test()

static void rint_test ( void  )
static

◆ round_test()

static void round_test ( void  )
static

◆ scalbln_test()

static void scalbln_test ( void  )
static

◆ scalbn_test()

static void scalbn_test ( void  )
static

◆ set_max_error()

static void set_max_error ( FLOAT  current,
FLOAT curr_max_error 
)
static

Referenced by check_float_internal().

◆ signbit_test()

static void signbit_test ( void  )
static

◆ sin_test()

static void sin_test ( void  )
static

◆ sincos()

void FUNC() sincos ( FLOAT  x,
FLOAT s,
FLOAT c 
)

◆ sincos_test()

static void sincos_test ( void  )
static

◆ sinh_test()

static void sinh_test ( void  )
static

◆ sqrt_test()

static void sqrt_test ( void  )
static

◆ tan_test()

static void tan_test ( void  )
static

◆ tanh_test()

static void tanh_test ( void  )
static

◆ test_exceptions()

static void test_exceptions ( const char *  test_name,
int  exception 
)
static

◆ test_single_exception()

static void test_single_exception ( const char *  test_name,
int  exception,
int  exc_flag,
int  fe_flag,
const char *  flag_name 
)
static

References fetestexcept(), noErrors, print_screen(), and printf.

Referenced by test_exceptions().

◆ tgamma_test()

static void tgamma_test ( void  )
static

◆ trunc_test()

static void trunc_test ( void  )
static

◆ update_stats()

static void update_stats ( int  ok,
int  xfail 
)
static

◆ y0_test()

static void y0_test ( void  )
static

◆ y1_test()

static void y1_test ( void  )
static

◆ yn_test()

static void yn_test ( void  )
static

Variable Documentation

◆ ignore_max_ulp

int ignore_max_ulp
static

◆ imag_max_error

FLOAT imag_max_error
static

Referenced by init_max_error().

◆ max_error

FLOAT max_error
static

◆ minus_infty

FLOAT minus_infty
static

◆ minus_zero

FLOAT minus_zero
static

◆ nan_value

FLOAT nan_value
static

◆ noErrors

int noErrors
static

◆ noExcTests

int noExcTests
static

Referenced by main(), and test_exceptions().

◆ noTests

int noTests
static

◆ noXFails

int noXFails
static

Referenced by main(), and update_stats().

◆ noXPasses

int noXPasses
static

Referenced by main(), and update_stats().

◆ output_max_error

int output_max_error
static

Referenced by main(), and print_screen_max_error().

◆ output_points

int output_points
static

Referenced by main(), and print_screen().

◆ output_ulps

int output_ulps
static

◆ plus_infty

FLOAT plus_infty
static

◆ plus_zero

FLOAT plus_zero
static

Referenced by fpclassify_test(), and initialize().

◆ real_max_error

FLOAT real_max_error
static

Referenced by init_max_error().

◆ ulps_file

FILE* ulps_file
static

◆ verbose

int verbose
static