math_cuda.h 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670
  1. // -*- C++ -*-
  2. //===----------------------------------------------------------------------===//
  3. //
  4. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  5. // See https://llvm.org/LICENSE.txt for license information.
  6. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef _LIBCPP_MATH_OLD_H
  10. #define _LIBCPP_MATH_OLD_H
  11. /*
  12. math.h synopsis
  13. Macros:
  14. HUGE_VAL
  15. HUGE_VALF // C99
  16. HUGE_VALL // C99
  17. INFINITY // C99
  18. NAN // C99
  19. FP_INFINITE // C99
  20. FP_NAN // C99
  21. FP_NORMAL // C99
  22. FP_SUBNORMAL // C99
  23. FP_ZERO // C99
  24. FP_FAST_FMA // C99
  25. FP_FAST_FMAF // C99
  26. FP_FAST_FMAL // C99
  27. FP_ILOGB0 // C99
  28. FP_ILOGBNAN // C99
  29. MATH_ERRNO // C99
  30. MATH_ERREXCEPT // C99
  31. math_errhandling // C99
  32. Types:
  33. float_t // C99
  34. double_t // C99
  35. // C90
  36. floating_point abs(floating_point x);
  37. floating_point acos (arithmetic x);
  38. float acosf(float x);
  39. long double acosl(long double x);
  40. floating_point asin (arithmetic x);
  41. float asinf(float x);
  42. long double asinl(long double x);
  43. floating_point atan (arithmetic x);
  44. float atanf(float x);
  45. long double atanl(long double x);
  46. floating_point atan2 (arithmetic y, arithmetic x);
  47. float atan2f(float y, float x);
  48. long double atan2l(long double y, long double x);
  49. floating_point ceil (arithmetic x);
  50. float ceilf(float x);
  51. long double ceill(long double x);
  52. floating_point cos (arithmetic x);
  53. float cosf(float x);
  54. long double cosl(long double x);
  55. floating_point cosh (arithmetic x);
  56. float coshf(float x);
  57. long double coshl(long double x);
  58. floating_point exp (arithmetic x);
  59. float expf(float x);
  60. long double expl(long double x);
  61. floating_point fabs (arithmetic x);
  62. float fabsf(float x);
  63. long double fabsl(long double x);
  64. floating_point floor (arithmetic x);
  65. float floorf(float x);
  66. long double floorl(long double x);
  67. floating_point fmod (arithmetic x, arithmetic y);
  68. float fmodf(float x, float y);
  69. long double fmodl(long double x, long double y);
  70. floating_point frexp (arithmetic value, int* exp);
  71. float frexpf(float value, int* exp);
  72. long double frexpl(long double value, int* exp);
  73. floating_point ldexp (arithmetic value, int exp);
  74. float ldexpf(float value, int exp);
  75. long double ldexpl(long double value, int exp);
  76. floating_point log (arithmetic x);
  77. float logf(float x);
  78. long double logl(long double x);
  79. floating_point log10 (arithmetic x);
  80. float log10f(float x);
  81. long double log10l(long double x);
  82. floating_point modf (floating_point value, floating_point* iptr);
  83. float modff(float value, float* iptr);
  84. long double modfl(long double value, long double* iptr);
  85. floating_point pow (arithmetic x, arithmetic y);
  86. float powf(float x, float y);
  87. long double powl(long double x, long double y);
  88. floating_point sin (arithmetic x);
  89. float sinf(float x);
  90. long double sinl(long double x);
  91. floating_point sinh (arithmetic x);
  92. float sinhf(float x);
  93. long double sinhl(long double x);
  94. floating_point sqrt (arithmetic x);
  95. float sqrtf(float x);
  96. long double sqrtl(long double x);
  97. floating_point tan (arithmetic x);
  98. float tanf(float x);
  99. long double tanl(long double x);
  100. floating_point tanh (arithmetic x);
  101. float tanhf(float x);
  102. long double tanhl(long double x);
  103. // C99
  104. bool signbit(arithmetic x);
  105. int fpclassify(arithmetic x);
  106. bool isfinite(arithmetic x);
  107. bool isinf(arithmetic x);
  108. bool isnan(arithmetic x);
  109. bool isnormal(arithmetic x);
  110. bool isgreater(arithmetic x, arithmetic y);
  111. bool isgreaterequal(arithmetic x, arithmetic y);
  112. bool isless(arithmetic x, arithmetic y);
  113. bool islessequal(arithmetic x, arithmetic y);
  114. bool islessgreater(arithmetic x, arithmetic y);
  115. bool isunordered(arithmetic x, arithmetic y);
  116. floating_point acosh (arithmetic x);
  117. float acoshf(float x);
  118. long double acoshl(long double x);
  119. floating_point asinh (arithmetic x);
  120. float asinhf(float x);
  121. long double asinhl(long double x);
  122. floating_point atanh (arithmetic x);
  123. float atanhf(float x);
  124. long double atanhl(long double x);
  125. floating_point cbrt (arithmetic x);
  126. float cbrtf(float x);
  127. long double cbrtl(long double x);
  128. floating_point copysign (arithmetic x, arithmetic y);
  129. float copysignf(float x, float y);
  130. long double copysignl(long double x, long double y);
  131. floating_point erf (arithmetic x);
  132. float erff(float x);
  133. long double erfl(long double x);
  134. floating_point erfc (arithmetic x);
  135. float erfcf(float x);
  136. long double erfcl(long double x);
  137. floating_point exp2 (arithmetic x);
  138. float exp2f(float x);
  139. long double exp2l(long double x);
  140. floating_point expm1 (arithmetic x);
  141. float expm1f(float x);
  142. long double expm1l(long double x);
  143. floating_point fdim (arithmetic x, arithmetic y);
  144. float fdimf(float x, float y);
  145. long double fdiml(long double x, long double y);
  146. floating_point fma (arithmetic x, arithmetic y, arithmetic z);
  147. float fmaf(float x, float y, float z);
  148. long double fmal(long double x, long double y, long double z);
  149. floating_point fmax (arithmetic x, arithmetic y);
  150. float fmaxf(float x, float y);
  151. long double fmaxl(long double x, long double y);
  152. floating_point fmin (arithmetic x, arithmetic y);
  153. float fminf(float x, float y);
  154. long double fminl(long double x, long double y);
  155. floating_point hypot (arithmetic x, arithmetic y);
  156. float hypotf(float x, float y);
  157. long double hypotl(long double x, long double y);
  158. int ilogb (arithmetic x);
  159. int ilogbf(float x);
  160. int ilogbl(long double x);
  161. floating_point lgamma (arithmetic x);
  162. float lgammaf(float x);
  163. long double lgammal(long double x);
  164. long long llrint (arithmetic x);
  165. long long llrintf(float x);
  166. long long llrintl(long double x);
  167. long long llround (arithmetic x);
  168. long long llroundf(float x);
  169. long long llroundl(long double x);
  170. floating_point log1p (arithmetic x);
  171. float log1pf(float x);
  172. long double log1pl(long double x);
  173. floating_point log2 (arithmetic x);
  174. float log2f(float x);
  175. long double log2l(long double x);
  176. floating_point logb (arithmetic x);
  177. float logbf(float x);
  178. long double logbl(long double x);
  179. long lrint (arithmetic x);
  180. long lrintf(float x);
  181. long lrintl(long double x);
  182. long lround (arithmetic x);
  183. long lroundf(float x);
  184. long lroundl(long double x);
  185. double nan (const char* str);
  186. float nanf(const char* str);
  187. long double nanl(const char* str);
  188. floating_point nearbyint (arithmetic x);
  189. float nearbyintf(float x);
  190. long double nearbyintl(long double x);
  191. floating_point nextafter (arithmetic x, arithmetic y);
  192. float nextafterf(float x, float y);
  193. long double nextafterl(long double x, long double y);
  194. floating_point nexttoward (arithmetic x, long double y);
  195. float nexttowardf(float x, long double y);
  196. long double nexttowardl(long double x, long double y);
  197. floating_point remainder (arithmetic x, arithmetic y);
  198. float remainderf(float x, float y);
  199. long double remainderl(long double x, long double y);
  200. floating_point remquo (arithmetic x, arithmetic y, int* pquo);
  201. float remquof(float x, float y, int* pquo);
  202. long double remquol(long double x, long double y, int* pquo);
  203. floating_point rint (arithmetic x);
  204. float rintf(float x);
  205. long double rintl(long double x);
  206. floating_point round (arithmetic x);
  207. float roundf(float x);
  208. long double roundl(long double x);
  209. floating_point scalbln (arithmetic x, long ex);
  210. float scalblnf(float x, long ex);
  211. long double scalblnl(long double x, long ex);
  212. floating_point scalbn (arithmetic x, int ex);
  213. float scalbnf(float x, int ex);
  214. long double scalbnl(long double x, int ex);
  215. floating_point tgamma (arithmetic x);
  216. float tgammaf(float x);
  217. long double tgammal(long double x);
  218. floating_point trunc (arithmetic x);
  219. float truncf(float x);
  220. long double truncl(long double x);
  221. */
  222. #if defined(__CUDACC_VER_MAJOR__) && __CUDACC_VER_MAJOR__ > 12
  223. // Try to rewrite the connection condition of this file in math.h, if this warning worked
  224. # warning "This header can lead to problems with CUDA 12+ due to the transfer of mathematical functions to its namespace."
  225. #endif
  226. #include <__config>
  227. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  228. # pragma GCC system_header
  229. #endif
  230. # if __has_include_next(<math.h>)
  231. # include_next <math.h>
  232. # endif
  233. #ifdef __cplusplus
  234. // We support including .h headers inside 'extern "C"' contexts, so switch
  235. // back to C++ linkage before including these C++ headers.
  236. extern "C++" {
  237. #include <__type_traits/enable_if.h>
  238. #include <__type_traits/is_floating_point.h>
  239. #include <__type_traits/is_integral.h>
  240. #include <__type_traits/is_same.h>
  241. #include <__type_traits/promote.h>
  242. #include <limits>
  243. #include <stdlib.h>
  244. # ifdef fpclassify
  245. # undef fpclassify
  246. # endif
  247. # ifdef signbit
  248. # undef signbit
  249. # endif
  250. # ifdef isfinite
  251. # undef isfinite
  252. # endif
  253. # ifdef isinf
  254. # undef isinf
  255. # endif
  256. # if defined(isnan) && !defined(_LIBCPP_MSVCRT)
  257. # undef isnan
  258. # endif
  259. # ifdef isnormal
  260. # undef isnormal
  261. # endif
  262. # ifdef isgreater
  263. # undef isgreater
  264. # endif
  265. # ifdef isgreaterequal
  266. # undef isgreaterequal
  267. # endif
  268. # ifdef isless
  269. # undef isless
  270. # endif
  271. # ifdef islessequal
  272. # undef islessequal
  273. # endif
  274. # ifdef islessgreater
  275. # undef islessgreater
  276. # endif
  277. # ifdef isunordered
  278. # undef isunordered
  279. # endif
  280. // signbit
  281. template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
  282. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT {
  283. return __builtin_signbit(__x);
  284. }
  285. template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value && std::is_signed<_A1>::value, int> = 0>
  286. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT {
  287. return __x < 0;
  288. }
  289. template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value && !std::is_signed<_A1>::value, int> = 0>
  290. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1) _NOEXCEPT {
  291. return false;
  292. }
  293. // fpclassify
  294. template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
  295. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT {
  296. return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
  297. }
  298. template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0>
  299. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT {
  300. return __x == 0 ? FP_ZERO : FP_NORMAL;
  301. }
  302. // The MSVC runtime already provides these functions as templates
  303. #ifndef _LIBCPP_MSVCRT
  304. // isfinite
  305. template <class _A1,
  306. std::__enable_if_t<std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, int> = 0>
  307. _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1 __x) _NOEXCEPT {
  308. return __builtin_isfinite((typename std::__promote<_A1>::type)__x);
  309. }
  310. template <class _A1,
  311. std::__enable_if_t<std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, int> = 0>
  312. _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1) _NOEXCEPT {
  313. return true;
  314. }
  315. // isinf
  316. template <class _A1,
  317. std::__enable_if_t<std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, int> = 0>
  318. _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1 __x) _NOEXCEPT {
  319. return __builtin_isinf((typename std::__promote<_A1>::type)__x);
  320. }
  321. template <class _A1>
  322. _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI
  323. typename std::enable_if< std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, bool>::type
  324. isinf(_A1) _NOEXCEPT {
  325. return false;
  326. }
  327. #if defined(_LIBCPP_PREFERRED_OVERLOAD) && !defined(__CUDACC__)
  328. _LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT {
  329. return __builtin_isinf(__x);
  330. }
  331. _LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isinf(double __x) _NOEXCEPT {
  332. return __builtin_isinf(__x);
  333. }
  334. _LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT {
  335. return __builtin_isinf(__x);
  336. }
  337. # endif
  338. // isnan
  339. template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
  340. _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1 __x) _NOEXCEPT {
  341. return __builtin_isnan(__x);
  342. }
  343. template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0>
  344. _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1) _NOEXCEPT {
  345. return false;
  346. }
  347. #if defined(_LIBCPP_PREFERRED_OVERLOAD) && !defined(__CUDACC__)
  348. _LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT {
  349. return __builtin_isnan(__x);
  350. }
  351. _LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isnan(double __x) _NOEXCEPT {
  352. return __builtin_isnan(__x);
  353. }
  354. _LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT {
  355. return __builtin_isnan(__x);
  356. }
  357. # endif
  358. // isnormal
  359. template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
  360. _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT {
  361. return __builtin_isnormal(__x);
  362. }
  363. template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0>
  364. _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT {
  365. return __x != 0;
  366. }
  367. // isgreater
  368. template <class _A1,
  369. class _A2,
  370. std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
  371. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) _NOEXCEPT {
  372. typedef typename std::__promote<_A1, _A2>::type type;
  373. return __builtin_isgreater((type)__x, (type)__y);
  374. }
  375. // isgreaterequal
  376. template <class _A1,
  377. class _A2,
  378. std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
  379. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT {
  380. typedef typename std::__promote<_A1, _A2>::type type;
  381. return __builtin_isgreaterequal((type)__x, (type)__y);
  382. }
  383. // isless
  384. template <class _A1,
  385. class _A2,
  386. std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
  387. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NOEXCEPT {
  388. typedef typename std::__promote<_A1, _A2>::type type;
  389. return __builtin_isless((type)__x, (type)__y);
  390. }
  391. // islessequal
  392. template <class _A1,
  393. class _A2,
  394. std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
  395. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y) _NOEXCEPT {
  396. typedef typename std::__promote<_A1, _A2>::type type;
  397. return __builtin_islessequal((type)__x, (type)__y);
  398. }
  399. // islessgreater
  400. template <class _A1,
  401. class _A2,
  402. std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
  403. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 __y) _NOEXCEPT {
  404. typedef typename std::__promote<_A1, _A2>::type type;
  405. return __builtin_islessgreater((type)__x, (type)__y);
  406. }
  407. // isunordered
  408. template <class _A1,
  409. class _A2,
  410. std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
  411. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 __y) _NOEXCEPT {
  412. typedef typename std::__promote<_A1, _A2>::type type;
  413. return __builtin_isunordered((type)__x, (type)__y);
  414. }
  415. #endif // _LIBCPP_MSVCRT
  416. // abs
  417. //
  418. // handled in stdlib.h
  419. // div
  420. //
  421. // handled in stdlib.h
  422. // We have to provide double overloads for <math.h> to work on platforms that don't provide the full set of math
  423. // functions. To make the overload set work with multiple functions that take the same arguments, we make our overloads
  424. // templates. Functions are preferred over function templates during overload resolution, which means that our overload
  425. // will only be selected when the C library doesn't provide one.
  426. // acos
  427. inline _LIBCPP_HIDE_FROM_ABI float acos(float __x) _NOEXCEPT {return __builtin_acosf(__x);}
  428. template <class = int>
  429. _LIBCPP_HIDE_FROM_ABI double acos(double __x) _NOEXCEPT {
  430. return __builtin_acos(__x);
  431. }
  432. inline _LIBCPP_HIDE_FROM_ABI long double acos(long double __x) _NOEXCEPT {return __builtin_acosl(__x);}
  433. template <class _A1>
  434. inline _LIBCPP_HIDE_FROM_ABI
  435. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  436. acos(_A1 __x) _NOEXCEPT {return __builtin_acos((double)__x);}
  437. // asin
  438. inline _LIBCPP_HIDE_FROM_ABI float asin(float __x) _NOEXCEPT {return __builtin_asinf(__x);}
  439. template <class = int>
  440. _LIBCPP_HIDE_FROM_ABI double asin(double __x) _NOEXCEPT {
  441. return __builtin_asin(__x);
  442. }
  443. inline _LIBCPP_HIDE_FROM_ABI long double asin(long double __x) _NOEXCEPT {return __builtin_asinl(__x);}
  444. template <class _A1>
  445. inline _LIBCPP_HIDE_FROM_ABI
  446. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  447. asin(_A1 __x) _NOEXCEPT {return __builtin_asin((double)__x);}
  448. // atan
  449. inline _LIBCPP_HIDE_FROM_ABI float atan(float __x) _NOEXCEPT {return __builtin_atanf(__x);}
  450. template <class = int>
  451. _LIBCPP_HIDE_FROM_ABI double atan(double __x) _NOEXCEPT {
  452. return __builtin_atan(__x);
  453. }
  454. inline _LIBCPP_HIDE_FROM_ABI long double atan(long double __x) _NOEXCEPT {return __builtin_atanl(__x);}
  455. template <class _A1>
  456. inline _LIBCPP_HIDE_FROM_ABI
  457. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  458. atan(_A1 __x) _NOEXCEPT {return __builtin_atan((double)__x);}
  459. // atan2
  460. inline _LIBCPP_HIDE_FROM_ABI float atan2(float __y, float __x) _NOEXCEPT {return __builtin_atan2f(__y, __x);}
  461. template <class = int>
  462. _LIBCPP_HIDE_FROM_ABI double atan2(double __x, double __y) _NOEXCEPT {
  463. return __builtin_atan2(__x, __y);
  464. }
  465. inline _LIBCPP_HIDE_FROM_ABI long double atan2(long double __y, long double __x) _NOEXCEPT {return __builtin_atan2l(__y, __x);}
  466. template <class _A1, class _A2>
  467. inline _LIBCPP_HIDE_FROM_ABI
  468. typename std::__enable_if_t
  469. <
  470. std::is_arithmetic<_A1>::value &&
  471. std::is_arithmetic<_A2>::value,
  472. std::__promote<_A1, _A2>
  473. >::type
  474. atan2(_A1 __y, _A2 __x) _NOEXCEPT
  475. {
  476. typedef typename std::__promote<_A1, _A2>::type __result_type;
  477. static_assert((!(std::_IsSame<_A1, __result_type>::value &&
  478. std::_IsSame<_A2, __result_type>::value)), "");
  479. return ::atan2((__result_type)__y, (__result_type)__x);
  480. }
  481. // ceil
  482. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT {return __builtin_ceilf(__x);}
  483. template <class = int>
  484. _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double ceil(double __x) _NOEXCEPT {
  485. return __builtin_ceil(__x);
  486. }
  487. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double ceil(long double __x) _NOEXCEPT {return __builtin_ceill(__x);}
  488. template <class _A1>
  489. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
  490. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  491. ceil(_A1 __x) _NOEXCEPT {return __builtin_ceil((double)__x);}
  492. // cos
  493. inline _LIBCPP_HIDE_FROM_ABI float cos(float __x) _NOEXCEPT {return __builtin_cosf(__x);}
  494. template <class = int>
  495. _LIBCPP_HIDE_FROM_ABI double cos(double __x) _NOEXCEPT {
  496. return __builtin_cos(__x);
  497. }
  498. inline _LIBCPP_HIDE_FROM_ABI long double cos(long double __x) _NOEXCEPT {return __builtin_cosl(__x);}
  499. template <class _A1>
  500. inline _LIBCPP_HIDE_FROM_ABI
  501. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  502. cos(_A1 __x) _NOEXCEPT {return __builtin_cos((double)__x);}
  503. // cosh
  504. inline _LIBCPP_HIDE_FROM_ABI float cosh(float __x) _NOEXCEPT {return __builtin_coshf(__x);}
  505. template <class = int>
  506. _LIBCPP_HIDE_FROM_ABI double cosh(double __x) _NOEXCEPT {
  507. return __builtin_cosh(__x);
  508. }
  509. inline _LIBCPP_HIDE_FROM_ABI long double cosh(long double __x) _NOEXCEPT {return __builtin_coshl(__x);}
  510. template <class _A1>
  511. inline _LIBCPP_HIDE_FROM_ABI
  512. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  513. cosh(_A1 __x) _NOEXCEPT {return __builtin_cosh((double)__x);}
  514. // exp
  515. inline _LIBCPP_HIDE_FROM_ABI float exp(float __x) _NOEXCEPT {return __builtin_expf(__x);}
  516. template <class = int>
  517. _LIBCPP_HIDE_FROM_ABI double exp(double __x) _NOEXCEPT {
  518. return __builtin_exp(__x);
  519. }
  520. inline _LIBCPP_HIDE_FROM_ABI long double exp(long double __x) _NOEXCEPT {return __builtin_expl(__x);}
  521. template <class _A1>
  522. inline _LIBCPP_HIDE_FROM_ABI
  523. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  524. exp(_A1 __x) _NOEXCEPT {return __builtin_exp((double)__x);}
  525. // fabs
  526. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT {return __builtin_fabsf(__x);}
  527. template <class = int>
  528. _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double fabs(double __x) _NOEXCEPT {
  529. return __builtin_fabs(__x);
  530. }
  531. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __x) _NOEXCEPT {return __builtin_fabsl(__x);}
  532. template <class _A1>
  533. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
  534. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  535. fabs(_A1 __x) _NOEXCEPT {return __builtin_fabs((double)__x);}
  536. // floor
  537. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT {return __builtin_floorf(__x);}
  538. template <class = int>
  539. _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double floor(double __x) _NOEXCEPT {
  540. return __builtin_floor(__x);
  541. }
  542. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double floor(long double __x) _NOEXCEPT {return __builtin_floorl(__x);}
  543. template <class _A1>
  544. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
  545. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  546. floor(_A1 __x) _NOEXCEPT {return __builtin_floor((double)__x);}
  547. // fmod
  548. inline _LIBCPP_HIDE_FROM_ABI float fmod(float __x, float __y) _NOEXCEPT {return __builtin_fmodf(__x, __y);}
  549. template <class = int>
  550. _LIBCPP_HIDE_FROM_ABI double fmod(double __x, double __y) _NOEXCEPT {
  551. return __builtin_fmod(__x, __y);
  552. }
  553. inline _LIBCPP_HIDE_FROM_ABI long double fmod(long double __x, long double __y) _NOEXCEPT {return __builtin_fmodl(__x, __y);}
  554. template <class _A1, class _A2>
  555. inline _LIBCPP_HIDE_FROM_ABI
  556. typename std::__enable_if_t
  557. <
  558. std::is_arithmetic<_A1>::value &&
  559. std::is_arithmetic<_A2>::value,
  560. std::__promote<_A1, _A2>
  561. >::type
  562. fmod(_A1 __x, _A2 __y) _NOEXCEPT
  563. {
  564. typedef typename std::__promote<_A1, _A2>::type __result_type;
  565. static_assert((!(std::_IsSame<_A1, __result_type>::value &&
  566. std::_IsSame<_A2, __result_type>::value)), "");
  567. return ::fmod((__result_type)__x, (__result_type)__y);
  568. }
  569. // frexp
  570. inline _LIBCPP_HIDE_FROM_ABI float frexp(float __x, int* __e) _NOEXCEPT {return __builtin_frexpf(__x, __e);}
  571. template <class = int>
  572. _LIBCPP_HIDE_FROM_ABI double frexp(double __x, int* __e) _NOEXCEPT {
  573. return __builtin_frexp(__x, __e);
  574. }
  575. inline _LIBCPP_HIDE_FROM_ABI long double frexp(long double __x, int* __e) _NOEXCEPT {return __builtin_frexpl(__x, __e);}
  576. template <class _A1>
  577. inline _LIBCPP_HIDE_FROM_ABI
  578. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  579. frexp(_A1 __x, int* __e) _NOEXCEPT {return __builtin_frexp((double)__x, __e);}
  580. // ldexp
  581. inline _LIBCPP_HIDE_FROM_ABI float ldexp(float __x, int __e) _NOEXCEPT {return __builtin_ldexpf(__x, __e);}
  582. template <class = int>
  583. _LIBCPP_HIDE_FROM_ABI double ldexp(double __x, int __e) _NOEXCEPT {
  584. return __builtin_ldexp(__x, __e);
  585. }
  586. inline _LIBCPP_HIDE_FROM_ABI long double ldexp(long double __x, int __e) _NOEXCEPT {return __builtin_ldexpl(__x, __e);}
  587. template <class _A1>
  588. inline _LIBCPP_HIDE_FROM_ABI
  589. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  590. ldexp(_A1 __x, int __e) _NOEXCEPT {return __builtin_ldexp((double)__x, __e);}
  591. // log
  592. inline _LIBCPP_HIDE_FROM_ABI float log(float __x) _NOEXCEPT {return __builtin_logf(__x);}
  593. template <class = int>
  594. _LIBCPP_HIDE_FROM_ABI double log(double __x) _NOEXCEPT {
  595. return __builtin_log(__x);
  596. }
  597. inline _LIBCPP_HIDE_FROM_ABI long double log(long double __x) _NOEXCEPT {return __builtin_logl(__x);}
  598. template <class _A1>
  599. inline _LIBCPP_HIDE_FROM_ABI
  600. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  601. log(_A1 __x) _NOEXCEPT {return __builtin_log((double)__x);}
  602. // log10
  603. inline _LIBCPP_HIDE_FROM_ABI float log10(float __x) _NOEXCEPT {return __builtin_log10f(__x);}
  604. template <class = int>
  605. _LIBCPP_HIDE_FROM_ABI double log10(double __x) _NOEXCEPT {
  606. return __builtin_log10(__x);
  607. }
  608. inline _LIBCPP_HIDE_FROM_ABI long double log10(long double __x) _NOEXCEPT {return __builtin_log10l(__x);}
  609. template <class _A1>
  610. inline _LIBCPP_HIDE_FROM_ABI
  611. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  612. log10(_A1 __x) _NOEXCEPT {return __builtin_log10((double)__x);}
  613. // modf
  614. inline _LIBCPP_HIDE_FROM_ABI float modf(float __x, float* __y) _NOEXCEPT {return __builtin_modff(__x, __y);}
  615. template <class = int>
  616. _LIBCPP_HIDE_FROM_ABI double modf(double __x, double* __y) _NOEXCEPT {
  617. return __builtin_modf(__x, __y);
  618. }
  619. inline _LIBCPP_HIDE_FROM_ABI long double modf(long double __x, long double* __y) _NOEXCEPT {return __builtin_modfl(__x, __y);}
  620. // pow
  621. inline _LIBCPP_HIDE_FROM_ABI float pow(float __x, float __y) _NOEXCEPT {return __builtin_powf(__x, __y);}
  622. template <class = int>
  623. _LIBCPP_HIDE_FROM_ABI double pow(double __x, double __y) _NOEXCEPT {
  624. return __builtin_pow(__x, __y);
  625. }
  626. inline _LIBCPP_HIDE_FROM_ABI long double pow(long double __x, long double __y) _NOEXCEPT {return __builtin_powl(__x, __y);}
  627. template <class _A1, class _A2>
  628. inline _LIBCPP_HIDE_FROM_ABI
  629. typename std::__enable_if_t
  630. <
  631. std::is_arithmetic<_A1>::value &&
  632. std::is_arithmetic<_A2>::value,
  633. std::__promote<_A1, _A2>
  634. >::type
  635. pow(_A1 __x, _A2 __y) _NOEXCEPT
  636. {
  637. typedef typename std::__promote<_A1, _A2>::type __result_type;
  638. static_assert((!(std::_IsSame<_A1, __result_type>::value &&
  639. std::_IsSame<_A2, __result_type>::value)), "");
  640. return ::pow((__result_type)__x, (__result_type)__y);
  641. }
  642. // sin
  643. inline _LIBCPP_HIDE_FROM_ABI float sin(float __x) _NOEXCEPT {return __builtin_sinf(__x);}
  644. template <class = int>
  645. _LIBCPP_HIDE_FROM_ABI double sin(double __x) _NOEXCEPT {
  646. return __builtin_sin(__x);
  647. }
  648. inline _LIBCPP_HIDE_FROM_ABI long double sin(long double __x) _NOEXCEPT {return __builtin_sinl(__x);}
  649. template <class _A1>
  650. inline _LIBCPP_HIDE_FROM_ABI
  651. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  652. sin(_A1 __x) _NOEXCEPT {return __builtin_sin((double)__x);}
  653. // sinh
  654. inline _LIBCPP_HIDE_FROM_ABI float sinh(float __x) _NOEXCEPT {return __builtin_sinhf(__x);}
  655. template <class = int>
  656. _LIBCPP_HIDE_FROM_ABI double sinh(double __x) _NOEXCEPT {
  657. return __builtin_sinh(__x);
  658. }
  659. inline _LIBCPP_HIDE_FROM_ABI long double sinh(long double __x) _NOEXCEPT {return __builtin_sinhl(__x);}
  660. template <class _A1>
  661. inline _LIBCPP_HIDE_FROM_ABI
  662. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  663. sinh(_A1 __x) _NOEXCEPT {return __builtin_sinh((double)__x);}
  664. // sqrt
  665. inline _LIBCPP_HIDE_FROM_ABI float sqrt(float __x) _NOEXCEPT {return __builtin_sqrtf(__x);}
  666. template <class = int>
  667. _LIBCPP_HIDE_FROM_ABI double sqrt(double __x) _NOEXCEPT {
  668. return __builtin_sqrt(__x);
  669. }
  670. inline _LIBCPP_HIDE_FROM_ABI long double sqrt(long double __x) _NOEXCEPT {return __builtin_sqrtl(__x);}
  671. template <class _A1>
  672. inline _LIBCPP_HIDE_FROM_ABI
  673. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  674. sqrt(_A1 __x) _NOEXCEPT {return __builtin_sqrt((double)__x);}
  675. // tan
  676. inline _LIBCPP_HIDE_FROM_ABI float tan(float __x) _NOEXCEPT {return __builtin_tanf(__x);}
  677. template <class = int>
  678. _LIBCPP_HIDE_FROM_ABI double tan(double __x) _NOEXCEPT {
  679. return __builtin_tan(__x);
  680. }
  681. inline _LIBCPP_HIDE_FROM_ABI long double tan(long double __x) _NOEXCEPT {return __builtin_tanl(__x);}
  682. template <class _A1>
  683. inline _LIBCPP_HIDE_FROM_ABI
  684. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  685. tan(_A1 __x) _NOEXCEPT {return __builtin_tan((double)__x);}
  686. // tanh
  687. inline _LIBCPP_HIDE_FROM_ABI float tanh(float __x) _NOEXCEPT {return __builtin_tanhf(__x);}
  688. template <class = int>
  689. _LIBCPP_HIDE_FROM_ABI double tanh(double __x) _NOEXCEPT {
  690. return __builtin_tanh(__x);
  691. }
  692. inline _LIBCPP_HIDE_FROM_ABI long double tanh(long double __x) _NOEXCEPT {return __builtin_tanhl(__x);}
  693. template <class _A1>
  694. inline _LIBCPP_HIDE_FROM_ABI
  695. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  696. tanh(_A1 __x) _NOEXCEPT {return __builtin_tanh((double)__x);}
  697. // acosh
  698. inline _LIBCPP_HIDE_FROM_ABI float acosh(float __x) _NOEXCEPT {return __builtin_acoshf(__x);}
  699. template <class = int>
  700. _LIBCPP_HIDE_FROM_ABI double acosh(double __x) _NOEXCEPT {
  701. return __builtin_acosh(__x);
  702. }
  703. inline _LIBCPP_HIDE_FROM_ABI long double acosh(long double __x) _NOEXCEPT {return __builtin_acoshl(__x);}
  704. template <class _A1>
  705. inline _LIBCPP_HIDE_FROM_ABI
  706. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  707. acosh(_A1 __x) _NOEXCEPT {return __builtin_acosh((double)__x);}
  708. // asinh
  709. inline _LIBCPP_HIDE_FROM_ABI float asinh(float __x) _NOEXCEPT {return __builtin_asinhf(__x);}
  710. template <class = int>
  711. _LIBCPP_HIDE_FROM_ABI double asinh(double __x) _NOEXCEPT {
  712. return __builtin_asinh(__x);
  713. }
  714. inline _LIBCPP_HIDE_FROM_ABI long double asinh(long double __x) _NOEXCEPT {return __builtin_asinhl(__x);}
  715. template <class _A1>
  716. inline _LIBCPP_HIDE_FROM_ABI
  717. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  718. asinh(_A1 __x) _NOEXCEPT {return __builtin_asinh((double)__x);}
  719. // atanh
  720. inline _LIBCPP_HIDE_FROM_ABI float atanh(float __x) _NOEXCEPT {return __builtin_atanhf(__x);}
  721. template <class = int>
  722. _LIBCPP_HIDE_FROM_ABI double atanh(double __x) _NOEXCEPT {
  723. return __builtin_atanh(__x);
  724. }
  725. inline _LIBCPP_HIDE_FROM_ABI long double atanh(long double __x) _NOEXCEPT {return __builtin_atanhl(__x);}
  726. template <class _A1>
  727. inline _LIBCPP_HIDE_FROM_ABI
  728. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  729. atanh(_A1 __x) _NOEXCEPT {return __builtin_atanh((double)__x);}
  730. // cbrt
  731. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT {return __builtin_cbrtf(__x);}
  732. template <class = int>
  733. _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double cbrt(double __x) _NOEXCEPT {
  734. return __builtin_cbrt(__x);
  735. }
  736. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double cbrt(long double __x) _NOEXCEPT {return __builtin_cbrtl(__x);}
  737. template <class _A1>
  738. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
  739. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  740. cbrt(_A1 __x) _NOEXCEPT {return __builtin_cbrt((double)__x);}
  741. // copysign
  742. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT {
  743. return ::__builtin_copysignf(__x, __y);
  744. }
  745. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT {
  746. return ::__builtin_copysignl(__x, __y);
  747. }
  748. template <class _A1, class _A2>
  749. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
  750. typename std::__enable_if_t
  751. <
  752. std::is_arithmetic<_A1>::value &&
  753. std::is_arithmetic<_A2>::value,
  754. std::__promote<_A1, _A2>
  755. >::type
  756. copysign(_A1 __x, _A2 __y) _NOEXCEPT {
  757. return ::__builtin_copysign(__x, __y);
  758. }
  759. // erf
  760. inline _LIBCPP_HIDE_FROM_ABI float erf(float __x) _NOEXCEPT {return __builtin_erff(__x);}
  761. template <class = int>
  762. _LIBCPP_HIDE_FROM_ABI double erf(double __x) _NOEXCEPT {
  763. return __builtin_erf(__x);
  764. }
  765. inline _LIBCPP_HIDE_FROM_ABI long double erf(long double __x) _NOEXCEPT {return __builtin_erfl(__x);}
  766. template <class _A1>
  767. inline _LIBCPP_HIDE_FROM_ABI
  768. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  769. erf(_A1 __x) _NOEXCEPT {return __builtin_erf((double)__x);}
  770. // erfc
  771. inline _LIBCPP_HIDE_FROM_ABI float erfc(float __x) _NOEXCEPT {return __builtin_erfcf(__x);}
  772. template <class = int>
  773. _LIBCPP_HIDE_FROM_ABI double erfc(double __x) _NOEXCEPT {
  774. return __builtin_erfc(__x);
  775. }
  776. inline _LIBCPP_HIDE_FROM_ABI long double erfc(long double __x) _NOEXCEPT {return __builtin_erfcl(__x);}
  777. template <class _A1>
  778. inline _LIBCPP_HIDE_FROM_ABI
  779. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  780. erfc(_A1 __x) _NOEXCEPT {return __builtin_erfc((double)__x);}
  781. // exp2
  782. inline _LIBCPP_HIDE_FROM_ABI float exp2(float __x) _NOEXCEPT {return __builtin_exp2f(__x);}
  783. template <class = int>
  784. _LIBCPP_HIDE_FROM_ABI double exp2(double __x) _NOEXCEPT {
  785. return __builtin_exp2(__x);
  786. }
  787. inline _LIBCPP_HIDE_FROM_ABI long double exp2(long double __x) _NOEXCEPT {return __builtin_exp2l(__x);}
  788. template <class _A1>
  789. inline _LIBCPP_HIDE_FROM_ABI
  790. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  791. exp2(_A1 __x) _NOEXCEPT {return __builtin_exp2((double)__x);}
  792. // expm1
  793. inline _LIBCPP_HIDE_FROM_ABI float expm1(float __x) _NOEXCEPT {return __builtin_expm1f(__x);}
  794. template <class = int>
  795. _LIBCPP_HIDE_FROM_ABI double expm1(double __x) _NOEXCEPT {
  796. return __builtin_expm1(__x);
  797. }
  798. inline _LIBCPP_HIDE_FROM_ABI long double expm1(long double __x) _NOEXCEPT {return __builtin_expm1l(__x);}
  799. template <class _A1>
  800. inline _LIBCPP_HIDE_FROM_ABI
  801. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  802. expm1(_A1 __x) _NOEXCEPT {return __builtin_expm1((double)__x);}
  803. // fdim
  804. inline _LIBCPP_HIDE_FROM_ABI float fdim(float __x, float __y) _NOEXCEPT {return __builtin_fdimf(__x, __y);}
  805. template <class = int>
  806. _LIBCPP_HIDE_FROM_ABI double fdim(double __x, double __y) _NOEXCEPT {
  807. return __builtin_fdim(__x, __y);
  808. }
  809. inline _LIBCPP_HIDE_FROM_ABI long double fdim(long double __x, long double __y) _NOEXCEPT {return __builtin_fdiml(__x, __y);}
  810. template <class _A1, class _A2>
  811. inline _LIBCPP_HIDE_FROM_ABI
  812. typename std::__enable_if_t
  813. <
  814. std::is_arithmetic<_A1>::value &&
  815. std::is_arithmetic<_A2>::value,
  816. std::__promote<_A1, _A2>
  817. >::type
  818. fdim(_A1 __x, _A2 __y) _NOEXCEPT
  819. {
  820. typedef typename std::__promote<_A1, _A2>::type __result_type;
  821. static_assert((!(std::_IsSame<_A1, __result_type>::value &&
  822. std::_IsSame<_A2, __result_type>::value)), "");
  823. return ::fdim((__result_type)__x, (__result_type)__y);
  824. }
  825. // fma
  826. inline _LIBCPP_HIDE_FROM_ABI float fma(float __x, float __y, float __z) _NOEXCEPT
  827. {
  828. return __builtin_fmaf(__x, __y, __z);
  829. }
  830. template <class = int>
  831. _LIBCPP_HIDE_FROM_ABI double fma(double __x, double __y, double __z) _NOEXCEPT {
  832. return __builtin_fma(__x, __y, __z);
  833. }
  834. inline _LIBCPP_HIDE_FROM_ABI long double fma(long double __x, long double __y, long double __z) _NOEXCEPT
  835. {
  836. return __builtin_fmal(__x, __y, __z);
  837. }
  838. template <class _A1, class _A2, class _A3>
  839. inline _LIBCPP_HIDE_FROM_ABI
  840. typename std::__enable_if_t
  841. <
  842. std::is_arithmetic<_A1>::value &&
  843. std::is_arithmetic<_A2>::value &&
  844. std::is_arithmetic<_A3>::value,
  845. std::__promote<_A1, _A2, _A3>
  846. >::type
  847. fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT
  848. {
  849. typedef typename std::__promote<_A1, _A2, _A3>::type __result_type;
  850. static_assert((!(std::_IsSame<_A1, __result_type>::value &&
  851. std::_IsSame<_A2, __result_type>::value &&
  852. std::_IsSame<_A3, __result_type>::value)), "");
  853. return __builtin_fma((__result_type)__x, (__result_type)__y, (__result_type)__z);
  854. }
  855. // fmax
  856. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT {return __builtin_fmaxf(__x, __y);}
  857. template <class = int>
  858. _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double fmax(double __x, double __y) _NOEXCEPT {
  859. return __builtin_fmax(__x, __y);
  860. }
  861. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double fmax(long double __x, long double __y) _NOEXCEPT {return __builtin_fmaxl(__x, __y);}
  862. template <class _A1, class _A2>
  863. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
  864. typename std::__enable_if_t
  865. <
  866. std::is_arithmetic<_A1>::value &&
  867. std::is_arithmetic<_A2>::value,
  868. std::__promote<_A1, _A2>
  869. >::type
  870. fmax(_A1 __x, _A2 __y) _NOEXCEPT
  871. {
  872. typedef typename std::__promote<_A1, _A2>::type __result_type;
  873. static_assert((!(std::_IsSame<_A1, __result_type>::value &&
  874. std::_IsSame<_A2, __result_type>::value)), "");
  875. return ::fmax((__result_type)__x, (__result_type)__y);
  876. }
  877. // fmin
  878. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT {return __builtin_fminf(__x, __y);}
  879. template <class = int>
  880. _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double fmin(double __x, double __y) _NOEXCEPT {
  881. return __builtin_fmin(__x, __y);
  882. }
  883. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double fmin(long double __x, long double __y) _NOEXCEPT {return __builtin_fminl(__x, __y);}
  884. template <class _A1, class _A2>
  885. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
  886. typename std::__enable_if_t
  887. <
  888. std::is_arithmetic<_A1>::value &&
  889. std::is_arithmetic<_A2>::value,
  890. std::__promote<_A1, _A2>
  891. >::type
  892. fmin(_A1 __x, _A2 __y) _NOEXCEPT
  893. {
  894. typedef typename std::__promote<_A1, _A2>::type __result_type;
  895. static_assert((!(std::_IsSame<_A1, __result_type>::value &&
  896. std::_IsSame<_A2, __result_type>::value)), "");
  897. return ::fmin((__result_type)__x, (__result_type)__y);
  898. }
  899. // hypot
  900. inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y) _NOEXCEPT {return __builtin_hypotf(__x, __y);}
  901. template <class = int>
  902. _LIBCPP_HIDE_FROM_ABI double hypot(double __x, double __y) _NOEXCEPT {
  903. return __builtin_hypot(__x, __y);
  904. }
  905. inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y) _NOEXCEPT {return __builtin_hypotl(__x, __y);}
  906. template <class _A1, class _A2>
  907. inline _LIBCPP_HIDE_FROM_ABI
  908. typename std::__enable_if_t
  909. <
  910. std::is_arithmetic<_A1>::value &&
  911. std::is_arithmetic<_A2>::value,
  912. std::__promote<_A1, _A2>
  913. >::type
  914. hypot(_A1 __x, _A2 __y) _NOEXCEPT
  915. {
  916. typedef typename std::__promote<_A1, _A2>::type __result_type;
  917. static_assert((!(std::_IsSame<_A1, __result_type>::value &&
  918. std::_IsSame<_A2, __result_type>::value)), "");
  919. return ::hypot((__result_type)__x, (__result_type)__y);
  920. }
  921. // ilogb
  922. inline _LIBCPP_HIDE_FROM_ABI int ilogb(float __x) _NOEXCEPT {return __builtin_ilogbf(__x);}
  923. template <class = int>
  924. _LIBCPP_HIDE_FROM_ABI double ilogb(double __x) _NOEXCEPT {
  925. return __builtin_ilogb(__x);
  926. }
  927. inline _LIBCPP_HIDE_FROM_ABI int ilogb(long double __x) _NOEXCEPT {return __builtin_ilogbl(__x);}
  928. template <class _A1>
  929. inline _LIBCPP_HIDE_FROM_ABI
  930. typename std::enable_if<std::is_integral<_A1>::value, int>::type
  931. ilogb(_A1 __x) _NOEXCEPT {return __builtin_ilogb((double)__x);}
  932. // lgamma
  933. inline _LIBCPP_HIDE_FROM_ABI float lgamma(float __x) _NOEXCEPT {return __builtin_lgammaf(__x);}
  934. template <class = int>
  935. _LIBCPP_HIDE_FROM_ABI double lgamma(double __x) _NOEXCEPT {
  936. return __builtin_lgamma(__x);
  937. }
  938. inline _LIBCPP_HIDE_FROM_ABI long double lgamma(long double __x) _NOEXCEPT {return __builtin_lgammal(__x);}
  939. template <class _A1>
  940. inline _LIBCPP_HIDE_FROM_ABI
  941. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  942. lgamma(_A1 __x) _NOEXCEPT {return __builtin_lgamma((double)__x);}
  943. // llrint
  944. inline _LIBCPP_HIDE_FROM_ABI long long llrint(float __x) _NOEXCEPT
  945. {
  946. return __builtin_llrintf(__x);
  947. }
  948. template <class = int>
  949. _LIBCPP_HIDE_FROM_ABI long long llrint(double __x) _NOEXCEPT {
  950. return __builtin_llrint(__x);
  951. }
  952. inline _LIBCPP_HIDE_FROM_ABI long long llrint(long double __x) _NOEXCEPT
  953. {
  954. return __builtin_llrintl(__x);
  955. }
  956. template <class _A1>
  957. inline _LIBCPP_HIDE_FROM_ABI
  958. typename std::enable_if<std::is_integral<_A1>::value, long long>::type
  959. llrint(_A1 __x) _NOEXCEPT
  960. {
  961. return __builtin_llrint((double)__x);
  962. }
  963. // llround
  964. inline _LIBCPP_HIDE_FROM_ABI long long llround(float __x) _NOEXCEPT
  965. {
  966. return __builtin_llroundf(__x);
  967. }
  968. template <class = int>
  969. _LIBCPP_HIDE_FROM_ABI long long llround(double __x) _NOEXCEPT {
  970. return __builtin_llround(__x);
  971. }
  972. inline _LIBCPP_HIDE_FROM_ABI long long llround(long double __x) _NOEXCEPT
  973. {
  974. return __builtin_llroundl(__x);
  975. }
  976. template <class _A1>
  977. inline _LIBCPP_HIDE_FROM_ABI
  978. typename std::enable_if<std::is_integral<_A1>::value, long long>::type
  979. llround(_A1 __x) _NOEXCEPT
  980. {
  981. return __builtin_llround((double)__x);
  982. }
  983. // log1p
  984. inline _LIBCPP_HIDE_FROM_ABI float log1p(float __x) _NOEXCEPT {return __builtin_log1pf(__x);}
  985. template <class = int>
  986. _LIBCPP_HIDE_FROM_ABI double log1p(double __x) _NOEXCEPT {
  987. return __builtin_log1p(__x);
  988. }
  989. inline _LIBCPP_HIDE_FROM_ABI long double log1p(long double __x) _NOEXCEPT {return __builtin_log1pl(__x);}
  990. template <class _A1>
  991. inline _LIBCPP_HIDE_FROM_ABI
  992. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  993. log1p(_A1 __x) _NOEXCEPT {return __builtin_log1p((double)__x);}
  994. // log2
  995. inline _LIBCPP_HIDE_FROM_ABI float log2(float __x) _NOEXCEPT {return __builtin_log2f(__x);}
  996. template <class = int>
  997. _LIBCPP_HIDE_FROM_ABI double log2(double __x) _NOEXCEPT {
  998. return __builtin_log2(__x);
  999. }
  1000. inline _LIBCPP_HIDE_FROM_ABI long double log2(long double __x) _NOEXCEPT {return __builtin_log2l(__x);}
  1001. template <class _A1>
  1002. inline _LIBCPP_HIDE_FROM_ABI
  1003. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  1004. log2(_A1 __x) _NOEXCEPT {return __builtin_log2((double)__x);}
  1005. // logb
  1006. inline _LIBCPP_HIDE_FROM_ABI float logb(float __x) _NOEXCEPT {return __builtin_logbf(__x);}
  1007. template <class = int>
  1008. _LIBCPP_HIDE_FROM_ABI double logb(double __x) _NOEXCEPT {
  1009. return __builtin_logb(__x);
  1010. }
  1011. inline _LIBCPP_HIDE_FROM_ABI long double logb(long double __x) _NOEXCEPT {return __builtin_logbl(__x);}
  1012. template <class _A1>
  1013. inline _LIBCPP_HIDE_FROM_ABI
  1014. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  1015. logb(_A1 __x) _NOEXCEPT {return __builtin_logb((double)__x);}
  1016. // lrint
  1017. inline _LIBCPP_HIDE_FROM_ABI long lrint(float __x) _NOEXCEPT
  1018. {
  1019. return __builtin_lrintf(__x);
  1020. }
  1021. template <class = int>
  1022. _LIBCPP_HIDE_FROM_ABI long lrint(double __x) _NOEXCEPT {
  1023. return __builtin_lrint(__x);
  1024. }
  1025. inline _LIBCPP_HIDE_FROM_ABI long lrint(long double __x) _NOEXCEPT
  1026. {
  1027. return __builtin_lrintl(__x);
  1028. }
  1029. template <class _A1>
  1030. inline _LIBCPP_HIDE_FROM_ABI
  1031. typename std::enable_if<std::is_integral<_A1>::value, long>::type
  1032. lrint(_A1 __x) _NOEXCEPT
  1033. {
  1034. return __builtin_lrint((double)__x);
  1035. }
  1036. // lround
  1037. inline _LIBCPP_HIDE_FROM_ABI long lround(float __x) _NOEXCEPT
  1038. {
  1039. return __builtin_lroundf(__x);
  1040. }
  1041. template <class = int>
  1042. _LIBCPP_HIDE_FROM_ABI long lround(double __x) _NOEXCEPT {
  1043. return __builtin_lround(__x);
  1044. }
  1045. inline _LIBCPP_HIDE_FROM_ABI long lround(long double __x) _NOEXCEPT
  1046. {
  1047. return __builtin_lroundl(__x);
  1048. }
  1049. template <class _A1>
  1050. inline _LIBCPP_HIDE_FROM_ABI
  1051. typename std::enable_if<std::is_integral<_A1>::value, long>::type
  1052. lround(_A1 __x) _NOEXCEPT
  1053. {
  1054. return __builtin_lround((double)__x);
  1055. }
  1056. // nan
  1057. // nearbyint
  1058. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT {return __builtin_nearbyintf(__x);}
  1059. template <class = int>
  1060. _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double nearbyint(double __x) _NOEXCEPT {
  1061. return __builtin_nearbyint(__x);
  1062. }
  1063. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double nearbyint(long double __x) _NOEXCEPT {return __builtin_nearbyintl(__x);}
  1064. template <class _A1>
  1065. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
  1066. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  1067. nearbyint(_A1 __x) _NOEXCEPT {return __builtin_nearbyint((double)__x);}
  1068. // nextafter
  1069. inline _LIBCPP_HIDE_FROM_ABI float nextafter(float __x, float __y) _NOEXCEPT {return __builtin_nextafterf(__x, __y);}
  1070. template <class = int>
  1071. _LIBCPP_HIDE_FROM_ABI double nextafter(double __x, double __y) _NOEXCEPT {
  1072. return __builtin_nextafter(__x, __y);
  1073. }
  1074. inline _LIBCPP_HIDE_FROM_ABI long double nextafter(long double __x, long double __y) _NOEXCEPT {return __builtin_nextafterl(__x, __y);}
  1075. template <class _A1, class _A2>
  1076. inline _LIBCPP_HIDE_FROM_ABI
  1077. typename std::__enable_if_t
  1078. <
  1079. std::is_arithmetic<_A1>::value &&
  1080. std::is_arithmetic<_A2>::value,
  1081. std::__promote<_A1, _A2>
  1082. >::type
  1083. nextafter(_A1 __x, _A2 __y) _NOEXCEPT
  1084. {
  1085. typedef typename std::__promote<_A1, _A2>::type __result_type;
  1086. static_assert((!(std::_IsSame<_A1, __result_type>::value &&
  1087. std::_IsSame<_A2, __result_type>::value)), "");
  1088. return ::nextafter((__result_type)__x, (__result_type)__y);
  1089. }
  1090. // nexttoward
  1091. inline _LIBCPP_HIDE_FROM_ABI float nexttoward(float __x, long double __y) _NOEXCEPT {return __builtin_nexttowardf(__x, __y);}
  1092. template <class = int>
  1093. _LIBCPP_HIDE_FROM_ABI double nexttoward(double __x, long double __y) _NOEXCEPT {
  1094. return __builtin_nexttoward(__x, __y);
  1095. }
  1096. inline _LIBCPP_HIDE_FROM_ABI long double nexttoward(long double __x, long double __y) _NOEXCEPT {return __builtin_nexttowardl(__x, __y);}
  1097. template <class _A1>
  1098. inline _LIBCPP_HIDE_FROM_ABI
  1099. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  1100. nexttoward(_A1 __x, long double __y) _NOEXCEPT {return __builtin_nexttoward((double)__x, __y);}
  1101. // remainder
  1102. inline _LIBCPP_HIDE_FROM_ABI float remainder(float __x, float __y) _NOEXCEPT {return __builtin_remainderf(__x, __y);}
  1103. template <class = int>
  1104. _LIBCPP_HIDE_FROM_ABI double remainder(double __x, double __y) _NOEXCEPT {
  1105. return __builtin_remainder(__x, __y);
  1106. }
  1107. inline _LIBCPP_HIDE_FROM_ABI long double remainder(long double __x, long double __y) _NOEXCEPT {return __builtin_remainderl(__x, __y);}
  1108. template <class _A1, class _A2>
  1109. inline _LIBCPP_HIDE_FROM_ABI
  1110. typename std::__enable_if_t
  1111. <
  1112. std::is_arithmetic<_A1>::value &&
  1113. std::is_arithmetic<_A2>::value,
  1114. std::__promote<_A1, _A2>
  1115. >::type
  1116. remainder(_A1 __x, _A2 __y) _NOEXCEPT
  1117. {
  1118. typedef typename std::__promote<_A1, _A2>::type __result_type;
  1119. static_assert((!(std::_IsSame<_A1, __result_type>::value &&
  1120. std::_IsSame<_A2, __result_type>::value)), "");
  1121. return ::remainder((__result_type)__x, (__result_type)__y);
  1122. }
  1123. // remquo
  1124. inline _LIBCPP_HIDE_FROM_ABI float remquo(float __x, float __y, int* __z) _NOEXCEPT {return __builtin_remquof(__x, __y, __z);}
  1125. template <class = int>
  1126. _LIBCPP_HIDE_FROM_ABI double remquo(double __x, double __y, int* __z) _NOEXCEPT {
  1127. return __builtin_remquo(__x, __y, __z);
  1128. }
  1129. inline _LIBCPP_HIDE_FROM_ABI long double remquo(long double __x, long double __y, int* __z) _NOEXCEPT {return __builtin_remquol(__x, __y, __z);}
  1130. template <class _A1, class _A2>
  1131. inline _LIBCPP_HIDE_FROM_ABI
  1132. typename std::__enable_if_t
  1133. <
  1134. std::is_arithmetic<_A1>::value &&
  1135. std::is_arithmetic<_A2>::value,
  1136. std::__promote<_A1, _A2>
  1137. >::type
  1138. remquo(_A1 __x, _A2 __y, int* __z) _NOEXCEPT
  1139. {
  1140. typedef typename std::__promote<_A1, _A2>::type __result_type;
  1141. static_assert((!(std::_IsSame<_A1, __result_type>::value &&
  1142. std::_IsSame<_A2, __result_type>::value)), "");
  1143. return ::remquo((__result_type)__x, (__result_type)__y, __z);
  1144. }
  1145. // rint
  1146. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT
  1147. {
  1148. return __builtin_rintf(__x);
  1149. }
  1150. template <class = int>
  1151. _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double rint(double __x) _NOEXCEPT {
  1152. return __builtin_rint(__x);
  1153. }
  1154. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __x) _NOEXCEPT
  1155. {
  1156. return __builtin_rintl(__x);
  1157. }
  1158. template <class _A1>
  1159. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
  1160. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  1161. rint(_A1 __x) _NOEXCEPT
  1162. {
  1163. return __builtin_rint((double)__x);
  1164. }
  1165. // round
  1166. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT
  1167. {
  1168. return __builtin_roundf(__x);
  1169. }
  1170. template <class = int>
  1171. _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double round(double __x) _NOEXCEPT {
  1172. return __builtin_round(__x);
  1173. }
  1174. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT
  1175. {
  1176. return __builtin_roundl(__x);
  1177. }
  1178. template <class _A1>
  1179. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
  1180. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  1181. round(_A1 __x) _NOEXCEPT
  1182. {
  1183. return __builtin_round((double)__x);
  1184. }
  1185. // scalbln
  1186. inline _LIBCPP_HIDE_FROM_ABI float scalbln(float __x, long __y) _NOEXCEPT {return __builtin_scalblnf(__x, __y);}
  1187. template <class = int>
  1188. _LIBCPP_HIDE_FROM_ABI double scalbln(double __x, long __y) _NOEXCEPT {
  1189. return __builtin_scalbln(__x, __y);
  1190. }
  1191. inline _LIBCPP_HIDE_FROM_ABI long double scalbln(long double __x, long __y) _NOEXCEPT {return __builtin_scalblnl(__x, __y);}
  1192. template <class _A1>
  1193. inline _LIBCPP_HIDE_FROM_ABI
  1194. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  1195. scalbln(_A1 __x, long __y) _NOEXCEPT {return __builtin_scalbln((double)__x, __y);}
  1196. // scalbn
  1197. inline _LIBCPP_HIDE_FROM_ABI float scalbn(float __x, int __y) _NOEXCEPT {return __builtin_scalbnf(__x, __y);}
  1198. template <class = int>
  1199. _LIBCPP_HIDE_FROM_ABI double scalbn(double __x, int __y) _NOEXCEPT {
  1200. return __builtin_scalbn(__x, __y);
  1201. }
  1202. inline _LIBCPP_HIDE_FROM_ABI long double scalbn(long double __x, int __y) _NOEXCEPT {return __builtin_scalbnl(__x, __y);}
  1203. template <class _A1>
  1204. inline _LIBCPP_HIDE_FROM_ABI
  1205. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  1206. scalbn(_A1 __x, int __y) _NOEXCEPT {return __builtin_scalbn((double)__x, __y);}
  1207. // tgamma
  1208. inline _LIBCPP_HIDE_FROM_ABI float tgamma(float __x) _NOEXCEPT {return __builtin_tgammaf(__x);}
  1209. template <class = int>
  1210. _LIBCPP_HIDE_FROM_ABI double tgamma(double __x) _NOEXCEPT {
  1211. return __builtin_tgamma(__x);
  1212. }
  1213. inline _LIBCPP_HIDE_FROM_ABI long double tgamma(long double __x) _NOEXCEPT {return __builtin_tgammal(__x);}
  1214. template <class _A1>
  1215. inline _LIBCPP_HIDE_FROM_ABI
  1216. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  1217. tgamma(_A1 __x) _NOEXCEPT {return __builtin_tgamma((double)__x);}
  1218. // trunc
  1219. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT
  1220. {
  1221. return __builtin_truncf(__x);
  1222. }
  1223. template <class = int>
  1224. _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double trunc(double __x) _NOEXCEPT {
  1225. return __builtin_trunc(__x);
  1226. }
  1227. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __x) _NOEXCEPT
  1228. {
  1229. return __builtin_truncl(__x);
  1230. }
  1231. template <class _A1>
  1232. _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
  1233. typename std::enable_if<std::is_integral<_A1>::value, double>::type
  1234. trunc(_A1 __x) _NOEXCEPT
  1235. {
  1236. return __builtin_trunc((double)__x);
  1237. }
  1238. } // extern "C++"
  1239. #endif // __cplusplus
  1240. #else // _LIBCPP_MATH_OLD_H
  1241. // This include lives outside the header guard in order to support an MSVC
  1242. // extension which allows users to do:
  1243. //
  1244. // #define _USE_MATH_DEFINES
  1245. // #include <math.h>
  1246. //
  1247. // and receive the definitions of mathematical constants, even if <math.h>
  1248. // has previously been included.
  1249. #if defined(_LIBCPP_MSVCRT) && defined(_USE_MATH_DEFINES)
  1250. #include_next <math.h>
  1251. #endif
  1252. #endif // _LIBCPP_MATH_OLD_H