This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Use __unused0 instead of __unused for user visible struct members


A patch was submitted for this a while back
https://sourceware.org/ml/libc-alpha/2012-01/msg00001.html and did not
get a good reception from the maintainer at the time. Attached is an
updated version for current glibc head.

The issue here is that use of __unused as a struct member name
conflicts with the historic use of __unused on BSD systems and code
for __attribute__((__unused__)) - unfortunately this has become part
of the user visible API of these systems. In my case I am trying to
cross compile NetBSD on ppc Linux and there is no way to do this
without patching the headers. In general most uses of __unused are
already __unused1, __unused2 etc, it is just a few cases that are not.
These fields are not part of the user API so these changes should not
affect any code outside glibc itself.

Justin

diff --git a/ports/sysdeps/unix/sysv/linux/alpha/bits/stat.h
b/ports/sysdeps/unix/sysv/linux/alpha/bits/stat.h
index 3e10647..688d0bb 100644
--- a/ports/sysdeps/unix/sysv/linux/alpha/bits/stat.h
+++ b/ports/sysdeps/unix/sysv/linux/alpha/bits/stat.h
@@ -92,7 +92,7 @@ struct stat
     __ST_TIME(a); /* Time of last access.  */
     __ST_TIME(m); /* Time of last modification.  */
     __ST_TIME(c); /* Time of last status change.  */
-    long __unused[3];
+    long __unused0[3];
   };

 #ifdef __USE_LARGEFILE64
@@ -113,7 +113,7 @@ struct stat64
     __ST_TIME(a); /* Time of last access.  */
     __ST_TIME(m); /* Time of last modification.  */
     __ST_TIME(c); /* Time of last status change.  */
-    long __unused[3];
+    long __unused0[3];
   };
 #endif

diff --git a/ports/sysdeps/unix/sysv/linux/alpha/kernel_stat.h
b/ports/sysdeps/unix/sysv/linux/alpha/kernel_stat.h
index 94d358e..cf59f8e 100644
--- a/ports/sysdeps/unix/sysv/linux/alpha/kernel_stat.h
+++ b/ports/sysdeps/unix/sysv/linux/alpha/kernel_stat.h
@@ -40,7 +40,7 @@ struct kernel_stat64
     unsigned long   st_mtimensec;
     unsigned long   st_ctime;
     unsigned long   st_ctimensec;
-    long            __unused[3];
+    long            __unused0[3];
   };

 /* Definition of `struct stat' used by glibc 2.0.  */
@@ -82,7 +82,7 @@ struct glibc21_stat
     unsigned int st_flags;
     unsigned int st_gen;
     int __pad3;
-    long __unused[4];
+    long __unused0[4];
   };

 #define XSTAT_IS_XSTAT64 1
diff --git a/ports/sysdeps/unix/sysv/linux/alpha/xstatconv.c
b/ports/sysdeps/unix/sysv/linux/alpha/xstatconv.c
index 79ec578..14cff92 100644
--- a/ports/sysdeps/unix/sysv/linux/alpha/xstatconv.c
+++ b/ports/sysdeps/unix/sysv/linux/alpha/xstatconv.c
@@ -74,10 +74,10 @@ __xstat_conv (int vers, struct kernel_stat *kbuf,
void *ubuf)
  buf->st_flags = kbuf->st_flags;
  buf->st_gen = kbuf->st_gen;
  buf->__pad3 = 0;
- buf->__unused[0] = 0;
- buf->__unused[1] = 0;
- buf->__unused[2] = 0;
- buf->__unused[3] = 0;
+ buf->__unused0[0] = 0;
+ buf->__unused0[1] = 0;
+ buf->__unused0[2] = 0;
+ buf->__unused0[3] = 0;
       }
       break;

@@ -105,9 +105,9 @@ __xstat_conv (int vers, struct kernel_stat *kbuf,
void *ubuf)
  buf->st_ctime = kbuf->st_ctime;
  buf->st_ctimensec = 0;

- buf->__unused[0] = 0;
- buf->__unused[1] = 0;
- buf->__unused[2] = 0;
+ buf->__unused0[0] = 0;
+ buf->__unused0[1] = 0;
+ buf->__unused0[2] = 0;
       }
       break;

diff --git a/ports/sysdeps/unix/sysv/linux/generic/bits/stat.h
b/ports/sysdeps/unix/sysv/linux/generic/bits/stat.h
index 6e74cec..b5dbd42 100644
--- a/ports/sysdeps/unix/sysv/linux/generic/bits/stat.h
+++ b/ports/sysdeps/unix/sysv/linux/generic/bits/stat.h
@@ -87,7 +87,7 @@ struct stat
     __time_t st_ctime; /* Time of last status change.  */
     unsigned long int st_ctimensec; /* Nsecs of last status change.  */
 #endif
-    int __unused[2];
+    int __unused0[2];
   };

 #undef __field64
@@ -125,7 +125,7 @@ struct stat64
     __time_t st_ctime; /* Time of last status change.  */
     unsigned long int st_ctimensec; /* Nsecs of last status change.  */
 #endif
-    int __unused[2];
+    int __unused0[2];
   };
 #endif

diff --git a/ports/sysdeps/unix/sysv/linux/ia64/bits/stat.h
b/ports/sysdeps/unix/sysv/linux/ia64/bits/stat.h
index b2071cd..1545f50 100644
--- a/ports/sysdeps/unix/sysv/linux/ia64/bits/stat.h
+++ b/ports/sysdeps/unix/sysv/linux/ia64/bits/stat.h
@@ -64,7 +64,7 @@ struct stat
 #endif
     __blksize_t st_blksize; /* Optimal block size for I/O.  */
     __blkcnt_t st_blocks; /* Nr. 512-byte blocks allocated.  */
-    long int __unused[3];
+    long int __unused0[3];
   };

 #ifdef __USE_LARGEFILE64
@@ -103,7 +103,7 @@ struct stat64
 #endif
     __blksize_t st_blksize; /* Optimal block size for I/O.  */
     __blkcnt64_t st_blocks; /* Nr. 512-byte blocks allocated.  */
-    long int __unused[3];
+    long int __unused0[3];
   };
 #endif

diff --git a/resolv/netdb.h b/resolv/netdb.h
index 412343b..68893dc 100644
--- a/resolv/netdb.h
+++ b/resolv/netdb.h
@@ -586,7 +586,7 @@ struct gaicb
   struct addrinfo *ar_result; /* Pointer to result.  */
   /* The following are internal elements.  */
   int __return;
-  int __unused[5];
+  int __unused0[5];
 };

 /* Lookup mode.  */
diff --git a/rt/aio.h b/rt/aio.h
index 23d602d..25ccb1b 100644
--- a/rt/aio.h
+++ b/rt/aio.h
@@ -54,7 +54,7 @@ struct aiocb
 #else
   __off64_t aio_offset; /* File offset.  */
 #endif
-  char __unused[32];
+  char __unused0[32];
 };

 /* The same for the 64bit offsets.  Please note that the members aio_fildes
@@ -77,7 +77,7 @@ struct aiocb64
   __ssize_t __return_value;

   __off64_t aio_offset; /* File offset.  */
-  char __unused[32];
+  char __unused0[32];
 };
 #endif

diff --git a/sysdeps/gnu/bits/utmp.h b/sysdeps/gnu/bits/utmp.h
index 8a768d9..f9d95fa 100644
--- a/sysdeps/gnu/bits/utmp.h
+++ b/sysdeps/gnu/bits/utmp.h
@@ -81,7 +81,7 @@ struct utmp
 #endif

   int32_t ut_addr_v6[4]; /* Internet address of remote host.  */
-  char __unused[20]; /* Reserved for future use.  */
+  char __unused0[20]; /* Reserved for future use.  */
 };

 /* Backwards compatibility hacks.  */
diff --git a/sysdeps/gnu/bits/utmpx.h b/sysdeps/gnu/bits/utmpx.h
index 6cfb316..a55deba 100644
--- a/sysdeps/gnu/bits/utmpx.h
+++ b/sysdeps/gnu/bits/utmpx.h
@@ -78,7 +78,7 @@ struct utmpx
   struct timeval ut_tv; /* Time entry was made.  */
 #endif
   __int32_t ut_addr_v6[4]; /* Internet address of remote host.  */
-  char __unused[20]; /* Reserved for future use.  */
+  char __unused0[20]; /* Reserved for future use.  */
 };


diff --git a/sysdeps/gnu/netinet/ip_icmp.h b/sysdeps/gnu/netinet/ip_icmp.h
index 136fb47..36b9733 100644
--- a/sysdeps/gnu/netinet/ip_icmp.h
+++ b/sysdeps/gnu/netinet/ip_icmp.h
@@ -38,7 +38,7 @@ struct icmphdr
     u_int32_t gateway; /* gateway address */
     struct
     {
-      u_int16_t __unused;
+      u_int16_t __unused0;
       u_int16_t mtu;
     } frag; /* path mtu discovery */
   } un;
diff --git a/sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h
b/sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h
index 935a68c..2ace563 100644
--- a/sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h
+++ b/sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h
@@ -97,7 +97,7 @@ typedef struct _libc_vrstate
 } vrregset_t  __attribute__((__aligned__(16)));

 typedef struct {
- unsigned long __unused[4];
+ unsigned long __unused0[4];
  int signal;
  int __pad0;
  unsigned long handler;
diff --git a/sysdeps/unix/sysv/linux/s390/bits/stat.h
b/sysdeps/unix/sysv/linux/s390/bits/stat.h
index 5d1e222..774c07d 100644
--- a/sysdeps/unix/sysv/linux/s390/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/s390/bits/stat.h
@@ -81,7 +81,7 @@ struct stat
 #endif
     __blksize_t st_blksize; /* Optimal block size for I/O. */
     __blkcnt_t st_blocks; /* Nr. 512-byte blocks allocated.  */
-    long int __unused[3];
+    long int __unused0[3];
   };
 #else
 struct stat
@@ -178,7 +178,7 @@ struct stat64
 #  endif
     __blksize_t st_blksize; /* Optimal block size for I/O. */
     __blkcnt64_t st_blocks; /* Nr. 512-byte blocks allocated.  */
-    long int __unused[3];
+    long int __unused0[3];
   };
 # else
 struct stat64
diff --git a/sysdeps/unix/sysv/linux/s390/bits/utmp.h
b/sysdeps/unix/sysv/linux/s390/bits/utmp.h
index a46470f..6b76549 100644
--- a/sysdeps/unix/sysv/linux/s390/bits/utmp.h
+++ b/sysdeps/unix/sysv/linux/s390/bits/utmp.h
@@ -81,7 +81,7 @@ struct utmp
 #endif

   int32_t ut_addr_v6[4]; /* Internet address of remote host.  */
-  char __unused[20]; /* Reserved for future use.  */
+  char __unused0[20]; /* Reserved for future use.  */
 };

 /* Backwards compatibility hacks.  */
diff --git a/sysdeps/unix/sysv/linux/s390/bits/utmpx.h
b/sysdeps/unix/sysv/linux/s390/bits/utmpx.h
index 1fba0b6..0f2f4f4 100644
--- a/sysdeps/unix/sysv/linux/s390/bits/utmpx.h
+++ b/sysdeps/unix/sysv/linux/s390/bits/utmpx.h
@@ -78,7 +78,7 @@ struct utmpx
   struct timeval ut_tv; /* Time entry was made.  */
 #endif
   __int32_t ut_addr_v6[4]; /* Internet address of remote host.  */
-  char __unused[20]; /* Reserved for future use.  */
+  char __unused0[20]; /* Reserved for future use.  */
 };


diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/utmp32.h
b/sysdeps/unix/sysv/linux/s390/s390-32/utmp32.h
index 350b3e6..0105fea 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/utmp32.h
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/utmp32.h
@@ -44,7 +44,7 @@ struct utmp32
   } ut_tv; /* Time entry was made.  */

   int32_t ut_addr_v6[4]; /* Internet address of remote host.  */
-  char __unused[20]; /* Reserved for future use.  */
+  char __unused0[20]; /* Reserved for future use.  */
 };


diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/utmpx32.h
b/sysdeps/unix/sysv/linux/s390/s390-32/utmpx32.h
index 82fc774..8d658e1 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/utmpx32.h
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/utmpx32.h
@@ -44,7 +44,7 @@ struct utmpx32
   } ut_tv; /* Time entry was made.  */

   __int32_t ut_addr_v6[4]; /* Internet address of remote host.  */
-  char __unused[20]; /* Reserved for future use.  */
+  char __unused0[20]; /* Reserved for future use.  */
 };

 /* The internal interface needed by the compat wrapper functions.  */
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h
b/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h
index f384bc7..039b380 100644
--- a/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h
+++ b/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h
@@ -82,7 +82,7 @@ struct flock
     __off64_t l_len; /* Size of the locked area; zero means until EOF.  */
 #endif
     __pid_t l_pid; /* Process holding the lock.  */
-    short int __unused;
+    short int __unused0;
   };

 #ifdef __USE_LARGEFILE64
@@ -93,7 +93,7 @@ struct flock64
     __off64_t l_start; /* Offset where the lock begins.  */
     __off64_t l_len; /* Size of the locked area; zero means until EOF.  */
     __pid_t l_pid; /* Process holding the lock.  */
-    short int __unused;
+    short int __unused0;
   };
 #endif

diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h
b/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h
index a4e411d..7af6f59 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h
@@ -41,7 +41,7 @@ struct kernel_stat64
     unsigned long int st_mtime_nsec;
     unsigned long int st_ctime_sec;
     unsigned long int st_ctime_nsec;
-    long int __unused[3];
+    long int __unused0[3];
   };

 #define XSTAT_IS_XSTAT64 1
diff --git a/sysdeps/unix/sysv/linux/sparc/sys/procfs.h
b/sysdeps/unix/sysv/linux/sparc/sys/procfs.h
index 4d8c450..a83938f 100644
--- a/sysdeps/unix/sysv/linux/sparc/sys/procfs.h
+++ b/sysdeps/unix/sysv/linux/sparc/sys/procfs.h
@@ -55,7 +55,7 @@ typedef struct
  unsigned long pr_regs[32];
  double pr_dregs[16];
       } pr_fr;
-    unsigned long __unused;
+    unsigned long __unused0;
     unsigned long pr_fsr;
     unsigned char pr_qcnt;
     unsigned char pr_q_entrysize;
@@ -150,7 +150,7 @@ typedef struct
  unsigned int pr_regs[32];
  double pr_dregs[16];
       } pr_fr;
-    unsigned int __unused;
+    unsigned int __unused0;
     unsigned int pr_fsr;
     unsigned char pr_qcnt;
     unsigned char pr_q_entrysize;
diff --git a/sysdeps/unix/sysv/linux/x86/bits/stat.h
b/sysdeps/unix/sysv/linux/x86/bits/stat.h
index 9e2f78f..cf74fdb 100644
--- a/sysdeps/unix/sysv/linux/x86/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/x86/bits/stat.h
@@ -103,7 +103,7 @@ struct stat
     __syscall_ulong_t st_ctimensec; /* Nsecs of last status change.  */
 #endif
 #ifdef __x86_64__
-    __syscall_slong_t __unused[3];
+    __syscall_slong_t __unused0[3];
 #else
 # ifndef __USE_FILE_OFFSET64
     unsigned long int __unused4;
@@ -161,7 +161,7 @@ struct stat64
     __syscall_ulong_t st_ctimensec; /* Nsecs of last status change.  */
 # endif
 # ifdef __x86_64__
-    __syscall_slong_t __unused[3];
+    __syscall_slong_t __unused0[3];
 # else
     __ino64_t st_ino; /* File serial number. */
 # endif

Attachment: unused.patch
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]