mirror of
https://github.com/postgres/postgres.git
synced 2025-09-03 15:22:11 +03:00
Add rint() to /port, remove from qnx/.
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/pgtypeslib/Makefile,v 1.5 2003/04/08 17:06:15 tgl Exp $
|
||||
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/pgtypeslib/Makefile,v 1.6 2003/05/09 16:26:29 momjian Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
@@ -18,7 +18,8 @@ SO_MINOR_VERSION= 0.0
|
||||
|
||||
override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(top_srcdir)/src/include/utils $(CPPFLAGS)
|
||||
|
||||
OBJS= numeric.o datetime.o common.o dt_common.o timestamp.o interval.o
|
||||
OBJS= numeric.o datetime.o common.o dt_common.o timestamp.o interval.o \
|
||||
$(filter rint.o, $(LIBOBJS))
|
||||
|
||||
all: all-lib
|
||||
|
||||
|
@@ -299,7 +299,6 @@ int DecodeDateTime(char **, int *, int, int *, struct tm *, fsec_t *, int *, boo
|
||||
void j2date(int, int *, int *, int *);
|
||||
void GetCurrentDateTime(struct tm*);
|
||||
int date2j(int, int, int);
|
||||
double rint(double x);
|
||||
|
||||
extern char* pgtypes_date_weekdays_short[];
|
||||
extern char* pgtypes_date_months[];
|
||||
|
@@ -510,108 +510,6 @@ char* pgtypes_date_weekdays_short[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri",
|
||||
|
||||
char* pgtypes_date_months[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", NULL};
|
||||
|
||||
#ifndef HAVE_RINT
|
||||
|
||||
/* @(#)s_rint.c 5.1 93/09/24 */
|
||||
/*
|
||||
* ====================================================
|
||||
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software is freely granted, provided that this notice
|
||||
* is preserved.
|
||||
* ====================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
* rint(x)
|
||||
* Return x rounded to integral value according to the prevailing
|
||||
* rounding mode.
|
||||
* Method:
|
||||
* Using floating addition.
|
||||
* Exception:
|
||||
* Inexact flag raised if x not equal to rint(x).
|
||||
*/
|
||||
|
||||
static const double one = 1.0,
|
||||
TWO52[2] = {
|
||||
4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */
|
||||
-4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */
|
||||
};
|
||||
|
||||
double
|
||||
rint(double x)
|
||||
{
|
||||
int i0,
|
||||
n0,
|
||||
j0,
|
||||
sx;
|
||||
unsigned i,
|
||||
i1;
|
||||
double w,
|
||||
t;
|
||||
|
||||
n0 = (*((int *) &one) >> 29) ^ 1;
|
||||
i0 = *(n0 + (int *) &x);
|
||||
sx = (i0 >> 31) & 1;
|
||||
i1 = *(1 - n0 + (int *) &x);
|
||||
j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
|
||||
if (j0 < 20)
|
||||
{
|
||||
if (j0 < 0)
|
||||
{
|
||||
if (((i0 & 0x7fffffff) | i1) == 0)
|
||||
return x;
|
||||
i1 |= (i0 & 0x0fffff);
|
||||
i0 &= 0xfffe0000;
|
||||
i0 |= ((i1 | -i1) >> 12) & 0x80000;
|
||||
*(n0 + (int *) &x) = i0;
|
||||
w = TWO52[sx] + x;
|
||||
t = w - TWO52[sx];
|
||||
i0 = *(n0 + (int *) &t);
|
||||
*(n0 + (int *) &t) = (i0 & 0x7fffffff) | (sx << 31);
|
||||
return t;
|
||||
}
|
||||
else
|
||||
{
|
||||
i = (0x000fffff) >> j0;
|
||||
if (((i0 & i) | i1) == 0)
|
||||
return x; /* x is integral */
|
||||
i >>= 1;
|
||||
if (((i0 & i) | i1) != 0)
|
||||
{
|
||||
if (j0 == 19)
|
||||
i1 = 0x40000000;
|
||||
else
|
||||
i0 = (i0 & (~i)) | ((0x20000) >> j0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (j0 > 51)
|
||||
{
|
||||
if (j0 == 0x400)
|
||||
return x + x; /* inf or NaN */
|
||||
else
|
||||
return x; /* x is integral */
|
||||
}
|
||||
else
|
||||
{
|
||||
i = ((unsigned) (0xffffffff)) >> (j0 - 20);
|
||||
if ((i1 & i) == 0)
|
||||
return x; /* x is integral */
|
||||
i >>= 1;
|
||||
if ((i1 & i) != 0)
|
||||
i1 = (i1 & (~i)) | ((0x40000000) >> (j0 - 20));
|
||||
}
|
||||
*(n0 + (int *) &x) = i0;
|
||||
*(1 - n0 + (int *) &x) = i1;
|
||||
w = TWO52[sx] + x;
|
||||
return w - TWO52[sx];
|
||||
}
|
||||
|
||||
#endif /* !HAVE_RINT */
|
||||
|
||||
static datetkn *
|
||||
datebsearch(char *key, datetkn *base, unsigned int nel)
|
||||
{
|
||||
|
Reference in New Issue
Block a user