Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8a934d6

Browse files
committed
Use isinf builtin for clang, for performance.
When compiling with clang glibc's definition of isinf() ends upleading to and external libc function call. That's because there was abug in the builtin in an old gcc version, and clang claimscompatibility with an older version. That causes clang to bemeasurably slower for floating point heavy workloads than gcc.To fix simply redirect isinf when using clang and clang confirms ithas __builtin_isinf().
1 parent266b6ac commit8a934d6

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

‎src/include/port.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,20 @@ extern intgetpeereid(int sock, uid_t *uid, gid_t *gid);
343343

344344
#ifndefHAVE_ISINF
345345
externintisinf(doublex);
346-
#endif
346+
#else
347+
/*
348+
* Glibc doesn't use the builtin for clang due to a *gcc* bug in a version
349+
* newer than the gcc compatibility clang claims to have. This would cause a
350+
* *lot* of superflous function calls, therefore revert when using clang.
351+
*/
352+
#ifdef__clang__
353+
/* needs to be separate to not confuse other compilers */
354+
#if__has_builtin(__builtin_isinf)
355+
#undef isinf
356+
#defineisinf __builtin_isinf
357+
#endif/* __has_builtin(isinf) */
358+
#endif/* __clang__ */
359+
#endif/* !HAVE_ISINF */
347360

348361
#ifndefHAVE_MKDTEMP
349362
externchar*mkdtemp(char*path);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp