]> sourceware.org Git - glibc.git/commitdiff
Fix nice getpriority, setpriority namespace (bug 18553).
authorJoseph Myers <joseph@codesourcery.com>
Wed, 17 Jun 2015 20:22:39 +0000 (20:22 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Wed, 17 Jun 2015 20:22:39 +0000 (20:22 +0000)
nice (XPG3) calls getpriority and setpriority (in XPG4 but not XPG3,
i.e. UX-shaded in XPG4).  This patch fixes this by making those
functions into weak aliases of __* functions and calling the __*
versions as needed.

Tested for x86_64 and x86 (testsuite, and that disassembly of
installed shared libraries is unchanged by this patch).

This completes cleaning up the unsorted linknamespace test XFAILs.

[BZ #18553]
* resource/getpriority.c (getpriority): Rename to __getpriority
and define as weak alias of __getpriority.
* resource/setpriority.c (setpriority): Rename to __setpriority
and define as weak alias of __setpriority.
* sysdeps/mach/hurd/getpriority.c (getpriority): Rename to
__getpriority and define as weak alias of __getpriority.
* sysdeps/mach/hurd/setpriority.c (setpriority): Rename to
__setpriority and define as weak alias of __setpriority.
* sysdeps/unix/syscalls.list (getpriority): Use __getpriority as
strong name.
(setpriority): Use __setpriority as strong name.
* sysdeps/unix/sysv/linux/getpriority.c (getpriority): Rename to
__getpriority and define as weak alias of __getpriority.
* include/sys/resource.h (__getpriority): Declare.  Use
libc_hidden_proto.
(__setpriority): Likewise.
(getpriority): Don't use libc_hidden_proto.
(setpriority): Likewise.
* sysdeps/posix/nice.c (nice): Call __getpriority instead of
getpriority.  Call __setpriority instead of setpriority.
* conform/Makefile (test-xfail-XPG3/unistd.h/linknamespace):
Remove variable.

ChangeLog
NEWS
conform/Makefile
include/sys/resource.h
resource/getpriority.c
resource/setpriority.c
sysdeps/mach/hurd/getpriority.c
sysdeps/mach/hurd/setpriority.c
sysdeps/posix/nice.c
sysdeps/unix/syscalls.list
sysdeps/unix/sysv/linux/getpriority.c

index 4ce8eb994802304e1c2223310e672ee39a1692a2..338bf8d76a4e9c98e1fb65b5f15456d7e9a46566 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,29 @@
 2015-06-17  Joseph Myers  <joseph@codesourcery.com>
 
+       [BZ #18553]
+       * resource/getpriority.c (getpriority): Rename to __getpriority
+       and define as weak alias of __getpriority.
+       * resource/setpriority.c (setpriority): Rename to __setpriority
+       and define as weak alias of __setpriority.
+       * sysdeps/mach/hurd/getpriority.c (getpriority): Rename to
+       __getpriority and define as weak alias of __getpriority.
+       * sysdeps/mach/hurd/setpriority.c (setpriority): Rename to
+       __setpriority and define as weak alias of __setpriority.
+       * sysdeps/unix/syscalls.list (getpriority): Use __getpriority as
+       strong name.
+       (setpriority): Use __setpriority as strong name.
+       * sysdeps/unix/sysv/linux/getpriority.c (getpriority): Rename to
+       __getpriority and define as weak alias of __getpriority.
+       * include/sys/resource.h (__getpriority): Declare.  Use
+       libc_hidden_proto.
+       (__setpriority): Likewise.
+       (getpriority): Don't use libc_hidden_proto.
+       (setpriority): Likewise.
+       * sysdeps/posix/nice.c (nice): Call __getpriority instead of
+       getpriority.  Call __setpriority instead of setpriority.
+       * conform/Makefile (test-xfail-XPG3/unistd.h/linknamespace):
+       Remove variable.
+
        [BZ #18547]
        * misc/getttyent.c (getttynam): Rename to __getttynam and define
        as weak alias of __getttynam.  Use prototype function definition.
diff --git a/NEWS b/NEWS
index 3adec9b817b95380044202c7f2a738a404bd300b..1f6b701b301fe8e28e5b32ac87300b71dadd9d0b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -22,7 +22,8 @@ Version 2.22
   18324, 18333, 18346, 18397, 18409, 18410, 18412, 18418, 18422, 18434,
   18444, 18468, 18469, 18470, 18479, 18483, 18495, 18496, 18497, 18498,
   18507, 18512, 18519, 18520, 18522, 18527, 18528, 18529, 18530, 18532,
-  18533, 18534, 18536, 18539, 18540, 18542, 18544, 18545, 18546, 18547.
+  18533, 18534, 18536, 18539, 18540, 18542, 18544, 18545, 18546, 18547,
+  18553.
 
 * Cache information can be queried via sysconf() function on s390 e.g. with
   _SC_LEVEL1_ICACHE_SIZE as argument.
index ad9cc697b4d4a005d86c36c316be2036586e7892..4bc8121d49a4e30555c11504b2da44a5436885aa 100644 (file)
@@ -342,6 +342,3 @@ test-xfail-XPG4/ndbm.h/linknamespace = yes
 test-xfail-UNIX98/ndbm.h/linknamespace = yes
 test-xfail-XOPEN2K/ndbm.h/linknamespace = yes
 test-xfail-XOPEN2K8/ndbm.h/linknamespace = yes
-
-# Unsorted expected failures.
-test-xfail-XPG3/unistd.h/linknamespace = yes
index 7622da969a6cd846f7c55b654264c106140b041d..688c46c4ae8c5b320fc1d5764ab8e423796f4726 100644 (file)
@@ -2,8 +2,14 @@
 #include <resource/sys/resource.h>
 
 #ifndef _ISOMAC
-libc_hidden_proto (getpriority)
-libc_hidden_proto (setpriority)
+/* Prototypes repeated instead of using __typeof because
+   sys/resource.h is included in C++ tests, and declaring functions
+   with __typeof and __THROW doesn't work for C++.  */
+extern int __getpriority (__priority_which_t __which, id_t __who) __THROW;
+libc_hidden_proto (__getpriority)
+extern int __setpriority (__priority_which_t __which, id_t __who, int __prio)
+     __THROW;
+libc_hidden_proto (__setpriority)
 libc_hidden_proto (getrlimit64)
 extern __typeof (getrlimit64) __getrlimit64;
 libc_hidden_proto (__getrlimit64);
index 88ec4dba0c5a5f6d9e411ac921ecc38553dd8f5b..6df7294578be92cfeba57fcdbfeb6fb024642aef 100644 (file)
    or user (as specified by WHO) is used.  A lower priority number means higher
    priority.  Priorities range from PRIO_MIN to PRIO_MAX.  */
 int
-getpriority (which, who)
+__getpriority (which, who)
      enum __priority_which which;
      id_t who;
 {
   __set_errno (ENOSYS);
   return -1;
 }
-libc_hidden_def (getpriority)
+libc_hidden_def (__getpriority)
+weak_alias (__getpriority, getpriority)
 
 stub_warning (getpriority)
index 08b0a95ea9fd08f7e9c2c047f53270df4100342e..91521bdbb95b31e1386aace5c5967e5d9dcd3b8d 100644 (file)
@@ -21,7 +21,7 @@
 /* Set the priority of all processes specified by WHICH and WHO
    to PRIO.  Returns 0 on success, -1 on errors.  */
 int
-setpriority (which, who, prio)
+__setpriority (which, who, prio)
      enum __priority_which which;
      id_t who;
      int prio;
@@ -29,6 +29,7 @@ setpriority (which, who, prio)
   __set_errno (ENOSYS);
   return -1;
 }
-libc_hidden_def (setpriority)
+libc_hidden_def (__setpriority)
+weak_alias (__setpriority, setpriority)
 
 stub_warning (setpriority)
index bb81ee69ef862c496948a9c4c8652275d9ac6ca9..73c7ad38c8013fcefffb235302a3393686c4521a 100644 (file)
@@ -24,7 +24,7 @@
    or user (as specified by WHO) is used.  A lower priority number means higher
    priority.  Priorities range from PRIO_MIN to PRIO_MAX.  */
 int
-getpriority (enum __priority_which which, id_t who)
+__getpriority (enum __priority_which which, id_t who)
 {
   error_t err, onerr;
   int maxpri = INT_MIN;
@@ -81,4 +81,5 @@ getpriority (enum __priority_which which, id_t who)
 
   return MACH_PRIORITY_TO_NICE (maxpri);
 }
-libc_hidden_def (getpriority)
+libc_hidden_def (__getpriority)
+weak_alias (__getpriority, getpriority)
index 43b8877fa0def6fcae290ed0b1689136de05cd00..41d7aa41fe1504665316a90518dcf56ae08cf7e9 100644 (file)
@@ -21,7 +21,7 @@
 /* Set the priority of all processes specified by WHICH and WHO
    to PRIO.  Returns 0 on success, -1 on errors.  */
 int
-setpriority (enum __priority_which which, id_t who, int prio)
+__setpriority (enum __priority_which which, id_t who, int prio)
 {
   error_t err;
   error_t pidloser, priloser;
@@ -94,4 +94,5 @@ setpriority (enum __priority_which which, id_t who, int prio)
 
   return err ? __hurd_fail (err) : 0;
 }
-libc_hidden_def (setpriority)
+libc_hidden_def (__setpriority)
+weak_alias (__setpriority, setpriority)
index 67b127348fed908501fb9653a1ee5d5f8611c85c..42bb99b7e143de5464171cec8a0eac0d421e95c5 100644 (file)
@@ -31,7 +31,7 @@ nice (int incr)
   /* -1 is a valid priority, so we use errno to check for an error.  */
   save = errno;
   __set_errno (0);
-  prio = getpriority (PRIO_PROCESS, 0);
+  prio = __getpriority (PRIO_PROCESS, 0);
   if (prio == -1)
     {
       if (errno != 0)
@@ -40,12 +40,12 @@ nice (int incr)
        __set_errno (save);
     }
 
-  result = setpriority (PRIO_PROCESS, 0, prio + incr);
+  result = __setpriority (PRIO_PROCESS, 0, prio + incr);
   if (result == -1)
     {
       if (errno == EACCES)
        errno = EPERM;
       return -1;
     }
-  return getpriority (PRIO_PROCESS, 0);
+  return __getpriority (PRIO_PROCESS, 0);
 }
index b3358bd9335242114892c11a90f08f8b20670b58..2254c761b4b988ba88d6ed558ed2bcd7bc3ff464 100644 (file)
@@ -29,7 +29,7 @@ gethostname   -       gethostname     i:bn    __gethostname   gethostname
 getitimer      -       getitimer       i:ip    __getitimer     getitimer
 getpeername    -       getpeername     i:ibN   __getpeername   getpeername
 getpid         -       getpid          Ei:     __getpid        getpid
-getpriority    -       getpriority     i:ii    getpriority
+getpriority    -       getpriority     i:ii    __getpriority   getpriority
 getrlimit      -       getrlimit       i:ip    __getrlimit     getrlimit
 getrusage      -       getrusage       i:ip    __getrusage     getrusage
 getsockname    -       getsockname     i:ibN   __getsockname   getsockname
@@ -72,7 +72,7 @@ sethostid     -       sethostid       i:i     sethostid
 sethostname    -       sethostname     i:pi    sethostname
 setitimer      -       setitimer       i:ipp   __setitimer     setitimer
 setpgid                -       setpgrp         i:ii    __setpgid       setpgid
-setpriority    -       setpriority     i:iii   setpriority
+setpriority    -       setpriority     i:iii   __setpriority   setpriority
 setregid       -       setregid        i:ii    __setregid      setregid
 setreuid       -       setreuid        i:ii    __setreuid      setreuid
 setrlimit      -       setrlimit       i:ip    __setrlimit setrlimit
index 96d9de316205ce33c6cacc079de2b26ecabd5fb7..9c691bb387a981ce6c9ed62beb8cd5a5df535fe0 100644 (file)
@@ -32,7 +32,7 @@
    priority.  Priorities range from PRIO_MIN to PRIO_MAX.  */
 
 int
-getpriority (enum __priority_which which, id_t who)
+__getpriority (enum __priority_which which, id_t who)
 {
   int res;
 
@@ -41,4 +41,5 @@ getpriority (enum __priority_which which, id_t who)
     res = PZERO - res;
   return res;
 }
-libc_hidden_def (getpriority)
+libc_hidden_def (__getpriority)
+weak_alias (__getpriority, getpriority)
This page took 0.140719 seconds and 5 git commands to generate.