Changeset 84929b0 in mainline for uspace/lib/math/generic/__fcompare.c
- Timestamp:
- 2018-08-29T20:06:00Z (6 years ago)
- Children:
- ed9043f7
- Parents:
- 184ff675
- git-author:
- Jiří Zárevúcky <jiri.zarevucky@…> (2018-08-29 19:44:33)
- git-committer:
- Jiří Zárevúcky <jiri.zarevucky@…> (2018-08-29 20:06:00)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/math/generic/__fcompare.c
r184ff675 r84929b0 1 1 /* 2 * Copyright (c) 201 1 Petr Koupy2 * Copyright (c) 2018 CZ.NIC, z.s.p.o. 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup libposix 30 * @{ 29 #include <math.h> 30 #include <stdarg.h> 31 32 /** 33 * Fallback symbol used when code including <math.h> is compiled with something 34 * other than GCC or Clang. The function itself must be built with GCC or Clang. 31 35 */ 32 /** @file Mathematical operations. 33 * 34 * The purpose of this file is only to provide prototypes of mathematical 35 * functions defined by C standard and by POSIX. 36 * 37 * It is up to the application to correctly link with either libmath 38 * (provided by HelenOS) or by some other math library (such as fdlibm). 39 */ 36 int __fcompare(size_t sz1, size_t sz2, ...) 37 { 38 va_list ap; 39 va_start(ap, sz2); 40 40 41 #ifndef POSIX_MATH_H_ 42 #define POSIX_MATH_H_ 41 long double val1; 42 long double val2; 43 43 44 #ifdef __GNUC__ 45 #define HUGE_VAL (__builtin_huge_val()) 46 #endif 44 switch (sz1) { 45 case 4: 46 val1 = (long double) va_arg(ap, double); 47 break; 48 case 8: 49 val1 = (long double) va_arg(ap, double); 50 break; 51 default: 52 val1 = va_arg(ap, long double); 53 break; 54 } 47 55 48 extern double ldexp(double, int); 49 extern double frexp(double, int *); 56 switch (sz2) { 57 case 4: 58 val2 = (long double) va_arg(ap, double); 59 break; 60 case 8: 61 val2 = (long double) va_arg(ap, double); 62 break; 63 default: 64 val2 = va_arg(ap, long double); 65 break; 66 } 50 67 51 extern double fabs(double); 52 extern double floor(double); 53 extern double ceil(double); 54 extern double modf(double, double *); 55 extern double fmod(double, double); 56 extern double pow(double, double); 57 extern double exp(double); 58 extern double frexp(double, int *); 59 extern double expm1(double); 60 extern double sqrt(double); 61 extern double log(double); 62 extern double log10(double); 63 extern double sin(double); 64 extern double sinh(double); 65 extern double asin(double); 66 extern double asinh(double); 67 extern double cos(double); 68 extern double cosh(double); 69 extern double acos(double); 70 extern double acosh(double); 71 extern double tan(double); 72 extern double tanh(double); 73 extern double atan(double); 74 extern double atanh(double); 75 extern double atan2(double, double); 76 extern double copysign(double, double); 68 va_end(ap); 77 69 78 #endif /* POSIX_MATH_H_ */ 70 if (isgreaterequal(val1, val2)) { 71 if (isgreater(val1, val2)) 72 return __FCOMPARE_GREATER; 73 else 74 return __FCOMPARE_EQUAL; 75 } else { 76 if (isless(val1, val2)) 77 return __FCOMPARE_LESS; 78 else 79 return 0; 80 } 81 } 79 82 80 /** @}81 */
Note:
See TracChangeset
for help on using the changeset viewer.