From 7c6f9d53c1f57bb9b679fcdb39d2b5a9c63e46d3 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 17 Aug 2012 13:52:32 -0700 Subject: Move some things from sysdeps/unix to sysdeps/posix. --- ChangeLog | 17 ++++++++++++++++ sysdeps/posix/alarm.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++ sysdeps/posix/mkfifo.c | 29 +++++++++++++++++++++++++++ sysdeps/posix/mkfifoat.c | 31 +++++++++++++++++++++++++++++ sysdeps/posix/nice.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ sysdeps/posix/time.c | 41 ++++++++++++++++++++++++++++++++++++++ sysdeps/posix/utime.c | 49 +++++++++++++++++++++++++++++++++++++++++++++ sysdeps/unix/alarm.c | 50 ---------------------------------------------- sysdeps/unix/mkfifo.c | 29 --------------------------- sysdeps/unix/mkfifoat.c | 31 ----------------------------- sysdeps/unix/nice.c | 52 ------------------------------------------------ sysdeps/unix/time.c | 41 -------------------------------------- sysdeps/unix/utime.c | 49 --------------------------------------------- 13 files changed, 269 insertions(+), 252 deletions(-) create mode 100644 sysdeps/posix/alarm.c create mode 100644 sysdeps/posix/mkfifo.c create mode 100644 sysdeps/posix/mkfifoat.c create mode 100644 sysdeps/posix/nice.c create mode 100644 sysdeps/posix/time.c create mode 100644 sysdeps/posix/utime.c delete mode 100644 sysdeps/unix/alarm.c delete mode 100644 sysdeps/unix/mkfifo.c delete mode 100644 sysdeps/unix/mkfifoat.c delete mode 100644 sysdeps/unix/nice.c delete mode 100644 sysdeps/unix/time.c delete mode 100644 sysdeps/unix/utime.c diff --git a/ChangeLog b/ChangeLog index 6f793c7..70407fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,22 @@ 2012-08-17 Roland McGrath + * sysdeps/unix/mkfifo.c: Moved ... + * sysdeps/posix/mkfifo.c: ... here. + * sysdeps/unix/mkfifoat.c: Moved ... + * sysdeps/posix/mkfifoat.c: ... here. + + * sysdeps/unix/utime.c: Moved ... + * sysdeps/posix/utime.c: ... here. + + * sysdeps/unix/time.c: Moved ... + * sysdeps/posix/time.c: ... here. + + * sysdeps/unix/nice.c: Moved ... + * sysdeps/posix/nice.c: ... here. + + * sysdeps/unix/alarm.c: Moved ... + * sysdeps/posix/alarm.c: ... here. + * intl/Makefile ($(codeset_mo)): Depend on the input file. 2012-08-17 Jeff Law diff --git a/sysdeps/posix/alarm.c b/sysdeps/posix/alarm.c new file mode 100644 index 0000000..730f2c4 --- /dev/null +++ b/sysdeps/posix/alarm.c @@ -0,0 +1,50 @@ +/* Copyright (C) 1991,1992,1994,1997,2002,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 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, see + . */ + +#include +#include + +/* Schedule an alarm. In SECONDS seconds, the process will get a SIGALRM. + If SECONDS is zero, any currently scheduled alarm will be cancelled. + The function returns the number of seconds remaining until the last + alarm scheduled would have signaled, or zero if there wasn't one. + There is no return value to indicate an error, but you can set `errno' + to 0 and check its value after calling `alarm', and this might tell you. + The signal may come late due to processor scheduling. */ +unsigned int +alarm (seconds) + unsigned int seconds; +{ + struct itimerval old, new; + unsigned int retval; + + new.it_interval.tv_usec = 0; + new.it_interval.tv_sec = 0; + new.it_value.tv_usec = 0; + new.it_value.tv_sec = (long int) seconds; + if (__setitimer (ITIMER_REAL, &new, &old) < 0) + return 0; + + retval = old.it_value.tv_sec; + /* Round to the nearest second, but never report zero seconds when + the alarm is still set. */ + if (old.it_value.tv_usec >= 500000 + || (retval == 0 && old.it_value.tv_usec > 0)) + ++retval; + return retval; +} +libc_hidden_def (alarm) diff --git a/sysdeps/posix/mkfifo.c b/sysdeps/posix/mkfifo.c new file mode 100644 index 0000000..70329bd --- /dev/null +++ b/sysdeps/posix/mkfifo.c @@ -0,0 +1,29 @@ +/* Copyright (C) 1991, 1996, 1997 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, see + . */ + +#include +#include +#include +#include + +/* Create a named pipe (FIFO) named PATH with protections MODE. */ +int +mkfifo (const char *path, mode_t mode) +{ + dev_t dev = 0; + return __xmknod (_MKNOD_VER, path, mode | S_IFIFO, &dev); +} diff --git a/sysdeps/posix/mkfifoat.c b/sysdeps/posix/mkfifoat.c new file mode 100644 index 0000000..33fa6bd --- /dev/null +++ b/sysdeps/posix/mkfifoat.c @@ -0,0 +1,31 @@ +/* Copyright (C) 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 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, see + . */ + +#include + + +/* Create a new FIFO with permission bits MODE. But interpret + relative PATH names relative to the directory associated with FD. */ +int +mkfifoat (fd, file, mode) + int fd; + const char *file; + mode_t mode; +{ + dev_t dev = 0; + return __xmknodat (_MKNOD_VER, fd, file, mode | S_IFIFO, &dev); +} diff --git a/sysdeps/posix/nice.c b/sysdeps/posix/nice.c new file mode 100644 index 0000000..b986ffb --- /dev/null +++ b/sysdeps/posix/nice.c @@ -0,0 +1,52 @@ +/* Copyright (C) 1992, 1996, 1997, 2001, 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 + 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, see + . */ + +#include +#include +#include + +/* Increment the scheduling priority of the calling process by INCR. + The superuser may use a negative INCR to decrement the priority. */ +int +nice (int incr) +{ + int save; + int prio; + int result; + + /* -1 is a valid priority, so we use errno to check for an error. */ + save = errno; + __set_errno (0); + prio = getpriority (PRIO_PROCESS, 0); + if (prio == -1) + { + if (errno != 0) + return -1; + else + __set_errno (save); + } + + result = setpriority (PRIO_PROCESS, 0, prio + incr); + if (result == -1) + { + if (errno == EACCES) + errno = EPERM; + return -1; + } + return getpriority (PRIO_PROCESS, 0); +} diff --git a/sysdeps/posix/time.c b/sysdeps/posix/time.c new file mode 100644 index 0000000..e026a38 --- /dev/null +++ b/sysdeps/posix/time.c @@ -0,0 +1,41 @@ +/* Copyright (C) 1991,92,97,2001,02 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, see + . */ + +#include /* For NULL. */ +#include +#include + + +/* Return the current time as a `time_t' and also put it in *T if T is + not NULL. Time is represented as seconds from Jan 1 00:00:00 1970. */ +time_t +time (t) + time_t *t; +{ + struct timeval tv; + time_t result; + + if (__gettimeofday (&tv, (struct timezone *) NULL)) + result = (time_t) -1; + else + result = (time_t) tv.tv_sec; + + if (t != NULL) + *t = result; + return result; +} +libc_hidden_def (time) diff --git a/sysdeps/posix/utime.c b/sysdeps/posix/utime.c new file mode 100644 index 0000000..a750ecc --- /dev/null +++ b/sysdeps/posix/utime.c @@ -0,0 +1,49 @@ +/* Copyright (C) 1991,94,97,2002 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, see + . */ + +#include +#include +#include +#include +#include +#include + + +/* Set the access and modification times of FILE to those given in TIMES. + If TIMES is NULL, set them to the current time. */ +int +utime (file, times) + const char *file; + const struct utimbuf *times; +{ + struct timeval timevals[2]; + struct timeval *tvp; + + if (times != NULL) + { + timevals[0].tv_sec = (time_t) times->actime; + timevals[0].tv_usec = 0L; + timevals[1].tv_sec = (time_t) times->modtime; + timevals[1].tv_usec = 0L; + tvp = timevals; + } + else + tvp = NULL; + + return __utimes (file, tvp); +} +libc_hidden_def (utime) diff --git a/sysdeps/unix/alarm.c b/sysdeps/unix/alarm.c deleted file mode 100644 index 730f2c4..0000000 --- a/sysdeps/unix/alarm.c +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 1991,1992,1994,1997,2002,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 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, see - . */ - -#include -#include - -/* Schedule an alarm. In SECONDS seconds, the process will get a SIGALRM. - If SECONDS is zero, any currently scheduled alarm will be cancelled. - The function returns the number of seconds remaining until the last - alarm scheduled would have signaled, or zero if there wasn't one. - There is no return value to indicate an error, but you can set `errno' - to 0 and check its value after calling `alarm', and this might tell you. - The signal may come late due to processor scheduling. */ -unsigned int -alarm (seconds) - unsigned int seconds; -{ - struct itimerval old, new; - unsigned int retval; - - new.it_interval.tv_usec = 0; - new.it_interval.tv_sec = 0; - new.it_value.tv_usec = 0; - new.it_value.tv_sec = (long int) seconds; - if (__setitimer (ITIMER_REAL, &new, &old) < 0) - return 0; - - retval = old.it_value.tv_sec; - /* Round to the nearest second, but never report zero seconds when - the alarm is still set. */ - if (old.it_value.tv_usec >= 500000 - || (retval == 0 && old.it_value.tv_usec > 0)) - ++retval; - return retval; -} -libc_hidden_def (alarm) diff --git a/sysdeps/unix/mkfifo.c b/sysdeps/unix/mkfifo.c deleted file mode 100644 index 70329bd..0000000 --- a/sysdeps/unix/mkfifo.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (C) 1991, 1996, 1997 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, see - . */ - -#include -#include -#include -#include - -/* Create a named pipe (FIFO) named PATH with protections MODE. */ -int -mkfifo (const char *path, mode_t mode) -{ - dev_t dev = 0; - return __xmknod (_MKNOD_VER, path, mode | S_IFIFO, &dev); -} diff --git a/sysdeps/unix/mkfifoat.c b/sysdeps/unix/mkfifoat.c deleted file mode 100644 index 33fa6bd..0000000 --- a/sysdeps/unix/mkfifoat.c +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright (C) 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 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, see - . */ - -#include - - -/* Create a new FIFO with permission bits MODE. But interpret - relative PATH names relative to the directory associated with FD. */ -int -mkfifoat (fd, file, mode) - int fd; - const char *file; - mode_t mode; -{ - dev_t dev = 0; - return __xmknodat (_MKNOD_VER, fd, file, mode | S_IFIFO, &dev); -} diff --git a/sysdeps/unix/nice.c b/sysdeps/unix/nice.c deleted file mode 100644 index b986ffb..0000000 --- a/sysdeps/unix/nice.c +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (C) 1992, 1996, 1997, 2001, 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 - 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, see - . */ - -#include -#include -#include - -/* Increment the scheduling priority of the calling process by INCR. - The superuser may use a negative INCR to decrement the priority. */ -int -nice (int incr) -{ - int save; - int prio; - int result; - - /* -1 is a valid priority, so we use errno to check for an error. */ - save = errno; - __set_errno (0); - prio = getpriority (PRIO_PROCESS, 0); - if (prio == -1) - { - if (errno != 0) - return -1; - else - __set_errno (save); - } - - result = setpriority (PRIO_PROCESS, 0, prio + incr); - if (result == -1) - { - if (errno == EACCES) - errno = EPERM; - return -1; - } - return getpriority (PRIO_PROCESS, 0); -} diff --git a/sysdeps/unix/time.c b/sysdeps/unix/time.c deleted file mode 100644 index e026a38..0000000 --- a/sysdeps/unix/time.c +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 1991,92,97,2001,02 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, see - . */ - -#include /* For NULL. */ -#include -#include - - -/* Return the current time as a `time_t' and also put it in *T if T is - not NULL. Time is represented as seconds from Jan 1 00:00:00 1970. */ -time_t -time (t) - time_t *t; -{ - struct timeval tv; - time_t result; - - if (__gettimeofday (&tv, (struct timezone *) NULL)) - result = (time_t) -1; - else - result = (time_t) tv.tv_sec; - - if (t != NULL) - *t = result; - return result; -} -libc_hidden_def (time) diff --git a/sysdeps/unix/utime.c b/sysdeps/unix/utime.c deleted file mode 100644 index a750ecc..0000000 --- a/sysdeps/unix/utime.c +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 1991,94,97,2002 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, see - . */ - -#include -#include -#include -#include -#include -#include - - -/* Set the access and modification times of FILE to those given in TIMES. - If TIMES is NULL, set them to the current time. */ -int -utime (file, times) - const char *file; - const struct utimbuf *times; -{ - struct timeval timevals[2]; - struct timeval *tvp; - - if (times != NULL) - { - timevals[0].tv_sec = (time_t) times->actime; - timevals[0].tv_usec = 0L; - timevals[1].tv_sec = (time_t) times->modtime; - timevals[1].tv_usec = 0L; - tvp = timevals; - } - else - tvp = NULL; - - return __utimes (file, tvp); -} -libc_hidden_def (utime) -- cgit v1.1