summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authordas <das@FreeBSD.org>2004-07-19 08:16:10 +0000
committerdas <das@FreeBSD.org>2004-07-19 08:16:10 +0000
commit7aef999db62cfb1370a29fad2bbee5c489b660ec (patch)
tree0682171fd2934d939f73a83ae70efdcd286af303 /lib/libc
parent67d8cb396ecf47239ba3bff7d7a8f44ed7ceb7d5 (diff)
downloadFreeBSD-src-7aef999db62cfb1370a29fad2bbee5c489b660ec.zip
FreeBSD-src-7aef999db62cfb1370a29fad2bbee5c489b660ec.tar.gz
Fix two bugs in the signbit() macro, which was implemented last year:
- It was added to libc instead of libm. Hopefully no programs rely on this mistake. - It didn't work properly on large long doubles because its argument was converted to type double, resulting in undefined behavior.
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/Makefile.inc5
-rw-r--r--lib/libc/gen/signbit.357
-rw-r--r--lib/libc/gen/signbit.c40
3 files changed, 2 insertions, 100 deletions
diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc
index 14b56ce..764766a 100644
--- a/lib/libc/gen/Makefile.inc
+++ b/lib/libc/gen/Makefile.inc
@@ -25,8 +25,7 @@ SRCS+= __xuname.c _pthread_stubs.c _rand48.c _spinlock_stub.c _thread_init.c \
raise.c readdir.c readpassphrase.c rewinddir.c \
scandir.c seed48.c seekdir.c sem.c semctl.c \
setdomainname.c sethostname.c setjmperr.c setmode.c \
- setproctitle.c setprogname.c \
- siginterrupt.c siglist.c signal.c signbit.c \
+ setproctitle.c setprogname.c siginterrupt.c siglist.c signal.c \
sigsetops.c sleep.c srand48.c statvfs.c stringlist.c strtofflags.c \
sysconf.c sysctl.c sysctlbyname.c sysctlnametomib.c \
syslog.c telldir.c termios.c time.c times.c timezone.c ttyname.c \
@@ -57,7 +56,7 @@ MAN+= alarm.3 arc4random.3 \
scandir.3 sem_destroy.3 sem_getvalue.3 sem_init.3 \
sem_open.3 sem_post.3 sem_wait.3 \
setjmp.3 setmode.3 setproctitle.3 shm_open.3 \
- siginterrupt.3 signal.3 signbit.3 sigsetops.3 sleep.3 \
+ siginterrupt.3 signal.3 sigsetops.3 sleep.3 \
statvfs.3 stringlist.3 \
strtofflags.3 sysconf.3 sysctl.3 syslog.3 tcgetpgrp.3 \
tcsendbreak.3 tcsetattr.3 tcsetpgrp.3 time.3 times.3 timezone.3 \
diff --git a/lib/libc/gen/signbit.3 b/lib/libc/gen/signbit.3
deleted file mode 100644
index fcc7df4..0000000
--- a/lib/libc/gen/signbit.3
+++ /dev/null
@@ -1,57 +0,0 @@
-.\" Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org>
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd February 11, 2003
-.Dt SIGNBIT 3
-.Os
-.Sh NAME
-.Nm signbit
-.Nd "determine whether a floating-point number's sign is negative"
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In math.h
-.Ft int
-.Fn signbit "real-floating x"
-.Sh DESCRIPTION
-The
-.Fn signbit
-macro takes an argument of
-.Fa x
-and returns non-zero if the value of its sign is negative, otherwise 0.
-.Sh SEE ALSO
-.Xr fpclassify 3 ,
-.Xr math 3
-.Sh STANDARDS
-The
-.Fn signbit
-macro conforms to
-.St -isoC-99 .
-.Sh HISTORY
-The
-.Fn signbit
-macro was added in
-.Fx 5.1 .
diff --git a/lib/libc/gen/signbit.c b/lib/libc/gen/signbit.c
deleted file mode 100644
index 02b48ee..0000000
--- a/lib/libc/gen/signbit.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*-
- * Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <math.h>
-
-#include "fpmath.h"
-
-int
-__signbit(double d)
-{
- union IEEEd2bits u;
-
- u.d = d;
- return (u.bits.sign);
-}
OpenPOWER on IntegriCloud