]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Update.
authorUlrich Drepper <drepper@redhat.com>
Mon, 7 Jun 1999 00:02:14 +0000 (00:02 +0000)
committerUlrich Drepper <drepper@redhat.com>
Mon, 7 Jun 1999 00:02:14 +0000 (00:02 +0000)
* sysdeps/unix/sysv/linux/kernel-features.h: Define
__ASSUME_SIOCGIFNAME for kernel >= 2.1.50.
* sysdeps/unix/sysv/linux/if_index.c: Correct typo (SIOGIFNAME ->
SIOCGIFNAME) and use __ASSUME_SIOCGIFNAME.

* sysdeps/libm-ieee754/w_j0.c: Remove __ from symbol definitions.
* sysdeps/libm-ieee754/w_j0f.c: Likewise.
* sysdeps/libm-ieee754/w_j0l.c: Likewise.
* sysdeps/libm-ieee754/w_j1.c: Likewise.
* sysdeps/libm-ieee754/w_j1f.c: Likewise.
* sysdeps/libm-ieee754/w_j1l.c: Likewise.
* sysdeps/libm-ieee754/w_jn.c: Likewise.
* sysdeps/libm-ieee754/w_jnf.c: Likewise.
* sysdeps/libm-ieee754/w_jnl.c: Likewise.

* stdio-common.c: Correct typos.

* math/libm-test.c (jn_test): Adjust delta.
(y1_test): Likewise.
(yn_test): Likewise.

* elf/do-lookup.h: It should never happen that if we expect a versioned
symbol from a file the file has no version table.  This should have
been checked in dl-version.c.
* elf/dl-lookup.c: Include assert.h.

17 files changed:
ChangeLog
elf/dl-lookup.c
elf/do-lookup.h
math/libm-test.c
stdio-common/vfprintf.c
sysdeps/libm-ieee754/w_j0.c
sysdeps/libm-ieee754/w_j0f.c
sysdeps/libm-ieee754/w_j0l.c
sysdeps/libm-ieee754/w_j1.c
sysdeps/libm-ieee754/w_j1f.c
sysdeps/libm-ieee754/w_j1l.c
sysdeps/libm-ieee754/w_jn.c
sysdeps/libm-ieee754/w_jnf.c
sysdeps/libm-ieee754/w_jnl.c
sysdeps/unix/sysv/linux/i386/sigaction.c
sysdeps/unix/sysv/linux/if_index.c
sysdeps/unix/sysv/linux/kernel-features.h

index 7671f61e475985e3649432a549a7b5004230814e..d7fa0d48a5358e8e291ee3cbc7168a0991fc7c8e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,31 @@
 1999-06-06  Ulrich Drepper  <drepper@cygnus.com>
 
+       * sysdeps/unix/sysv/linux/kernel-features.h: Define
+       __ASSUME_SIOCGIFNAME for kernel >= 2.1.50.
+       * sysdeps/unix/sysv/linux/if_index.c: Correct typo (SIOGIFNAME ->
+       SIOCGIFNAME) and use __ASSUME_SIOCGIFNAME.
+
+       * sysdeps/libm-ieee754/w_j0.c: Remove __ from symbol definitions.
+       * sysdeps/libm-ieee754/w_j0f.c: Likewise.
+       * sysdeps/libm-ieee754/w_j0l.c: Likewise.
+       * sysdeps/libm-ieee754/w_j1.c: Likewise.
+       * sysdeps/libm-ieee754/w_j1f.c: Likewise.
+       * sysdeps/libm-ieee754/w_j1l.c: Likewise.
+       * sysdeps/libm-ieee754/w_jn.c: Likewise.
+       * sysdeps/libm-ieee754/w_jnf.c: Likewise.
+       * sysdeps/libm-ieee754/w_jnl.c: Likewise.
+
+       * stdio-common.c: Correct typos.
+
+       * math/libm-test.c (jn_test): Adjust delta.
+       (y1_test): Likewise.
+       (yn_test): Likewise.
+
+       * elf/do-lookup.h: It should never happen that if we expect a versioned
+       symbol from a file the file has no version table.  This should have
+       been checked in dl-version.c.
+       * elf/dl-lookup.c: Include assert.h.
+
        * sysdeps/unix/sysv/linux/i386/sigaction.c: Correct restorer
        function handling.
 
index 16173c9068e91f8aed05c9539413203e8433f1f6..76465878333518bac815158fa8289e0aac431946 100644 (file)
@@ -18,6 +18,7 @@
    Boston, MA 02111-1307, USA.  */
 
 #include <alloca.h>
+#include <assert.h>
 #include <string.h>
 #include <unistd.h>
 #include <elf/ldsodefs.h>
index 01ad29345e83a64cd1c80d7f9715a1cc1b0e8531..147560bd32d7d1363a5be8bd86b3cdd40da2eff1 100644 (file)
@@ -99,10 +99,14 @@ FCT (const char *undef_name, unsigned long int hash,
              /* We need a versioned symbol but haven't found any.  If
                 this is the object which is referenced in the verneed
                 entry it is a bug in the library since a symbol must
-                not simply disappear.  */
-             if (version->filename != NULL
-                 && _dl_name_match_p (version->filename, map))
-               return -2;
+                not simply disappear.
+
+                It would also be a bug in the object since it means that
+                the list of required versions is incomplete and so the
+                tests in dl-version.c haven't found a problem.*/
+             assert (version->filename == NULL
+                     || ! _dl_name_match_p (version->filename, map));
+
              /* Otherwise we accept the symbol.  */
            }
          else
index 49cce03d00ee85c1efac95192f0aef37d789c907..3e5033094c07847ab74d5d8aa864247b2f16b276 100644 (file)
@@ -5618,7 +5618,7 @@ jn_test (void)
             CHOOSE(0, 0, 3e-17));
   check ("jn (10, 0) = 0", FUNC(jn) (10, 0.0), 0.0);
   check_eps ("jn (10, 0.1) = 2.6905...*10^-20", FUNC(jn) (10, 0.1), 0.26905328954342155795e-19,
-            CHOOSE(0, 2e-35, 2e-27));
+            CHOOSE(0, 2e-35, 4e-27));
   check_eps ("jn (10, 0.7) = 7.517...*10^-12", FUNC(jn) (10, 0.7), 0.75175911502153953928e-11,
             CHOOSE(0, 7e-27, 9e-19));
   check_eps ("jn (10, 1.0) = 2.630...*10^-11", FUNC(jn) (10, 1.0), 0.26306151236874532070e-9,
@@ -5682,7 +5682,8 @@ y1_test (void)
             CHOOSE(0, 3e-16, 0));
   check_eps ("y1 (1.0) = -0.78121...", FUNC(y1) (1.0), -0.78121282130028871655,
             CHOOSE(0, 2e-16, 0));
-  check ("y1 (1.5) = -0.41230...", FUNC(y1) (1.5), -0.41230862697391129595);
+  check_eps ("y1 (1.5) = -0.41230...", FUNC(y1) (1.5), -0.41230862697391129595,
+            CHOOSE (0, 0, 3e-8));
   check_eps ("y1 (2.0) = -0.10703...", FUNC(y1) (2.0), -0.10703243154093754689,
             CHOOSE(0, 2e-17, 1.5e-8));
   check_eps ("y1 (8.0) = -0.15806...", FUNC(y1) (8.0), -0.15806046173124749426,
@@ -5735,7 +5736,8 @@ yn_test (void)
             CHOOSE(0, 3e-16, 0));
   check_eps ("yn (1, 1.0) = -0.78121...", FUNC(yn) (1, 1.0), -0.78121282130028871655,
             CHOOSE(0, 2e-16, 0));
-  check ("yn (1, 1.5) = -0.41230...", FUNC(yn) (1, 1.5), -0.41230862697391129595);
+  check_eps ("yn (1, 1.5) = -0.41230...", FUNC(yn) (1, 1.5), -0.41230862697391129595,
+            CHOOSE (0, 0, 3e-8));
   check_eps ("yn (1, 2.0) = -0.10703...", FUNC(yn) (1, 2.0), -0.10703243154093754689,
             CHOOSE(0, 2e-17, 2e-8));
   check_eps ("yn (1, 8.0) = -0.15806...", FUNC(yn) (1, 8.0), -0.15806046173124749426,
@@ -5764,7 +5766,7 @@ yn_test (void)
   check_eps ("yn (10, 0.1) = -1.183...*10^18", FUNC(yn) (10, 0.1), -0.11831335132045197885e19,
             CHOOSE(0, 6e2, 2e11));
   check_eps ("yn (10, 0.7) = -4.244...*10^9", FUNC(yn) (10, 0.7), -0.42447194260703866924e10,
-            CHOOSE(0, 3e-6, 6e2));
+            CHOOSE(0, 3e-6, 8e2));
   check_eps ("yn (10, 1.0) = -1.216...*10^8", FUNC(yn) (10, 1.0), -0.12161801427868918929e9,
             CHOOSE(0, 0, 9));
   check_eps ("yn (10, 2.0) = -129184.5...", FUNC(yn) (10, 2.0), -129184.54220803928264,
index e544c6518cfe2e9e2a83880d302a594ffbcd3167..390ce91f71e5d191293d671bc9d6cb535c312692 100644 (file)
@@ -1088,8 +1088,8 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
       int showsign = 0;        /* Always begin with plus or minus sign.  */
       int group = 0;   /* Print numbers according grouping rules.  */
       int is_long_double = 0; /* Argument is long double/ long long int.  */
-      int is_short = 0;        /* Argument is long int.  */
-      int is_long = 0; /* Argument is short int.  */
+      int is_short = 0;        /* Argument is short int.  */
+      int is_long = 0; /* Argument is long int.  */
       int is_char = 0; /* Argument is promoted (unsigned) char.  */
       int width = 0;   /* Width of output; 0 means none specified.  */
       int prec = -1;   /* Precision of output; -1 means none specified.  */
index c327e1c98f668ab6612933573f58282f57974f44..5a018760bb98d919c48c0c3e0c5ee8a7af3f9bfd 100644 (file)
@@ -22,9 +22,9 @@ static char rcsid[] = "$NetBSD: w_j0.c,v 1.6 1995/05/10 20:49:11 jtc Exp $";
 #include "math_private.h"
 
 #ifdef __STDC__
-       double __j0(double x)           /* wrapper j0 */
+       double j0(double x)             /* wrapper j0 */
 #else
-       double __j0(x)                  /* wrapper j0 */
+       double j0(x)                    /* wrapper j0 */
        double x;
 #endif
 {
@@ -39,17 +39,15 @@ static char rcsid[] = "$NetBSD: w_j0.c,v 1.6 1995/05/10 20:49:11 jtc Exp $";
            return z;
 #endif
 }
-weak_alias (__j0, j0)
 #ifdef NO_LONG_DOUBLE
-strong_alias (__j0, __j0l)
-weak_alias (__j0, j0l)
+strong_alias (j0, j0l)
 #endif
 
 
 #ifdef __STDC__
-       double __y0(double x)           /* wrapper y0 */
+       double y0(double x)             /* wrapper y0 */
 #else
-       double __y0(x)                  /* wrapper y0 */
+       double y0(x)                    /* wrapper y0 */
        double x;
 #endif
 {
@@ -73,8 +71,6 @@ weak_alias (__j0, j0l)
            return z;
 #endif
 }
-weak_alias (__y0, y0)
 #ifdef NO_LONG_DOUBLE
-strong_alias (__y0, __y0l)
-weak_alias (__y0, y0l)
+strong_alias (y0, y0l)
 #endif
index cc8ec6f2d9a4cf1ab85378859c2b24f8e9354423..32e2eebb565dce747a814de277b4b5b14d767918 100644 (file)
@@ -8,7 +8,7 @@
  *
  * Developed at SunPro, a Sun Microsystems, Inc. business.
  * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
+ * software is freely granted, provided that this notice
  * is preserved.
  * ====================================================
  */
@@ -25,9 +25,9 @@ static char rcsid[] = "$NetBSD: w_j0f.c,v 1.3 1995/05/10 20:49:13 jtc Exp $";
 #include "math_private.h"
 
 #ifdef __STDC__
-       float __j0f(float x)            /* wrapper j0f */
+       float j0f(float x)              /* wrapper j0f */
 #else
-       float __j0f(x)                  /* wrapper j0f */
+       float j0f(x)                    /* wrapper j0f */
        float x;
 #endif
 {
@@ -43,12 +43,11 @@ static char rcsid[] = "$NetBSD: w_j0f.c,v 1.3 1995/05/10 20:49:13 jtc Exp $";
            return z;
 #endif
 }
-weak_alias (__j0f, j0f)
 
 #ifdef __STDC__
-       float __y0f(float x)            /* wrapper y0f */
+       float y0f(float x)              /* wrapper y0f */
 #else
-       float __y0f(x)                  /* wrapper y0f */
+       float y0f(x)                    /* wrapper y0f */
        float x;
 #endif
 {
@@ -73,4 +72,3 @@ weak_alias (__j0f, j0f)
            return z;
 #endif
 }
-weak_alias (__y0f, y0f)
index 7b4144c95eeb9babd320d8ca9c65c28d85366bc7..b74d9ddcff2dbbfa7f891c535712cec6c014b446 100644 (file)
@@ -26,9 +26,9 @@ static char rcsid[] = "$NetBSD: $";
 #include "math_private.h"
 
 #ifdef __STDC__
-       long double __j0l(long double x)                /* wrapper j0l */
+       long double j0l(long double x)          /* wrapper j0l */
 #else
-       long double __j0l(x)                            /* wrapper j0 */
+       long double j0l(x)                              /* wrapper j0 */
        long double x;
 #endif
 {
@@ -43,12 +43,11 @@ static char rcsid[] = "$NetBSD: $";
            return z;
 #endif
 }
-weak_alias (__j0l, j0l)
 
 #ifdef __STDC__
-       long double __y0l(long double x)                /* wrapper y0l */
+       long double y0l(long double x)          /* wrapper y0l */
 #else
-       long double __y0l(x)                            /* wrapper y0 */
+       long double y0l(x)                              /* wrapper y0 */
        long double x;
 #endif
 {
@@ -72,4 +71,3 @@ weak_alias (__j0l, j0l)
            return z;
 #endif
 }
-weak_alias (__y0l, y0l)
index ae6e9b5537ca0146c7d613cd3304b1df79f23619..39fe8543b1c184cc717eba183331eaebc8abdf64 100644 (file)
@@ -22,9 +22,9 @@ static char rcsid[] = "$NetBSD: w_j1.c,v 1.6 1995/05/10 20:49:15 jtc Exp $";
 #include "math_private.h"
 
 #ifdef __STDC__
-       double __j1(double x)           /* wrapper j1 */
+       double j1(double x)             /* wrapper j1 */
 #else
-       double __j1(x)                  /* wrapper j1 */
+       double j1(x)                    /* wrapper j1 */
        double x;
 #endif
 {
@@ -40,17 +40,15 @@ static char rcsid[] = "$NetBSD: w_j1.c,v 1.6 1995/05/10 20:49:15 jtc Exp $";
            return z;
 #endif
 }
-weak_alias (__j1, j1)
 #ifdef NO_LONG_DOUBLE
-strong_alias (__j1, __j1l)
-weak_alias (__j1, j1l)
+strong_alias (j1, j1l)
 #endif
 
 
 #ifdef __STDC__
-       double __y1(double x)           /* wrapper y1 */
+       double y1(double x)             /* wrapper y1 */
 #else
-       double __y1(x)                  /* wrapper y1 */
+       double y1(x)                    /* wrapper y1 */
        double x;
 #endif
 {
@@ -74,8 +72,6 @@ weak_alias (__j1, j1l)
            return z;
 #endif
 }
-weak_alias (__y1, y1)
 #ifdef NO_LONG_DOUBLE
-strong_alias (__y1, __y1l)
-weak_alias (__y1, y1l)
+strong_alias (y1, y1l)
 #endif
index a1419b31b82aca903630e74ec493026b5f4385a6..2a7c8db819cf11aad8b1765296e63de7b22bc09d 100644 (file)
@@ -8,7 +8,7 @@
  *
  * Developed at SunPro, a Sun Microsystems, Inc. business.
  * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
+ * software is freely granted, provided that this notice
  * is preserved.
  * ====================================================
  */
 static char rcsid[] = "$NetBSD: w_j1f.c,v 1.3 1995/05/10 20:49:17 jtc Exp $";
 #endif
 
-/* 
- * wrapper of j1f,y1f 
+/*
+ * wrapper of j1f,y1f
  */
 
 #include "math.h"
 #include "math_private.h"
 
 #ifdef __STDC__
-       float __j1f(float x)            /* wrapper j1f */
+       float j1f(float x)              /* wrapper j1f */
 #else
-       float __j1f(x)                  /* wrapper j1f */
+       float j1f(x)                    /* wrapper j1f */
        float x;
 #endif
 {
@@ -44,12 +44,11 @@ static char rcsid[] = "$NetBSD: w_j1f.c,v 1.3 1995/05/10 20:49:17 jtc Exp $";
            return z;
 #endif
 }
-weak_alias (__j1f, j1f)
 
 #ifdef __STDC__
-       float __y1f(float x)            /* wrapper y1f */
+       float y1f(float x)              /* wrapper y1f */
 #else
-       float __y1f(x)                  /* wrapper y1f */
+       float y1f(x)                    /* wrapper y1f */
        float x;
 #endif
 {
@@ -74,4 +73,3 @@ weak_alias (__j1f, j1f)
            return z;
 #endif
 }
-weak_alias (__y1f, y1f)
index 223ab79cde70b9f0cd10e0b64e79f88ea01956ba..49a486cf8ed1344566a13b963baea0ea70e56776 100644 (file)
@@ -26,9 +26,9 @@ static char rcsid[] = "$NetBSD: $";
 #include "math_private.h"
 
 #ifdef __STDC__
-       long double __j1l(long double x)        /* wrapper j1l */
+       long double j1l(long double x)  /* wrapper j1l */
 #else
-       long double __j1l(x)                    /* wrapper j1l */
+       long double j1l(x)                      /* wrapper j1l */
        long double x;
 #endif
 {
@@ -44,12 +44,11 @@ static char rcsid[] = "$NetBSD: $";
            return z;
 #endif
 }
-weak_alias (__j1l, j1l)
 
 #ifdef __STDC__
-       long double __y1l(long double x)        /* wrapper y1l */
+       long double y1l(long double x)  /* wrapper y1l */
 #else
-       long double __y1l(x)                    /* wrapper y1l */
+       long double y1l(x)                      /* wrapper y1l */
        long double x;
 #endif
 {
@@ -73,4 +72,3 @@ weak_alias (__j1l, j1l)
            return z;
 #endif
 }
-weak_alias (__y1l, y1l)
index ecd86c0d8b616f7db5df0dc2794f5ef3743b647e..85fc383fb7540b1b8c5d6b37f4599c994219eacb 100644 (file)
@@ -44,9 +44,9 @@ static char rcsid[] = "$NetBSD: w_jn.c,v 1.6 1995/05/10 20:49:19 jtc Exp $";
 #include "math_private.h"
 
 #ifdef __STDC__
-       double __jn(int n, double x)    /* wrapper jn */
+       double jn(int n, double x)      /* wrapper jn */
 #else
-       double __jn(n,x)                        /* wrapper jn */
+       double jn(n,x)                  /* wrapper jn */
        double x; int n;
 #endif
 {
@@ -62,17 +62,15 @@ static char rcsid[] = "$NetBSD: w_jn.c,v 1.6 1995/05/10 20:49:19 jtc Exp $";
            return z;
 #endif
 }
-weak_alias (__jn, jn)
 #ifdef NO_LONG_DOUBLE
-strong_alias (__jn, __jnl)
-weak_alias (__jn, jnl)
+strong_alias (jn, jnl)
 #endif
 
 
 #ifdef __STDC__
-       double __yn(int n, double x)    /* wrapper yn */
+       double yn(int n, double x)      /* wrapper yn */
 #else
-       double __yn(n,x)                        /* wrapper yn */
+       double yn(n,x)                  /* wrapper yn */
        double x; int n;
 #endif
 {
@@ -96,8 +94,6 @@ weak_alias (__jn, jnl)
            return z;
 #endif
 }
-weak_alias (__yn, yn)
 #ifdef NO_LONG_DOUBLE
-strong_alias (__yn, __ynl)
-weak_alias (__yn, ynl)
+strong_alias (yn, ynl)
 #endif
index 82cdc9f769c024db7519d2688bab593bcbbdcce4..63ad33557300138ab339f55b34f7a41fb48a2dbc 100644 (file)
@@ -8,7 +8,7 @@
  *
  * Developed at SunPro, a Sun Microsystems, Inc. business.
  * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
+ * software is freely granted, provided that this notice
  * is preserved.
  * ====================================================
  */
@@ -21,9 +21,9 @@ static char rcsid[] = "$NetBSD: w_jnf.c,v 1.3 1995/05/10 20:49:21 jtc Exp $";
 #include "math_private.h"
 
 #ifdef __STDC__
-       float __jnf(int n, float x)     /* wrapper jnf */
+       float jnf(int n, float x)       /* wrapper jnf */
 #else
-       float __jnf(n,x)                        /* wrapper jnf */
+       float jnf(n,x)                  /* wrapper jnf */
        float x; int n;
 #endif
 {
@@ -40,12 +40,11 @@ static char rcsid[] = "$NetBSD: w_jnf.c,v 1.3 1995/05/10 20:49:21 jtc Exp $";
            return z;
 #endif
 }
-weak_alias (__jnf, jnf)
 
 #ifdef __STDC__
-       float __ynf(int n, float x)     /* wrapper ynf */
+       float ynf(int n, float x)       /* wrapper ynf */
 #else
-       float __ynf(n,x)                        /* wrapper ynf */
+       float ynf(n,x)                  /* wrapper ynf */
        float x; int n;
 #endif
 {
@@ -70,4 +69,3 @@ weak_alias (__jnf, jnf)
            return z;
 #endif
 }
-weak_alias (__ynf, ynf)
index 0a243db30a24a70b4a9d11a653bf3da23bf835ae..866e3cdb00c25619f09127cee4c5933b84156deb 100644 (file)
@@ -48,9 +48,9 @@ static char rcsid[] = "$NetBSD: $";
 #include "math_private.h"
 
 #ifdef __STDC__
-       long double __jnl(int n, long double x) /* wrapper jnl */
+       long double jnl(int n, long double x)   /* wrapper jnl */
 #else
-       long double __jnl(n,x)                  /* wrapper jnl */
+       long double jnl(n,x)                    /* wrapper jnl */
        long double x; int n;
 #endif
 {
@@ -66,12 +66,11 @@ static char rcsid[] = "$NetBSD: $";
            return z;
 #endif
 }
-weak_alias (__jnl, jnl)
 
 #ifdef __STDC__
-       long double __ynl(int n, long double x) /* wrapper ynl */
+       long double ynl(int n, long double x)   /* wrapper ynl */
 #else
-       long double __ynl(n,x)                  /* wrapper ynl */
+       long double ynl(n,x)                    /* wrapper ynl */
        long double x; int n;
 #endif
 {
@@ -95,4 +94,3 @@ weak_alias (__jnl, jnl)
            return z;
 #endif
 }
-weak_alias (__ynl, ynl)
index fddb22a4e0dda55e64ec2fdf0be9e9d4792a0baa..c126cdaee8ae75f86cb9f6b9a18e18789041b0a3 100644 (file)
@@ -75,7 +75,7 @@ __sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
        {
          kact.k_sa_handler = act->sa_handler;
          memcpy (&kact.sa_mask, &act->sa_mask, sizeof (sigset_t));
-         kact.sa_flags = act->sa_flags;
+         kact.sa_flags = act->sa_flags | SA_RESTORER;
 
          kact.sa_restorer = ((act->sa_flags & SA_SIGINFO)
                              ? &restore_rt : &restore);
index 9b3db6abfb4cbe243539e575bde5fe69feec770e..67fba93cd428c9ac797fda2f90b7316738461bae 100644 (file)
@@ -26,6 +26,8 @@
 #include <sys/ioctl.h>
 #include <bits/libc-lock.h>
 
+#include "kernel-features.h"
+
 /* Try to get a socket to talk to the kernel.  */
 #if defined SIOGIFINDEX || defined SIOGIFNAME
 static int
@@ -120,8 +122,12 @@ if_nameindex (void)
   unsigned int nifs, i;
   int rq_len;
   struct if_nameindex *idx = NULL;
+# if __ASSUME_SIOCGIFNAME == 0
   static int old_siocgifconf;
-#define RQ_IFS 4
+# else
+#  define old_siocgifconf 0
+# endif
+# define RQ_IFS        4
 
   if (fd < 0)
     return NULL;
@@ -136,7 +142,9 @@ if_nameindex (void)
       ifc.ifc_len = 0;
       if (__ioctl (fd, SIOCGIFCONF, &ifc) < 0 || ifc.ifc_len == 0)
        {
+# if __ASSUME_SIOCGIFNAME == 0
          old_siocgifconf = 1;
+# endif
          rq_len = RQ_IFS * sizeof (struct ifreq);
        }
       else
@@ -199,24 +207,31 @@ if_nameindex (void)
 char *
 if_indextoname (unsigned int ifindex, char *ifname)
 {
-#ifndef SIOGIFINDEX
+#if !defined SIOGIFINDEX && __ASSUME_SIOCGIFNAME == 0
   __set_errno (ENOSYS);
   return NULL;
 #else
+# if __ASSUME_SIOCGIFNAME == 0
   struct if_nameindex *idx;
   struct if_nameindex *p;
   char *result = NULL;
+# endif
 
-#ifdef SIOGIFNAME
+# if defined SIOCGIFNAME || __ASSUME_SIOCGIFNAME > 0
   /* We may be able to do the conversion directly, rather than searching a
      list.  This ioctl is not present in kernels before version 2.1.50.  */
   struct ifreq ifr;
   int fd;
-  static int siogifname_works_not;
+#  if __ASSUME_SIOCGIFNAME == 0
+  static int siocgifname_works_not;
 
-  if (!siogifname_works_not)
+  if (!siocgifname_works_not)
+#  endif
     {
+#  if __ASSUME_SIOCGIFNAME == 0
       int serrno = errno;
+#  endif
+      int status;
 
       fd = opensock ();
 
@@ -224,23 +239,27 @@ if_indextoname (unsigned int ifindex, char *ifname)
        return NULL;
 
       ifr.ifr_ifindex = ifindex;
-      if (__ioctl (fd, SIOGIFNAME, &ifr) < 0)
+      status = __ioctl (fd, SIOCGIFNAME, &ifr);
+
+      __close (fd);
+
+#  if __ASSUME_SIOCGIFNAME == 0
+      if (status  < 0)
        {
          if (errno == EINVAL)
-           siogifname_works_not = 1; /* Don't make the same mistake twice. */
+           siocgifname_works_not = 1; /* Don't make the same mistake twice. */
        }
       else
-       {
-         __close (fd);
-         return strncpy (ifname, ifr.ifr_name, IFNAMSIZ);
-       }
-
-      __close (fd);
+       return strncpy (ifname, ifr.ifr_name, IFNAMSIZ);
 
       __set_errno (serrno);
+#  else
+      return status < 0 ? NULL : strncpy (ifname, ifr.ifr_name, IFNAMSIZ);
+#  endif
     }
-#endif
+# endif
 
+# if __ASSUME_SIOCGIFNAME == 0
   idx = if_nameindex ();
 
   if (idx != NULL)
@@ -255,5 +274,6 @@ if_indextoname (unsigned int ifindex, char *ifname)
       if_freenameindex (idx);
     }
   return result;
+# endif
 #endif
 }
index 1bd7ba4ba8938164dbf44054359089662f966384..db2bfe24d5ce6638cadc1056b0441f8eab3df02f 100644 (file)
@@ -69,3 +69,8 @@
 #if __LINUX_KERNEL_VERSION >= 131584
 # define __ASSUME_SETRESUID_SYSCALL    1
 #endif
+
+/* The SIOCGIFNAME ioctl is available starting with 2.1.50.  */
+#if __LINUX_KERNEL_VERSION >= 131408
+# define __ASSUME_SIOCGIFNAME          1
+#endif