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

Commitc04d35f

Browse files
committed
Try to detect runtime unavailability of __builtin_mul_overflow(int64).
On some systems the results of 64 bit __builtin_mul_overflow()operations can be computed at compile time, but not at runtime. Theknown cases are arm buildfar animals using clang where the runtimeoperation is implemented in a unavailable function.Try to avoid compile-time computation by using volatile arguments to__builtin_mul_overflow(). In that case we hopefully will get a linkerror when unavailable, similar to what buildfarm animals dangomushiand gull are reporting.Author: Andres FreundDiscussion:https://postgr.es/m/20171213213754.pydkyjs6bt2hvsdb@alap3.anarazel.de
1 parentc757a3d commitc04d35f

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

‎config/c-compiler.m4

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,17 @@ fi])# PGAC_C_BUILTIN_CONSTANT_P
310310
# and define HAVE__BUILTIN_OP_OVERFLOW if so.
311311
#
312312
# Check for the most complicated case, 64 bit multiplication, as a
313-
# proxy for all of the operations. Have to link to be sure to
314-
# recognize a missing __builtin_mul_overflow.
313+
# proxy for all of the operations. Use volatile variables to avoid the
314+
# compiler computing result at compile time, even though the runtime
315+
# might not supply operation. Have to link to be sure to recognize a
316+
# missing __builtin_mul_overflow.
315317
AC_DEFUN([PGAC_C_BUILTIN_OP_OVERFLOW],
316318
[AC_CACHE_CHECK(for__builtin_mul_overflow,pgac_cv__builtin_op_overflow,
317319
[AC_LINK_IFELSE([AC_LANG_PROGRAM([],
318-
[PG_INT64_TYPE result;
319-
__builtin_mul_overflow((PG_INT64_TYPE) 1, (PG_INT64_TYPE) 2, &result);]
320+
[PG_INT64_TYPE a = 1;
321+
PG_INT64_TYPE b = 1;
322+
PG_INT64_TYPE result;
323+
__builtin_mul_overflow(*(volatile PG_INT64_TYPE *) a, *(volatile PG_INT64_TYPE *) b, &result);]
320324
)],
321325
[pgac_cv__builtin_op_overflow=yes],
322326
[pgac_cv__builtin_op_overflow=no])])

‎configure

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14488,8 +14488,10 @@ else
1448814488
int
1448914489
main ()
1449014490
{
14491+
PG_INT64_TYPE a = 1;
14492+
PG_INT64_TYPE b = 1;
1449114493
PG_INT64_TYPE result;
14492-
__builtin_mul_overflow((PG_INT64_TYPE) 1, (PG_INT64_TYPE) 2, &result);
14494+
__builtin_mul_overflow(*(volatilePG_INT64_TYPE *) a, *(volatilePG_INT64_TYPE *) b, &result);
1449314495
1449414496
;
1449514497
return 0;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp