Changeset View
Changeset View
Standalone View
Standalone View
lib/msun/src/math_private.h
Show First 20 Lines • Show All 638 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
#endif /* LDBL_MANT_DIG */ | #endif /* LDBL_MANT_DIG */ | ||||
/* | /* | ||||
* irint() and i64rint() give the same result as casting to their integer | * irint() and i64rint() give the same result as casting to their integer | ||||
* return type provided their arg is a floating point integer. They can | * return type provided their arg is a floating point integer. They can | ||||
* sometimes be more efficient because no rounding is required. | * sometimes be more efficient because no rounding is required. | ||||
*/ | */ | ||||
#if (defined(amd64) || defined(__i386__)) && defined(__GNUCLIKE_ASM) | #if defined(amd64) || defined(__i386__) | ||||
arichardson: Pre-existing but shouldn't this be `defined(__amd64__)`? And I guess _Generic if you want to… | |||||
jhbAuthorUnsubmitted Done Inline ActionsMmmm, interesting. Note that irintf() and irintd() aren't defined for amd64 so I think if this was fixed it wouldn't compile on amd64. jhb: Mmmm, interesting. Note that irintf() and irintd() aren't defined for amd64 so I think if this… | |||||
#define irint(x) \ | #define irint(x) \ | ||||
(sizeof(x) == sizeof(float) && \ | (sizeof(x) == sizeof(float) && \ | ||||
sizeof(__float_t) == sizeof(long double) ? irintf(x) : \ | sizeof(__float_t) == sizeof(long double) ? irintf(x) : \ | ||||
sizeof(x) == sizeof(double) && \ | sizeof(x) == sizeof(double) && \ | ||||
sizeof(__double_t) == sizeof(long double) ? irintd(x) : \ | sizeof(__double_t) == sizeof(long double) ? irintd(x) : \ | ||||
sizeof(x) == sizeof(long double) ? irintl(x) : (int)(x)) | sizeof(x) == sizeof(long double) ? irintl(x) : (int)(x)) | ||||
#else | #else | ||||
#define irint(x) ((int)(x)) | #define irint(x) ((int)(x)) | ||||
#endif | #endif | ||||
#define i64rint(x) ((int64_t)(x)) /* only needed for ld128 so not opt. */ | #define i64rint(x) ((int64_t)(x)) /* only needed for ld128 so not opt. */ | ||||
#if defined(__i386__) && defined(__GNUCLIKE_ASM) | #if defined(__i386__) | ||||
static __inline int | static __inline int | ||||
irintf(float x) | irintf(float x) | ||||
{ | { | ||||
int n; | int n; | ||||
__asm("fistl %0" : "=m" (n) : "t" (x)); | __asm("fistl %0" : "=m" (n) : "t" (x)); | ||||
return (n); | return (n); | ||||
} | } | ||||
static __inline int | static __inline int | ||||
irintd(double x) | irintd(double x) | ||||
{ | { | ||||
int n; | int n; | ||||
__asm("fistl %0" : "=m" (n) : "t" (x)); | __asm("fistl %0" : "=m" (n) : "t" (x)); | ||||
return (n); | return (n); | ||||
} | } | ||||
#endif | #endif | ||||
#if (defined(__amd64__) || defined(__i386__)) && defined(__GNUCLIKE_ASM) | #if defined(__amd64__) || defined(__i386__) | ||||
static __inline int | static __inline int | ||||
irintl(long double x) | irintl(long double x) | ||||
{ | { | ||||
int n; | int n; | ||||
__asm("fistl %0" : "=m" (n) : "t" (x)); | __asm("fistl %0" : "=m" (n) : "t" (x)); | ||||
return (n); | return (n); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 236 Lines • Show Last 20 Lines |
Pre-existing but shouldn't this be defined(__amd64__)? And I guess _Generic if you want to modernize it.