Skip to content

Commit 360f67d

Browse files
committed
Still further adjust degree-based trig functions for more portability.
Indeed, the non-static declaration foreseen in my previous commit message is necessary. Per Noah Misch.
1 parent 65abaab commit 360f67d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/backend/utils/adt/float.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ static int float8_cmp_internal(float8 a, float8 b);
8383
static double sind_q1(double x);
8484
static double cosd_q1(double x);
8585

86+
/* This is INTENTIONALLY NOT STATIC. Don't "fix" it. */
87+
void init_degree_constants(float8 thirty, float8 forty_five, float8 sixty,
88+
float8 one_half, float8 one);
89+
8690
#ifndef HAVE_CBRT
8791
/*
8892
* Some machines (in particular, some versions of AIX) have an extern
@@ -1771,11 +1775,16 @@ dtan(PG_FUNCTION_ARGS)
17711775
* want exact results, we must ensure that none of the scaling constants used
17721776
* in the degree-based trig functions are computed that way.
17731777
*
1778+
* The whole approach fails if init_degree_constants() gets inlined into the
1779+
* call sites, since then constant-folding can happen anyway. Currently it
1780+
* seems sufficient to declare it non-static to prevent that. We have no
1781+
* expectation that other files will call this, but don't tell gcc that.
1782+
*
17741783
* Other hazards we are trying to forestall with this kluge include the
17751784
* possibility that compilers will rearrange the expressions, or compute
17761785
* some intermediate results in registers wider than a standard double.
17771786
*/
1778-
static void
1787+
void
17791788
init_degree_constants(float8 thirty, float8 forty_five, float8 sixty,
17801789
float8 one_half, float8 one)
17811790
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy