Different behaviour when compiling with or without the optimizer
linus@epact.se
linus@epact.se
Tue Oct 26 14:01:00 GMT 1999
I am the maintainer of a client program to a conferencing system. The
client has a function to calculate the phase of the moon. That
function was written back in 1991 by someone else and I havn't touched
it since.
I noticed that the function, if compiled on my newly installed Redhat
6 machine with the egcs compiler, the execution of the function dumps
core with SIGSEGV. If I turn of the optimizer on that module it works
perfectly.
I have then trimmed down the program as much as I can with the same
problem still there and attaches that to this email.
Here is hopefully the information needed for you:
Version of gcc:
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
Source file that reproduces the bug:
================================================================
#include <time.h>
#include <math.h>
static short ix;
static struct tm dt;
#define RADS (M_PI/180.0)
/* When is nearest phase? */
static double
pcon (void)
{
double frc;
double year;
double k;
double t;
double tmp;
int leap;
year = (dt.tm_hour + ((dt.tm_min + (dt.tm_sec / 60.0)) / 60.0)) / 24.0;
year += dt.tm_yday;
/* Leap year? */
leap = dt.tm_year + 1900;
leap = (leap % 4 == 0 && (leap % 100 != 0 || leap % 400 == 0));
/* This year with decimals */
year = dt.tm_year + year / (365.0 + leap);
k = year * 12.3685;
k -= (frc = k - floor (k));
/* Determine nearest phase */
for ( ix = 0 ; frc > ix * 0.25 + 0.125 ; ix++ )
;
t = (k += ix * 0.25) / 1236.85;
tmp = 2415020.75933 + 29.53058868 * k
+ (1.178E-4 - 1.55E-7 * t) * pow (t, 2.0);
tmp += 3.3E-4 * sin (166.56*RADS + 132.87*RADS * t
- 9.173E-3*RADS * pow(t, 2.0));
return t;
}
int
main()
{
time_t cur_time = 0;
dt = *gmtime(&cur_time);
pcon();
}
================================================================
Output from the preprocessor run with optimizer on.
================================================================
$ gcc -O2 p.c -E
# 1 "p.c"
# 1 "/usr/include/time.h" 1 3
# 1 "/usr/include/features.h" 1 3
# 137 "/usr/include/features.h" 3
# 195 "/usr/include/features.h" 3
# 1 "/usr/include/sys/cdefs.h" 1 3
# 71 "/usr/include/sys/cdefs.h" 3
# 103 "/usr/include/sys/cdefs.h" 3
# 249 "/usr/include/features.h" 2 3
# 1 "/usr/include/gnu/stubs.h" 1 3
# 277 "/usr/include/features.h" 2 3
# 28 "/usr/include/time.h" 2 3
# 1 "/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stddef.h" 1 3
# 19 "/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stddef.h" 3
# 61 "/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stddef.h" 3
# 131 "/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stddef.h" 3
typedef unsigned int size_t;
# 271 "/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stddef.h" 3
# 283 "/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stddef.h" 3
# 317 "/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stddef.h" 3
# 38 "/usr/include/time.h" 2 3
# 1 "/usr/include/bits/time.h" 1 3
# 59 "/usr/include/bits/time.h" 3
# 42 "/usr/include/time.h" 2 3
# 1 "/usr/include/bits/types.h" 1 3
# 1 "/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stddef.h" 1 3
# 19 "/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stddef.h" 3
# 61 "/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stddef.h" 3
# 131 "/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stddef.h" 3
# 188 "/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stddef.h" 3
# 271 "/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stddef.h" 3
# 283 "/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stddef.h" 3
# 317 "/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stddef.h" 3
# 29 "/usr/include/bits/types.h" 2 3
typedef unsigned char __u_char;
typedef unsigned short __u_short;
typedef unsigned int __u_int;
typedef unsigned long __u_long;
__extension__ typedef unsigned long long int __u_quad_t;
__extension__ typedef long long int __quad_t;
# 48 "/usr/include/bits/types.h" 3
typedef signed char __int8_t;
typedef unsigned char __uint8_t;
typedef signed short int __int16_t;
typedef unsigned short int __uint16_t;
typedef signed int __int32_t;
typedef unsigned int __uint32_t;
__extension__ typedef signed long long int __int64_t;
__extension__ typedef unsigned long long int __uint64_t;
typedef __quad_t *__qaddr_t;
typedef __u_quad_t __dev_t;
typedef __u_int __uid_t;
typedef __u_int __gid_t;
typedef __u_long __ino_t;
typedef __u_int __mode_t;
typedef __u_int __nlink_t;
typedef long int __off_t;
typedef __quad_t __loff_t;
typedef int __pid_t;
typedef int __ssize_t;
typedef long int __rlim_t;
typedef __quad_t __rlim64_t;
typedef __u_int __id_t;
typedef struct
{
int __val[2];
} __fsid_t;
typedef int __daddr_t;
typedef char *__caddr_t;
typedef long int __time_t;
typedef long int __swblk_t;
typedef long int __clock_t;
typedef unsigned long int __fd_mask;
typedef struct
{
__fd_mask __fds_bits[1024 / (8 * sizeof (__fd_mask)) ];
} __fd_set;
typedef int __key_t;
typedef unsigned short int __ipc_pid_t;
typedef __u_long __blkcnt_t;
typedef __u_quad_t __blkcnt64_t;
typedef long int __fsblkcnt_t;
typedef __quad_t __fsblkcnt64_t;
typedef __u_long __fsfilcnt_t;
typedef __u_quad_t __fsfilcnt64_t;
typedef __u_long __ino64_t;
typedef __loff_t __off64_t;
typedef int __t_scalar_t;
typedef unsigned int __t_uscalar_t;
typedef int __intptr_t;
# 57 "/usr/include/time.h" 2 3
typedef __clock_t clock_t;
typedef __time_t time_t;
struct timespec
{
long int tv_sec;
long int tv_nsec;
};
struct tm
{
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
long int tm_gmtoff;
__const char *tm_zone;
};
extern clock_t clock (void) ;
extern time_t time (time_t *__timer) ;
extern double difftime (time_t __time1, time_t __time0)
__attribute__ ((__const__));
extern time_t mktime (struct tm *__tp) ;
extern size_t strftime (char * __s, size_t __maxsize,
__const char * __format,
__const struct tm * __tp) ;
extern struct tm *gmtime (__const time_t *__timer) ;
extern struct tm *localtime (__const time_t *__timer) ;
extern struct tm *__gmtime_r (__const time_t * __timer,
struct tm * __tp) ;
extern struct tm *gmtime_r (__const time_t * __timer,
struct tm * __tp) ;
extern struct tm *localtime_r (__const time_t * __timer,
struct tm * __tp) ;
extern char *asctime (__const struct tm *__tp) ;
extern char *ctime (__const time_t *__timer) ;
extern char *asctime_r (__const struct tm * __tp,
char * __buf) ;
extern char *ctime_r (__const time_t * __timer,
char * __buf) ;
extern char *__tzname[2];
extern int __daylight;
extern long int __timezone;
extern char *tzname[2];
extern void tzset (void) ;
extern int daylight;
extern long int timezone;
extern int stime (__const time_t *__when) ;
extern time_t timegm (struct tm *__tp) ;
extern time_t timelocal (struct tm *__tp) ;
extern int dysize (int __year) ;
extern int nanosleep (__const struct timespec *__requested_time,
struct timespec *__remaining) ;
# 264 "/usr/include/time.h" 3
# 274 "/usr/include/time.h" 3
# 1 "p.c" 2
# 1 "/usr/include/math.h" 1 3
# 1 "/usr/include/bits/huge_val.h" 1 3
# 68 "/usr/include/bits/huge_val.h" 3
# 33 "/usr/include/math.h" 2 3
# 1 "/usr/include/bits/mathdef.h" 1 3
# 45 "/usr/include/bits/mathdef.h" 3
# 40 "/usr/include/math.h" 2 3
# 1 "/usr/include/bits/mathcalls.h" 1 3
extern double acos (double __x) ; extern double __acos (double __x) ;
extern double asin (double __x) ; extern double __asin (double __x) ;
extern double atan (double __x) ; extern double __atan (double __x) ;
extern double atan2 (double __y, double __x) ; extern double __atan2 (double __y, double __x) ;
extern double cos (double __x) ; extern double __cos (double __x) ;
extern double sin (double __x) ; extern double __sin (double __x) ;
extern double tan (double __x) ; extern double __tan (double __x) ;
extern double cosh (double __x) ; extern double __cosh (double __x) ;
extern double sinh (double __x) ; extern double __sinh (double __x) ;
extern double tanh (double __x) ; extern double __tanh (double __x) ;
extern double acosh (double __x) ; extern double __acosh (double __x) ;
extern double asinh (double __x) ; extern double __asinh (double __x) ;
extern double atanh (double __x) ; extern double __atanh (double __x) ;
extern double exp (double __x) ; extern double __exp (double __x) ;
extern double frexp (double __x, int *__exponent) ; extern double __frexp (double __x, int *__exponent) ;
extern double ldexp (double __x, int __exponent) ; extern double __ldexp (double __x, int __exponent) ;
extern double log (double __x) ; extern double __log (double __x) ;
extern double log10 (double __x) ; extern double __log10 (double __x) ;
extern double modf (double __x, double *__iptr) ; extern double __modf (double __x, double *__iptr) ;
extern double expm1 (double __x) ; extern double __expm1 (double __x) ;
extern double log1p (double __x) ; extern double __log1p (double __x) ;
extern double logb (double __x) ; extern double __logb (double __x) ;
extern double pow (double __x, double __y) ; extern double __pow (double __x, double __y) ;
extern double sqrt (double __x) ; extern double __sqrt (double __x) ;
extern double hypot (double __x, double __y) ; extern double __hypot (double __x, double __y) ;
extern double cbrt (double __x) ; extern double __cbrt (double __x) ;
extern double ceil (double __x) ; extern double __ceil (double __x) ;
extern double fabs (double __x) __attribute__ ( (__const__) ); extern double __fabs (double __x) __attribute__ ( (__const__) ) ;
extern double floor (double __x) ; extern double __floor (double __x) ;
extern double fmod (double __x, double __y) ; extern double __fmod (double __x, double __y) ;
extern int __isinf (double __value) __attribute__ ((__const__));
extern int isinf (double __value) __attribute__ ((__const__));
extern int finite (double __value) __attribute__ ( (__const__) ); extern int __finite (double __value) __attribute__ ( (__const__) ) ;
extern double infnan (int __error) __attribute__ ( (__const__) ); extern double __infnan (int __error) __attribute__ ( (__const__) ) ;
extern double drem (double __x, double __y) ; extern double __drem (double __x, double __y) ;
extern double significand (double __x) ; extern double __significand (double __x) ;
extern double copysign (double __x, double __y) __attribute__ ( (__const__) ); extern double __copysign (double __x, double __y) __attribute__ ( (__const__) ) ;
extern int isnan (double __value) __attribute__ ( (__const__) ); extern int __isnan (double __value) __attribute__ ( (__const__) ) ;
extern double j0 (double ) ; extern double __j0 (double ) ;
extern double j1 (double ) ; extern double __j1 (double ) ;
extern double jn (int, double ) ; extern double __jn (int, double ) ;
extern double y0 (double ) ; extern double __y0 (double ) ;
extern double y1 (double ) ; extern double __y1 (double ) ;
extern double yn (int, double ) ; extern double __yn (int, double ) ;
extern double erf (double ) ; extern double __erf (double ) ;
extern double erfc (double ) ; extern double __erfc (double ) ;
extern double lgamma (double ) ; extern double __lgamma (double ) ;
extern double tgamma (double ) ; extern double __tgamma (double ) ;
extern double gamma (double ) ; extern double __gamma (double ) ;
extern double lgamma_r (double , int *__signgamp) ; extern double __lgamma_r (double , int *__signgamp) ;
extern double rint (double __x) ; extern double __rint (double __x) ;
extern double nextafter (double __x, double __y) __attribute__ ( (__const__) ); extern double __nextafter (double __x, double __y) __attribute__ ( (__const__) ) ;
extern double remainder (double __x, double __y) ; extern double __remainder (double __x, double __y) ;
extern double scalb (double __x, double __n) ; extern double __scalb (double __x, double __n) ;
extern double scalbn (double __x, int __n) ; extern double __scalbn (double __x, int __n) ;
extern int ilogb (double __x) ; extern int __ilogb (double __x) ;
# 330 "/usr/include/bits/mathcalls.h" 3
# 63 "/usr/include/math.h" 2 3
# 1 "/usr/include/bits/mathcalls.h" 1 3
extern float acosf (float __x) ; extern float __acosf (float __x) ;
extern float asinf (float __x) ; extern float __asinf (float __x) ;
extern float atanf (float __x) ; extern float __atanf (float __x) ;
extern float atan2f (float __y, float __x) ; extern float __atan2f (float __y, float __x) ;
extern float cosf (float __x) ; extern float __cosf (float __x) ;
extern float sinf (float __x) ; extern float __sinf (float __x) ;
extern float tanf (float __x) ; extern float __tanf (float __x) ;
extern float coshf (float __x) ; extern float __coshf (float __x) ;
extern float sinhf (float __x) ; extern float __sinhf (float __x) ;
extern float tanhf (float __x) ; extern float __tanhf (float __x) ;
extern float acoshf (float __x) ; extern float __acoshf (float __x) ;
extern float asinhf (float __x) ; extern float __asinhf (float __x) ;
extern float atanhf (float __x) ; extern float __atanhf (float __x) ;
extern float expf (float __x) ; extern float __expf (float __x) ;
extern float frexpf (float __x, int *__exponent) ; extern float __frexpf (float __x, int *__exponent) ;
extern float ldexpf (float __x, int __exponent) ; extern float __ldexpf (float __x, int __exponent) ;
extern float logf (float __x) ; extern float __logf (float __x) ;
extern float log10f (float __x) ; extern float __log10f (float __x) ;
extern float modff (float __x, float *__iptr) ; extern float __modff (float __x, float *__iptr) ;
extern float expm1f (float __x) ; extern float __expm1f (float __x) ;
extern float log1pf (float __x) ; extern float __log1pf (float __x) ;
extern float logbf (float __x) ; extern float __logbf (float __x) ;
extern float powf (float __x, float __y) ; extern float __powf (float __x, float __y) ;
extern float sqrtf (float __x) ; extern float __sqrtf (float __x) ;
extern float hypotf (float __x, float __y) ; extern float __hypotf (float __x, float __y) ;
extern float cbrtf (float __x) ; extern float __cbrtf (float __x) ;
extern float ceilf (float __x) ; extern float __ceilf (float __x) ;
extern float fabsf (float __x) __attribute__ ( (__const__) ); extern float __fabsf (float __x) __attribute__ ( (__const__) ) ;
extern float floorf (float __x) ; extern float __floorf (float __x) ;
extern float fmodf (float __x, float __y) ; extern float __fmodf (float __x, float __y) ;
extern int __isinff (float __value) __attribute__ ((__const__));
extern int isinff (float __value) __attribute__ ((__const__));
extern int finitef (float __value) __attribute__ ( (__const__) ); extern int __finitef (float __value) __attribute__ ( (__const__) ) ;
extern float infnanf (int __error) __attribute__ ( (__const__) ); extern float __infnanf (int __error) __attribute__ ( (__const__) ) ;
extern float dremf (float __x, float __y) ; extern float __dremf (float __x, float __y) ;
extern float significandf (float __x) ; extern float __significandf (float __x) ;
extern float copysignf (float __x, float __y) __attribute__ ( (__const__) ); extern float __copysignf (float __x, float __y) __attribute__ ( (__const__) ) ;
extern int isnanf (float __value) __attribute__ ( (__const__) ); extern int __isnanf (float __value) __attribute__ ( (__const__) ) ;
extern float j0f (float ) ; extern float __j0f (float ) ;
extern float j1f (float ) ; extern float __j1f (float ) ;
extern float jnf (int, float ) ; extern float __jnf (int, float ) ;
extern float y0f (float ) ; extern float __y0f (float ) ;
extern float y1f (float ) ; extern float __y1f (float ) ;
extern float ynf (int, float ) ; extern float __ynf (int, float ) ;
extern float erff (float ) ; extern float __erff (float ) ;
extern float erfcf (float ) ; extern float __erfcf (float ) ;
extern float lgammaf (float ) ; extern float __lgammaf (float ) ;
extern float tgammaf (float ) ; extern float __tgammaf (float ) ;
extern float gammaf (float ) ; extern float __gammaf (float ) ;
extern float lgammaf_r (float , int *__signgamp) ; extern float __lgammaf_r (float , int *__signgamp) ;
extern float rintf (float __x) ; extern float __rintf (float __x) ;
extern float nextafterf (float __x, float __y) __attribute__ ( (__const__) ); extern float __nextafterf (float __x, float __y) __attribute__ ( (__const__) ) ;
extern float remainderf (float __x, float __y) ; extern float __remainderf (float __x, float __y) ;
extern float scalbf (float __x, float __n) ; extern float __scalbf (float __x, float __n) ;
extern float scalbnf (float __x, int __n) ; extern float __scalbnf (float __x, int __n) ;
extern int ilogbf (float __x) ; extern int __ilogbf (float __x) ;
# 330 "/usr/include/bits/mathcalls.h" 3
# 82 "/usr/include/math.h" 2 3
# 1 "/usr/include/bits/mathcalls.h" 1 3
extern long double acosl (long double __x) ; extern long double __acosl (long double __x) ;
extern long double asinl (long double __x) ; extern long double __asinl (long double __x) ;
extern long double atanl (long double __x) ; extern long double __atanl (long double __x) ;
extern long double atan2l (long double __y, long double __x) ; extern long double __atan2l (long double __y, long double __x) ;
extern long double cosl (long double __x) ; extern long double __cosl (long double __x) ;
extern long double sinl (long double __x) ; extern long double __sinl (long double __x) ;
extern long double tanl (long double __x) ; extern long double __tanl (long double __x) ;
extern long double coshl (long double __x) ; extern long double __coshl (long double __x) ;
extern long double sinhl (long double __x) ; extern long double __sinhl (long double __x) ;
extern long double tanhl (long double __x) ; extern long double __tanhl (long double __x) ;
extern long double acoshl (long double __x) ; extern long double __acoshl (long double __x) ;
extern long double asinhl (long double __x) ; extern long double __asinhl (long double __x) ;
extern long double atanhl (long double __x) ; extern long double __atanhl (long double __x) ;
extern long double expl (long double __x) ; extern long double __expl (long double __x) ;
extern long double frexpl (long double __x, int *__exponent) ; extern long double __frexpl (long double __x, int *__exponent) ;
extern long double ldexpl (long double __x, int __exponent) ; extern long double __ldexpl (long double __x, int __exponent) ;
extern long double logl (long double __x) ; extern long double __logl (long double __x) ;
extern long double log10l (long double __x) ; extern long double __log10l (long double __x) ;
extern long double modfl (long double __x, long double *__iptr) ; extern long double __modfl (long double __x, long double *__iptr) ;
extern long double expm1l (long double __x) ; extern long double __expm1l (long double __x) ;
extern long double log1pl (long double __x) ; extern long double __log1pl (long double __x) ;
extern long double logbl (long double __x) ; extern long double __logbl (long double __x) ;
extern long double powl (long double __x, long double __y) ; extern long double __powl (long double __x, long double __y) ;
extern long double sqrtl (long double __x) ; extern long double __sqrtl (long double __x) ;
extern long double hypotl (long double __x, long double __y) ; extern long double __hypotl (long double __x, long double __y) ;
extern long double cbrtl (long double __x) ; extern long double __cbrtl (long double __x) ;
extern long double ceill (long double __x) ; extern long double __ceill (long double __x) ;
extern long double fabsl (long double __x) __attribute__ ( (__const__) ); extern long double __fabsl (long double __x) __attribute__ ( (__const__) ) ;
extern long double floorl (long double __x) ; extern long double __floorl (long double __x) ;
extern long double fmodl (long double __x, long double __y) ; extern long double __fmodl (long double __x, long double __y) ;
extern int __isinfl (long double __value) __attribute__ ((__const__));
extern int isinfl (long double __value) __attribute__ ((__const__));
extern int finitel (long double __value) __attribute__ ( (__const__) ); extern int __finitel (long double __value) __attribute__ ( (__const__) ) ;
extern long double infnanl (int __error) __attribute__ ( (__const__) ); extern long double __infnanl (int __error) __attribute__ ( (__const__) ) ;
extern long double dreml (long double __x, long double __y) ; extern long double __dreml (long double __x, long double __y) ;
extern long double significandl (long double __x) ; extern long double __significandl (long double __x) ;
extern long double copysignl (long double __x, long double __y) __attribute__ ( (__const__) ); extern long double __copysignl (long double __x, long double __y) __attribute__ ( (__const__) ) ;
extern int isnanl (long double __value) __attribute__ ( (__const__) ); extern int __isnanl (long double __value) __attribute__ ( (__const__) ) ;
extern long double j0l (long double ) ; extern long double __j0l (long double ) ;
extern long double j1l (long double ) ; extern long double __j1l (long double ) ;
extern long double jnl (int, long double ) ; extern long double __jnl (int, long double ) ;
extern long double y0l (long double ) ; extern long double __y0l (long double ) ;
extern long double y1l (long double ) ; extern long double __y1l (long double ) ;
extern long double ynl (int, long double ) ; extern long double __ynl (int, long double ) ;
extern long double erfl (long double ) ; extern long double __erfl (long double ) ;
extern long double erfcl (long double ) ; extern long double __erfcl (long double ) ;
extern long double lgammal (long double ) ; extern long double __lgammal (long double ) ;
extern long double tgammal (long double ) ; extern long double __tgammal (long double ) ;
extern long double gammal (long double ) ; extern long double __gammal (long double ) ;
extern long double lgammal_r (long double , int *__signgamp) ; extern long double __lgammal_r (long double , int *__signgamp) ;
extern long double rintl (long double __x) ; extern long double __rintl (long double __x) ;
extern long double nextafterl (long double __x, long double __y) __attribute__ ( (__const__) ); extern long double __nextafterl (long double __x, long double __y) __attribute__ ( (__const__) ) ;
extern long double remainderl (long double __x, long double __y) ; extern long double __remainderl (long double __x, long double __y) ;
extern long double scalbl (long double __x, long double __n) ; extern long double __scalbl (long double __x, long double __n) ;
extern long double scalbnl (long double __x, int __n) ; extern long double __scalbnl (long double __x, int __n) ;
extern int ilogbl (long double __x) ; extern int __ilogbl (long double __x) ;
# 330 "/usr/include/bits/mathcalls.h" 3
# 99 "/usr/include/math.h" 2 3
extern int signgam;
# 232 "/usr/include/math.h" 3
typedef enum
{
_IEEE_ = -1,
_SVID_,
_XOPEN_,
_POSIX_,
_ISOC_
} _LIB_VERSION_TYPE;
extern _LIB_VERSION_TYPE _LIB_VERSION;
struct exception
{
int type;
char *name;
double arg1;
double arg2;
double retval;
};
extern int matherr (struct exception *__exc) ;
# 1 "/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/float.h" 1 3
union __convert_long_double {
unsigned __convert_long_double_i[4];
long double __convert_long_double_d;
};
# 289 "/usr/include/math.h" 2 3
# 299 "/usr/include/math.h" 3
# 336 "/usr/include/math.h" 3
# 1 "/usr/include/bits/mathinline.h" 1 3
# 130 "/usr/include/bits/mathinline.h" 3
extern __inline double __sgn ( double ); extern __inline double __sgn ( double __x ) { return __x == 0.0 ? 0.0 : (__x > 0.0 ? 1.0 : -1.0) ; } extern __inline float __sgnf ( float ); extern __inline float __sgnf ( float __x ) { return __x == 0.0 ? 0.0 : (__x > 0.0 ? 1.0 : -1.0) ; } extern __inline long double __sgnl ( long double ); extern __inline long double __sgnl ( long double __x ) { return __x == 0.0 ? 0.0 : (__x > 0.0 ? 1.0 : -1.0) ; }
extern __inline double __pow2 ( double ); extern __inline double __pow2 ( double __x ) { register long double __value; register long double __exponent; __extension__ long long int __p = (long long int) __x; if (__x == (long double) __p) { __asm __volatile__ ("fscale" : "=t" (__value) : "0" (1.0), "u" (__x)); return __value; } __asm __volatile__ ("fld %%st(0)\n\t" "frndint # int(x)\n\t" "fxch\n\t" "fsub %%st(1) # fract(x)\n\t" "f2xm1 # 2^(fract(x)) - 1\n\t" : "=t" (__value), "=u" (__exponent) : "0" (__x)); __value += 1.0; __asm __volatile__ ("fscale" : "=t" (__value) : "0" (__value), "u" (__exponent)); return __value ; } extern __inline float !
__pow2f ( float ); extern __inline float __pow2f ( float __x ) { register long double __value; register long double __exponent; __extension__ long long int __p = (long long int) __x; if (__x == (long double) __p) { __asm __volatile__ ("fscale" : "=t" (__value) : "0" (1.0), "u" (__x)); return __value; } __asm __volatile__ ("fld %%st(0)\n\t" "frndint # int(x)\n\t" "fxch\n\t" "fsub %%st(1) # fract(x)\n\t" "f2xm1 # 2^(fract(x)) - 1\n\t" : "=t" (__value), "=u" (__exponent) : "0" (__x)); __value += 1.0; __asm __volatile__ ("fscale" : "=t" (__value) : "0" (__value), "u" (__exponent)); return __value ; } extern __inline long double __pow2l ( long dou!
ble ); extern __inline long double __pow2l ( long double __x ) { register long double __value; register long double __exponent; __extension__ long long int __p = (long long int) __x; if (__x == (long double) __p) { __asm __volatile__ ("fscale" : "=t" (__value) : "0" (1.0), "u" (__x)); return __value; } __asm __volatile__ ("fld %%st(0)\n\t" "frndint # int(x)\n\t" "fxch\n\t" "fsub %%st(1) # fract(x)\n\t" "f2xm1 # 2^(fract(x)) - 1\n\t" : "=t" (__value), "=u" (__exponent) : "0" (__x)); __value += 1.0; __asm __volatile__ ("fscale" : "=t" (__value) : "0" (__value), "u" (__exponent)); return __value ; }
# 254 "/usr/include/bits/mathinline.h" 3
# 276 "/usr/include/bits/mathinline.h" 3
extern __inline void __sincos (double __x, double *__sinx, double *__cosx);
extern __inline void
__sincos (double __x, double *__sinx, double *__cosx)
{
register long double __cosr; register long double __sinr; __asm __volatile__ ("fsincos\n\t" "fnstsw %%ax\n\t" "testl $0x400, %%eax\n\t" "jz 1f\n\t" "fldpi\n\t" "fadd %%st(0)\n\t" "fxch %%st(1)\n\t" "2: fprem1\n\t" "fnstsw %%ax\n\t" "testl $0x400, %%eax\n\t" "jnz 2b\n\t" "fstp %%st(1)\n\t" "fsincos\n\t" "1:" : "=t" (__cosr), "=u" (__sinr) : "0" (__x)); *__sinx = __sinr; *__cosx = __cosr ;
}
extern __inline void __sincosf (float __x, float *__sinx, float *__cosx);
extern __inline void
__sincosf (float __x, float *__sinx, float *__cosx)
{
register long double __cosr; register long double __sinr; __asm __volatile__ ("fsincos\n\t" "fnstsw %%ax\n\t" "testl $0x400, %%eax\n\t" "jz 1f\n\t" "fldpi\n\t" "fadd %%st(0)\n\t" "fxch %%st(1)\n\t" "2: fprem1\n\t" "fnstsw %%ax\n\t" "testl $0x400, %%eax\n\t" "jnz 2b\n\t" "fstp %%st(1)\n\t" "fsincos\n\t" "1:" : "=t" (__cosr), "=u" (__sinr) : "0" (__x)); *__sinx = __sinr; *__cosx = __cosr ;
}
extern __inline void __sincosl (long double __x, long double *__sinx,
long double *__cosx);
extern __inline void
__sincosl (long double __x, long double *__sinx, long double *__cosx)
{
register long double __cosr; register long double __sinr; __asm __volatile__ ("fsincos\n\t" "fnstsw %%ax\n\t" "testl $0x400, %%eax\n\t" "jz 1f\n\t" "fldpi\n\t" "fadd %%st(0)\n\t" "fxch %%st(1)\n\t" "2: fprem1\n\t" "fnstsw %%ax\n\t" "testl $0x400, %%eax\n\t" "jnz 2b\n\t" "fstp %%st(1)\n\t" "fsincos\n\t" "1:" : "=t" (__cosr), "=u" (__sinr) : "0" (__x)); *__sinx = __sinr; *__cosx = __cosr ;
}
# 322 "/usr/include/bits/mathinline.h" 3
extern __inline long double __expm1l ( long double ); extern __inline long double __expm1l ( long double __x ) { register long double __value; register long double __exponent; register long double __temp; __asm __volatile__ ("fldl2e # e^x - 1 = 2^(x * log2(e)) - 1\n\t" "fmul %%st(1) # x * log2(e)\n\t" "fst %%st(1)\n\t" "frndint # int(x * log2(e))\n\t" "fxch\n\t" "fsub %%st(1) # fract(x * log2(e))\n\t" "f2xm1 # 2^(fract(x * log2(e))) - 1\n\t" "fscale # 2^(x * log2(e)) - 2^(int(x * log2(e)))\n\t" : "=t" (__value), "=u" (__exponent) : "0" (__x)); __asm __volatile__ ("fscale # 2^int(x * log2(e))\n\t" : "=t" (__temp) : "0" (1.0), "u" (__exponent)); __temp -= 1.0; return __temp + __value ; }
# 342 "/usr/include/bits/mathinline.h" 3
extern __inline double exp ( double ); extern __inline double exp ( double __x ) { register long double __value; register long double __exponent; __asm __volatile__ ("fldl2e # e^x = 2^(x * log2(e))\n\t" "fmul %%st(1) # x * log2(e)\n\t" "fst %%st(1)\n\t" "frndint # int(x * log2(e))\n\t" "fxch\n\t" "fsub %%st(1) # fract(x * log2(e))\n\t" "f2xm1 # 2^(fract(x * log2(e))) - 1\n\t" : "=t" (__value), "=u" (__exponent) : "0" (__x)); __value += 1.0; __asm __volatile__ ("fscale" : "=t" (__value) : "0" (__value), "u" (__exponent)); return __value ; } extern __inline float expf ( float ); extern __inline float expf ( float __x ) { register long double __value; register long double __exponent; __asm __volatile__ ("fldl2e # e^x = 2^(x * log2(e))\n\t" "fmul %%st(1) # x * log2(e)\n\t" "fst %%st(1)\n\t" "frndint # int(x * log2(e))\n\t" "fxch\n\t" "fsub %%st(1) # fract(x * log2(e))\n\t" "f2xm1 # 2^(fract(x * log2(e))) - !
1\n\t" : "=t" (__value), "=u" (__exponent) : "0" (__x)); __value += 1.0; __asm __volatile__ ("fscale" : "=t" (__value) : "0" (__value), "u" (__exponent)); return __value ; } extern __inline long double expl ( long double ); extern __inline long double expl ( long double __x ) { register long double __value; register long double __exponent; __asm __volatile__ ("fldl2e # e^x = 2^(x * log2(e))\n\t" "fmul %%st(1) # x * log2(e)\n\t" "fst %%st(1)\n\t" "frndint # int(x * log2(e))\n\t" "fxch\n\t" "fsub %%st(1) # fract(x * log2(e))\n\t" "f2xm1 # 2^(fract(x * log2(e))) - 1\n\t" : "=t" (__value), "=u" (__exponent) : "0" (__x)); __value += 1.0; __asm __volatile__ ("fscale" : "=t" (__value) : "0" (__value), "u" (__exponent)); return __value ; }
extern __inline long double __expl ( long double ); extern __inline long double __expl ( long double __x ) { register long double __value; register long double __exponent; __asm __volatile__ ("fldl2e # e^x = 2^(x * log2(e))\n\t" "fmul %%st(1) # x * log2(e)\n\t" "fst %%st(1)\n\t" "frndint # int(x * log2(e))\n\t" "fxch\n\t" "fsub %%st(1) # fract(x * log2(e))\n\t" "f2xm1 # 2^(fract(x * log2(e))) - 1\n\t" : "=t" (__value), "=u" (__exponent) : "0" (__x)); __value += 1.0; __asm __volatile__ ("fscale" : "=t" (__value) : "0" (__value), "u" (__exponent)); return __value ; }
extern __inline double tan ( double ); extern __inline double tan ( double __x ) { register long double __value; register long double __value2 __attribute__ ((__unused__)); __asm __volatile__ ("fptan" : "=t" (__value2), "=u" (__value) : "0" (__x)); return __value ; } extern __inline float tanf ( float ); extern __inline float tanf ( float __x ) { register long double __value; register long double __value2 __attribute__ ((__unused__)); __asm __volatile__ ("fptan" : "=t" (__value2), "=u" (__value) : "0" (__x)); return __value ; } extern __inline long double tanl ( long double ); extern __inline long double tanl ( long double __x ) { register long double __value; register long double __value2 __attribute__ ((__unused__)); __asm __vola!
tile__ ("fptan" : "=t" (__value2), "=u" (__value) : "0" (__x)); return __value ; }
extern __inline double atan2 ( double , double ); extern __inline double atan2 ( double __y , double __x ) { register long double __value; __asm __volatile__ ("fpatan\n\t" : "=t" (__value) : "0" (__x), "u" (__y) : "st(1)"); return __value ; } extern __inline float atan2f ( float , float ); extern __inline float atan2f ( float __y , float __x ) { register long double __value; __asm __volatile__ ("fpatan\n\t" : "=t" (__value) : "0" (__x), "u" (__y) : "st(1)"); return __value ; } extern __inline long double atan2l ( long double , long double ); extern __inline long double atan2l ( long double __y , long double __x ) { register long double __value; __asm __volatile__ ("fpatan\n\t" : "=t" (__value) : "0" (__x), "u" (__y) : "st(1)"); return __value ; }
extern __inline long double __atan2l ( long double , long double ); extern __inline long double __atan2l ( long double __y , long double __x ) { register long double __value; __asm __volatile__ ("fpatan\n\t" : "=t" (__value) : "0" (__x), "u" (__y) : "st(1)"); return __value ; }
extern __inline double fmod ( double , double ); extern __inline double fmod ( double __x , double __y ) { register long double __value; __asm __volatile__ ("1: fprem\n\t" "fnstsw %%ax\n\t" "sahf\n\t" "jp 1b" : "=t" (__value) : "0" (__x), "u" (__y) : "ax", "cc"); return __value ; } extern __inline float fmodf ( float , float ); extern __inline float fmodf ( float __x , float __y ) { register long double __value; __asm __volatile__ ("1: fprem\n\t" "fnstsw %%ax\n\t" "sahf\n\t" "jp 1b" : "=t" (__value) : "0" (__x), "u" (__y) : "ax", "cc"); return __value ; } extern __inline long double fmodl ( long double , long double ); extern __inline long double fmodl ( long double !
__x , long double __y ) { register long double __value; __asm __volatile__ ("1: fprem\n\t" "fnstsw %%ax\n\t" "sahf\n\t" "jp 1b" : "=t" (__value) : "0" (__x), "u" (__y) : "ax", "cc"); return __value ; }
# 374 "/usr/include/bits/mathinline.h" 3
extern __inline double pow ( double , double ); extern __inline double pow ( double __x , double __y ) { register long double __value; register long double __exponent; __extension__ long long int __p = (long long int) __y; if (__x == 0.0 && __y > 0.0) return 0.0; if (__y == (double) __p) { long double __r = 1.0; if (__p == 0) return 1.0; if (__p < 0) { __p = -__p; __x = 1.0 / __x; } while (1) { if (__p & 1) __r *= __x; __p >>= 1; if (__p == 0) return __r; __x *= __x; } } __asm __volatile__ ("fyl2x" : "=t" (__value) : "0" (__x), "u" (1.0!
) : "st(1)"); __asm __volatile__ ("fmul %%st(1) # y * log2(x)\n\t" "fst %%st(1)\n\t" "frndint # int(y * log2(x))\n\t" "fxch\n\t" "fsub %%st(1) # fract(y * log2(x))\n\t" "f2xm1 # 2^(fract(y * log2(x))) - 1\n\t" : "=t" (__value), "=u" (__exponent) : "0" (__y), "1" (__value)); __value += 1.0; __asm __volatile__ ("fscale" : "=t" (__value) : "0" (__value), "u" (__exponent)); return __value ; } extern __inline float powf ( float , float ); extern __inline float powf ( float __x , float __y ) { register long double __value; register long double __exponent; __extension__ long long int __p = (long long int) __y; if (__x == 0.0 && __y > 0.0) return 0.0; if (__y == (double) __p) { !
long double __r = 1.0; if (__p == 0) return 1.0; if (__p < 0) { __p = -__p; __x = 1.0 / __x; } while (1) { if (__p & 1) __r *= __x; __p >>= 1; if (__p == 0) return __r; __x *= __x; } } __asm __volatile__ ("fyl2x" : "=t" (__value) : "0" (__x), "u" (1.0) : "st(1)"); __asm __volatile__ ("fmul %%st(1) # y * log2(x)\n\t" "fst %%st(1)\n\t" "frndint # int(y * log2(x))\n\t" "fxch\n\t" "fsub %%st(1) # fract(y * log2(x))\n\t" "f2xm1 # 2^(fract(y * log2(x))) - 1\n\t" : "=t" (__value), "=u" (__exponent) : "0" (__y), "1" (__value)); __value += 1.0; !
__asm __volatile__ ("fscale" : "=t" (__value) : "0" (__value), "u" (__exponent)); return __value ; } extern __inline long double powl ( long double , long double ); extern __inline long double powl ( long double __x , long double __y ) { register long double __value; register long double __exponent; __extension__ long long int __p = (long long int) __y; if (__x == 0.0 && __y > 0.0) return 0.0; if (__y == (double) __p) { long double __r = 1.0; if (__p == 0) return 1.0; if (__p < 0) { __p = -__p; __x = 1.0 / __x; } while (1) { if (__p & 1) __r *= __x; __p >>= 1; if (__p == 0) re!
turn __r; __x *= __x; } } __asm __volatile__ ("fyl2x" : "=t" (__value) : "0" (__x), "u" (1.0) : "st(1)"); __asm __volatile__ ("fmul %%st(1) # y * log2(x)\n\t" "fst %%st(1)\n\t" "frndint # int(y * log2(x))\n\t" "fxch\n\t" "fsub %%st(1) # fract(y * log2(x))\n\t" "f2xm1 # 2^(fract(y * log2(x))) - 1\n\t" : "=t" (__value), "=u" (__exponent) : "0" (__y), "1" (__value)); __value += 1.0; __asm __volatile__ ("fscale" : "=t" (__value) : "0" (__value), "u" (__exponent)); return __value ; }
# 418 "/usr/include/bits/mathinline.h" 3
extern __inline double sqrt ( double ); extern __inline double sqrt ( double __x) { register double __result; __asm __volatile__ ( "fsqrt" : "=t" (__result) : "0" (__x) ); return __result; } extern __inline float sqrtf ( float ); extern __inline float sqrtf ( float __x) { register float __result; __asm __volatile__ ( "fsqrt" : "=t" (__result) : "0" (__x) ); return __result; } extern __inline long double sqrtl ( long double ); extern __inline long double sqrtl ( long double __x) { register long double __result; __asm __volatile__ ( "fsqrt" : "=t" (__result) : "0" (__x) ); return __result; }
extern __inline long double __sqrtl ( long double ); extern __inline long double __sqrtl ( long double __x) { register long double __result; __asm __volatile__ ( "fsqrt" : "=t" (__result) : "0" (__x) ); return __result; }
extern __inline double fabs ( double ); extern __inline double fabs ( double __x ) { return __builtin_fabs (__x) ; }
extern __inline float fabsf ( float ); extern __inline float fabsf ( float __x ) { return __builtin_fabsf (__x) ; }
extern __inline long double fabsl ( long double ); extern __inline long double fabsl ( long double __x ) { return __builtin_fabsl (__x) ; }
extern __inline long double __fabsl ( long double ); extern __inline long double __fabsl ( long double __x ) { return __builtin_fabsl (__x) ; }
extern __inline double sin ( double ); extern __inline double sin ( double __x) { register double __result; __asm __volatile__ ( "fsin" : "=t" (__result) : "0" (__x) ); return __result; } extern __inline float sinf ( float ); extern __inline float sinf ( float __x) { register float __result; __asm __volatile__ ( "fsin" : "=t" (__result) : "0" (__x) ); return __result; } extern __inline long double sinl ( long double ); extern __inline long double sinl ( long double __x) { register long double __result; __asm __volatile__ ( "fsin" : "=t" (__result) : "0" (__x) ); return __result; }
extern __inline double cos ( double ); extern __inline double cos ( double __x) { register double __result; __asm __volatile__ ( "fcos" : "=t" (__result) : "0" (__x) ); return __result; } extern __inline float cosf ( float ); extern __inline float cosf ( float __x) { register float __result; __asm __volatile__ ( "fcos" : "=t" (__result) : "0" (__x) ); return __result; } extern __inline long double cosl ( long double ); extern __inline long double cosl ( long double __x) { register long double __result; __asm __volatile__ ( "fcos" : "=t" (__result) : "0" (__x) ); return __result; }
extern __inline double atan ( double ); extern __inline double atan ( double __x) { register double __result; __asm __volatile__ ( "fld1; fpatan" : "=t" (__result) : "0" (__x) ); return __result; } extern __inline float atanf ( float ); extern __inline float atanf ( float __x) { register float __result; __asm __volatile__ ( "fld1; fpatan" : "=t" (__result) : "0" (__x) ); return __result; } extern __inline long double atanl ( long double ); extern __inline long double atanl ( long double __x) { register long double __result; __asm __volatile__ ( "fld1; fpatan" : "=t" (__result) : "0" (__x) ); return __result; }
extern __inline double log ( double ); extern __inline double log ( double __x) { register double __result; __asm __volatile__ ( "fldln2; fxch; fyl2x" : "=t" (__result) : "0" (__x) ); return __result; } extern __inline float logf ( float ); extern __inline float logf ( float __x) { register float __result; __asm __volatile__ ( "fldln2; fxch; fyl2x" : "=t" (__result) : "0" (__x) ); return __result; } extern __inline long double logl ( long double ); extern __inline long double logl ( long double __x) { register long double __result; __asm __volatile__ ( "fldln2; fxch; fyl2x" : "=t" (__result) : "0" (__x) ); return __result; }
extern __inline double log10 ( double ); extern __inline double log10 ( double __x) { register double __result; __asm __volatile__ ( "fldlg2; fxch; fyl2x" : "=t" (__result) : "0" (__x) ); return __result; } extern __inline float log10f ( float ); extern __inline float log10f ( float __x) { register float __result; __asm __volatile__ ( "fldlg2; fxch; fyl2x" : "=t" (__result) : "0" (__x) ); return __result; } extern __inline long double log10l ( long double ); extern __inline long double log10l ( long double __x) { register long double __result; __asm __volatile__ ( "fldlg2; fxch; fyl2x" : "=t" (__result) : "0" (__x) ); return __result; }
extern __inline double asin ( double ); extern __inline double asin ( double __x ) { return __atan2l (__x, __sqrtl (1.0 - __x * __x)) ; } extern __inline float asinf ( float ); extern __inline float asinf ( float __x ) { return __atan2l (__x, __sqrtl (1.0 - __x * __x)) ; } extern __inline long double asinl ( long double ); extern __inline long double asinl ( long double __x ) { return __atan2l (__x, __sqrtl (1.0 - __x * __x)) ; }
extern __inline double acos ( double ); extern __inline double acos ( double __x ) { return __atan2l (__sqrtl (1.0 - __x * __x), __x) ; } extern __inline float acosf ( float ); extern __inline float acosf ( float __x ) { return __atan2l (__sqrtl (1.0 - __x * __x), __x) ; } extern __inline long double acosl ( long double ); extern __inline long double acosl ( long double __x ) { return __atan2l (__sqrtl (1.0 - __x * __x), __x) ; }
extern __inline long double __sgn1l ( long double ); extern __inline long double __sgn1l ( long double __x ) { return __x >= 0.0 ? 1.0 : -1.0 ; }
extern __inline double sinh ( double ); extern __inline double sinh ( double __x ) { register long double __exm1 = __expm1l (__fabsl (__x)); return 0.5 * (__exm1 / (__exm1 + 1.0) + __exm1) * __sgn1l (__x) ; } extern __inline float sinhf ( float ); extern __inline float sinhf ( float __x ) { register long double __exm1 = __expm1l (__fabsl (__x)); return 0.5 * (__exm1 / (__exm1 + 1.0) + __exm1) * __sgn1l (__x) ; } extern __inline long double sinhl ( long double ); extern __inline long double sinhl ( long double __x ) { register long double __exm1 = __expm1l (__fabsl (__x)); return 0.5 * (__exm1 / (__exm1 + 1.0) + __exm1) * __sgn1l (__x) ; }
extern __inline double cosh ( double ); extern __inline double cosh ( double __x ) { register long double __ex = __expl (__x); return 0.5 * (__ex + 1.0 / __ex) ; } extern __inline float coshf ( float ); extern __inline float coshf ( float __x ) { register long double __ex = __expl (__x); return 0.5 * (__ex + 1.0 / __ex) ; } extern __inline long double coshl ( long double ); extern __inline long double coshl ( long double __x ) { register long double __ex = __expl (__x); return 0.5 * (__ex + 1.0 / __ex) ; }
extern __inline double tanh ( double ); extern __inline double tanh ( double __x ) { register long double __exm1 = __expm1l (-__fabsl (__x + __x)); return __exm1 / (__exm1 + 2.0) * __sgn1l (-__x) ; } extern __inline float tanhf ( float ); extern __inline float tanhf ( float __x ) { register long double __exm1 = __expm1l (-__fabsl (__x + __x)); return __exm1 / (__exm1 + 2.0) * __sgn1l (-__x) ; } extern __inline long double tanhl ( long double ); extern __inline long double tanhl ( long double __x ) { register long double __exm1 = __expm1l (-__fabsl (__x + __x)); return __exm1 / (__exm1 + 2.0) * __sgn1l (-__x) ; }
extern __inline double floor ( double ); extern __inline double floor ( double __x ) { register long double __value; __volatile unsigned short int __cw; __volatile unsigned short int __cwtmp; __asm __volatile ("fnstcw %0" : "=m" (__cw)); __cwtmp = (__cw & 0xf3ff) | 0x0400; __asm __volatile ("fldcw %0" : : "m" (__cwtmp)); __asm __volatile ("frndint" : "=t" (__value) : "0" (__x)); __asm __volatile ("fldcw %0" : : "m" (__cw)); return __value ; } extern __inline float floorf ( float ); extern __inline float floorf ( float __x ) { register long double __value; __volatile unsigned short int __cw; __volatile unsigned short int __cwtmp; __asm __volatile ("fnstcw %0" : "=m" (__cw)); __cwtmp = (__cw & 0xf3ff) | 0x0400; __asm __volatile ("fldcw %0" : : "m" (__cwtmp)); __asm!
__volatile ("frndint" : "=t" (__value) : "0" (__x)); __asm __volatile ("fldcw %0" : : "m" (__cw)); return __value ; } extern __inline long double floorl ( long double ); extern __inline long double floorl ( long double __x ) { register long double __value; __volatile unsigned short int __cw; __volatile unsigned short int __cwtmp; __asm __volatile ("fnstcw %0" : "=m" (__cw)); __cwtmp = (__cw & 0xf3ff) | 0x0400; __asm __volatile ("fldcw %0" : : "m" (__cwtmp)); __asm __volatile ("frndint" : "=t" (__value) : "0" (__x)); __asm __volatile ("fldcw %0" : : "m" (__cw)); return __value ; }
# 472 "/usr/include/bits/mathinline.h" 3
extern __inline double ceil ( double ); extern __inline double ceil ( double __x ) { register long double __value; __volatile unsigned short int __cw; __volatile unsigned short int __cwtmp; __asm __volatile ("fnstcw %0" : "=m" (__cw)); __cwtmp = (__cw & 0xf3ff) | 0x0800; __asm __volatile ("fldcw %0" : : "m" (__cwtmp)); __asm __volatile ("frndint" : "=t" (__value) : "0" (__x)); __asm __volatile ("fldcw %0" : : "m" (__cw)); return __value ; } extern __inline float ceilf ( float ); extern __inline float ceilf ( float __x ) { register long double __value; __volatile unsigned short int __cw; __volatile unsigned short int __cwtmp; __asm __volatile ("fnstcw %0" : "=m" (__cw)); __cwtmp = (__cw & 0xf3ff) | 0x0800; __asm __volatile ("fldcw %0" : : "m" (__cwtmp)); __asm _!
_volatile ("frndint" : "=t" (__value) : "0" (__x)); __asm __volatile ("fldcw %0" : : "m" (__cw)); return __value ; } extern __inline long double ceill ( long double ); extern __inline long double ceill ( long double __x ) { register long double __value; __volatile unsigned short int __cw; __volatile unsigned short int __cwtmp; __asm __volatile ("fnstcw %0" : "=m" (__cw)); __cwtmp = (__cw & 0xf3ff) | 0x0800; __asm __volatile ("fldcw %0" : : "m" (__cwtmp)); __asm __volatile ("frndint" : "=t" (__value) : "0" (__x)); __asm __volatile ("fldcw %0" : : "m" (__cw)); return __value ; }
# 483 "/usr/include/bits/mathinline.h" 3
extern __inline double ldexp (double __x, int __y);
extern __inline double
ldexp (double __x, int __y)
{
register long double __value; __asm __volatile__ ("fscale" : "=t" (__value) : "0" (__x), "u" ((long double) __y)); return __value ;
}
extern __inline double expm1 ( double ); extern __inline double expm1 ( double __x ) { register long double __value; register long double __exponent; register long double __temp; __asm __volatile__ ("fldl2e # e^x - 1 = 2^(x * log2(e)) - 1\n\t" "fmul %%st(1) # x * log2(e)\n\t" "fst %%st(1)\n\t" "frndint # int(x * log2(e))\n\t" "fxch\n\t" "fsub %%st(1) # fract(x * log2(e))\n\t" "f2xm1 # 2^(fract(x * log2(e))) - 1\n\t" "fscale # 2^(x * log2(e)) - 2^(int(x * log2(e)))\n\t" : "=t" (__value), "=u" (__exponent) : "0" (__x)); __asm __volatile__ ("fscale # 2^int(x * log2(e))\n\t" : "=t" (__temp) : "0" (1.0), "u" (__exponent)); __temp -= 1.0; return __temp + __value ; } extern __inline float expm1f ( float ); extern __inline float expm1f ( float __x ) { register long double __value; register long double __exponent; register long double __temp; __asm __volatile__ ("fldl2e # e^x - 1 = 2^(x * log2(e)) - 1\n\t" "fmul %!
%st(1) # x * log2(e)\n\t" "fst %%st(1)\n\t" "frndint # int(x * log2(e))\n\t" "fxch\n\t" "fsub %%st(1) # fract(x * log2(e))\n\t" "f2xm1 # 2^(fract(x * log2(e))) - 1\n\t" "fscale # 2^(x * log2(e)) - 2^(int(x * log2(e)))\n\t" : "=t" (__value), "=u" (__exponent) : "0" (__x)); __asm __volatile__ ("fscale # 2^int(x * log2(e))\n\t" : "=t" (__temp) : "0" (1.0), "u" (__exponent)); __temp -= 1.0; return __temp + __value ; } extern __inline long double expm1l ( long double ); extern __inline long double expm1l ( long double __x ) { register long double __value; register long double __exponent; register long double __temp; __asm __volatile__ ("fldl2e # e^x - 1 = 2^(x * log2(e)) - 1\n\t" "fmul %%st(1) # x * log2(e)\n\t" "fst %%st(1)\n\t" "frndint # int(x * log2(e))\n\t" "fxch\n\t" "fsub %%st(1) # fract(x * log2(e))\n\t" "f2xm1 # 2^(fract(x * log2(e))) - 1\n\t" "fscale # 2^(x * log2(e)) - 2^(int(x * log2(e)))\n\t" : "=t" (__value), "=u" (!
__exponent) : "0" (__x)); __asm __volatile__ ("fscale # 2^int(x * log2(e))\n\t" : "=t" (__temp) : "0" (1.0), "u" (__exponent)); __temp -= 1.0; return __temp + __value ; }
extern __inline double log1p ( double ); extern __inline double log1p ( double __x ) { register long double __value; if (__fabsl (__x) >= 1.0 - 0.5 * 1.41421356237309504880L ) __value = logl (1.0 + __x); else __asm __volatile__ ("fldln2\n\t" "fxch\n\t" "fyl2xp1" : "=t" (__value) : "0" (__x)); return __value ; } extern __inline float log1pf ( float ); extern __inline float log1pf ( float __x ) { register long double __value; if (__fabsl (__x) >= 1.0 - 0.5 * 1.41421356237309504880L ) __value = logl (1.0 + __x); else __asm __volatile__ ("fldln2\n\t" "fxch\n\t" "fyl2xp1" : "=t" (__value) : "0" (__x)); return __value ; } extern __inline!
long double log1pl ( long double ); extern __inline long double log1pl ( long double __x ) { register long double __value; if (__fabsl (__x) >= 1.0 - 0.5 * 1.41421356237309504880L ) __value = logl (1.0 + __x); else __asm __volatile__ ("fldln2\n\t" "fxch\n\t" "fyl2xp1" : "=t" (__value) : "0" (__x)); return __value ; }
# 519 "/usr/include/bits/mathinline.h" 3
extern __inline double asinh ( double ); extern __inline double asinh ( double __x ) { register long double __y = __fabsl (__x); return (log1pl (__y * __y / (__sqrtl (__y * __y + 1.0) + 1.0) + __y) * __sgn1l (__x)) ; } extern __inline float asinhf ( float ); extern __inline float asinhf ( float __x ) { register long double __y = __fabsl (__x); return (log1pl (__y * __y / (__sqrtl (__y * __y + 1.0) + 1.0) + __y) * __sgn1l (__x)) ; } extern __inline long double asinhl ( long double ); extern __inline long double asinhl ( long double __x ) { register long double __y = __fabsl (__x); return (log1pl (__y * __y / (__sqrtl (__y * __y + 1.0) + 1.0) + __y) * __sgn1l (__x)) ; }
extern __inline double acosh ( double ); extern __inline double acosh ( double __x ) { return logl (__x + __sqrtl (__x - 1.0) * __sqrtl (__x + 1.0)) ; } extern __inline float acoshf ( float ); extern __inline float acoshf ( float __x ) { return logl (__x + __sqrtl (__x - 1.0) * __sqrtl (__x + 1.0)) ; } extern __inline long double acoshl ( long double ); extern __inline long double acoshl ( long double __x ) { return logl (__x + __sqrtl (__x - 1.0) * __sqrtl (__x + 1.0)) ; }
extern __inline double atanh ( double ); extern __inline double atanh ( double __x ) { register long double __y = __fabsl (__x); return -0.5 * log1pl (-(__y + __y) / (1.0 + __y)) * __sgn1l (__x) ; } extern __inline float atanhf ( float ); extern __inline float atanhf ( float __x ) { register long double __y = __fabsl (__x); return -0.5 * log1pl (-(__y + __y) / (1.0 + __y)) * __sgn1l (__x) ; } extern __inline long double atanhl ( long double ); extern __inline long double atanhl ( long double __x ) { register long double __y = __fabsl (__x); return -0.5 * log1pl (-(__y + __y) / (1.0 + __y)) * __sgn1l (__x) ; }
extern __inline double hypot ( double , double ); extern __inline double hypot ( double __x , double __y ) { return __sqrtl (__x * __x + __y * __y) ; } extern __inline float hypotf ( float , float ); extern __inline float hypotf ( float __x , float __y ) { return __sqrtl (__x * __x + __y * __y) ; } extern __inline long double hypotl ( long double , long double ); extern __inline long double hypotl ( long double __x , long double __y ) { return __sqrtl (__x * __x + __y * __y) ; }
extern __inline double logb ( double ); extern __inline double logb ( double __x ) { register long double __value; register long double __junk; __asm __volatile__ ("fxtract\n\t" : "=t" (__junk), "=u" (__value) : "0" (__x)); return __value ; } extern __inline float logbf ( float ); extern __inline float logbf ( float __x ) { register long double __value; register long double __junk; __asm __volatile__ ("fxtract\n\t" : "=t" (__junk), "=u" (__value) : "0" (__x)); return __value ; } extern __inline long double logbl ( long double ); extern __inline long double logbl ( long double __x ) { register long double __value; register long double __junk; __asm __volatile__ ("fxtract\n\t" : "=t" (__junk!
), "=u" (__value) : "0" (__x)); return __value ; }
# 614 "/usr/include/bits/mathinline.h" 3
extern __inline double drem ( double , double ); extern __inline double drem ( double __x , double __y ) { register double __value; register int __clobbered; __asm __volatile__ ("1: fprem1\n\t" "fstsw %%ax\n\t" "sahf\n\t" "jp 1b" : "=t" (__value), "=&a" (__clobbered) : "0" (__x), "u" (__y) : "cc"); return __value ; } extern __inline float dremf ( float , float ); extern __inline float dremf ( float __x , float __y ) { register double __value; register int __clobbered; __asm __volatile__ ("1: fprem1\n\t" "fstsw %%ax\n\t" "sahf\n\t" "jp 1b" : "=t" (__value), "=&a" (__clobbered) : "0" (__x), "u" (__y) : "cc"); return __value ; } extern __inline long double dreml ( lon!
g double , long double ); extern __inline long double dreml ( long double __x , long double __y ) { register double __value; register int __clobbered; __asm __volatile__ ("1: fprem1\n\t" "fstsw %%ax\n\t" "sahf\n\t" "jp 1b" : "=t" (__value), "=&a" (__clobbered) : "0" (__x), "u" (__y) : "cc"); return __value ; }
# 629 "/usr/include/bits/mathinline.h" 3
extern __inline int __finite (double __x) __attribute__ ((__const__));
extern __inline int
__finite (double __x)
{
return (__extension__
(((((union { double __d; int __i[2]; }) {__d: __x}).__i[1]
| 0x800fffff) + 1) >> 31));
}
extern __inline double __coshm1 ( double ); extern __inline double __coshm1 ( double __x ) { register long double __exm1 = __expm1l (__fabsl (__x)); return 0.5 * (__exm1 / (__exm1 + 1.0)) * __exm1 ; } extern __inline float __coshm1f ( float ); extern __inline float __coshm1f ( float __x ) { register long double __exm1 = __expm1l (__fabsl (__x)); return 0.5 * (__exm1 / (__exm1 + 1.0)) * __exm1 ; } extern __inline long double __coshm1l ( long double ); extern __inline long double __coshm1l ( long double __x ) { register long double __exm1 = __expm1l (__fabsl (__x)); return 0.5 * (__exm1 / (__exm1 + 1.0)) * __exm1 ; }
extern __inline double __acosh1p ( double ); extern __inline double __acosh1p ( double __x ) { return log1pl (__x + __sqrtl (__x) * __sqrtl (__x + 2.0)) ; } extern __inline float __acosh1pf ( float ); extern __inline float __acosh1pf ( float __x ) { return log1pl (__x + __sqrtl (__x) * __sqrtl (__x + 2.0)) ; } extern __inline long double __acosh1pl ( long double ); extern __inline long double __acosh1pl ( long double __x ) { return log1pl (__x + __sqrtl (__x) * __sqrtl (__x + 2.0)) ; }
# 670 "/usr/include/bits/mathinline.h" 3
# 348 "/usr/include/math.h" 2 3
# 407 "/usr/include/math.h" 3
# 2 "p.c" 2
static short ix;
static struct tm dt;
static double
pcon (void)
{
double frc;
double year;
double k;
double t;
double tmp;
int leap;
year = (dt.tm_hour + ((dt.tm_min + (dt.tm_sec / 60.0)) / 60.0)) / 24.0;
year += dt.tm_yday;
leap = dt.tm_year + 1900;
leap = (leap % 4 == 0 && (leap % 100 != 0 || leap % 400 == 0));
year = dt.tm_year + year / (365.0 + leap);
k = year * 12.3685;
k -= (frc = k - floor (k));
for ( ix = 0 ; frc > ix * 0.25 + 0.125 ; ix++ )
;
t = (k += ix * 0.25) / 1236.85;
tmp = 2415020.75933 + 29.53058868 * k
+ (1.178E-4 - 1.55E-7 * t) * pow (t, 2.0);
tmp += 3.3E-4 * sin (166.56* (3.14159265358979323846 /180.0) + 132.87* (3.14159265358979323846 /180.0) * t
- 9.173E-3* (3.14159265358979323846 /180.0) * pow(t, 2.0));
return t;
}
int
main()
{
time_t cur_time = 0;
dt = *gmtime(&cur_time);
pcon();
}
================================================================
My guess is that there is some problem with inlining and compiling the
pow function. Since this function is delivered with the compiler I
have not bothered to search any further down to see if it is the
function definition or the compilation of it that has the problem.
What leads me to believe this is the following four observations:
1. When stepping through the function in the debugger, the problem
appears in the last call to pow(). It is the last one because I
removed all excessive code.
2. When running the program in the debugger, the program gets the
sigsegv on the __inline_mathcode2 (pow, __x, __y, \-line in the
mathinline.h include file.
3. If I copy the inlined function pow, the result of the macros,
insert it in the program, remove all the \ to make the compiler
distinguish the lines and #define pow to something else while
includeing the math.h library, the error is on the line:
__extension__ long long int __p = (long long int) __y; in the
inlined function pow().
4. When optimizing the -lm library is not used, meaning that it is the
inlined version that is the problem and not any library.
$ gcc -O2 p.c -o p
$ ./p
Segmentation fault
$ gcc p.c -o p
/tmp/ccrLLMQz.o: In function `pcon':
/tmp/ccrLLMQz.o(.text+0x160): undefined reference to `floor'
/tmp/ccrLLMQz.o(.text+0x217): undefined reference to `pow'
/tmp/ccrLLMQz.o(.text+0x27c): undefined reference to `pow'
/tmp/ccrLLMQz.o(.text+0x2bf): undefined reference to `sin'
collect2: ld returned 1 exit status
$ gcc p.c -o p -lm
$ ./p
$
More information about the Gcc-bugs
mailing list