float_wrappers.c 9.1 KB

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