1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00
* 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.
This commit is contained in:
Ulrich Drepper
1999-06-07 00:02:14 +00:00
parent e0082312bc
commit 9a8fcca0b3
17 changed files with 134 additions and 100 deletions

View File

@ -1,5 +1,31 @@
1999-06-06 Ulrich Drepper <drepper@cygnus.com> 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 * sysdeps/unix/sysv/linux/i386/sigaction.c: Correct restorer
function handling. function handling.

View File

@ -18,6 +18,7 @@
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <alloca.h> #include <alloca.h>
#include <assert.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <elf/ldsodefs.h> #include <elf/ldsodefs.h>

View 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 /* We need a versioned symbol but haven't found any. If
this is the object which is referenced in the verneed this is the object which is referenced in the verneed
entry it is a bug in the library since a symbol must entry it is a bug in the library since a symbol must
not simply disappear. */ not simply disappear.
if (version->filename != NULL
&& _dl_name_match_p (version->filename, map)) It would also be a bug in the object since it means that
return -2; 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. */ /* Otherwise we accept the symbol. */
} }
else else

View File

@ -5618,7 +5618,7 @@ jn_test (void)
CHOOSE(0, 0, 3e-17)); CHOOSE(0, 0, 3e-17));
check ("jn (10, 0) = 0", FUNC(jn) (10, 0.0), 0.0); 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, 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, check_eps ("jn (10, 0.7) = 7.517...*10^-12", FUNC(jn) (10, 0.7), 0.75175911502153953928e-11,
CHOOSE(0, 7e-27, 9e-19)); CHOOSE(0, 7e-27, 9e-19));
check_eps ("jn (10, 1.0) = 2.630...*10^-11", FUNC(jn) (10, 1.0), 0.26306151236874532070e-9, 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)); CHOOSE(0, 3e-16, 0));
check_eps ("y1 (1.0) = -0.78121...", FUNC(y1) (1.0), -0.78121282130028871655, check_eps ("y1 (1.0) = -0.78121...", FUNC(y1) (1.0), -0.78121282130028871655,
CHOOSE(0, 2e-16, 0)); 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, check_eps ("y1 (2.0) = -0.10703...", FUNC(y1) (2.0), -0.10703243154093754689,
CHOOSE(0, 2e-17, 1.5e-8)); CHOOSE(0, 2e-17, 1.5e-8));
check_eps ("y1 (8.0) = -0.15806...", FUNC(y1) (8.0), -0.15806046173124749426, 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)); CHOOSE(0, 3e-16, 0));
check_eps ("yn (1, 1.0) = -0.78121...", FUNC(yn) (1, 1.0), -0.78121282130028871655, check_eps ("yn (1, 1.0) = -0.78121...", FUNC(yn) (1, 1.0), -0.78121282130028871655,
CHOOSE(0, 2e-16, 0)); 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, check_eps ("yn (1, 2.0) = -0.10703...", FUNC(yn) (1, 2.0), -0.10703243154093754689,
CHOOSE(0, 2e-17, 2e-8)); CHOOSE(0, 2e-17, 2e-8));
check_eps ("yn (1, 8.0) = -0.15806...", FUNC(yn) (1, 8.0), -0.15806046173124749426, 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, check_eps ("yn (10, 0.1) = -1.183...*10^18", FUNC(yn) (10, 0.1), -0.11831335132045197885e19,
CHOOSE(0, 6e2, 2e11)); CHOOSE(0, 6e2, 2e11));
check_eps ("yn (10, 0.7) = -4.244...*10^9", FUNC(yn) (10, 0.7), -0.42447194260703866924e10, 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, check_eps ("yn (10, 1.0) = -1.216...*10^8", FUNC(yn) (10, 1.0), -0.12161801427868918929e9,
CHOOSE(0, 0, 9)); CHOOSE(0, 0, 9));
check_eps ("yn (10, 2.0) = -129184.5...", FUNC(yn) (10, 2.0), -129184.54220803928264, check_eps ("yn (10, 2.0) = -129184.5...", FUNC(yn) (10, 2.0), -129184.54220803928264,

View 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 showsign = 0; /* Always begin with plus or minus sign. */
int group = 0; /* Print numbers according grouping rules. */ int group = 0; /* Print numbers according grouping rules. */
int is_long_double = 0; /* Argument is long double/ long long int. */ int is_long_double = 0; /* Argument is long double/ long long int. */
int is_short = 0; /* Argument is long int. */ int is_short = 0; /* Argument is short int. */
int is_long = 0; /* Argument is short int. */ int is_long = 0; /* Argument is long int. */
int is_char = 0; /* Argument is promoted (unsigned) char. */ int is_char = 0; /* Argument is promoted (unsigned) char. */
int width = 0; /* Width of output; 0 means none specified. */ int width = 0; /* Width of output; 0 means none specified. */
int prec = -1; /* Precision of output; -1 means none specified. */ int prec = -1; /* Precision of output; -1 means none specified. */

View 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" #include "math_private.h"
#ifdef __STDC__ #ifdef __STDC__
double __j0(double x) /* wrapper j0 */ double j0(double x) /* wrapper j0 */
#else #else
double __j0(x) /* wrapper j0 */ double j0(x) /* wrapper j0 */
double x; double x;
#endif #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; return z;
#endif #endif
} }
weak_alias (__j0, j0)
#ifdef NO_LONG_DOUBLE #ifdef NO_LONG_DOUBLE
strong_alias (__j0, __j0l) strong_alias (j0, j0l)
weak_alias (__j0, j0l)
#endif #endif
#ifdef __STDC__ #ifdef __STDC__
double __y0(double x) /* wrapper y0 */ double y0(double x) /* wrapper y0 */
#else #else
double __y0(x) /* wrapper y0 */ double y0(x) /* wrapper y0 */
double x; double x;
#endif #endif
{ {
@ -73,8 +71,6 @@ weak_alias (__j0, j0l)
return z; return z;
#endif #endif
} }
weak_alias (__y0, y0)
#ifdef NO_LONG_DOUBLE #ifdef NO_LONG_DOUBLE
strong_alias (__y0, __y0l) strong_alias (y0, y0l)
weak_alias (__y0, y0l)
#endif #endif

View File

@ -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" #include "math_private.h"
#ifdef __STDC__ #ifdef __STDC__
float __j0f(float x) /* wrapper j0f */ float j0f(float x) /* wrapper j0f */
#else #else
float __j0f(x) /* wrapper j0f */ float j0f(x) /* wrapper j0f */
float x; float x;
#endif #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; return z;
#endif #endif
} }
weak_alias (__j0f, j0f)
#ifdef __STDC__ #ifdef __STDC__
float __y0f(float x) /* wrapper y0f */ float y0f(float x) /* wrapper y0f */
#else #else
float __y0f(x) /* wrapper y0f */ float y0f(x) /* wrapper y0f */
float x; float x;
#endif #endif
{ {
@ -73,4 +72,3 @@ weak_alias (__j0f, j0f)
return z; return z;
#endif #endif
} }
weak_alias (__y0f, y0f)

View File

@ -26,9 +26,9 @@ static char rcsid[] = "$NetBSD: $";
#include "math_private.h" #include "math_private.h"
#ifdef __STDC__ #ifdef __STDC__
long double __j0l(long double x) /* wrapper j0l */ long double j0l(long double x) /* wrapper j0l */
#else #else
long double __j0l(x) /* wrapper j0 */ long double j0l(x) /* wrapper j0 */
long double x; long double x;
#endif #endif
{ {
@ -43,12 +43,11 @@ static char rcsid[] = "$NetBSD: $";
return z; return z;
#endif #endif
} }
weak_alias (__j0l, j0l)
#ifdef __STDC__ #ifdef __STDC__
long double __y0l(long double x) /* wrapper y0l */ long double y0l(long double x) /* wrapper y0l */
#else #else
long double __y0l(x) /* wrapper y0 */ long double y0l(x) /* wrapper y0 */
long double x; long double x;
#endif #endif
{ {
@ -72,4 +71,3 @@ weak_alias (__j0l, j0l)
return z; return z;
#endif #endif
} }
weak_alias (__y0l, y0l)

View 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" #include "math_private.h"
#ifdef __STDC__ #ifdef __STDC__
double __j1(double x) /* wrapper j1 */ double j1(double x) /* wrapper j1 */
#else #else
double __j1(x) /* wrapper j1 */ double j1(x) /* wrapper j1 */
double x; double x;
#endif #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; return z;
#endif #endif
} }
weak_alias (__j1, j1)
#ifdef NO_LONG_DOUBLE #ifdef NO_LONG_DOUBLE
strong_alias (__j1, __j1l) strong_alias (j1, j1l)
weak_alias (__j1, j1l)
#endif #endif
#ifdef __STDC__ #ifdef __STDC__
double __y1(double x) /* wrapper y1 */ double y1(double x) /* wrapper y1 */
#else #else
double __y1(x) /* wrapper y1 */ double y1(x) /* wrapper y1 */
double x; double x;
#endif #endif
{ {
@ -74,8 +72,6 @@ weak_alias (__j1, j1l)
return z; return z;
#endif #endif
} }
weak_alias (__y1, y1)
#ifdef NO_LONG_DOUBLE #ifdef NO_LONG_DOUBLE
strong_alias (__y1, __y1l) strong_alias (y1, y1l)
weak_alias (__y1, y1l)
#endif #endif

View File

@ -25,9 +25,9 @@ static char rcsid[] = "$NetBSD: w_j1f.c,v 1.3 1995/05/10 20:49:17 jtc Exp $";
#include "math_private.h" #include "math_private.h"
#ifdef __STDC__ #ifdef __STDC__
float __j1f(float x) /* wrapper j1f */ float j1f(float x) /* wrapper j1f */
#else #else
float __j1f(x) /* wrapper j1f */ float j1f(x) /* wrapper j1f */
float x; float x;
#endif #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; return z;
#endif #endif
} }
weak_alias (__j1f, j1f)
#ifdef __STDC__ #ifdef __STDC__
float __y1f(float x) /* wrapper y1f */ float y1f(float x) /* wrapper y1f */
#else #else
float __y1f(x) /* wrapper y1f */ float y1f(x) /* wrapper y1f */
float x; float x;
#endif #endif
{ {
@ -74,4 +73,3 @@ weak_alias (__j1f, j1f)
return z; return z;
#endif #endif
} }
weak_alias (__y1f, y1f)

View File

@ -26,9 +26,9 @@ static char rcsid[] = "$NetBSD: $";
#include "math_private.h" #include "math_private.h"
#ifdef __STDC__ #ifdef __STDC__
long double __j1l(long double x) /* wrapper j1l */ long double j1l(long double x) /* wrapper j1l */
#else #else
long double __j1l(x) /* wrapper j1l */ long double j1l(x) /* wrapper j1l */
long double x; long double x;
#endif #endif
{ {
@ -44,12 +44,11 @@ static char rcsid[] = "$NetBSD: $";
return z; return z;
#endif #endif
} }
weak_alias (__j1l, j1l)
#ifdef __STDC__ #ifdef __STDC__
long double __y1l(long double x) /* wrapper y1l */ long double y1l(long double x) /* wrapper y1l */
#else #else
long double __y1l(x) /* wrapper y1l */ long double y1l(x) /* wrapper y1l */
long double x; long double x;
#endif #endif
{ {
@ -73,4 +72,3 @@ weak_alias (__j1l, j1l)
return z; return z;
#endif #endif
} }
weak_alias (__y1l, y1l)

View 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" #include "math_private.h"
#ifdef __STDC__ #ifdef __STDC__
double __jn(int n, double x) /* wrapper jn */ double jn(int n, double x) /* wrapper jn */
#else #else
double __jn(n,x) /* wrapper jn */ double jn(n,x) /* wrapper jn */
double x; int n; double x; int n;
#endif #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; return z;
#endif #endif
} }
weak_alias (__jn, jn)
#ifdef NO_LONG_DOUBLE #ifdef NO_LONG_DOUBLE
strong_alias (__jn, __jnl) strong_alias (jn, jnl)
weak_alias (__jn, jnl)
#endif #endif
#ifdef __STDC__ #ifdef __STDC__
double __yn(int n, double x) /* wrapper yn */ double yn(int n, double x) /* wrapper yn */
#else #else
double __yn(n,x) /* wrapper yn */ double yn(n,x) /* wrapper yn */
double x; int n; double x; int n;
#endif #endif
{ {
@ -96,8 +94,6 @@ weak_alias (__jn, jnl)
return z; return z;
#endif #endif
} }
weak_alias (__yn, yn)
#ifdef NO_LONG_DOUBLE #ifdef NO_LONG_DOUBLE
strong_alias (__yn, __ynl) strong_alias (yn, ynl)
weak_alias (__yn, ynl)
#endif #endif

View File

@ -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" #include "math_private.h"
#ifdef __STDC__ #ifdef __STDC__
float __jnf(int n, float x) /* wrapper jnf */ float jnf(int n, float x) /* wrapper jnf */
#else #else
float __jnf(n,x) /* wrapper jnf */ float jnf(n,x) /* wrapper jnf */
float x; int n; float x; int n;
#endif #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; return z;
#endif #endif
} }
weak_alias (__jnf, jnf)
#ifdef __STDC__ #ifdef __STDC__
float __ynf(int n, float x) /* wrapper ynf */ float ynf(int n, float x) /* wrapper ynf */
#else #else
float __ynf(n,x) /* wrapper ynf */ float ynf(n,x) /* wrapper ynf */
float x; int n; float x; int n;
#endif #endif
{ {
@ -70,4 +69,3 @@ weak_alias (__jnf, jnf)
return z; return z;
#endif #endif
} }
weak_alias (__ynf, ynf)

View File

@ -48,9 +48,9 @@ static char rcsid[] = "$NetBSD: $";
#include "math_private.h" #include "math_private.h"
#ifdef __STDC__ #ifdef __STDC__
long double __jnl(int n, long double x) /* wrapper jnl */ long double jnl(int n, long double x) /* wrapper jnl */
#else #else
long double __jnl(n,x) /* wrapper jnl */ long double jnl(n,x) /* wrapper jnl */
long double x; int n; long double x; int n;
#endif #endif
{ {
@ -66,12 +66,11 @@ static char rcsid[] = "$NetBSD: $";
return z; return z;
#endif #endif
} }
weak_alias (__jnl, jnl)
#ifdef __STDC__ #ifdef __STDC__
long double __ynl(int n, long double x) /* wrapper ynl */ long double ynl(int n, long double x) /* wrapper ynl */
#else #else
long double __ynl(n,x) /* wrapper ynl */ long double ynl(n,x) /* wrapper ynl */
long double x; int n; long double x; int n;
#endif #endif
{ {
@ -95,4 +94,3 @@ weak_alias (__jnl, jnl)
return z; return z;
#endif #endif
} }
weak_alias (__ynl, ynl)

View File

@ -75,7 +75,7 @@ __sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
{ {
kact.k_sa_handler = act->sa_handler; kact.k_sa_handler = act->sa_handler;
memcpy (&kact.sa_mask, &act->sa_mask, sizeof (sigset_t)); 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) kact.sa_restorer = ((act->sa_flags & SA_SIGINFO)
? &restore_rt : &restore); ? &restore_rt : &restore);

View File

@ -26,6 +26,8 @@
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <bits/libc-lock.h> #include <bits/libc-lock.h>
#include "kernel-features.h"
/* Try to get a socket to talk to the kernel. */ /* Try to get a socket to talk to the kernel. */
#if defined SIOGIFINDEX || defined SIOGIFNAME #if defined SIOGIFINDEX || defined SIOGIFNAME
static int static int
@ -120,7 +122,11 @@ if_nameindex (void)
unsigned int nifs, i; unsigned int nifs, i;
int rq_len; int rq_len;
struct if_nameindex *idx = NULL; struct if_nameindex *idx = NULL;
# if __ASSUME_SIOCGIFNAME == 0
static int old_siocgifconf; static int old_siocgifconf;
# else
# define old_siocgifconf 0
# endif
# define RQ_IFS 4 # define RQ_IFS 4
if (fd < 0) if (fd < 0)
@ -136,7 +142,9 @@ if_nameindex (void)
ifc.ifc_len = 0; ifc.ifc_len = 0;
if (__ioctl (fd, SIOCGIFCONF, &ifc) < 0 || ifc.ifc_len == 0) if (__ioctl (fd, SIOCGIFCONF, &ifc) < 0 || ifc.ifc_len == 0)
{ {
# if __ASSUME_SIOCGIFNAME == 0
old_siocgifconf = 1; old_siocgifconf = 1;
# endif
rq_len = RQ_IFS * sizeof (struct ifreq); rq_len = RQ_IFS * sizeof (struct ifreq);
} }
else else
@ -199,24 +207,31 @@ if_nameindex (void)
char * char *
if_indextoname (unsigned int ifindex, char *ifname) if_indextoname (unsigned int ifindex, char *ifname)
{ {
#ifndef SIOGIFINDEX #if !defined SIOGIFINDEX && __ASSUME_SIOCGIFNAME == 0
__set_errno (ENOSYS); __set_errno (ENOSYS);
return NULL; return NULL;
#else #else
# if __ASSUME_SIOCGIFNAME == 0
struct if_nameindex *idx; struct if_nameindex *idx;
struct if_nameindex *p; struct if_nameindex *p;
char *result = NULL; 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 /* 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. */ list. This ioctl is not present in kernels before version 2.1.50. */
struct ifreq ifr; struct ifreq ifr;
int fd; 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; int serrno = errno;
# endif
int status;
fd = opensock (); fd = opensock ();
@ -224,23 +239,27 @@ if_indextoname (unsigned int ifindex, char *ifname)
return NULL; return NULL;
ifr.ifr_ifindex = ifindex; 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) 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 else
{
__close (fd);
return strncpy (ifname, ifr.ifr_name, IFNAMSIZ); return strncpy (ifname, ifr.ifr_name, IFNAMSIZ);
}
__close (fd);
__set_errno (serrno); __set_errno (serrno);
# else
return status < 0 ? NULL : strncpy (ifname, ifr.ifr_name, IFNAMSIZ);
# endif
} }
# endif # endif
# if __ASSUME_SIOCGIFNAME == 0
idx = if_nameindex (); idx = if_nameindex ();
if (idx != NULL) if (idx != NULL)
@ -256,4 +275,5 @@ if_indextoname (unsigned int ifindex, char *ifname)
} }
return result; return result;
# endif # endif
#endif
} }

View File

@ -69,3 +69,8 @@
#if __LINUX_KERNEL_VERSION >= 131584 #if __LINUX_KERNEL_VERSION >= 131584
# define __ASSUME_SETRESUID_SYSCALL 1 # define __ASSUME_SETRESUID_SYSCALL 1
#endif #endif
/* The SIOCGIFNAME ioctl is available starting with 2.1.50. */
#if __LINUX_KERNEL_VERSION >= 131408
# define __ASSUME_SIOCGIFNAME 1
#endif