Add rint() to /port, remove from qnx/.

This commit is contained in:
Bruce Momjian 2003-05-09 16:26:29 +00:00
parent 995773be1c
commit 0afe5417d7
9 changed files with 19 additions and 149 deletions

4
configure vendored
View File

@ -11078,7 +11078,8 @@ fi
for ac_func in fseeko gethostname getopt_long getrusage inet_aton random srandom strcasecmp strdup strerror strtol strtoul
for ac_func in fseeko gethostname getopt_long getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
@ -11261,6 +11262,7 @@ LIBOBJS="$LIBOBJS dirmod.$ac_objext"
LIBOBJS="$LIBOBJS opendir.$ac_objext" ;;
esac
# Now that rint() is /port, I am not sure this still works, bjm 2003-05-09
# On HPUX 9, rint() is not in regular libm.a but in /lib/pa1.1/libm.a;
# this hackery with HPUXMATHLIB allows us to cope.
HPUXMATHLIB=""

View File

@ -1,5 +1,5 @@
dnl Process this file with autoconf to produce a configure script.
dnl $Header: /cvsroot/pgsql/configure.in,v 1.246 2003/05/09 01:16:29 momjian Exp $
dnl $Header: /cvsroot/pgsql/configure.in,v 1.247 2003/05/09 16:26:28 momjian Exp $
dnl
dnl Developers, please strive to achieve this order:
dnl
@ -839,7 +839,7 @@ else
AC_CHECK_FUNCS([fpclass fp_class fp_class_d class], [break])
fi
AC_REPLACE_FUNCS([fseeko gethostname getopt_long getrusage inet_aton random srandom strcasecmp strdup strerror strtol strtoul])
AC_REPLACE_FUNCS([fseeko gethostname getopt_long getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul])
# system's version of getaddrinfo(), if any, may be used only if we found
# a definition for struct addrinfo; see notes in src/include/getaddrinfo.h
@ -867,6 +867,7 @@ AC_LIBOBJ(dirmod)
AC_LIBOBJ(opendir) ;;
esac
# Now that rint() is /port, I am not sure this still works, bjm 2003-05-09
# On HPUX 9, rint() is not in regular libm.a but in /lib/pa1.1/libm.a;
# this hackery with HPUXMATHLIB allows us to cope.
HPUXMATHLIB=""

View File

@ -4,7 +4,7 @@
# Makefile for port/qnx4
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/Makefile,v 1.4 2003/04/24 17:16:13 momjian Exp $
# $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/Makefile,v 1.5 2003/05/09 16:26:29 momjian Exp $
#
#-------------------------------------------------------------------------
@ -12,16 +12,13 @@ subdir = src/backend/port/qnx4
top_builddir = ../../../..
include $(top_builddir)/src/Makefile.global
OBJS = isnan.o rint.o sem.o shm.o
OBJS = isnan.o sem.o shm.o
all: SUBSYS.o tstrint tstsem tstshm
all: SUBSYS.o tstsem tstshm
SUBSYS.o: $(OBJS)
$(LD) $(LDREL) $(LDOUT) SUBSYS.o $(OBJS)
tstrint: tstrint.o rint.o
$(CC) -o tstrint rint.o tstrint.o
tstsem: tstsem.o sem.o
$(CC) -o tstsem sem.o tstsem.o
@ -32,7 +29,7 @@ depend dep:
$(CC) -MM $(CFLAGS) *.c >depend
clean:
rm -f SUBSYS.o $(OBJS) tstrint tstrint.o tstsem tstsem.o tstshm tstshm.o
rm -f SUBSYS.o $(OBJS) tstsem tstsem.o tstshm tstshm.o
ifeq (depend,$(wildcard depend))
include depend

View File

@ -1,32 +0,0 @@
/*-------------------------------------------------------------------------
*
* tstrint.c
* rint() test
*
* Copyright (c) 1999, repas AEG Automation GmbH
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/tstrint.c,v 1.4 2002/11/08 20:23:56 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "c.h"
#include <errno.h>
int
main(int argc, char **argv)
{
double x;
if (argc != 2)
exit(1);
x = strtod(argv[1], NULL);
printf("rint( %f ) = %f\n", x, rint(x));
return 0;
}

View File

@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: c.h,v 1.142 2003/05/09 01:16:29 momjian Exp $
* $Id: c.h,v 1.143 2003/05/09 16:26:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -811,6 +811,10 @@ extern int isinf(double x);
extern int gethostname(char *name, int namelen);
#endif
#ifndef HAVE_RINT
extern double rint(double x);
#endif
#ifndef HAVE_INET_ATON
# include <netinet/in.h>
# include <arpa/inet.h>

View File

@ -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

View File

@ -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[];

View File

@ -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)
{

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/rint.c,v 1.3 2001/08/24 14:07:49 petere Exp $
* $Header: /cvsroot/pgsql/src/port/rint.c,v 1.1 2003/05/09 16:26:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/