diff options
-rw-r--r-- | libc/unistd/Makefile.in | 6 | ||||
-rw-r--r-- | libc/unistd/confstr.c | 21 | ||||
-rw-r--r-- | libc/unistd/daemon.c | 145 | ||||
-rw-r--r-- | libc/unistd/exec.c | 20 | ||||
-rw-r--r-- | libc/unistd/getlogin.c | 23 | ||||
-rw-r--r-- | libc/unistd/getopt-susv3.c | 15 | ||||
-rw-r--r-- | libc/unistd/getopt.c | 1 | ||||
-rw-r--r-- | libc/unistd/getopt_long-susv3.c | 58 | ||||
-rw-r--r-- | libc/unistd/getpass.c | 23 | ||||
-rw-r--r-- | libc/unistd/sysconf.c | 24 | ||||
-rw-r--r-- | libc/unistd/usershell.c | 5 |
11 files changed, 146 insertions, 195 deletions
diff --git a/libc/unistd/Makefile.in b/libc/unistd/Makefile.in index 6e85e10c9..5231ec69c 100644 --- a/libc/unistd/Makefile.in +++ b/libc/unistd/Makefile.in @@ -19,11 +19,11 @@ CSRC := $(filter-out daemon.c,$(CSRC)) endif ifeq ($(UCLIBC_HAS_GNU_GETOPT),y) -CSRC := $(filter-out getopt-susv3.c getopt_long-susv3.c,$(CSRC)) +CSRC := $(filter-out getopt-susv3.c getopt_long-simple.c,$(CSRC)) else CSRC := $(filter-out getopt.c,$(CSRC)) ifneq ($(UCLIBC_HAS_GETOPT_LONG),y) -CSRC := $(filter-out getopt_long-susv3.c,$(CSRC)) +CSRC := $(filter-out getopt_long-simple.c,$(CSRC)) endif endif @@ -41,6 +41,8 @@ UNISTD_SRC := $(patsubst %.c,$(UNISTD_DIR)/%.c,$(CSRC)) UNISTD_OBJ := $(patsubst %.c,$(UNISTD_OUT)/%.o,$(CSRC)) libc-y += $(UNISTD_OBJ) +libc-a-y += $(UNISTD_OBJ) +libc-so-y += $(UNISTD_OBJ:.o=.os) objclean-y += unistd_objclean diff --git a/libc/unistd/confstr.c b/libc/unistd/confstr.c index 8d1c8d303..34ae98483 100644 --- a/libc/unistd/confstr.c +++ b/libc/unistd/confstr.c @@ -1,20 +1,21 @@ -/* Copyright (C) 1991, 1996, 1997, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1996, 1997, 2000-2002, 2003, 2004 + 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 Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. + 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 - Library General Public License for more details. + Lesser General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ + 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. */ #include <stddef.h> #include <errno.h> @@ -28,7 +29,7 @@ libc_hidden_proto(memcpy) /* If BUF is not NULL and LEN > 0, fill in at most LEN - 1 bytes of BUF with the value corresponding to NAME and zero-terminate BUF. Return the number of bytes required to hold NAME's entire value. */ -size_t confstr ( int name, char *buf, size_t len) +size_t confstr (int name, char *buf, size_t len) { const char *string; size_t string_len; diff --git a/libc/unistd/daemon.c b/libc/unistd/daemon.c index 4c18e55fa..895e8fca0 100644 --- a/libc/unistd/daemon.c +++ b/libc/unistd/daemon.c @@ -1,40 +1,65 @@ /* vi: set sw=4 ts=4: */ /* daemon implementation for uClibc * - * Copyright (c) 1991, 1993 + * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * - * Modified for uClibc by Erik Andersen <andersee@debian.org> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. + * 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 program 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 Library General Public License - * for more details. + * 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change + * ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change> * - * You should have received a copy of the GNU Library General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * Original copyright notice is retained at the end of this file. + * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. */ -#define dup2 __dup2 -#define setsid __setsid -#define chdir __chdir -#define fork __fork +/* + * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> + * + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + * Modified for uClibc by Erik Andersen <andersen@uclibc.org> + */ #include <stdio.h> #include <features.h> #include <fcntl.h> #include <paths.h> #include <unistd.h> +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ +#include <errno.h> +#include <sys/stat.h> +#include <not-cancel.h> +#endif -#if defined __ARCH_HAS_MMU__ +#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98) + +libc_hidden_proto(open) +libc_hidden_proto(close) +libc_hidden_proto(_exit) +libc_hidden_proto(dup2) +libc_hidden_proto(setsid) +libc_hidden_proto(chdir) +libc_hidden_proto(fork) int daemon( int nochdir, int noclose ) { @@ -46,63 +71,55 @@ int daemon( int nochdir, int noclose ) case 0: break; default: - _exit_internal(0); + _exit(0); } if (setsid() == -1) return(-1); +#ifndef __UCLIBC_HAS_THREADS_NATIVE__ /* Make certain we are not a session leader, or else we * might reacquire a controlling terminal */ if (fork()) - _exit_internal(0); + _exit(0); +#endif if (!nochdir) chdir("/"); - if (!noclose && (fd = __open(_PATH_DEVNULL, O_RDWR, 0)) != -1) { - dup2(fd, STDIN_FILENO); - dup2(fd, STDOUT_FILENO); - dup2(fd, STDERR_FILENO); - if (fd > 2) - __close(fd); +#ifndef __UCLIBC_HAS_THREADS_NATIVE__ + if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) + { +#else + if (!noclose) + { + struct stat64 st; + + if ((fd = open_not_cancel(_PATH_DEVNULL, O_RDWR, 0)) != -1 + && (__builtin_expect (fstat64 (fd, &st), 0) == 0)) + { + if (__builtin_expect (S_ISCHR (st.st_mode), 1) != 0) { +#endif + dup2(fd, STDIN_FILENO); + dup2(fd, STDOUT_FILENO); + dup2(fd, STDERR_FILENO); + if (fd > 2) + close(fd); +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ + } + else { + /* We must set an errno value since no + function call actually failed. */ + close_not_cancel_no_status (fd); + __set_errno (ENODEV); + return -1; + } + } else { + close_not_cancel_no_status (fd); + return -1; + } +#endif } return(0); } - #endif - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. 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. - * - * 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change - * ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change> - * - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - - diff --git a/libc/unistd/exec.c b/libc/unistd/exec.c index 3563723ad..47aab27e7 100644 --- a/libc/unistd/exec.c +++ b/libc/unistd/exec.c @@ -1,18 +1,6 @@ /* Copyright (C) 2004 Manuel Novoa III * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. */ /* Jan 1, 2004 @@ -40,17 +28,16 @@ #include <sys/mman.h> libc_hidden_proto(execl) +libc_hidden_proto(execle) libc_hidden_proto(execvp) libc_hidden_proto(memcpy) libc_hidden_proto(strchr) libc_hidden_proto(strlen) -libc_hidden_proto(strchrnul) libc_hidden_proto(execve) libc_hidden_proto(mmap) libc_hidden_proto(munmap) libc_hidden_proto(getenv) -libc_hidden_proto(__environ) /**********************************************************************/ #if defined(__ARCH_USE_MMU__) || defined(__UCLIBC_UCLINUX_BROKEN_MUNMAP__) @@ -180,6 +167,7 @@ int execle(const char *path, const char *arg, ...) return n; } +libc_hidden_def(execle) #endif /**********************************************************************/ @@ -221,6 +209,8 @@ int execlp(const char *file, const char *arg, ...) /**********************************************************************/ #ifdef L_execvp +libc_hidden_proto(strchrnul) + /* Use a default path that matches glibc behavior, since SUSv3 says * this is implementation-defined. The default is current working dir, * /bin, and then /usr/bin. */ diff --git a/libc/unistd/getlogin.c b/libc/unistd/getlogin.c index 296d8d7fc..42438b327 100644 --- a/libc/unistd/getlogin.c +++ b/libc/unistd/getlogin.c @@ -1,23 +1,8 @@ /* vi: set sw=4 ts=4: */ -/* getlogin for uClibc - * - * Copyright (C) 2000 by Lineo, inc. and Erik Andersen - * Copyright (C) 2000-2002 by Erik Andersen <andersen@uclibc.org> - * Written by Erik Andersen <andersen@uclibc.org> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program 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 Library General Public License - * for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +/* + * getlogin for uClibc + * Copyright (C) 2000-2006 by Erik Andersen <andersen@uclibc.org> + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. */ #include <stdlib.h> diff --git a/libc/unistd/getopt-susv3.c b/libc/unistd/getopt-susv3.c index df36bfbb8..b13368c38 100644 --- a/libc/unistd/getopt-susv3.c +++ b/libc/unistd/getopt-susv3.c @@ -1,18 +1,6 @@ /* Copyright (C) 2003 Manuel Novoa III * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. */ /* ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION! @@ -37,7 +25,6 @@ libc_hidden_proto(fprintf) libc_hidden_proto(strchr) -libc_hidden_proto(stderr) #ifdef __UCLIBC_MJN3_ONLY__ #warning TODO: Enable gettext awareness. diff --git a/libc/unistd/getopt.c b/libc/unistd/getopt.c index cffde47e1..0c30032c9 100644 --- a/libc/unistd/getopt.c +++ b/libc/unistd/getopt.c @@ -127,7 +127,6 @@ libc_hidden_proto(strlen) libc_hidden_proto(strncmp) libc_hidden_proto(getenv) libc_hidden_proto(fprintf) -libc_hidden_proto(stderr) /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, diff --git a/libc/unistd/getopt_long-susv3.c b/libc/unistd/getopt_long-susv3.c deleted file mode 100644 index 9bae3d845..000000000 --- a/libc/unistd/getopt_long-susv3.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2006 Rich Felker <dalias@aerifal.cx> - * - * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. - */ - -#include <stddef.h> -#include <getopt.h> -#include <stdio.h> - -libc_hidden_proto(getopt) - -static int __getopt_long(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *idx, int longonly) -{ - if (optind >= argc || !argv[optind] || argv[optind][0] != '-') return -1; - if ((longonly && argv[optind][1]) || - (argv[optind][1] == '-' && argv[optind][2])) - { - int i; - char *opt = argv[optind]+2; - for (i=0; longopts[i].name; i++) { - const char *name = longopts[i].name; - while (*name && *name++ == *opt++); - if (*name && *opt != '=') continue; - if (*opt == '=') { - if (!longopts[i].has_arg) continue; - optarg = opt+1; - } else { - if (longopts[i].has_arg == required_argument) { - if (!(optarg = argv[++optind])) - return ':'; - } else optarg = NULL; - } - optind++; - if (idx) *idx = i; - if (longopts[i].flag) { - *longopts[i].flag = longopts[i].val; - return 0; - } - return longopts[i].val; - } - if (argv[optind][1] == '-') { - optind++; - return '?'; - } - } - return getopt(argc, argv, optstring); -} - -int getopt_long(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *idx) -{ - return __getopt_long(argc, argv, optstring, longopts, idx, 0); -} - -int getopt_long_only(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *idx) -{ - return __getopt_long(argc, argv, optstring, longopts, idx, 1); -} diff --git a/libc/unistd/getpass.c b/libc/unistd/getpass.c index 455838c62..34dbf355b 100644 --- a/libc/unistd/getpass.c +++ b/libc/unistd/getpass.c @@ -1,20 +1,20 @@ -/* Copyright (C) 1992,93,94,95,96,97,98,99 Free Software Foundation, Inc. +/* Copyright (C) 1992-1999,2001,2003,2004,2005 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 Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. + 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 - Library General Public License for more details. + Lesser General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ + 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. */ #include <stdio.h> #include <string.h> @@ -22,6 +22,8 @@ #include <unistd.h> #include <string.h> +#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_XOPEN2K) + libc_hidden_proto(strlen) libc_hidden_proto(tcsetattr) libc_hidden_proto(tcgetattr) @@ -35,8 +37,6 @@ libc_hidden_proto(fputs) libc_hidden_proto(fputc) libc_hidden_proto(putc) libc_hidden_proto(__fputc_unlocked) -libc_hidden_proto(stdin) -libc_hidden_proto(stderr) /* It is desirable to use this bit on systems that have it. The only bit of terminal state we want to twiddle is echoing, which is @@ -120,3 +120,4 @@ getpass (prompt) return buf; } +#endif diff --git a/libc/unistd/sysconf.c b/libc/unistd/sysconf.c index 0dde75102..430759889 100644 --- a/libc/unistd/sysconf.c +++ b/libc/unistd/sysconf.c @@ -1,3 +1,4 @@ +/* vi: set sw=4 ts=4: */ /* Copyright (C) 1991, 93, 95, 96, 97, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -32,6 +33,9 @@ #ifdef __UCLIBC_HAS_REGEX__ #include <regex.h> #endif +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ +#include <sysdep.h> +#endif libc_hidden_proto(sysconf) @@ -81,6 +85,26 @@ long int sysconf(int name) __set_errno(EINVAL); return -1; +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ +# ifdef __NR_clock_getres + case _SC_MONOTONIC_CLOCK: + /* Check using the clock_getres system call. */ + { + struct timespec ts; + INTERNAL_SYSCALL_DECL (err); + int r; + r = INTERNAL_SYSCALL (clock_getres, err, 2, CLOCK_MONOTONIC, &ts); + return INTERNAL_SYSCALL_ERROR_P (r, err) ? -1 : _POSIX_VERSION; + } +# endif + case _SC_THREAD_CPUTIME: +# ifdef _POSIX_THREAD_CPUTIME > 0 + return _POSIX_THREAD_CPUTIME; +# else + return -1; +# endif +#endif + case _SC_ARG_MAX: #ifdef ARG_MAX return ARG_MAX; diff --git a/libc/unistd/usershell.c b/libc/unistd/usershell.c index e053d94b7..ea4a04ba4 100644 --- a/libc/unistd/usershell.c +++ b/libc/unistd/usershell.c @@ -40,6 +40,8 @@ #include <unistd.h> #include <paths.h> +#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98) + libc_hidden_proto(fstat) libc_hidden_proto(fopen) libc_hidden_proto(fclose) @@ -48,7 +50,7 @@ libc_hidden_proto(fileno) libc_hidden_proto(fgets_unlocked) #ifdef __UCLIBC_HAS_XLOCALE__ libc_hidden_proto(__ctype_b_loc) -#else +#elif __UCLIBC_HAS_CTYPE_TABLES__ libc_hidden_proto(__ctype_b) #endif @@ -146,3 +148,4 @@ cleanup: fclose(fp); return (char **) validsh; } +#endif |