ldouble_wrappers.c 8.9 KB

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