File indexing completed on 2025-05-11 08:24:37
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #ifdef HAVE_CONFIG_H
0035 #include "config.h"
0036 #endif
0037
0038
0039
0040 #include <errno.h>
0041 #include <limits.h>
0042 #include <math.h>
0043 #include <fenv.h> /* contains declarations of fenv methods */
0044 #include <stddef.h>
0045 #include <stdint.h>
0046 #include <stdio.h>
0047 #include <string.h>
0048 #include <rtems/test-info.h>
0049 #include <tmacros.h>
0050 #include <float.h>
0051
0052 const char rtems_test_name[] = "PSXFENV 01";
0053
0054
0055 rtems_task Init( rtems_task_argument ignored );
0056
0057
0058 rtems_task Init(rtems_task_argument ignored)
0059 {
0060 double a, b, c;
0061 int r;
0062 fexcept_t excepts;
0063 TEST_BEGIN();
0064
0065
0066
0067
0068
0069
0070
0071 #ifdef FE_ALL_EXCEPT
0072 r = fesetenv( FE_DFL_ENV );
0073 if ( r ) {
0074 printf( "fesetenv ==> %d\n", r);
0075 }
0076 rtems_test_assert( r == 0 );
0077
0078
0079 r = feclearexcept( FE_ALL_EXCEPT );
0080 if ( r ) {
0081 printf( "feclearexcept ==> 0x%x\n", r );
0082 }
0083 rtems_test_assert( r == 0 );
0084
0085 r = fetestexcept( FE_ALL_EXCEPT );
0086 if ( r ) {
0087 printf( "fetestexcept ==> 0x%x\n", r );
0088 }
0089 rtems_test_assert( r == 0 );
0090
0091
0092
0093 a = 0.0;
0094 b = 1.0;
0095 c = b/a;
0096 (void) c;
0097
0098 r = fegetexceptflag( &excepts, FE_ALL_EXCEPT );
0099 if ( r ) {
0100 printf( "fegetexceptflag ==> 0x%x\n", r );
0101 }
0102 rtems_test_assert( r == 0 );
0103
0104 r = fesetexceptflag( &excepts, FE_ALL_EXCEPT );
0105 if ( r ) {
0106 printf( "fesetexceptflag ==> 0x%x\n", r );
0107 }
0108 rtems_test_assert( r == 0 );
0109
0110
0111
0112
0113
0114 #ifdef FE_TONEAREST
0115 rtems_test_assert( fegetround() == FE_TONEAREST );
0116 #endif
0117 #ifdef FE_TOWARDZERO
0118 r = fesetround( FE_TOWARDZERO );
0119 if ( r ) {
0120 printf( "fesetround ==> 0x%x\n", r );
0121 }
0122 rtems_test_assert( r == 0 );
0123 rtems_test_assert( fegetround() == FE_TOWARDZERO );
0124 #endif
0125 #ifdef FE_DOWNWARD
0126 r = fesetround( FE_DOWNWARD );
0127 if ( r ) {
0128 printf( "fesetround ==> 0x%x\n", r );
0129 }
0130 rtems_test_assert( r == 0 );
0131 rtems_test_assert( fegetround() == FE_DOWNWARD );
0132 #endif
0133 #ifdef FE_UPWARD
0134 r = fesetround( FE_UPWARD );
0135 if ( r ) {
0136 printf( "fesetround ==> 0x%x\n", r );
0137 }
0138 rtems_test_assert( r == 0 );
0139 rtems_test_assert( fegetround() == FE_UPWARD );
0140 #endif
0141 #ifdef FE_TONEAREST
0142 r = fesetround( FE_TONEAREST );
0143 if ( r ) {
0144 printf( "fesetround ==> 0x%x\n", r );
0145 }
0146 rtems_test_assert( r == 0 );
0147 #endif
0148
0149 #ifdef FE_DIVBYZERO
0150 r = feraiseexcept( FE_DIVBYZERO ) ;
0151 rtems_test_assert( fetestexcept( FE_DIVBYZERO ) );
0152 #endif
0153
0154
0155 a = 10.0;
0156 c = b/a;
0157
0158 #endif
0159
0160 TEST_END();
0161 rtems_test_exit(0);
0162 }
0163
0164
0165
0166 #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
0167 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
0168
0169 #define CONFIGURE_MAXIMUM_TASKS 1
0170
0171 #define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 6
0172
0173 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
0174
0175 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
0176
0177 #define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
0178
0179 #define CONFIGURE_INIT
0180 #include <rtems/confdefs.h>
0181