1 /* 2 * PROJECT: ReactOS CRT library 3 * LICENSE: MIT (https://spdx.org/licenses/MIT) 4 * PURPOSE: Implementation of _handle_error / _handle_errorf for libm 5 * COPYRIGHT: Copyright 2022 Timo Kreuzer <timo.kreuzer@reactos.org> 6 */ 7 8 #include <math.h> 9 10 int 11 __cdecl 12 _invoke_matherr( 13 int type, 14 char* name, 15 double arg1, 16 double arg2, 17 double retval); 18 19 /*! 20 * @brief Handles an error condition. 21 * @param fname - The name of the function that caused the error. 22 * @param opcode - Opcode of the function that cause the error (see OP_* consants in fpieee.h). 23 * @param value - The value to be returned, encoded as uint64_t. 24 * @param type - The type of error (see _DOMAIN, ... in math.h) 25 * @param flags - Exception flags (see AMD_F_* constants). 26 * @param error - Specifies the CRT error code (EDOM, ...). 27 * @param arg1 - First parameter to the function that cause the error. 28 * @param arg2 - Second parameter to the function that cause the error. 29 * @param nargs - Number of parameters to the function that cause the error. 30 * @return The value to be returned. 31 */ 32 double 33 __cdecl 34 _handle_error( 35 char *fname, 36 int opcode, 37 unsigned long long value, 38 int type, 39 int flags, 40 int error, 41 double arg1, 42 double arg2, 43 int nargs) 44 { 45 float retval = *(double*)&value; 46 47 _invoke_matherr(type, fname, arg1, arg2, retval); 48 49 return retval; 50 } 51 52 53 54 float 55 __cdecl 56 _handle_errorf( 57 char *fname, 58 int opcode, 59 unsigned long long value, 60 int type, 61 int flags, 62 int error, 63 float arg1, 64 float arg2, 65 int nargs) 66 { 67 float retval = *(float*)&value; 68 69 _invoke_matherr(type, fname, arg1, arg2, retval); 70 71 return retval; 72 } 73