Bug 21666 - Optimization level -O2 breaks float (double) conversion
Summary: Optimization level -O2 breaks float (double) conversion
Status: RESOLVED DUPLICATE of bug 21920
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.4.4
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-19 18:35 UTC by Jonathan Beit-Aharon
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Beit-Aharon 2005-05-19 18:35:04 UTC
the exact version of GCC:
gcc34 (GCC) 3.4.4 20050114 (prerelease) [FreeBSD]
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

(also tested with: gcc33 (GCC) 3.3.1 [FreeBSD]
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.)


the system type:
FreeBSD jb.intrusic.com 4.9-RELEASE FreeBSD 4.9-RELEASE #0: Tue Jan 18 08:31:50
EST 2005     root@jb.intrusic.com:/usr/obj/usr/src/sys/JB  i386


the options given when GCC was configured/built:
cd /usr/ports/lang/gcc34; make; make install


the complete command line that triggers the bug:
gcc34 --verbose -O2 -pthread -D_THREAD_SAFE -DPCAP_DONT_INCLUDE_PCAP_BPF_H -fpic
-I/usr/local/include/postgresql/server/ -lz -o pg_timestamptz2 pg_timestamptz2.c

(also did it with the gcc33, and otherwise the same line)


the compiler output (error messages, warnings, etc.):
Reading specs from /usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/specs
Configured with: ./..//gcc-3.4-20050114/configure --disable-nls
--with-system-zlib --with-libiconv-prefix=/usr/local --program-suffix=34
--with-gxx-include-dir=/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/c++/
--disable-shared --prefix=/usr/local i386-portbld-freebsd4.9
Thread model: posix
gcc version 3.4.4 20050114 (prerelease) [FreeBSD]
 /usr/local/libexec/gcc/i386-portbld-freebsd4.9/3.4.4/cc1 -quiet -v
-I/usr/local/include/postgresql/server/ -D__PIC__ -D__pic__ -D_THREAD_SAFE
-DPCAP_DONT_INCLUDE_PCAP_BPF_H pg_timestamptz2.c -quiet -dumpbase
pg_timestamptz2.c -auxbase pg_timestamptz2 -O2 -version -fpic -o
/var/tmp//ccpuIIQW.s
ignoring nonexistent directory
"/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/../../../../i386-portbld-freebsd4.9/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include/postgresql/server/
 /usr/local/include
 /usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include
 /usr/include
End of search list.
GNU C version 3.4.4 20050114 (prerelease) [FreeBSD] (i386-portbld-freebsd4.9)
        compiled by GNU C version 3.4.4 20050114 (prerelease) [FreeBSD].
GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=31958
 as -o /var/tmp//cckWDfD6.o /var/tmp//ccpuIIQW.s
 /usr/local/libexec/gcc/i386-portbld-freebsd4.9/3.4.4/collect2 -V
-dynamic-linker /usr/libexec/ld-elf.so.1 -o pg_timestamptz2 /usr/lib/crt1.o
/usr/lib/crti.o /usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/crtbegin.o
-L/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4
-L/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/../../.. -lz
/var/tmp//cckWDfD6.o -lgcc -lc_r -lgcc
/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/crtend.o /usr/lib/crtn.o
GNU ld version 2.12.1 [FreeBSD] 2002-07-20
  Supported emulations:
   elf_i386



the preprocessed file (*.i*) that triggers the bug, generated by adding
--save-temps to the complete compilation command:
It is (1921 lines according to wc -l):

# 1 "pg_timestamptz2.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "pg_timestamptz2.c"
# 13 "pg_timestamptz2.c"
# 1 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/stdio.h" 1 3 4
# 52 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/stdio.h" 3 4
# 1 "/usr/include/sys/cdefs.h" 1 3 4
# 53 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/stdio.h" 2 3 4
# 1 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/machine/ansi.h" 1 3 4
# 127 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/machine/ansi.h" 3 4
typedef int __attribute__((__mode__(__DI__))) __int64_t;
typedef unsigned int __attribute__((__mode__(__DI__))) __uint64_t;
# 139 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/machine/ansi.h" 3 4
typedef signed char __int8_t;
typedef unsigned char __uint8_t;
typedef short __int16_t;
typedef unsigned short __uint16_t;
typedef int __int32_t;
typedef unsigned int __uint32_t;

typedef int __intptr_t;
typedef unsigned int __uintptr_t;





typedef union {
 char __mbstate8[128];
 __int64_t _mbstateL;
} __mbstate_t;
# 54 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/stdio.h" 2 3 4


typedef unsigned int size_t;







typedef __int64_t fpos_t;
# 75 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/stdio.h" 3 4
struct __sbuf {
 unsigned char *_base;
 int _size;
};
# 106 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/stdio.h" 3 4
typedef struct __sFILE {
 unsigned char *_p;
 int _r;
 int _w;
 short _flags;
 short _file;
 struct __sbuf _bf;
 int _lbfsize;


 void *_cookie;
 int (*_close) (void *);
 int (*_read) (void *, char *, int);
 fpos_t (*_seek) (void *, fpos_t, int);
 int (*_write) (void *, const char *, int);


 struct __sbuf _ub;
 unsigned char *_up;
 int _ur;


 unsigned char _ubuf[3];
 unsigned char _nbuf[1];


 struct __sbuf _lb;


 int _blksize;
 fpos_t _offset;
} FILE;


extern FILE *__stdinp, *__stdoutp, *__stderrp;

# 209 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/stdio.h" 3 4

void clearerr (FILE *);
int fclose (FILE *);
int feof (FILE *);
int ferror (FILE *);
int fflush (FILE *);
int fgetc (FILE *);
int fgetpos (FILE *, fpos_t *);
char *fgets (char *, int, FILE *);
FILE *fopen (const char *, const char *);
int fprintf (FILE *, const char *, ...);
int fputc (int, FILE *);
int fputs (const char *, FILE *);
size_t fread (void *, size_t, size_t, FILE *);
FILE *freopen (const char *, const char *, FILE *);
int fscanf (FILE *, const char *, ...);
int fseek (FILE *, long, int);
int fsetpos (FILE *, const fpos_t *);
long ftell (FILE *);
size_t fwrite (const void *, size_t, size_t, FILE *);
int getc (FILE *);
int getchar (void);
char *gets (char *);

extern const int sys_nerr;
extern const char *const sys_errlist[];

void perror (const char *);
int printf (const char *, ...);
int putc (int, FILE *);
int putchar (int);
int puts (const char *);
int remove (const char *);
int rename (const char *, const char *);
void rewind (FILE *);
int scanf (const char *, ...);
void setbuf (FILE *, char *);
int setvbuf (FILE *, char *, int, size_t);
int sprintf (char *, const char *, ...);
int sscanf (const char *, const char *, ...);
FILE *tmpfile (void);
char *tmpnam (char *);
int ungetc (int, FILE *);
int vfprintf (FILE *, const char *, __builtin_va_list);
int vprintf (const char *, __builtin_va_list);
int vsprintf (char *, const char *, __builtin_va_list);

# 266 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/stdio.h" 3 4

char *ctermid (char *);
FILE *fdopen (int, const char *);
int fileno (FILE *);
int ftrylockfile (FILE *);
void flockfile (FILE *);
void funlockfile (FILE *);










int ftruncate (int, __int64_t);



__int64_t lseek (int, __int64_t, int);



void *mmap (void *, size_t, int, int, int, __int64_t);



int truncate (const char *, __int64_t);









int asprintf (char **, const char *, ...) __attribute__((__format__ (__printf__,
2, 3)));
char *ctermid_r (char *);
char *fgetln (FILE *, size_t *);





const char *fmtcheck (const char *, const char *)
__attribute__((__format_arg__(2)));
int fpurge (FILE *);
int fseeko (FILE *, __int64_t, int);
__int64_t ftello (FILE *);
int getw (FILE *);
int pclose (FILE *);
FILE *popen (const char *, const char *);
int putw (int, FILE *);
void setbuffer (FILE *, char *, int);
int setlinebuf (FILE *);
char *tempnam (const char *, const char *);
int snprintf (char *, size_t, const char *, ...) __attribute__((__format__
(__printf__, 3, 4)));
int vasprintf (char **, const char *, __builtin_va_list)
     __attribute__((__format__ (__printf__, 2, 0)));
int vsnprintf (char *, size_t, const char *, __builtin_va_list)
     __attribute__((__format__ (__printf__, 3, 0)));
int vscanf (const char *, __builtin_va_list) __attribute__((__format__
(__scanf__, 1, 0)));
int vsscanf (const char *, const char *, __builtin_va_list)
     __attribute__((__format__ (__scanf__, 2, 0)));

# 341 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/stdio.h" 3 4
int vfscanf(FILE *, const char *, __builtin_va_list) __asm__ ("" "__svfscanf");





FILE *funopen (const void *, int (*)(void *, char *, int), int (*)(void *, const
char *, int), fpos_t (*)(void *, fpos_t, int), int (*)(void *));













int __srget (FILE *);
int __svfscanf (FILE *, const char *, __builtin_va_list);
int __swbuf (int, FILE *);








static __inline int __sputc(int _c, FILE *_p) {
 if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))
  return (*_p->_p++ = _c);
 else
  return (__swbuf(_c, _p));
}
# 423 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/stdio.h" 3 4
void _flockfile_debug (FILE *, char *, int);





extern int __isthreaded;
static __inline int __getc_locked(FILE *_fp) { int _ret; if (__isthreaded)
flockfile(_fp); _ret = (--(_fp)->_r < 0 ? __srget(_fp) : (int)(*(_fp)->_p++));
if (__isthreaded) funlockfile(_fp); return (_ret); }
# 441 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/stdio.h" 3 4
static __inline int __putc_locked(int _x, FILE *_fp) { int _ret; if
(__isthreaded) flockfile(_fp); _ret = __sputc(_x, _fp); if (__isthreaded)
funlockfile(_fp); return (_ret); }
# 14 "pg_timestamptz2.c" 2
# 1 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/stddef.h" 1 3 4
# 151 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/stddef.h" 3 4
typedef int ptrdiff_t;
# 294 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/stddef.h" 3 4
typedef int rune_t;
# 325 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/stddef.h" 3 4
typedef int wchar_t;
# 15 "pg_timestamptz2.c" 2
# 1 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/stdlib.h" 1 3 4
# 80 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/stdlib.h" 3 4
typedef struct {
 int quot;
 int rem;
} div_t;

typedef struct {
 long quot;
 long rem;
} ldiv_t;
# 99 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/stdlib.h" 3 4
extern int __mb_cur_max;



void abort (void) __attribute__((__noreturn__));
int abs (int) __attribute__((__const__));
int atexit (void (*)(void));
double atof (const char *);
int atoi (const char *);
long atol (const char *);
void *bsearch (const void *, const void *, size_t, size_t, int (*)(const void *,
const void *));

void *calloc (size_t, size_t);
div_t div (int, int) __attribute__((__const__));
void exit (int) __attribute__((__noreturn__));
void free (void *);
char *getenv (const char *);
long labs (long) __attribute__((__const__));
ldiv_t ldiv (long, long) __attribute__((__const__));
void *malloc (size_t);
void qsort (void *, size_t, size_t, int (*)(const void *, const void *));

int rand (void);
void *realloc (void *, size_t);
void srand (unsigned);
double strtod (const char *, char **);
long strtol (const char *, char **, int);

long long
  strtoll (const char *, char **, int);

unsigned long
  strtoul (const char *, char **, int);

unsigned long long
  strtoull (const char *, char **, int);

int system (const char *);

int mblen (const char *, size_t);
size_t mbstowcs (wchar_t *, const char *, size_t);
int wctomb (char *, wchar_t);
int mbtowc (wchar_t *, const char *, size_t);
size_t wcstombs (char *, const wchar_t *, size_t);


int putenv (const char *);
int setenv (const char *, const char *, int);

double drand48 (void);
double erand48 (unsigned short[3]);
long jrand48 (unsigned short[3]);
void lcong48 (unsigned short[7]);
long lrand48 (void);
long mrand48 (void);
long nrand48 (unsigned short[3]);
unsigned short
 *seed48 (unsigned short[3]);
void srand48 (long);

void *alloca (size_t);

__uint32_t
  arc4random (void);
void arc4random_addrandom (unsigned char *dat, int datlen);
void arc4random_stir (void);
char *getbsize (int *, long *);
char *cgetcap (char *, char *, int);
int cgetclose (void);
int cgetent (char **, char **, char *);
int cgetfirst (char **, char **);
int cgetmatch (char *, char *);
int cgetnext (char **, char **);
int cgetnum (char *, char *, long *);
int cgetset (char *);
int cgetstr (char *, char *, char **);
int cgetustr (char *, char *, char **);

int daemon (int, int);
char *devname (int, int);
int getloadavg (double [], int);
const char *
 getprogname (void);

char *group_from_gid (unsigned long, int);
int heapsort (void *, size_t, size_t, int (*)(const void *, const void *));

char *initstate (unsigned long, char *, long);
int mergesort (void *, size_t, size_t, int (*)(const void *, const void *));

int radixsort (const unsigned char **, int, const unsigned char *, unsigned);

int sradixsort (const unsigned char **, int, const unsigned char *, unsigned);

int rand_r (unsigned *);
long random (void);
void *reallocf (void *, size_t);
char *realpath (const char *, char resolved_path[]);
void setprogname (const char *);
char *setstate (char *);
void srandom (unsigned long);
void srandomdev (void);
char *user_from_uid (unsigned long, int);

__int64_t strtoq (const char *, char **, int);
__uint64_t
  strtouq (const char *, char **, int);

void unsetenv (const char *);


# 16 "pg_timestamptz2.c" 2
# 1 "/usr/include/string.h" 1 3 4
# 52 "/usr/include/string.h" 3 4

void *memchr (const void *, int, size_t);
int memcmp (const void *, const void *, size_t);
void *memcpy (void *, const void *, size_t);
void *memmove (void *, const void *, size_t);
void *memset (void *, int, size_t);
char *strcat (char *, const char *);
char *strchr (const char *, int);
int strcmp (const char *, const char *);
int strcoll (const char *, const char *);
char *strcpy (char *, const char *);
size_t strcspn (const char *, const char *);
char *strerror (int);
size_t strlen (const char *);
char *strncat (char *, const char *, size_t);
int strncmp (const char *, const char *, size_t);
char *strncpy (char *, const char *, size_t);
char *strpbrk (const char *, const char *);
char *strrchr (const char *, int);
size_t strspn (const char *, const char *);
char *strstr (const char *, const char *);
char *strtok (char *, const char *);
size_t strxfrm (char *, const char *, size_t);



int bcmp (const void *, const void *, size_t);
void bcopy (const void *, void *, size_t);
void bzero (void *, size_t);
int ffs (int);
char *index (const char *, int);
void *memccpy (void *, const void *, int, size_t);
char *rindex (const char *, int);
int strcasecmp (const char *, const char *);
char *strcasestr (const char *, const char *);
char *strdup (const char *);
int strerror_r (int, char *, size_t);
size_t strlcat (char *, const char *, size_t);
size_t strlcpy (char *, const char *, size_t);
void strmode (int, char *);
int strncasecmp (const char *, const char *, size_t);
char *strnstr (const char *, const char *, size_t);
char *strsep (char **, const char *);
char *strsignal (int);
char *strtok_r (char *, const char *, char **);
void swab (const void *, void *, size_t);


# 17 "pg_timestamptz2.c" 2
# 1 "/usr/include/errno.h" 1 3 4
# 47 "/usr/include/errno.h" 3 4

int * __error (void);

# 18 "pg_timestamptz2.c" 2
# 1 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/stdarg.h" 1 3 4
# 43 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/stdarg.h" 3 4
typedef __builtin_va_list __gnuc_va_list;
# 105 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/stdarg.h" 3 4
typedef __gnuc_va_list va_list;
# 19 "pg_timestamptz2.c" 2
# 1 "/usr/include/time.h" 1 3 4
# 45 "/usr/include/time.h" 3 4
# 1 "/usr/include/sys/_posix.h" 1 3 4
# 46 "/usr/include/time.h" 2 3 4
# 63 "/usr/include/time.h" 3 4
typedef unsigned long clock_t;




typedef long time_t;
# 85 "/usr/include/time.h" 3 4
typedef int clockid_t;




typedef int timer_t;





struct timespec {
 time_t tv_sec;
 long 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 tm_gmtoff;
 char *tm_zone;
};




extern char *tzname[];



char *asctime (const struct tm *);
clock_t clock (void);
char *ctime (const time_t *);
double difftime (time_t, time_t);
struct tm *gmtime (const time_t *);
struct tm *localtime (const time_t *);
time_t mktime (struct tm *);
size_t strftime (char *, size_t, const char *, const struct tm *);
time_t time (time_t *);


void tzset (void);



char *asctime_r (const struct tm *, char *);
char *ctime_r (const time_t *, char *);
struct tm *gmtime_r (const time_t *, struct tm *);
struct tm *localtime_r (const time_t *, struct tm *);
char *strptime (const char *, const char *, struct tm *);
char *timezone (int, int);
void tzsetwall (void);
time_t timelocal (struct tm * const);
time_t timegm (struct tm * const);




int clock_getres (clockid_t, struct timespec *);
int clock_gettime (clockid_t, struct timespec *);
int clock_settime (clockid_t, const struct timespec *);
int nanosleep (const struct timespec *, struct timespec *);


# 20 "pg_timestamptz2.c" 2
# 1 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/math.h" 1 3 4
# 32 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/math.h" 3 4
extern char __infinity[];
# 56 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/math.h" 3 4
extern int signgam;


enum fdversion {fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix};
# 71 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/math.h" 3 4
extern enum fdversion _fdlib_version;
# 81 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/math.h" 3 4
struct exception {
 int type;
 char *name;
 double arg1;
 double arg2;
 double retval;
};
# 111 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/math.h" 3 4




extern double acos (double);
extern double asin (double);
extern double atan (double);
extern double atan2 (double, double);
extern double cos (double);
extern double sin (double);
extern double tan (double);

extern double cosh (double);
extern double sinh (double);
extern double tanh (double);

extern double exp (double);
extern double frexp (double, int *);
extern double ldexp (double, int);
extern double log (double);
extern double log10 (double);
extern double modf (double, double *);

extern double pow (double, double);
extern double sqrt (double);

extern double ceil (double);
extern double fabs (double);
extern double floor (double);
extern double fmod (double, double);


extern double erf (double);
extern double erfc (double);
extern double gamma (double);
extern double hypot (double, double);
extern int isinf (double);
extern int isnan (double);
extern int finite (double);
extern double j0 (double);
extern double j1 (double);
extern double jn (int, double);
extern double lgamma (double);
extern double y0 (double);
extern double y1 (double);
extern double yn (int, double);


extern double acosh (double);
extern double asinh (double);
extern double atanh (double);
extern double cbrt (double);
extern double logb (double);
extern double nextafter (double, double);
extern double remainder (double, double);
extern double scalb (double, double);


extern int matherr (struct exception *);





extern double significand (double);




extern double copysign (double, double);
extern int ilogb (double);
extern double rint (double);
extern double scalbn (double, int);




extern double drem (double, double);
extern double expm1 (double);
extern double log1p (double);
# 203 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/math.h" 3 4
extern float acosf (float);
extern float asinf (float);
extern float atanf (float);
extern float atan2f (float, float);
extern float cosf (float);
extern float sinf (float);
extern float tanf (float);

extern float coshf (float);
extern float sinhf (float);
extern float tanhf (float);

extern float expf (float);
extern float frexpf (float, int *);
extern float ldexpf (float, int);
extern float logf (float);
extern float log10f (float);
extern float modff (float, float *);

extern float powf (float, float);
extern float sqrtf (float);

extern float ceilf (float);
extern float fabsf (float);
extern float floorf (float);
extern float fmodf (float, float);

extern float erff (float);
extern float erfcf (float);
extern float gammaf (float);
extern float hypotf (float, float);
extern int isnanf (float);
extern int finitef (float);
extern float j0f (float);
extern float j1f (float);
extern float jnf (int, float);
extern float lgammaf (float);
extern float y0f (float);
extern float y1f (float);
extern float ynf (int, float);

extern float acoshf (float);
extern float asinhf (float);
extern float atanhf (float);
extern float cbrtf (float);
extern float logbf (float);
extern float nextafterf (float, float);
extern float remainderf (float, float);
extern float scalbf (float, float);




extern float significandf (float);





extern float copysignf (float, float);
extern int ilogbf (float);
extern float rintf (float);
extern float scalbnf (float, int);




extern float dremf (float, float);
extern float expm1f (float);
extern float log1pf (float);
# 286 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/math.h" 3 4

# 21 "pg_timestamptz2.c" 2

# 1 "/usr/include/sys/time.h" 1 3 4
# 40 "/usr/include/sys/time.h" 3 4
# 1 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/sys/types.h" 1 3 4
# 57 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/sys/types.h" 3 4
# 1 "/usr/include/sys/inttypes.h" 1 3 4
# 11 "/usr/include/sys/inttypes.h" 3 4
typedef __int8_t int8_t;
typedef __int16_t int16_t;
typedef __int32_t int32_t;
typedef __int64_t int64_t;

typedef __uint8_t uint8_t;
typedef __uint16_t uint16_t;
typedef __uint32_t uint32_t;
typedef __uint64_t uint64_t;

typedef __intptr_t intptr_t;
typedef __uintptr_t uintptr_t;
# 58 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/sys/types.h" 2 3 4
# 1 "/usr/include/machine/types.h" 1 3 4
# 41 "/usr/include/machine/types.h" 3 4
typedef struct _physadr {
 int r[1];
} *physadr;

typedef struct label_t {
 int val[6];
} label_t;


typedef unsigned int vm_offset_t;
typedef __int64_t vm_ooffset_t;



typedef unsigned int vm_paddr_t;

typedef unsigned int vm_pindex_t;
typedef unsigned int vm_size_t;

typedef __int32_t register_t;
typedef __uint32_t u_register_t;







typedef __uint32_t intrmask_t;


typedef void inthand2_t (void *_cookie);
typedef void ointhand2_t (int _device_id);
# 59 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/sys/types.h" 2 3 4


typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
typedef unsigned long u_long;
typedef unsigned short ushort;
typedef unsigned int uint;


typedef __uint8_t u_int8_t;
typedef __uint16_t u_int16_t;
typedef __uint32_t u_int32_t;
typedef __uint64_t u_int64_t;

typedef u_int64_t u_quad_t;
typedef int64_t quad_t;
typedef quad_t * qaddr_t;

typedef char * caddr_t;
typedef const char * c_caddr_t;
typedef volatile char *v_caddr_t;
typedef int32_t daddr_t;
typedef u_int32_t u_daddr_t;
typedef u_int32_t fixpt_t;
typedef u_int32_t gid_t;
typedef u_int32_t in_addr_t;
typedef u_int16_t in_port_t;
typedef u_int32_t ino_t;
typedef long key_t;
typedef u_int16_t mode_t;
typedef u_int16_t nlink_t;
typedef __int64_t off_t;
typedef int pid_t;
typedef quad_t rlim_t;



typedef int32_t segsz_t;

typedef int32_t swblk_t;
typedef int32_t ufs_daddr_t;
typedef u_int32_t uid_t;
# 117 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/sys/types.h" 3 4
typedef u_int32_t dev_t;
# 135 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/sys/types.h" 3 4
# 1 "/usr/include/machine/endian.h" 1 3 4
# 62 "/usr/include/machine/endian.h" 3 4

unsigned long htonl (unsigned long);
unsigned short htons (unsigned short);
unsigned long ntohl (unsigned long);
unsigned short ntohs (unsigned short);

# 136 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/sys/types.h" 2 3 4
# 157 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/sys/types.h" 3 4
typedef int ssize_t;
# 184 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/sys/types.h" 3 4
typedef unsigned long fd_mask;






typedef struct fd_set {
 fd_mask fds_bits[(((1024) + (((sizeof(fd_mask) * 8)) - 1)) / ((sizeof(fd_mask)
* 8)))];
} fd_set;
# 208 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/sys/types.h" 3 4

# 225 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/sys/types.h" 3 4

# 41 "/usr/include/sys/time.h" 2 3 4





struct timeval {
 long tv_sec;
 long tv_usec;
};
# 70 "/usr/include/sys/time.h" 3 4
struct timezone {
 int tz_minuteswest;
 int tz_dsttime;
};
# 134 "/usr/include/sys/time.h" 3 4
struct timecounter;
typedef unsigned timecounter_get_t (struct timecounter *);
typedef void timecounter_pps_t (struct timecounter *);

struct timecounter {

 timecounter_get_t *tc_get_timecount;
 timecounter_pps_t *tc_poll_pps;
 unsigned tc_counter_mask;
 u_int32_t tc_frequency;
 char *tc_name;
 void *tc_priv;

 int64_t tc_adjustment;
 u_int32_t tc_scale_micro;
 u_int32_t tc_scale_nano_i;
 u_int32_t tc_scale_nano_f;
 unsigned tc_offset_count;
 u_int32_t tc_offset_sec;
 u_int32_t tc_offset_micro;
 u_int64_t tc_offset_nano;
 struct timeval tc_microtime;
 struct timespec tc_nanotime;
 struct timecounter *tc_avail;
 struct timecounter *tc_other;
 struct timecounter *tc_tweak;
};
# 239 "/usr/include/sys/time.h" 3 4
struct itimerval {
 struct timeval it_interval;
 struct timeval it_value;
};




struct clockinfo {
 int hz;
 int tick;
 int tickadj;
 int stathz;
 int profhz;
};
# 295 "/usr/include/sys/time.h" 3 4

int adjtime (const struct timeval *, struct timeval *);
int futimes (int, const struct timeval *);
int getitimer (int, struct itimerval *);
int gettimeofday (struct timeval *, struct timezone *);
int lutimes (const char *, const struct timeval *);
int setitimer (int, const struct itimerval *, struct itimerval *);
int settimeofday (const struct timeval *, const struct timezone *);
int utimes (const char *, const struct timeval *);

# 23 "pg_timestamptz2.c" 2
# 1 "/usr/local/include/postgresql/server/postgres.h" 1
# 48 "/usr/local/include/postgresql/server/postgres.h"
# 1 "/usr/local/include/postgresql/server/c.h" 1
# 53 "/usr/local/include/postgresql/server/c.h"
# 1 "/usr/local/include/postgresql/server/pg_config.h" 1
# 54 "/usr/local/include/postgresql/server/c.h" 2
# 1 "/usr/local/include/postgresql/server/pg_config_manual.h" 1
# 55 "/usr/local/include/postgresql/server/c.h" 2

# 1 "/usr/local/include/postgresql/server/pg_config_os.h" 1



typedef unsigned char slock_t;
# 57 "/usr/local/include/postgresql/server/c.h" 2

# 1 "/usr/local/include/postgresql/server/postgres_ext.h" 1
# 29 "/usr/local/include/postgresql/server/postgres_ext.h"
typedef unsigned int Oid;
# 59 "/usr/local/include/postgresql/server/c.h" 2




# 1 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/stddef.h" 1 3 4
# 64 "/usr/local/include/postgresql/server/c.h" 2


# 1 "/usr/include/strings.h" 1 3 4
# 67 "/usr/local/include/postgresql/server/c.h" 2
# 84 "/usr/local/include/postgresql/server/c.h"
# 1 "/usr/include/locale.h" 1 3 4
# 39 "/usr/include/locale.h" 3 4
struct lconv {
 char *decimal_point;
 char *thousands_sep;
 char *grouping;
 char *int_curr_symbol;
 char *currency_symbol;
 char *mon_decimal_point;
 char *mon_thousands_sep;
 char *mon_grouping;
 char *positive_sign;
 char *negative_sign;
 char int_frac_digits;
 char frac_digits;
 char p_cs_precedes;
 char p_sep_by_space;
 char n_cs_precedes;
 char n_sep_by_space;
 char p_sign_posn;
 char n_sign_posn;
};
# 76 "/usr/include/locale.h" 3 4

struct lconv *localeconv (void);
char *setlocale (int, const char *);

# 85 "/usr/local/include/postgresql/server/c.h" 2


# 1 "/usr/local/include/libintl.h" 1 3
# 118 "/usr/local/include/libintl.h" 3
extern char *gettext (const char *__msgid)
       __asm__ ("" "libintl_gettext");
# 134 "/usr/local/include/libintl.h" 3
extern char *dgettext (const char *__domainname, const char *__msgid)
       __asm__ ("" "libintl_dgettext");
# 152 "/usr/local/include/libintl.h" 3
extern char *dcgettext (const char *__domainname, const char *__msgid,
   int __category)
       __asm__ ("" "libintl_dcgettext");
# 172 "/usr/local/include/libintl.h" 3
extern char *ngettext (const char *__msgid1, const char *__msgid2,
         unsigned long int __n)
       __asm__ ("" "libintl_ngettext");
# 191 "/usr/local/include/libintl.h" 3
extern char *dngettext (const char *__domainname,
   const char *__msgid1, const char *__msgid2,
   unsigned long int __n)
       __asm__ ("" "libintl_dngettext");
# 213 "/usr/local/include/libintl.h" 3
extern char *dcngettext (const char *__domainname,
    const char *__msgid1, const char *__msgid2,
    unsigned long int __n, int __category)
       __asm__ ("" "libintl_dcngettext");
# 233 "/usr/local/include/libintl.h" 3
extern char *textdomain (const char *__domainname)
       __asm__ ("" "libintl_textdomain");
# 251 "/usr/local/include/libintl.h" 3
extern char *bindtextdomain (const char *__domainname, const char *__dirname)
       __asm__ ("" "libintl_bindtextdomain");
# 269 "/usr/local/include/libintl.h" 3
extern char *bind_textdomain_codeset (const char *__domainname,
          const char *__codeset)
       __asm__ ("" "libintl_bind_textdomain_codeset");
# 374 "/usr/local/include/libintl.h" 3
extern void
       libintl_set_relocation_prefix (const char *orig_prefix,
          const char *curr_prefix);
# 88 "/usr/local/include/postgresql/server/c.h" 2
# 166 "/usr/local/include/postgresql/server/c.h"
typedef char bool;
# 179 "/usr/local/include/postgresql/server/c.h"
typedef bool *BoolPtr;
# 210 "/usr/local/include/postgresql/server/c.h"
typedef char *Pointer;
# 219 "/usr/local/include/postgresql/server/c.h"
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
# 232 "/usr/local/include/postgresql/server/c.h"
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;






typedef uint8 bool8;
typedef uint16 bool16;
typedef uint32 bool32;





typedef uint8 bits8;
typedef uint16 bits16;
typedef uint32 bits32;






typedef uint8 word8;
typedef uint16 word16;
typedef uint32 word32;
# 273 "/usr/local/include/postgresql/server/c.h"
typedef float float32data;
typedef double float64data;
typedef float *float32;
typedef double *float64;
# 295 "/usr/local/include/postgresql/server/c.h"
typedef long long int int64;


typedef unsigned long long int uint64;
# 348 "/usr/local/include/postgresql/server/c.h"
typedef size_t Size;
# 357 "/usr/local/include/postgresql/server/c.h"
typedef unsigned int Index;
# 367 "/usr/local/include/postgresql/server/c.h"
typedef signed int Offset;




typedef int16 int2;
typedef int32 int4;
typedef float float4;
typedef double float8;
# 387 "/usr/local/include/postgresql/server/c.h"
typedef Oid regproc;
typedef regproc RegProcedure;

typedef uint32 TransactionId;

typedef uint32 CommandId;



typedef int32 AclId;





typedef struct
{
 int indx[6];
} IntArray;
# 417 "/usr/local/include/postgresql/server/c.h"
struct varlena
{
 int32 vl_len;
 char vl_dat[1];
};
# 430 "/usr/local/include/postgresql/server/c.h"
typedef struct varlena bytea;
typedef struct varlena text;
typedef struct varlena BpChar;
typedef struct varlena VarChar;





typedef int2 int2vector[32];
typedef Oid oidvector[32];
# 449 "/usr/local/include/postgresql/server/c.h"
typedef union nameData
{
 char data[64];
 int alignmentDummy;
} NameData;
typedef NameData *Name;
# 797 "/usr/local/include/postgresql/server/c.h"
# 1 "/usr/local/include/postgresql/server/port.h" 1
# 16 "/usr/local/include/postgresql/server/port.h"
# 1 "/usr/include/pwd.h" 1 3 4
# 71 "/usr/include/pwd.h" 3 4
struct passwd {
 char *pw_name;
 char *pw_passwd;
 uid_t pw_uid;
 gid_t pw_gid;
 time_t pw_change;
 char *pw_class;
 char *pw_gecos;
 char *pw_dir;
 char *pw_shell;
 time_t pw_expire;
 int pw_fields;
};
# 100 "/usr/include/pwd.h" 3 4

struct passwd *getpwuid (uid_t);
struct passwd *getpwnam (const char *);

struct passwd *getpwent (void);
int setpassent (int);
void setpwent (void);
void endpwent (void);


# 17 "/usr/local/include/postgresql/server/port.h" 2
# 1 "/usr/include/netdb.h" 1 3 4
# 80 "/usr/include/netdb.h" 3 4
extern int h_errno;






struct hostent {
 char *h_name;
 char **h_aliases;
 int h_addrtype;
 int h_length;
 char **h_addr_list;

};





struct netent {
 char *n_name;
 char **n_aliases;
 int n_addrtype;
 unsigned long n_net;
};

struct servent {
 char *s_name;
 char **s_aliases;
 int s_port;
 char *s_proto;
};

struct protoent {
 char *p_name;
 char **p_aliases;
 int p_proto;
};

struct addrinfo {
 int ai_flags;
 int ai_family;
 int ai_socktype;
 int ai_protocol;
 size_t ai_addrlen;
 char *ai_canonname;
 struct sockaddr *ai_addr;
 struct addrinfo *ai_next;
};
# 204 "/usr/include/netdb.h" 3 4
typedef __uint32_t socklen_t;




void endhostent (void);
void endnetent (void);
void endnetgrent (void);
void endprotoent (void);
void endservent (void);
void freehostent (struct hostent *);
struct hostent *gethostbyaddr (const char *, int, int);
struct hostent *gethostbyname (const char *);
struct hostent *gethostbyname2 (const char *, int);
struct hostent *gethostent (void);
struct hostent *getipnodebyaddr (const void *, size_t, int, int *);
struct hostent *getipnodebyname (const char *, int, int, int *);
struct netent *getnetbyaddr (unsigned long, int);
struct netent *getnetbyname (const char *);
struct netent *getnetent (void);
int getnetgrent (char **, char **, char **);
struct protoent *getprotobyname (const char *);
struct protoent *getprotobynumber (int);
struct protoent *getprotoent (void);
struct servent *getservbyname (const char *, const char *);
struct servent *getservbyport (int, const char *);
struct servent *getservent (void);
void herror (const char *);
const char *hstrerror (int);
int innetgr (const char *, const char *, const char *, const char *);

void sethostent (int);

void setnetent (int);
void setprotoent (int);
int getaddrinfo (const char *, const char *, const struct addrinfo *, struct
addrinfo **);

int getnameinfo (const struct sockaddr *, socklen_t, char *, size_t, char *,
size_t, int);

void freeaddrinfo (struct addrinfo *);
char *gai_strerror (int);
void setnetgrent (const char *);
void setservent (int);






void _sethosthtent (int);
void _endhosthtent (void);
void _sethostdnsent (int);
void _endhostdnsent (void);
void _setnethtent (int);
void _endnethtent (void);
void _setnetdnsent (int);
void _endnetdnsent (void);
struct hostent * _gethostbyhtname (const char *, int);
struct hostent * _gethostbydnsname (const char *, int);
struct hostent * _gethostbynisname (const char *, int);
struct hostent * _gethostbyhtaddr (const char *, int, int);
struct hostent * _gethostbydnsaddr (const char *, int, int);
struct hostent * _gethostbynisaddr (const char *, int, int);
struct netent * _getnetbyhtname (const char *);
struct netent * _getnetbydnsname (const char *);
struct netent * _getnetbynisname (const char *);
struct netent * _getnetbyhtaddr (unsigned long, int);
struct netent * _getnetbydnsaddr (unsigned long, int);
struct netent * _getnetbynisaddr (unsigned long, int);
void _map_v4v6_address (const char *, char *);
void _map_v4v6_hostent (struct hostent *, char **, int *);

# 18 "/usr/local/include/postgresql/server/port.h" 2



extern bool is_absolute_path(const char *filename);
extern char *first_path_separator(const char *filename);
extern char *last_path_separator(const char *filename);
extern char *get_progname(char *argv0);

extern char *simple_prompt(const char *prompt, int maxlen, bool echo);
# 113 "/usr/local/include/postgresql/server/port.h"
extern char *pqStrerror(int errnum, char *strerrbuf, size_t buflen);


extern int pqGetpwuid(uid_t uid, struct passwd * resultbuf, char *buffer,
     size_t buflen, struct passwd **result);


extern int pqGethostbyname(const char *name,
    struct hostent *resultbuf,
    char *buffer, size_t buflen,
    struct hostent **result,
    int *herrno);
# 798 "/usr/local/include/postgresql/server/c.h" 2
# 49 "/usr/local/include/postgresql/server/postgres.h" 2
# 1 "/usr/local/include/postgresql/server/utils/elog.h" 1
# 60 "/usr/local/include/postgresql/server/utils/elog.h"
# 1 "/usr/local/include/postgresql/server/utils/errcodes.h" 1
# 61 "/usr/local/include/postgresql/server/utils/elog.h" 2
# 93 "/usr/local/include/postgresql/server/utils/elog.h"
extern bool errstart(int elevel, const char *filename, int lineno,
   const char *funcname);
extern void errfinish(int dummy,...);

extern int errcode(int sqlerrcode);

extern int errcode_for_file_access(void);
extern int errcode_for_socket_access(void);

extern int
errmsg(const char *fmt,...)


__attribute__((format(printf, 1, 2)));

extern int
errmsg_internal(const char *fmt,...)


__attribute__((format(printf, 1, 2)));

extern int
errdetail(const char *fmt,...)


__attribute__((format(printf, 1, 2)));

extern int
errhint(const char *fmt,...)


__attribute__((format(printf, 1, 2)));

extern int
errcontext(const char *fmt,...)


__attribute__((format(printf, 1, 2)));

extern int errfunction(const char *funcname);
extern int errposition(int cursorpos);
# 143 "/usr/local/include/postgresql/server/utils/elog.h"
extern void
elog_finish(int elevel, const char *fmt,...)


__attribute__((format(printf, 2, 3)));




typedef struct ErrorContextCallback
{
 struct ErrorContextCallback *previous;
 void (*callback) (void *arg);
 void *arg;
} ErrorContextCallback;

extern ErrorContextCallback *error_context_stack;




typedef enum
{
 PGERROR_TERSE,
 PGERROR_DEFAULT,
 PGERROR_VERBOSE
} PGErrorVerbosity;

extern PGErrorVerbosity Log_error_verbosity;
extern bool Log_timestamp;
extern bool Log_pid;


extern int Use_syslog;




extern void DebugFileOpen(void);
# 50 "/usr/local/include/postgresql/server/postgres.h" 2
# 1 "/usr/local/include/postgresql/server/utils/palloc.h" 1
# 36 "/usr/local/include/postgresql/server/utils/palloc.h"
typedef struct MemoryContextData *MemoryContext;






extern MemoryContext CurrentMemoryContext;




extern void *MemoryContextAlloc(MemoryContext context, Size size);
extern void *MemoryContextAllocZero(MemoryContext context, Size size);
extern void *MemoryContextAllocZeroAligned(MemoryContext context, Size size);
# 69 "/usr/local/include/postgresql/server/utils/palloc.h"
extern void pfree(void *pointer);

extern void *repalloc(void *pointer, Size size);

extern MemoryContext MemoryContextSwitchTo(MemoryContext context);





extern char *MemoryContextStrdup(MemoryContext context, const char *string);
# 51 "/usr/local/include/postgresql/server/postgres.h" 2
# 64 "/usr/local/include/postgresql/server/postgres.h"
typedef struct varattrib
{
 int32 va_header;

 union
 {
  struct
  {
   int32 va_rawsize;
   char va_data[1];
  } va_compressed;

  struct
  {
   int32 va_rawsize;
   int32 va_extsize;
   Oid va_valueid;
   Oid va_toastrelid;
  } va_external;

  char va_data[1];
 } va_content;
} varattrib;
# 132 "/usr/local/include/postgresql/server/postgres.h"
typedef unsigned long Datum;


typedef Datum *DatumPtr;
# 366 "/usr/local/include/postgresql/server/postgres.h"
extern Datum Int64GetDatum(int64 X);
# 385 "/usr/local/include/postgresql/server/postgres.h"
extern Datum Float4GetDatum(float4 X);
# 405 "/usr/local/include/postgresql/server/postgres.h"
extern Datum Float8GetDatum(float8 X);
# 477 "/usr/local/include/postgresql/server/postgres.h"
extern bool assert_enabled;
# 530 "/usr/local/include/postgresql/server/postgres.h"
extern int ExceptionalCondition(char *conditionName, char *errorType,
      char *fileName, int lineNumber);
# 550 "/usr/local/include/postgresql/server/postgres.h"
typedef int4 aclitem;
# 24 "pg_timestamptz2.c" 2
# 1 "/usr/local/include/postgresql/server/utils/timestamp.h" 1
# 18 "/usr/local/include/postgresql/server/utils/timestamp.h"
# 1 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/limits.h" 1 3 4
# 11 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/limits.h" 3 4
# 1 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/syslimits.h" 1 3 4






# 1 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/limits.h" 1 3 4
# 122 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/limits.h" 3 4
# 1 "/usr/include/limits.h" 1 3 4
# 94 "/usr/include/limits.h" 3 4
# 1 "/usr/include/machine/limits.h" 1 3 4
# 95 "/usr/include/limits.h" 2 3 4

# 1 "/usr/include/sys/syslimits.h" 1 3 4
# 97 "/usr/include/limits.h" 2 3 4
# 123 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/limits.h" 2 3 4
# 8 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/syslimits.h" 2 3 4
# 12 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/limits.h" 2 3 4
# 19 "/usr/local/include/postgresql/server/utils/timestamp.h" 2
# 1 "/usr/local/lib/gcc/i386-portbld-freebsd4.9/3.4.4/include/float.h" 1 3 4
# 20 "/usr/local/include/postgresql/server/utils/timestamp.h" 2

# 1 "/usr/local/include/postgresql/server/fmgr.h" 1
# 28 "/usr/local/include/postgresql/server/fmgr.h"
typedef struct FunctionCallInfoData *FunctionCallInfo;

typedef Datum (*PGFunction) (FunctionCallInfo fcinfo);







typedef struct FmgrInfo
{
 PGFunction fn_addr;

 Oid fn_oid;

 short fn_nargs;

 bool fn_strict;

 bool fn_retset;
 void *fn_extra;
 MemoryContext fn_mcxt;
 struct Node *fn_expr;
} FmgrInfo;




typedef struct FunctionCallInfoData
{
 FmgrInfo *flinfo;
 struct Node *context;
 struct Node *resultinfo;
 bool isnull;

 short nargs;
 Datum arg[32];
 bool argnull[32];
} FunctionCallInfoData;





extern void fmgr_info(Oid functionId, FmgrInfo *finfo);






extern void fmgr_info_cxt(Oid functionId, FmgrInfo *finfo,
     MemoryContext mcxt);




extern void fmgr_info_copy(FmgrInfo *dstinfo, FmgrInfo *srcinfo,
      MemoryContext destcxt);
# 141 "/usr/local/include/postgresql/server/fmgr.h"
extern struct varlena *pg_detoast_datum(struct varlena * datum);
extern struct varlena *pg_detoast_datum_copy(struct varlena * datum);
extern struct varlena *pg_detoast_datum_slice(struct varlena * datum,
        int32 first, int32 count);
# 267 "/usr/local/include/postgresql/server/fmgr.h"
typedef struct
{
 int api_version;


} Pg_finfo_record;


typedef Pg_finfo_record *(*PGFInfoFunction) (void);
# 299 "/usr/local/include/postgresql/server/fmgr.h"
extern Datum DirectFunctionCall1(PGFunction func, Datum arg1);
extern Datum DirectFunctionCall2(PGFunction func, Datum arg1, Datum arg2);
extern Datum DirectFunctionCall3(PGFunction func, Datum arg1, Datum arg2,
     Datum arg3);
extern Datum DirectFunctionCall4(PGFunction func, Datum arg1, Datum arg2,
     Datum arg3, Datum arg4);
extern Datum DirectFunctionCall5(PGFunction func, Datum arg1, Datum arg2,
     Datum arg3, Datum arg4, Datum arg5);
extern Datum DirectFunctionCall6(PGFunction func, Datum arg1, Datum arg2,
     Datum arg3, Datum arg4, Datum arg5,
     Datum arg6);
extern Datum DirectFunctionCall7(PGFunction func, Datum arg1, Datum arg2,
     Datum arg3, Datum arg4, Datum arg5,
     Datum arg6, Datum arg7);
extern Datum DirectFunctionCall8(PGFunction func, Datum arg1, Datum arg2,
     Datum arg3, Datum arg4, Datum arg5,
     Datum arg6, Datum arg7, Datum arg8);
extern Datum DirectFunctionCall9(PGFunction func, Datum arg1, Datum arg2,
     Datum arg3, Datum arg4, Datum arg5,
     Datum arg6, Datum arg7, Datum arg8,
     Datum arg9);





extern Datum FunctionCall1(FmgrInfo *flinfo, Datum arg1);
extern Datum FunctionCall2(FmgrInfo *flinfo, Datum arg1, Datum arg2);
extern Datum FunctionCall3(FmgrInfo *flinfo, Datum arg1, Datum arg2,
     Datum arg3);
extern Datum FunctionCall4(FmgrInfo *flinfo, Datum arg1, Datum arg2,
     Datum arg3, Datum arg4);
extern Datum FunctionCall5(FmgrInfo *flinfo, Datum arg1, Datum arg2,
     Datum arg3, Datum arg4, Datum arg5);
extern Datum FunctionCall6(FmgrInfo *flinfo, Datum arg1, Datum arg2,
     Datum arg3, Datum arg4, Datum arg5,
     Datum arg6);
extern Datum FunctionCall7(FmgrInfo *flinfo, Datum arg1, Datum arg2,
     Datum arg3, Datum arg4, Datum arg5,
     Datum arg6, Datum arg7);
extern Datum FunctionCall8(FmgrInfo *flinfo, Datum arg1, Datum arg2,
     Datum arg3, Datum arg4, Datum arg5,
     Datum arg6, Datum arg7, Datum arg8);
extern Datum FunctionCall9(FmgrInfo *flinfo, Datum arg1, Datum arg2,
     Datum arg3, Datum arg4, Datum arg5,
     Datum arg6, Datum arg7, Datum arg8,
     Datum arg9);







extern Datum OidFunctionCall1(Oid functionId, Datum arg1);
extern Datum OidFunctionCall2(Oid functionId, Datum arg1, Datum arg2);
extern Datum OidFunctionCall3(Oid functionId, Datum arg1, Datum arg2,
     Datum arg3);
extern Datum OidFunctionCall4(Oid functionId, Datum arg1, Datum arg2,
     Datum arg3, Datum arg4);
extern Datum OidFunctionCall5(Oid functionId, Datum arg1, Datum arg2,
     Datum arg3, Datum arg4, Datum arg5);
extern Datum OidFunctionCall6(Oid functionId, Datum arg1, Datum arg2,
     Datum arg3, Datum arg4, Datum arg5,
     Datum arg6);
extern Datum OidFunctionCall7(Oid functionId, Datum arg1, Datum arg2,
     Datum arg3, Datum arg4, Datum arg5,
     Datum arg6, Datum arg7);
extern Datum OidFunctionCall8(Oid functionId, Datum arg1, Datum arg2,
     Datum arg3, Datum arg4, Datum arg5,
     Datum arg6, Datum arg7, Datum arg8);
extern Datum OidFunctionCall9(Oid functionId, Datum arg1, Datum arg2,
     Datum arg3, Datum arg4, Datum arg5,
     Datum arg6, Datum arg7, Datum arg8,
     Datum arg9);





extern Pg_finfo_record *fetch_finfo_record(void *filehandle, char *funcname);
extern Oid fmgr_internal_function(const char *proname);
extern Oid get_fn_expr_rettype(FmgrInfo *flinfo);
extern Oid get_fn_expr_argtype(FmgrInfo *flinfo, int argnum);




extern char *Dynamic_library_path;

extern PGFunction load_external_function(char *filename, char *funcname,
        bool signalNotFound, void **filehandle);
extern PGFunction lookup_external_function(void *filehandle, char *funcname);
extern void load_file(char *filename);
# 408 "/usr/local/include/postgresql/server/fmgr.h"
extern char *fmgr(Oid procedureId,...);
# 22 "/usr/local/include/postgresql/server/utils/timestamp.h" 2
# 41 "/usr/local/include/postgresql/server/utils/timestamp.h"
typedef double Timestamp;
typedef double TimestampTz;


typedef struct
{




 double time;


 int32 month;

} Interval;
# 133 "/usr/local/include/postgresql/server/utils/timestamp.h"
typedef double fsec_t;
# 156 "/usr/local/include/postgresql/server/utils/timestamp.h"
extern Datum timestamp_in(FunctionCallInfo fcinfo);
extern Datum timestamp_out(FunctionCallInfo fcinfo);
extern Datum timestamp_recv(FunctionCallInfo fcinfo);
extern Datum timestamp_send(FunctionCallInfo fcinfo);
extern Datum timestamp_scale(FunctionCallInfo fcinfo);
extern Datum timestamp_eq(FunctionCallInfo fcinfo);
extern Datum timestamp_ne(FunctionCallInfo fcinfo);
extern Datum timestamp_lt(FunctionCallInfo fcinfo);
extern Datum timestamp_le(FunctionCallInfo fcinfo);
extern Datum timestamp_ge(FunctionCallInfo fcinfo);
extern Datum timestamp_gt(FunctionCallInfo fcinfo);
extern Datum timestamp_finite(FunctionCallInfo fcinfo);
extern Datum timestamp_cmp(FunctionCallInfo fcinfo);
extern Datum timestamp_smaller(FunctionCallInfo fcinfo);
extern Datum timestamp_larger(FunctionCallInfo fcinfo);

extern Datum interval_in(FunctionCallInfo fcinfo);
extern Datum interval_out(FunctionCallInfo fcinfo);
extern Datum interval_recv(FunctionCallInfo fcinfo);
extern Datum interval_send(FunctionCallInfo fcinfo);
extern Datum interval_scale(FunctionCallInfo fcinfo);
extern Datum interval_eq(FunctionCallInfo fcinfo);
extern Datum interval_ne(FunctionCallInfo fcinfo);
extern Datum interval_lt(FunctionCallInfo fcinfo);
extern Datum interval_le(FunctionCallInfo fcinfo);
extern Datum interval_ge(FunctionCallInfo fcinfo);
extern Datum interval_gt(FunctionCallInfo fcinfo);
extern Datum interval_finite(FunctionCallInfo fcinfo);
extern Datum interval_cmp(FunctionCallInfo fcinfo);
extern Datum interval_hash(FunctionCallInfo fcinfo);
extern Datum interval_smaller(FunctionCallInfo fcinfo);
extern Datum interval_larger(FunctionCallInfo fcinfo);

extern Datum timestamp_text(FunctionCallInfo fcinfo);
extern Datum text_timestamp(FunctionCallInfo fcinfo);
extern Datum interval_text(FunctionCallInfo fcinfo);
extern Datum text_interval(FunctionCallInfo fcinfo);
extern Datum timestamp_trunc(FunctionCallInfo fcinfo);
extern Datum interval_trunc(FunctionCallInfo fcinfo);
extern Datum timestamp_part(FunctionCallInfo fcinfo);
extern Datum interval_part(FunctionCallInfo fcinfo);
extern Datum timestamp_zone(FunctionCallInfo fcinfo);
extern Datum timestamp_izone(FunctionCallInfo fcinfo);
extern Datum timestamp_timestamptz(FunctionCallInfo fcinfo);

extern Datum timestamptz_in(FunctionCallInfo fcinfo);
extern Datum timestamptz_out(FunctionCallInfo fcinfo);
extern Datum timestamptz_recv(FunctionCallInfo fcinfo);
extern Datum timestamptz_send(FunctionCallInfo fcinfo);
extern Datum timestamptz_scale(FunctionCallInfo fcinfo);
extern Datum timestamptz_timestamp(FunctionCallInfo fcinfo);
extern Datum timestamptz_zone(FunctionCallInfo fcinfo);
extern Datum timestamptz_izone(FunctionCallInfo fcinfo);
extern Datum timestamptz_timestamptz(FunctionCallInfo fcinfo);

extern Datum interval_um(FunctionCallInfo fcinfo);
extern Datum interval_pl(FunctionCallInfo fcinfo);
extern Datum interval_mi(FunctionCallInfo fcinfo);
extern Datum interval_mul(FunctionCallInfo fcinfo);
extern Datum mul_d_interval(FunctionCallInfo fcinfo);
extern Datum interval_div(FunctionCallInfo fcinfo);
extern Datum interval_accum(FunctionCallInfo fcinfo);
extern Datum interval_avg(FunctionCallInfo fcinfo);

extern Datum timestamp_mi(FunctionCallInfo fcinfo);
extern Datum timestamp_pl_span(FunctionCallInfo fcinfo);
extern Datum timestamp_mi_span(FunctionCallInfo fcinfo);
extern Datum timestamp_age(FunctionCallInfo fcinfo);
extern Datum overlaps_timestamp(FunctionCallInfo fcinfo);

extern Datum timestamptz_text(FunctionCallInfo fcinfo);
extern Datum text_timestamptz(FunctionCallInfo fcinfo);
extern Datum timestamptz_pl_span(FunctionCallInfo fcinfo);
extern Datum timestamptz_mi_span(FunctionCallInfo fcinfo);
extern Datum timestamptz_age(FunctionCallInfo fcinfo);
extern Datum timestamptz_trunc(FunctionCallInfo fcinfo);
extern Datum timestamptz_part(FunctionCallInfo fcinfo);

extern Datum now(FunctionCallInfo fcinfo);



extern int tm2timestamp(struct tm * tm, fsec_t fsec, int *tzp, Timestamp *dt);
extern int timestamp2tm(Timestamp dt, int *tzp, struct tm * tm,
    fsec_t *fsec, char **tzn);
extern void dt2time(Timestamp dt, int *hour, int *min, int *sec, fsec_t *fsec);

extern int interval2tm(Interval span, struct tm * tm, fsec_t *fsec);
extern int tm2interval(struct tm * tm, fsec_t fsec, Interval *span);

extern Timestamp SetEpochTimestamp(void);
extern void GetEpochTime(struct tm * tm);

extern void isoweek2date(int woy, int *year, int *mon, int *mday);
extern int date2isoweek(int year, int mon, int mday);
# 25 "pg_timestamptz2.c" 2

static const long lPostgresEpoch = 946684800;
int PG_PostgresTimestamp(Timestamp *ptTimestamp, struct timeval tTimeval);
int PG_PcapTimestamp(struct timeval *ptTimeval, const Timestamp tTimestamp);

typedef struct { long li[2]; } ntimestamp;
ntimestamp htonts(Timestamp s);
Timestamp ntohts(ntimestamp s);

static void hex(const char *, int, const char *);
static int revcmp(const char *, const char *, size_t);

static char *default_argv[] = {
 ((void *)0),
 "1116205115.314373",
 "1116205177.274158"
};

int main(int argc, char *argv[]) {

 int j, success;

 success = 0;

 if ( argc == 1 ) {
  argc = 3;
  default_argv[0] = argv[0];
  argv = default_argv;
 }

 for ( j = 1; j < argc; ++j ) {
  struct timeval tv1, tv2;
  Timestamp ts1, ts2;
  ntimestamp nts;
  int bad, worse;

  if ( sscanf(argv[j], "%ld.%ld", &tv1.tv_sec, &tv1.tv_usec) != 2 ) {
   fprintf((__stderrp), "Wtf? %s\n", argv[j]);
   continue;
  }
# 73 "pg_timestamptz2.c"
  PG_PostgresTimestamp(&ts1, tv1);

  nts = htonts(ts1);
  bad = revcmp((char *) &ts1, (char *) &nts, sizeof ts1);

  ts2 = ntohts(nts);
  if ( ! bad ) {
   bad = memcmp(&ts1, &ts2, sizeof ts1);
   worse = 0;
  }
  else {
   worse = revcmp((char *) &nts, (char *) &ts2, sizeof nts);
  }

  PG_PcapTimestamp(&tv2, ts2);

  printf("%ld.%06ld (%.6f) => %ld.%06ld (%.6f)\n",
      tv1.tv_sec, tv1.tv_usec, (double) ts1,
      tv2.tv_sec, tv2.tv_usec, (double) ts2);

  hex((void *) &ts1, sizeof ts1, "Timestamp before htonts()");
  hex((void *) &nts, sizeof nts,
   bad ? "ntimestamp after htonts() bad" :
         "ntimestamp after htonts()");
  hex((void *) &ts2, sizeof ts2,
   worse ? "Timestamp after ntohts() worse" :
     bad ? "Timestamp after ntohts() bad" :
           "Timestamp after ntohts()");

  printf("\n");

  if ( bad || worse ) success = 1;
 }

 printf("%s\n", success == 0 ? "OK" : "BAD");

    return success;
}

static void hex(const char *data, int size, const char *commentary) {
 int j;
 for (j=0; j < size; ++j) printf(" %02x", data[j] & 0xff);
 printf(" %s\n", commentary);
}

static int revcmp(const char *s1, const char *s2, size_t len)
{
 for ( s2 += len - 1; len > 0; --len, ++s1, --s2 ) {
  if ( *s1 != *s2 ) return *s2 - *s1;
 }

 return 0;
}




int
PG_PostgresTimestamp(Timestamp *ptTimestamp, struct timeval tTimeval)
{
    *ptTimestamp =
        tTimeval.tv_sec - lPostgresEpoch +
        ((double) tTimeval.tv_usec)/1.0e6;
    return 1;
}




int
PG_PcapTimestamp(struct timeval *ptTimeval, const Timestamp tTimestamp)
{
    double dFrac, dInt;

    dFrac = modf((double) tTimestamp, &dInt);

    ptTimeval->tv_sec = (long) dInt + lPostgresEpoch;
    ptTimeval->tv_usec = (long) (dFrac * 1.0e6);

    return 1;
}




ntimestamp htonts(Timestamp s)
{
 ntimestamp nt;

 nt.li[0] = __extension__ ({ register u_long __X = (((long *) &s)[1]); __asm
("xchgb %h1, %b1\n\trorl $16, %1\n\txchgb %h1, %b1" : "=q" (__X) : "0" (__X));
__X; });
 nt.li[1] = __extension__ ({ register u_long __X = (((long *) &s)[0]); __asm
("xchgb %h1, %b1\n\trorl $16, %1\n\txchgb %h1, %b1" : "=q" (__X) : "0" (__X));
__X; });

 return nt;
}




Timestamp ntohts(ntimestamp nt)
{
 Timestamp s;

 ((long *) &s)[0] = __extension__ ({ register u_long __X = (nt.li[1]); __asm
("xchgb %h1, %b1\n\trorl $16, %1\n\txchgb %h1, %b1" : "=q" (__X) : "0" (__X));
__X; });
 ((long *) &s)[1] = __extension__ ({ register u_long __X = (nt.li[0]); __asm
("xchgb %h1, %b1\n\trorl $16, %1\n\txchgb %h1, %b1" : "=q" (__X) : "0" (__X));
__X; });

 return s;
}
Comment 1 Andrew Pinski 2005-05-19 19:15:46 UTC
You are violating C aliasing rules:
((long *) &s)[0] = __extension__ ({ register u_long __X = (nt.li[1]); __asm
("xchgb %h1, %b1\n\trorl $16, %1\n\txchgb %h1, %b1" : "=q" (__X) : "0" (__X));
__X; });

s is a double but you are accessing it as a long.
Comment 2 Jonathan Beit-Aharon 2005-05-19 20:43:57 UTC
Subject: Re:  Optimization level -O2 breaks float (double) conversion

Dear Pinskia and Co.,
As a former compiler developer myself I was just trying to help, and I'm 
sorry to tell you that your answer was not to the point.

In order to transmit this double-precision-float we have to reformat it 
into/from "Network Byte Ordering".  The compiler generated no warnings, 
and the generated code works fine when un-optimized or when optimized 
with -O1.

The problem reproduction program reformats X into Y and then reformats Y 
into X with the inverse operation.  It then verifies that the original X 
has the same value as the final X.

There is absolutely no reason why the -O2 optimization should break the 
code, and hence this bug is valid as a regression in -O2 relative to -O1.

Regards,
Jonathan

pinskia at gcc dot gnu dot org wrote:

>------- Additional Comments From pinskia at gcc dot gnu dot org  2005-05-19 19:15 -------
>You are violating C aliasing rules:
>((long *) &s)[0] = __extension__ ({ register u_long __X = (nt.li[1]); __asm
>("xchgb %h1, %b1\n\trorl $16, %1\n\txchgb %h1, %b1" : "=q" (__X) : "0" (__X));
>__X; });
>
>s is a double but you are accessing it as a long.
>
>  
>

Comment 3 Andrew Pinski 2005-05-19 21:34:42 UTC
(In reply to comment #2)
> Subject: Re:  Optimization level -O2 breaks float (double) conversion
> 
> Dear Pinski and Co.,
> As a former compiler developer myself I was just trying to help, and I'm 
> sorry to tell you that your answer was not to the point.

The code is undefined by the C standard so we could compile it to make your hardware unusable after 
you execute that code (yes I am joking but that is what the C standard allows us to do).  read http://
gcc.gnu.org/bugs.html and the explication on that page about this commonly reported bug.

You can either workaround it by using -fno-strict-aliasing or using an union.  And yes the compiler 
does generate a warning with -Wstrict-aliasing (which is included with -Wall).
Comment 4 Andrew Pinski 2005-06-05 09:19:01 UTC
Reopening to ..
Comment 5 Andrew Pinski 2005-06-05 09:19:19 UTC
Mark as a dup of bug 21920.

*** This bug has been marked as a duplicate of 21920 ***