float_wrappers.c 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Wrapper functions implementing all the float math functions
  4. * defined by SuSv3 by actually calling the double version of
  5. * each function and then casting the result back to a float
  6. * to return to the user.
  7. *
  8. * Copyright (C) 2005 by Erik Andersen <andersen@uclibc.org>
  9. *
  10. * GNU Lesser General Public License version 2.1 or later.
  11. */
  12. #include "math.h"
  13. /* For the time being, do _NOT_ implement these functions
  14. * that are defined by SuSv3 */
  15. #undef L_exp2f /*float exp2f(float);*/
  16. #undef L_fdimf /*float fdimf(float, float);*/
  17. #undef L_fmaf /*float fmaf(float, float, float);*/
  18. #undef L_fmaxf /*float fmaxf(float, float);*/
  19. #undef L_fminf /*float fminf(float, float);*/
  20. #undef L_llrintf /*long long llrintf(float);*/
  21. #undef L_log2f /*float log2f(float);*/
  22. #undef L_lrintf /*long lrintf(float);*/
  23. #undef L_nearbyintf /*float nearbyintf(float);*/
  24. #undef L_nexttowardf /*float nexttowardf(float, long double);*/
  25. #undef L_remquof /*float remquof(float, float, int *);*/
  26. #undef L_scalblnf /*float scalblnf(float, long);*/
  27. #undef L_tgammaf /*float tgammaf(float);*/
  28. #undef L_truncf /*float truncf(float);*/
  29. /* Implement the following, as defined by SuSv3 */
  30. #if 0
  31. float acosf(float);
  32. float acoshf(float);
  33. float asinf(float);
  34. float asinhf(float);
  35. float atan2f(float, float);
  36. float atanf(float);
  37. float atanhf(float);
  38. float cbrtf(float);
  39. float ceilf(float);
  40. float copysignf(float, float);
  41. float cosf(float);
  42. float coshf(float);
  43. float erfcf(float);
  44. float erff(float);
  45. float expf(float);
  46. float expm1f(float);
  47. float fabsf(float);
  48. float floorf(float);
  49. float fmodf(float, float);
  50. float frexpf(float value, int *);
  51. float hypotf(float, float);
  52. int ilogbf(float);
  53. float ldexpf(float, int);
  54. float lgammaf(float);
  55. long long llroundf(float);
  56. float log10f(float);
  57. float log1pf(float);
  58. float logbf(float);
  59. float logf(float);
  60. long lroundf(float);
  61. float modff(float, float *);
  62. float nextafterf(float, float);
  63. float powf(float, float);
  64. float remainderf(float, float);
  65. float rintf(float);
  66. float roundf(float);
  67. float scalbnf(float, int);
  68. float sinf(float);
  69. float sinhf(float);
  70. float sqrtf(float);
  71. float tanf(float);
  72. float tanhf(float);
  73. #endif
  74. #ifdef L_acosf
  75. libm_hidden_proto(acos)
  76. float acosf (float x)
  77. {
  78. return (float) acos( (double)x );
  79. }
  80. #endif
  81. #ifdef L_acoshf
  82. libm_hidden_proto(acosh)
  83. float acoshf (float x)
  84. {
  85. return (float) acosh( (double)x );
  86. }
  87. #endif
  88. #ifdef L_asinf
  89. libm_hidden_proto(asin)
  90. float asinf (float x)
  91. {
  92. return (float) asin( (double)x );
  93. }
  94. #endif
  95. #ifdef L_asinhf
  96. libm_hidden_proto(asinh)
  97. float asinhf (float x)
  98. {
  99. return (float) asinh( (double)x );
  100. }
  101. #endif
  102. #ifdef L_atan2f
  103. libm_hidden_proto(atan2)
  104. float atan2f (float x, float y)
  105. {
  106. return (float) atan2( (double)x, (double)y );
  107. }
  108. #endif
  109. #ifdef L_atanf
  110. libm_hidden_proto(atan)
  111. float atanf (float x)
  112. {
  113. return (float) atan( (double)x );
  114. }
  115. #endif
  116. #ifdef L_atanhf
  117. libm_hidden_proto(atanh)
  118. float atanhf (float x)
  119. {
  120. return (float) atanh( (double)x );
  121. }
  122. #endif
  123. #ifdef L_cbrtf
  124. libm_hidden_proto(cbrt)
  125. float cbrtf (float x)
  126. {
  127. return (float) cbrt( (double)x );
  128. }
  129. #endif
  130. #ifdef L_ceilf
  131. libm_hidden_proto(ceil)
  132. float ceilf (float x)
  133. {
  134. return (float) ceil( (double)x );
  135. }
  136. #endif
  137. #ifdef L_copysignf
  138. libm_hidden_proto(copysign)
  139. float copysignf (float x, float y)
  140. {
  141. return (float) copysign( (double)x, (double)y );
  142. }
  143. #endif
  144. #ifdef L_cosf
  145. libm_hidden_proto(cos)
  146. float cosf (float x)
  147. {
  148. return (float) cos( (double)x );
  149. }
  150. #endif
  151. #ifdef L_coshf
  152. libm_hidden_proto(cosh)
  153. float coshf (float x)
  154. {
  155. return (float) cosh( (double)x );
  156. }
  157. #endif
  158. #ifdef L_erfcf
  159. libm_hidden_proto(erfc)
  160. float erfcf (float x)
  161. {
  162. return (float) erfc( (double)x );
  163. }
  164. #endif
  165. #ifdef L_erff
  166. libm_hidden_proto(erf)
  167. float erff (float x)
  168. {
  169. return (float) erf( (double)x );
  170. }
  171. #endif
  172. #ifdef L_exp2f
  173. libm_hidden_proto(exp2)
  174. float exp2f (float x)
  175. {
  176. return (float) exp2( (double)x );
  177. }
  178. #endif
  179. #ifdef L_expf
  180. libm_hidden_proto(exp)
  181. float expf (float x)
  182. {
  183. return (float) exp( (double)x );
  184. }
  185. #endif
  186. #ifdef L_expm1f
  187. libm_hidden_proto(expm1)
  188. float expm1f (float x)
  189. {
  190. return (float) expm1( (double)x );
  191. }
  192. #endif
  193. #ifdef L_fabsf
  194. libm_hidden_proto(fabs)
  195. float fabsf (float x)
  196. {
  197. return (float) fabs( (double)x );
  198. }
  199. #endif
  200. #ifdef L_fdimf
  201. libm_hidden_proto(fdim)
  202. float fdimf (float x, float y)
  203. {
  204. return (float) fdim( (double)x, (double)y );
  205. }
  206. #endif
  207. #ifdef L_floorf
  208. libm_hidden_proto(floor)
  209. float floorf (float x)
  210. {
  211. return (float) floor( (double)x );
  212. }
  213. #endif
  214. #ifdef L_fmaf
  215. libm_hidden_proto(fma)
  216. float fmaf (float x, float y, float z)
  217. {
  218. return (float) fma( (double)x, (double)y, (double)z );
  219. }
  220. #endif
  221. #ifdef L_fmaxf
  222. libm_hidden_proto(fmax)
  223. float fmaxf (float x, float y)
  224. {
  225. return (float) fmax( (double)x, (double)y );
  226. }
  227. #endif
  228. #ifdef L_fminf
  229. libm_hidden_proto(fmin)
  230. float fminf (float x, float y)
  231. {
  232. return (float) fmin( (double)x, (double)y );
  233. }
  234. #endif
  235. #ifdef L_fmodf
  236. libm_hidden_proto(fmod)
  237. float fmodf (float x, float y)
  238. {
  239. return (float) fmod( (double)x, (double)y );
  240. }
  241. #endif
  242. #ifdef L_frexpf
  243. libm_hidden_proto(frexp)
  244. float frexpf (float x, int *exp)
  245. {
  246. return (float) frexp( (double)x, exp );
  247. }
  248. #endif
  249. #ifdef L_hypotf
  250. libm_hidden_proto(hypot)
  251. float hypotf (float x, float y)
  252. {
  253. return (float) hypot( (double)x, (double)y );
  254. }
  255. #endif
  256. #ifdef L_ilogbf
  257. libm_hidden_proto(ilogb)
  258. int ilogbf (float x)
  259. {
  260. return (float) ilogb( (double)x );
  261. }
  262. #endif
  263. #ifdef L_ldexpf
  264. libm_hidden_proto(ldexp)
  265. float ldexpf (float x, int exp)
  266. {
  267. return (float) ldexp( (double)x, exp );
  268. }
  269. #endif
  270. #ifdef L_lgammaf
  271. libm_hidden_proto(lgamma)
  272. float lgammaf (float x)
  273. {
  274. return (float) lgamma( (double)x );
  275. }
  276. #endif
  277. #ifdef L_llrintf
  278. libm_hidden_proto(llrint)
  279. long long llrintf (float x)
  280. {
  281. return (float) llrint( (double)x );
  282. }
  283. #endif
  284. #ifdef L_llroundf
  285. libm_hidden_proto(llround)
  286. long long llroundf (float x)
  287. {
  288. return (float) llround( (double)x );
  289. }
  290. #endif
  291. #ifdef L_log10f
  292. libm_hidden_proto(log10)
  293. float log10f (float x)
  294. {
  295. return (float) log10( (double)x );
  296. }
  297. #endif
  298. #ifdef L_log1pf
  299. libm_hidden_proto(log1p)
  300. float log1pf (float x)
  301. {
  302. return (float) log1p( (double)x );
  303. }
  304. #endif
  305. #ifdef L_log2f
  306. libm_hidden_proto(log2)
  307. float log2f (float x)
  308. {
  309. return (float) log2( (double)x );
  310. }
  311. #endif
  312. #ifdef L_logbf
  313. libm_hidden_proto(logb)
  314. float logbf (float x)
  315. {
  316. return (float) logb( (double)x );
  317. }
  318. #endif
  319. #ifdef L_logf
  320. libm_hidden_proto(log)
  321. float logf (float x)
  322. {
  323. return (float) log( (double)x );
  324. }
  325. #endif
  326. #ifdef L_lrintf
  327. libm_hidden_proto(lrint)
  328. long lrintf (float x)
  329. {
  330. return (float) lrint( (double)x );
  331. }
  332. #endif
  333. #ifdef L_lroundf
  334. libm_hidden_proto(lround)
  335. long lroundf (float x)
  336. {
  337. return (float) lround( (double)x );
  338. }
  339. #endif
  340. #ifdef L_modff
  341. libm_hidden_proto(modf)
  342. float modff (float x, float *iptr)
  343. {
  344. double y, result;
  345. result = modf ( x, &y );
  346. *iptr = (float)y;
  347. return (float) result;
  348. }
  349. #endif
  350. #ifdef L_nearbyintf
  351. libm_hidden_proto(nearbyint)
  352. float nearbyintf (float x)
  353. {
  354. return (float) nearbyint( (double)x );
  355. }
  356. #endif
  357. #ifdef L_nextafterf
  358. libm_hidden_proto(nextafter)
  359. float nextafterf (float x, float y)
  360. {
  361. return (float) nextafter( (double)x, (double)y );
  362. }
  363. #endif
  364. #ifdef L_nexttowardf
  365. libm_hidden_proto(nexttoward)
  366. float nexttowardf (float x, long double y)
  367. {
  368. return (float) nexttoward( (double)x, (double)y );
  369. }
  370. #endif
  371. #ifdef L_powf
  372. libm_hidden_proto(pow)
  373. float powf (float x, float y)
  374. {
  375. return (float) pow( (double)x, (double)y );
  376. }
  377. #endif
  378. #ifdef L_remainderf
  379. libm_hidden_proto(remainder)
  380. float remainderf (float x, float y)
  381. {
  382. return (float) remainder( (double)x, (double)y );
  383. }
  384. #endif
  385. #ifdef L_remquof
  386. libm_hidden_proto(remquo)
  387. float remquof (float x, float y, int *quo)
  388. {
  389. return (float) remquo( (double)x, (double)y, quo );
  390. }
  391. #endif
  392. #ifdef L_rintf
  393. libm_hidden_proto(rint)
  394. float rintf (float x)
  395. {
  396. return (float) rint( (double)x );
  397. }
  398. #endif
  399. #ifdef L_roundf
  400. libm_hidden_proto(round)
  401. float roundf (float x)
  402. {
  403. return (float) round( (double)x );
  404. }
  405. #endif
  406. #ifdef L_scalblnf
  407. libm_hidden_proto(scalbln)
  408. float scalblnf (float x, long exp)
  409. {
  410. return (float) scalbln( (double)x, exp );
  411. }
  412. #endif
  413. #ifdef L_scalbnf
  414. libm_hidden_proto(scalbn)
  415. float scalbnf (float x, int exp)
  416. {
  417. return (float) scalbn( (double)x, exp );
  418. }
  419. #endif
  420. #ifdef L_sinf
  421. libm_hidden_proto(sin)
  422. float sinf (float x)
  423. {
  424. return (float) sin( (double)x );
  425. }
  426. #endif
  427. #ifdef L_sinhf
  428. libm_hidden_proto(sinh)
  429. float sinhf (float x)
  430. {
  431. return (float) sinh( (double)x );
  432. }
  433. #endif
  434. #ifdef L_sqrtf
  435. libm_hidden_proto(sqrt)
  436. float sqrtf (float x)
  437. {
  438. return (float) sqrt( (double)x );
  439. }
  440. #endif
  441. #ifdef L_tanf
  442. libm_hidden_proto(tan)
  443. float tanf (float x)
  444. {
  445. return (float) tan( (double)x );
  446. }
  447. #endif
  448. #ifdef L_tanhf
  449. libm_hidden_proto(tanh)
  450. float tanhf (float x)
  451. {
  452. return (float) tanh( (double)x );
  453. }
  454. #endif
  455. #ifdef L_tgammaf
  456. libm_hidden_proto(tgamma)
  457. float tgammaf (float x)
  458. {
  459. return (float) tgamma( (double)x );
  460. }
  461. #endif
  462. #ifdef L_truncf
  463. libm_hidden_proto(trunc)
  464. float truncf (float x)
  465. {
  466. return (float) trunc( (double)x );
  467. }
  468. #endif