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

Commitc6d21d5

Browse files
committed
Try harder to detect unavailability of __builtin_mul_overflow(int64).
Commitc04d35f didn't quite do the job here, because it still allowedthe compiler to deduce that the function call could be optimized away.Prevent that by putting the arguments and results in global variables.Discussion:https://postgr.es/m/20171213213754.pydkyjs6bt2hvsdb@alap3.anarazel.de
1 parentb31a9d7 commitc6d21d5

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

‎config/c-compiler.m4

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -310,18 +310,19 @@ 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.Use volatile variables to avoidthe
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.
313+
# proxy for all of the operations. To detect the case wherethe compiler
314+
#knows the function but library support is missing, we must link not just
315+
#compile, and store the results in global variables so the compiler doesn't
316+
#optimize away the call.
317317
AC_DEFUN([PGAC_C_BUILTIN_OP_OVERFLOW],
318318
[AC_CACHE_CHECK(for__builtin_mul_overflow,pgac_cv__builtin_op_overflow,
319-
[AC_LINK_IFELSE([AC_LANG_PROGRAM([],
320-
[PG_INT64_TYPE a = 1;
319+
[AC_LINK_IFELSE([AC_LANG_PROGRAM([
320+
PG_INT64_TYPE a = 1;
321321
PG_INT64_TYPE b = 1;
322322
PG_INT64_TYPE result;
323-
__builtin_mul_overflow(*(volatile PG_INT64_TYPE *) a, *(volatile PG_INT64_TYPE *) b, &result);]
324-
)],
323+
int oflo;
324+
],
325+
[oflo = __builtin_mul_overflow(a, b, &result);])],
325326
[pgac_cv__builtin_op_overflow=yes],
326327
[pgac_cv__builtin_op_overflow=no])])
327328
if test x"$pgac_cv__builtin_op_overflow" = xyes ; then

‎configure

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14485,14 +14485,15 @@ else
1448514485
cat confdefs.h -<<_ACEOF >conftest.$ac_ext
1448614486
/* end confdefs.h. */
1448714487
14488-
int
14489-
main ()
14490-
{
1449114488
PG_INT64_TYPE a = 1;
1449214489
PG_INT64_TYPE b = 1;
1449314490
PG_INT64_TYPE result;
14494-
__builtin_mul_overflow(*(volatile PG_INT64_TYPE *) a, *(volatile PG_INT64_TYPE *) b, &result);
14491+
int oflo;
1449514492
14493+
int
14494+
main ()
14495+
{
14496+
oflo = __builtin_mul_overflow(a, b, &result);
1449614497
;
1449714498
return 0;
1449814499
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp