ldouble_wrappers.c 8.8 KB

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