summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
Diffstat (limited to 'misc')
-rw-r--r--misc/Makefile9
-rw-r--r--misc/bits/syslog-ldbl.h36
-rw-r--r--misc/efgcvt.c49
-rw-r--r--misc/efgcvt_r.c40
-rw-r--r--misc/pselect.c36
-rw-r--r--misc/qefgcvt_r.c2
-rw-r--r--misc/sys/cdefs.h28
-rw-r--r--misc/sys/syslog.h3
-rw-r--r--misc/syslog.c15
-rw-r--r--misc/tst-pselect.c121
10 files changed, 283 insertions, 56 deletions
diff --git a/misc/Makefile b/misc/Makefile
index 5199b6b653..7d60baa7d6 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1991-2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+# Copyright (C) 1991-2002,2003,2004,2005,2006 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
@@ -25,11 +25,12 @@ subdir := misc
headers := sys/uio.h bits/uio.h sys/ioctl.h bits/ioctls.h bits/ioctl-types.h \
sys/ptrace.h sys/file.h sys/dir.h sys/cdefs.h \
ar.h a.out.h libgen.h stab.h bits/stab.def sgtty.h \
- ttyent.h syslog.h sys/syslog.h paths.h sys/reboot.h \
+ ttyent.h paths.h sys/reboot.h \
sys/mman.h sys/param.h fstab.h mntent.h search.h err.h error.h \
sys/queue.h sysexits.h syscall.h sys/syscall.h sys/swap.h \
sys/select.h ustat.h sys/ustat.h bits/ustat.h sys/sysinfo.h \
- regexp.h bits/select.h bits/mman.h sys/xattr.h bits/syslog.h
+ regexp.h bits/select.h bits/mman.h sys/xattr.h \
+ syslog.h sys/syslog.h bits/syslog.h bits/syslog-ldbl.h
routines := brk sbrk sstk ioctl \
readv writev \
@@ -76,7 +77,7 @@ endif
gpl2lgpl := error.c error.h
tests := tst-dirname tst-tsearch tst-fdset tst-efgcvt tst-mntent tst-hsearch \
- tst-error1
+ tst-error1 tst-pselect
ifeq (no,$(cross-compiling))
tests: $(objpfx)tst-error1-mem
endif
diff --git a/misc/bits/syslog-ldbl.h b/misc/bits/syslog-ldbl.h
new file mode 100644
index 0000000000..d153c8f8cd
--- /dev/null
+++ b/misc/bits/syslog-ldbl.h
@@ -0,0 +1,36 @@
+/* -mlong-double-64 compatibility mode for syslog functions.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_SYSLOG_H
+# error "Never include <bits/syslog-ldbl.h> directly; use <sys/syslog.h> instead."
+#endif
+
+__LDBL_REDIR_DECL (syslog)
+
+#ifdef __USE_BSD
+__LDBL_REDIR_DECL (vsyslog)
+#endif
+
+#if __USE_FORTIFY_LEVEL > 0 && !defined __cplusplus
+__LDBL_REDIR_DECL (__syslog_chk)
+
+# ifdef __USE_BSD
+__LDBL_REDIR_DECL (__vsyslog_chk)
+# endif
+#endif
diff --git a/misc/efgcvt.c b/misc/efgcvt.c
index 915d00dfd5..b9fb4a9b71 100644
--- a/misc/efgcvt.c
+++ b/misc/efgcvt.c
@@ -1,5 +1,6 @@
/* Compatibility functions for floating point formatting.
- Copyright (C) 1995, 1996, 1997, 1999, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1997, 1999, 2002, 2006
+ Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -23,6 +24,7 @@
#include <sys/param.h>
#include <float.h>
#include <bits/libc-lock.h>
+#include <math_ldbl_opt.h>
#ifndef FLOAT_TYPE
# define FLOAT_TYPE double
@@ -44,10 +46,14 @@
# error "NDIGIT_MAX must be precomputed"
# define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * DBL_MANT_DIG + 1.0)))
# endif
+#else
+# define LONG_DOUBLE_CVT
#endif
#define APPEND(a, b) APPEND2 (a, b)
#define APPEND2(a, b) a##b
+#define __APPEND(a, b) __APPEND2 (a, b)
+#define __APPEND2(a, b) __##a##b
#define FCVT_BUFFER APPEND (FUNC_PREFIX, fcvt_buffer)
@@ -60,14 +66,14 @@ static char ECVT_BUFFER[MAXDIG];
libc_freeres_ptr (static char *FCVT_BUFPTR);
char *
-APPEND (FUNC_PREFIX, fcvt) (value, ndigit, decpt, sign)
+__APPEND (FUNC_PREFIX, fcvt) (value, ndigit, decpt, sign)
FLOAT_TYPE value;
int ndigit, *decpt, *sign;
{
if (FCVT_BUFPTR == NULL)
{
- if (APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign,
- FCVT_BUFFER, MAXDIG) != -1)
+ if (__APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign,
+ FCVT_BUFFER, MAXDIG) != -1)
return FCVT_BUFFER;
FCVT_BUFPTR = (char *) malloc (FCVT_MAXDIG);
@@ -75,26 +81,26 @@ APPEND (FUNC_PREFIX, fcvt) (value, ndigit, decpt, sign)
return FCVT_BUFFER;
}
- (void) APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign,
- FCVT_BUFPTR, FCVT_MAXDIG);
+ (void) __APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign,
+ FCVT_BUFPTR, FCVT_MAXDIG);
return FCVT_BUFPTR;
}
char *
-APPEND (FUNC_PREFIX, ecvt) (value, ndigit, decpt, sign)
+__APPEND (FUNC_PREFIX, ecvt) (value, ndigit, decpt, sign)
FLOAT_TYPE value;
int ndigit, *decpt, *sign;
{
- (void) APPEND (FUNC_PREFIX, ecvt_r) (value, ndigit, decpt, sign,
- ECVT_BUFFER, MAXDIG);
+ (void) __APPEND (FUNC_PREFIX, ecvt_r) (value, ndigit, decpt, sign,
+ ECVT_BUFFER, MAXDIG);
return ECVT_BUFFER;
}
char *
-APPEND (FUNC_PREFIX, gcvt) (value, ndigit, buf)
+__APPEND (FUNC_PREFIX, gcvt) (value, ndigit, buf)
FLOAT_TYPE value;
int ndigit;
char *buf;
@@ -102,3 +108,26 @@ APPEND (FUNC_PREFIX, gcvt) (value, ndigit, buf)
sprintf (buf, "%.*" FLOAT_FMT_FLAG "g", MIN (ndigit, NDIGIT_MAX), value);
return buf;
}
+
+#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
+# ifdef LONG_DOUBLE_CVT
+# define cvt_symbol(symbol) \
+ cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \
+ APPEND (FUNC_PREFIX, symbol), GLIBC_2_4)
+# define cvt_symbol_1(lib, local, symbol, version) \
+ versioned_symbol (lib, local, symbol, version)
+# else
+# define cvt_symbol(symbol) \
+ cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \
+ APPEND (q, symbol), GLIBC_2_0); \
+ strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol))
+# define cvt_symbol_1(lib, local, symbol, version) \
+ compat_symbol (lib, local, symbol, version)
+# endif
+#else
+# define cvt_symbol(symbol) \
+ strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol))
+#endif
+cvt_symbol(fcvt);
+cvt_symbol(ecvt);
+cvt_symbol(gcvt);
diff --git a/misc/efgcvt_r.c b/misc/efgcvt_r.c
index 69cca9038f..ba9566d22c 100644
--- a/misc/efgcvt_r.c
+++ b/misc/efgcvt_r.c
@@ -1,5 +1,6 @@
/* Compatibility functions for floating point formatting, reentrant versions.
- Copyright (C) 1995,96,97,98,99,2000,01,02,04 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2006
+ Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -25,6 +26,7 @@
#include <math.h>
#include <stdlib.h>
#include <sys/param.h>
+#include <math_ldbl_opt.h>
#ifndef FLOAT_TYPE
# define FLOAT_TYPE double
@@ -55,10 +57,14 @@
# error "FLOAT_MIN_10_NORM must be precomputed"
# define FLOAT_MIN_10_NORM exp10 (DBL_MIN_10_EXP)
# endif
+#else
+# define LONG_DOUBLE_CVT
#endif
#define APPEND(a, b) APPEND2 (a, b)
#define APPEND2(a, b) a##b
+#define __APPEND(a, b) __APPEND2 (a, b)
+#define __APPEND2(a, b) __##a##b
#define FLOOR APPEND(floor, FLOAT_NAME_EXT)
#define FABS APPEND(fabs, FLOAT_NAME_EXT)
@@ -67,7 +73,7 @@
int
-APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign, buf, len)
+__APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign, buf, len)
FLOAT_TYPE value;
int ndigit, *decpt, *sign;
char *buf;
@@ -163,10 +169,9 @@ APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign, buf, len)
return 0;
}
-libc_hidden_def (APPEND (FUNC_PREFIX, fcvt_r))
int
-APPEND (FUNC_PREFIX, ecvt_r) (value, ndigit, decpt, sign, buf, len)
+__APPEND (FUNC_PREFIX, ecvt_r) (value, ndigit, decpt, sign, buf, len)
FLOAT_TYPE value;
int ndigit, *decpt, *sign;
char *buf;
@@ -229,11 +234,32 @@ APPEND (FUNC_PREFIX, ecvt_r) (value, ndigit, decpt, sign, buf, len)
*sign = isfinite (value) ? signbit (value) != 0 : 0;
}
else
- if (APPEND (FUNC_PREFIX, fcvt_r) (value, MIN (ndigit, NDIGIT_MAX) - 1,
- decpt, sign, buf, len))
+ if (__APPEND (FUNC_PREFIX, fcvt_r) (value, MIN (ndigit, NDIGIT_MAX) - 1,
+ decpt, sign, buf, len))
return -1;
*decpt += exponent;
return 0;
}
-libc_hidden_def (APPEND (FUNC_PREFIX, ecvt_r))
+
+#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
+# ifdef LONG_DOUBLE_CVT
+# define cvt_symbol(symbol) \
+ cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \
+ APPEND (FUNC_PREFIX, symbol), GLIBC_2_4)
+# define cvt_symbol_1(lib, local, symbol, version) \
+ versioned_symbol (lib, local, symbol, version)
+# else
+# define cvt_symbol(symbol) \
+ cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \
+ APPEND (q, symbol), GLIBC_2_0); \
+ strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol))
+# define cvt_symbol_1(lib, local, symbol, version) \
+ compat_symbol (lib, local, symbol, version)
+# endif
+#else
+# define cvt_symbol(symbol) \
+ strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol))
+#endif
+cvt_symbol(fcvt_r);
+cvt_symbol(ecvt_r);
diff --git a/misc/pselect.c b/misc/pselect.c
index 43b371cce7..80cf8be4b3 100644
--- a/misc/pselect.c
+++ b/misc/pselect.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996,1997,1998,2001,2002,2003 Free Software Foundation, Inc.
+/* Copyright (C) 1996-1998,2001,2002,2003,2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -24,15 +24,16 @@
#include <sys/select.h>
#include <sysdep-cancel.h>
+
/* Check the first NFDS descriptors each in READFDS (if not NULL) for read
readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS
(if not NULL) for exceptional conditions. If TIMEOUT is not NULL, time out
after waiting the interval specified therein. Additionally set the sigmask
SIGMASK for this call. Returns the number of ready descriptors, or -1 for
errors. */
-static int
-do_pselect (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
- const struct timespec *timeout, const sigset_t *sigmask)
+int
+__pselect (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
+ const struct timespec *timeout, const sigset_t *sigmask)
{
struct timeval tval;
int retval;
@@ -61,28 +62,9 @@ do_pselect (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
return retval;
}
-
-
-int
-__pselect (nfds, readfds, writefds, exceptfds, timeout, sigmask)
- int nfds;
- fd_set *readfds;
- fd_set *writefds;
- fd_set *exceptfds;
- const struct timespec *timeout;
- const sigset_t *sigmask;
-{
- if (SINGLE_THREAD_P)
- return do_pselect (nfds, readfds, writefds, exceptfds, timeout, sigmask);
-
- int oldtype = LIBC_CANCEL_ASYNC ();
-
- int result = do_pselect (nfds, readfds, writefds, exceptfds, timeout,
- sigmask);
-
- LIBC_CANCEL_RESET (oldtype);
-
- return result;
-}
+#ifndef __pselect
weak_alias (__pselect, pselect)
strong_alias (__pselect, __libc_pselect)
+/* __select handles cancellation. */
+LIBC_CANCEL_HANDLED ();
+#endif
diff --git a/misc/qefgcvt_r.c b/misc/qefgcvt_r.c
index d5b2a799b3..a03ff748ef 100644
--- a/misc/qefgcvt_r.c
+++ b/misc/qefgcvt_r.c
@@ -43,6 +43,8 @@
#endif
#if LDBL_MIN_10_EXP == -37
# define FLOAT_MIN_10_NORM 1.0e-37L
+#elif LDBL_MIN_10_EXP == -291
+# define FLOAT_MIN_10_NORM 1.0e-291L
#elif LDBL_MIN_10_EXP == -307
# define FLOAT_MIN_10_NORM 1.0e-307L
#elif LDBL_MIN_10_EXP == -4931
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index eb192cca49..ce5e83d571 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1992-2001, 2002, 2004, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2001, 2002, 2004, 2005, 2006
+ Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -309,4 +310,29 @@
# endif
#endif
+#include <bits/wordsize.h>
+
+#if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
+# define __LDBL_COMPAT 1
+# ifdef __REDIRECT
+# define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)
+# define __LDBL_REDIR(name, proto) \
+ __LDBL_REDIR1 (name, proto, __nldbl_##name)
+# define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)
+# define __LDBL_REDIR_NTH(name, proto) \
+ __LDBL_REDIR1_NTH (name, proto, __nldbl_##name)
+# define __LDBL_REDIR1_DECL(name, alias) \
+ extern __typeof (name) name __asm (__ASMNAME (#alias));
+# define __LDBL_REDIR_DECL(name) \
+ extern __typeof (name) name __asm (__ASMNAME ("__nldbl_" #name));
+# endif
+#endif
+#if !defined __LDBL_COMPAT || !defined __REDIRECT
+# define __LDBL_REDIR1(name, proto, alias) name proto
+# define __LDBL_REDIR(name, proto) name proto
+# define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW
+# define __LDBL_REDIR_NTH(name, proto) name proto __THROW
+# define __LDBL_REDIR_DECL(name)
+#endif
+
#endif /* sys/cdefs.h */
diff --git a/misc/sys/syslog.h b/misc/sys/syslog.h
index 9de7570d8a..0bc5b8d677 100644
--- a/misc/sys/syslog.h
+++ b/misc/sys/syslog.h
@@ -206,6 +206,9 @@ extern void vsyslog (int __pri, __const char *__fmt, __gnuc_va_list __ap)
#if __USE_FORTIFY_LEVEL > 0 && !defined __cplusplus
# include <bits/syslog.h>
#endif
+#ifdef __LDBL_COMPAT
+# include <bits/syslog-ldbl.h>
+#endif
__END_DECLS
diff --git a/misc/syslog.c b/misc/syslog.c
index 6b0e7748fe..5781b4a964 100644
--- a/misc/syslog.c
+++ b/misc/syslog.c
@@ -58,6 +58,8 @@ static char sccsid[] = "@(#)syslog.c 8.4 (Berkeley) 3/18/94";
#endif
#include <libio/iolibio.h>
+#include <math_ldbl_opt.h>
+
#define ftell(s) INTUSE(_IO_ftell) (s)
static int LogType = SOCK_DGRAM; /* type of socket connection */
@@ -109,7 +111,7 @@ cancel_handler (void *ptr)
* print message on log file; output is intended for syslogd(8).
*/
void
-syslog(int pri, const char *fmt, ...)
+__syslog(int pri, const char *fmt, ...)
{
va_list ap;
@@ -117,7 +119,8 @@ syslog(int pri, const char *fmt, ...)
__vsyslog_chk(pri, -1, fmt, ap);
va_end(ap);
}
-libc_hidden_def (syslog)
+ldbl_hidden_def (__syslog, syslog)
+ldbl_strong_alias (__syslog, syslog)
void
__syslog_chk(int pri, int flag, const char *fmt, ...)
@@ -318,14 +321,12 @@ __vsyslog_chk(int pri, int flag, const char *fmt, va_list ap)
libc_hidden_def (__vsyslog_chk)
void
-vsyslog(pri, fmt, ap)
- int pri;
- register const char *fmt;
- va_list ap;
+__vsyslog(int pri, const char *fmt, va_list ap)
{
__vsyslog_chk (pri, -1, fmt, ap);
}
-libc_hidden_def (vsyslog)
+ldbl_hidden_def (__vsyslog, vsyslog)
+ldbl_strong_alias (__vsyslog, vsyslog)
static struct sockaddr_un SyslogAddr; /* AF_UNIX address of local logger */
diff --git a/misc/tst-pselect.c b/misc/tst-pselect.c
new file mode 100644
index 0000000000..123c31912e
--- /dev/null
+++ b/misc/tst-pselect.c
@@ -0,0 +1,121 @@
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/select.h>
+#include <sys/wait.h>
+
+
+static volatile int handler_called;
+
+static void
+handler (int sig)
+{
+ handler_called = 1;
+}
+
+
+static int
+do_test (void)
+{
+ struct sigaction sa;
+ sa.sa_handler = handler;
+ sa.sa_flags = 0;
+ sigemptyset (&sa.sa_mask);
+
+ if (sigaction (SIGUSR1, &sa, NULL) != 0)
+ {
+ puts ("sigaction failed");
+ return 1;
+ }
+
+ if (sigblock (SIGUSR1) != 0)
+ {
+ puts ("sigblock failed");
+ return 1;
+ }
+
+ int fds[2][2];
+
+ if (pipe (fds[0]) != 0 || pipe (fds[1]) != 0)
+ {
+ puts ("pipe failed");
+ return 1;
+ }
+
+ fd_set rfds;
+ FD_ZERO (&rfds);
+
+ sigset_t ss;
+ sigprocmask (SIG_SETMASK, NULL, &ss);
+ sigdelset (&ss, SIGUSR1);
+
+ struct timespec to = { .tv_sec = 0, .tv_nsec = 500000000 };
+
+ pid_t p = fork ();
+ if (p == 0)
+ {
+ close (fds[0][1]);
+ close (fds[1][0]);
+
+ FD_SET (fds[0][0], &rfds);
+
+ int e;
+ do
+ {
+ errno = 0;
+ e = pselect (fds[0][0] + 1, &rfds, NULL, NULL, &to, &ss);
+ }
+ while (e == 0);
+
+ if (e != -1)
+ {
+ puts ("child: pselect did not fail");
+ return 0;
+ }
+ if (errno != EINTR)
+ {
+ puts ("child: pselect did not set errno to EINTR");
+ return 0;
+ }
+
+ TEMP_FAILURE_RETRY (write (fds[1][1], "foo", 3));
+
+ exit (0);
+ }
+
+ close (fds[0][0]);
+ close (fds[1][1]);
+
+ FD_SET (fds[1][0], &rfds);
+
+ kill (p, SIGUSR1);
+
+ int e = pselect (fds[1][0] + 1, &rfds, NULL, NULL, NULL, &ss);
+ if (e == -1)
+ {
+ puts ("parent: pselect failed");
+ return 1;
+ }
+ if (e != 1)
+ {
+ puts ("parent: pselect did not report readable fd");
+ return 1;
+ }
+ if (!FD_ISSET (fds[1][0], &rfds))
+ {
+ puts ("parent: pselect reports wrong fd");
+ return 1;
+ }
+
+ if (TEMP_FAILURE_RETRY (waitpid (p, NULL, 0)) != p)
+ {
+ puts ("waitpid failed");
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"