ldouble_wrappers.c 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Wrapper functions implementing all the long double math functions
  4. * defined by SuSv3 by actually calling the double version of
  5. * each function and then casting the result back to a long double
  6. * to return to the user.
  7. *
  8. * Copyright (C) 2005 by Erik Andersen <andersen@uclibc.org>
  9. *
  10. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  11. */
  12. #include <features.h>
  13. /* Prevent math.h from defining colliding inlines */
  14. #undef __USE_EXTERN_INLINES
  15. #include "math.h"
  16. #include <complex.h>
  17. /* Implement the following, as defined by SuSv3 */
  18. #if 0
  19. long double acoshl(long double);
  20. long double acosl(long double);
  21. long double asinhl(long double);
  22. long double asinl(long double);
  23. long double atan2l(long double, long double);
  24. long double atanhl(long double);
  25. long double atanl(long double);
  26. long double cargl(long double complex);
  27. long double cbrtl(long double);
  28. long double ceill(long double);
  29. long double copysignl(long double, long double);
  30. long double coshl(long double);
  31. long double cosl(long double);
  32. long double erfcl(long double);
  33. long double erfl(long double);
  34. long double exp2l(long double);
  35. long double expl(long double);
  36. long double expm1l(long double);
  37. long double fabsl(long double);
  38. long double fdiml(long double, long double);
  39. long double floorl(long double);
  40. long double fmal(long double, long double, long double);
  41. long double fmaxl(long double, long double);
  42. long double fminl(long double, long double);
  43. long double fmodl(long double, long double);
  44. long double frexpl(long double value, int *);
  45. long double hypotl(long double, long double);
  46. int ilogbl(long double);
  47. long double ldexpl(long double, int);
  48. long double lgammal(long double);
  49. long long llrintl(long double);
  50. long long llroundl(long double);
  51. long double log10l(long double);
  52. long double log1pl(long double);
  53. long double log2l(long double);
  54. long double logbl(long double);
  55. long double logl(long double);
  56. long lrintl(long double);
  57. long lroundl(long double);
  58. long double modfl(long double, long double *);
  59. long double nearbyintl(long double);
  60. long double nextafterl(long double, long double);
  61. long double nexttowardl(long double, long double);
  62. long double powl(long double, long double);
  63. long double remainderl(long double, long double);
  64. long double remquol(long double, long double, int *);
  65. long double rintl(long double);
  66. long double roundl(long double);
  67. long double scalblnl(long double, long);
  68. long double scalbnl(long double, int);
  69. long double sinhl(long double);
  70. long double sinl(long double);
  71. long double sqrtl(long double);
  72. long double tanhl(long double);
  73. long double tanl(long double);
  74. long double tgammal(long double);
  75. long double truncl(long double);
  76. #endif
  77. #ifdef L_acoshl
  78. long double acoshl (long double x)
  79. {
  80. return (long double) acosh( (double)x );
  81. }
  82. #endif
  83. #ifdef L_acosl
  84. long double acosl (long double x)
  85. {
  86. return (long double) acos( (double)x );
  87. }
  88. #endif
  89. #ifdef L_asinhl
  90. long double asinhl (long double x)
  91. {
  92. return (long double) asinh( (double)x );
  93. }
  94. #endif
  95. #ifdef L_asinl
  96. long double asinl (long double x)
  97. {
  98. return (long double) asin( (double)x );
  99. }
  100. #endif
  101. #ifdef L_atan2l
  102. long double atan2l (long double x, long double y)
  103. {
  104. return (long double) atan2( (double)x, (double)y );
  105. }
  106. #endif
  107. #ifdef L_atanhl
  108. long double atanhl (long double x)
  109. {
  110. return (long double) atanh( (double)x );
  111. }
  112. #endif
  113. #ifdef L_atanl
  114. long double atanl (long double x)
  115. {
  116. return (long double) atan( (double)x );
  117. }
  118. #endif
  119. #ifdef L_cargl
  120. long double cargl (long double complex x)
  121. {
  122. return (long double) carg( (double complex)x );
  123. }
  124. #endif
  125. #ifdef L_cbrtl
  126. long double cbrtl (long double x)
  127. {
  128. return (long double) cbrt( (double)x );
  129. }
  130. #endif
  131. #ifdef L_ceill
  132. long double ceill (long double x)
  133. {
  134. return (long double) ceil( (double)x );
  135. }
  136. #endif
  137. #ifdef L_copysignl
  138. long double copysignl (long double x, long double y)
  139. {
  140. return (long double) copysign( (double)x, (double)y );
  141. }
  142. #endif
  143. #ifdef L_coshl
  144. long double coshl (long double x)
  145. {
  146. return (long double) cosh( (double)x );
  147. }
  148. #endif
  149. #ifdef L_cosl
  150. long double cosl (long double x)
  151. {
  152. return (long double) cos( (double)x );
  153. }
  154. #endif
  155. #ifdef L_erfcl
  156. long double erfcl (long double x)
  157. {
  158. return (long double) erfc( (double)x );
  159. }
  160. #endif
  161. #ifdef L_erfl
  162. long double erfl (long double x)
  163. {
  164. return (long double) erf( (double)x );
  165. }
  166. #endif
  167. #ifdef L_exp2l
  168. long double exp2l (long double x)
  169. {
  170. return (long double) exp2( (double)x );
  171. }
  172. #endif
  173. #ifdef L_expl
  174. long double expl (long double x)
  175. {
  176. return (long double) exp( (double)x );
  177. }
  178. #endif
  179. #ifdef L_expm1l
  180. long double expm1l (long double x)
  181. {
  182. return (long double) expm1( (double)x );
  183. }
  184. #endif
  185. #ifdef L_fabsl
  186. long double fabsl (long double x)
  187. {
  188. return (long double) fabs( (double)x );
  189. }
  190. #endif
  191. #ifdef L_fdiml
  192. long double fdiml (long double x, long double y)
  193. {
  194. return (long double) fdim( (double)x, (double)y );
  195. }
  196. #endif
  197. #ifdef L_floorl
  198. long double floorl (long double x)
  199. {
  200. return (long double) floor( (double)x );
  201. }
  202. #endif
  203. #ifdef L_fmal
  204. long double fmal (long double x, long double y, long double z)
  205. {
  206. return (long double) fma( (double)x, (double)y, (double)z );
  207. }
  208. #endif
  209. #ifdef L_fmaxl
  210. long double fmaxl (long double x, long double y)
  211. {
  212. return (long double) fmax( (double)x, (double)y );
  213. }
  214. #endif
  215. #ifdef L_fminl
  216. long double fminl (long double x, long double y)
  217. {
  218. return (long double) fmin( (double)x, (double)y );
  219. }
  220. #endif
  221. #ifdef L_fmodl
  222. long double fmodl (long double x, long double y)
  223. {
  224. return (long double) fmod( (double)x, (double)y );
  225. }
  226. #endif
  227. #ifdef L_frexpl
  228. long double frexpl (long double x, int *exp)
  229. {
  230. return (long double) frexp( (double)x, exp );
  231. }
  232. #endif
  233. #ifdef L_hypotl
  234. long double hypotl (long double x, long double y)
  235. {
  236. return (long double) hypot( (double)x, (double)y );
  237. }
  238. #endif
  239. #ifdef L_ilogbl
  240. int ilogbl (long double x)
  241. {
  242. return (long double) ilogb( (double)x );
  243. }
  244. #endif
  245. #ifdef L_ldexpl
  246. long double ldexpl (long double x, int exp)
  247. {
  248. return (long double) ldexp( (double)x, exp );
  249. }
  250. #endif
  251. #ifdef L_lgammal
  252. long double lgammal (long double x)
  253. {
  254. return (long double) lgamma( (double)x );
  255. }
  256. #endif
  257. #ifdef L_llrintl
  258. long long llrintl (long double x)
  259. {
  260. return (long double) llrint( (double)x );
  261. }
  262. #endif
  263. #ifdef L_llroundl
  264. long long llroundl (long double x)
  265. {
  266. return (long double) llround( (double)x );
  267. }
  268. #endif
  269. #ifdef L_log10l
  270. long double log10l (long double x)
  271. {
  272. return (long double) log10( (double)x );
  273. }
  274. #endif
  275. #ifdef L_log1pl
  276. long double log1pl (long double x)
  277. {
  278. return (long double) log1p( (double)x );
  279. }
  280. #endif
  281. #ifdef L_log2l
  282. long double log2l (long double x)
  283. {
  284. return (long double) log2( (double)x );
  285. }
  286. #endif
  287. #ifdef L_logbl
  288. long double logbl (long double x)
  289. {
  290. return (long double) logb( (double)x );
  291. }
  292. #endif
  293. #ifdef L_logl
  294. long double logl (long double x)
  295. {
  296. return (long double) log( (double)x );
  297. }
  298. #endif
  299. #ifdef L_lrintl
  300. long lrintl (long double x)
  301. {
  302. return (long double) lrint( (double)x );
  303. }
  304. #endif
  305. #ifdef L_lroundl
  306. long lroundl (long double x)
  307. {
  308. return (long double) lround( (double)x );
  309. }
  310. #endif
  311. #ifdef L_modfl
  312. long double modfl (long double x, long double *iptr)
  313. {
  314. double y, result;
  315. result = modf ( x, &y );
  316. *iptr = (long double)y;
  317. return (long double) result;
  318. }
  319. #endif
  320. #ifdef L_nearbyintl
  321. long double nearbyintl (long double x)
  322. {
  323. return (long double) nearbyint( (double)x );
  324. }
  325. #endif
  326. #ifdef L_nextafterl
  327. long double nextafterl (long double x, long double y)
  328. {
  329. return (long double) nextafter( (double)x, (double)y );
  330. }
  331. #endif
  332. #ifdef L_nexttowardl
  333. long double nexttowardl (long double x, long double y)
  334. {
  335. return (long double) nexttoward( (double)x, (double)y );
  336. }
  337. #endif
  338. #ifdef L_powl
  339. long double powl (long double x, long double y)
  340. {
  341. return (long double) pow( (double)x, (double)y );
  342. }
  343. #endif
  344. #ifdef L_remainderl
  345. long double remainderl (long double x, long double y)
  346. {
  347. return (long double) remainder( (double)x, (double)y );
  348. }
  349. #endif
  350. #ifdef L_remquol
  351. long double remquol (long double x, long double y, int *quo)
  352. {
  353. return (long double) remquo( (double)x, (double)y, quo );
  354. }
  355. #endif
  356. #ifdef L_rintl
  357. long double rintl (long double x)
  358. {
  359. return (long double) rint( (double)x );
  360. }
  361. #endif
  362. #ifdef L_roundl
  363. long double roundl (long double x)
  364. {
  365. return (long double) round( (double)x );
  366. }
  367. #endif
  368. #ifdef L_scalblnl
  369. long double scalblnl (long double x, long exp)
  370. {
  371. return (long double) scalbln( (double)x, exp );
  372. }
  373. #endif
  374. #ifdef L_scalbnl
  375. long double scalbnl (long double x, int exp)
  376. {
  377. return (long double) scalbn( (double)x, exp );
  378. }
  379. #endif
  380. #ifdef L_sinhl
  381. long double sinhl (long double x)
  382. {
  383. return (long double) sinh( (double)x );
  384. }
  385. #endif
  386. #ifdef L_sinl
  387. long double sinl (long double x)
  388. {
  389. return (long double) sin( (double)x );
  390. }
  391. #endif
  392. #ifdef L_sqrtl
  393. long double sqrtl (long double x)
  394. {
  395. return (long double) sqrt( (double)x );
  396. }
  397. #endif
  398. #ifdef L_tanhl
  399. long double tanhl (long double x)
  400. {
  401. return (long double) tanh( (double)x );
  402. }
  403. #endif
  404. #ifdef L_tanl
  405. long double tanl (long double x)
  406. {
  407. return (long double) tan( (double)x );
  408. }
  409. #endif
  410. #ifdef L_tgammal
  411. long double tgammal (long double x)
  412. {
  413. return (long double) tgamma( (double)x );
  414. }
  415. #endif
  416. #ifdef L_truncl
  417. long double truncl (long double x)
  418. {
  419. return (long double) trunc( (double)x );
  420. }
  421. #endif
  422. #ifdef __DO_C99_MATH__
  423. #ifdef L_fpclassifyl
  424. int __fpclassifyl (long double x)
  425. {
  426. return __fpclassify ( (double) x );
  427. }
  428. libm_hidden_def(__fpclassifyl)
  429. #endif
  430. #ifdef L_finitel
  431. int __finitel (long double x)
  432. {
  433. return __finite ( (double)x );
  434. }
  435. libm_hidden_def(__finitel)
  436. #endif
  437. #ifdef L_signbitl
  438. int __signbitl (long double x)
  439. {
  440. return __signbitl ( (double)x );
  441. }
  442. libm_hidden_def(__signbitl)
  443. #endif
  444. #ifdef L_isnanl
  445. int __isnanl (long double x)
  446. {
  447. return __isnan ( (double)x );
  448. }
  449. libm_hidden_def(__isnanl)
  450. #endif
  451. #ifdef L_isinfl
  452. int __isinfl (long double x)
  453. {
  454. return __isinf ( (double)x );
  455. }
  456. libm_hidden_def(__isinfl)
  457. #endif
  458. #endif