public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Allow [f]statfs64 to alias [f]statfs
@ 2016-11-07 22:13 Steve Ellcey
  2016-11-09 21:21 ` Steve Ellcey
  2016-11-17  8:53 ` Andreas Schwab
  0 siblings, 2 replies; 9+ messages in thread
From: Steve Ellcey @ 2016-11-07 22:13 UTC (permalink / raw)
  To: libc-alpha

This is a preparatory patch for the ILP32 aarch64 patch.  On that system
statfs and fstatfs will match statfs64 and fstatfs64.  So this patch
follows what was already done for xstat and fxstat in making the 64
bit entry points aliases of the regular versions.  Right now this will
not affect any existing platform because none of them define
STATFS_IS_STATFS64 but aarch64 will define this later.

My main question is, is this an OK use of '#ifdef' or should the
STATFS_IS_STATFS64 be defined on all platforms (presumably in kernel_stat.h)
so that we can check the value instead of checking to see it is defined
or not?  I know that we want to move in that direction but I wasn't
sure if I should include that change in this patch or not.  I also wasn't
sure if I should try to change how XSTAT_IS_XSTAT64 or STAT_IS_KERNEL_STAT
are used.

There are 13 kernel_stat.h files in the glibc source tree, in addition
to a number of _HAVE_* macros, some of them define XSTAT_IS_XSTAT64
and some define STAT_IS_KERNEL_STAT.  Those are the only defines
in those files right now.  So the magnitude of the change isn't too large
if we do want to define those two macros everywhere.

I tested this patch on x86 to make sure nothing broke and I tested with
the full ILP32 aarch64 patch to make sure this part of the patch worked
with the rest of the ILP32 changes.

Is the patch OK like this or should it be redone?

Steve Ellcey
sellcey@caviumnetworks.com


2016-11-07  Steve Ellcey  <sellcey@caviumnetworks.com>

	* sysdeps/unix/sysv/linux/fstatfs64.c: Make __fstatfs and fstatfs
	aliases of __fstatfs64 if __STATFS_IS_STATFS64 is set.
	* sysdeps/unix/sysv/linux/statfs64.c: Ditto for __statfs, statfs,
	and __statfs64.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c: Do not
	define __fstatfs and fstatfs if __STATFS_IS_STATFS64 is set.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c: Ditto
	for __statfs and statfs.


diff --git a/sysdeps/unix/sysv/linux/fstatfs64.c b/sysdeps/unix/sysv/linux/fstatfs64.c
index a624de6..ac11fff 100644
--- a/sysdeps/unix/sysv/linux/fstatfs64.c
+++ b/sysdeps/unix/sysv/linux/fstatfs64.c
@@ -70,3 +70,8 @@ __fstatfs64 (int fd, struct statfs64 *buf)
 #endif
 }
 weak_alias (__fstatfs64, fstatfs64)
+
+#ifdef STATFS_IS_STATFS64
+weak_alias (__fstatfs64, __fstatfs)
+weak_alias (__fstatfs64, fstatfs)
+#endif
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c
index be9599a..e41afb9 100644
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c
+++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c
@@ -20,6 +20,7 @@
 #include <sys/statfs.h>
 #include <stddef.h>
 
+#ifndef STATFS_IS_STATFS64
 #include "overflow.h"
 
 /* Return information about the filesystem on which FD resides.  */
@@ -30,3 +31,4 @@ __fstatfs (int fd, struct statfs *buf)
   return rc ?: statfs_overflow (buf);
 }
 weak_alias (__fstatfs, fstatfs)
+#endif
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c
index 1937f05..a7f9187 100644
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c
+++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c
@@ -20,6 +20,7 @@
 #include <sys/statfs.h>
 #include <stddef.h>
 
+#ifndef STATFS_IS_STATFS64
 #include "overflow.h"
 
 /* Return information about the filesystem on which FILE resides.  */
@@ -31,3 +32,4 @@ __statfs (const char *file, struct statfs *buf)
 }
 libc_hidden_def (__statfs)
 weak_alias (__statfs, statfs)
+#endif
diff --git a/sysdeps/unix/sysv/linux/statfs64.c b/sysdeps/unix/sysv/linux/statfs64.c
index de42261..c75d4cf 100644
--- a/sysdeps/unix/sysv/linux/statfs64.c
+++ b/sysdeps/unix/sysv/linux/statfs64.c
@@ -72,3 +72,9 @@ __statfs64 (const char *file, struct statfs64 *buf)
 #endif
 }
 weak_alias (__statfs64, statfs64)
+
+#ifdef STATFS_IS_STATFS64
+weak_alias (__statfs64, __statfs)
+weak_alias (__statfs64, statfs)
+libc_hidden_ver (__statfs64, __statfs)
+#endif

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Allow [f]statfs64 to alias [f]statfs
  2016-11-07 22:13 [PATCH] Allow [f]statfs64 to alias [f]statfs Steve Ellcey
@ 2016-11-09 21:21 ` Steve Ellcey
  2016-11-16 22:55   ` Steve Ellcey
  2016-11-17  8:53 ` Andreas Schwab
  1 sibling, 1 reply; 9+ messages in thread
From: Steve Ellcey @ 2016-11-09 21:21 UTC (permalink / raw)
  To: sellcey, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 2455 bytes --]

On Mon, 2016-11-07 at 14:13 -0800, Steve Ellcey wrote:
> This is a preparatory patch for the ILP32 aarch64 patch.  On that system
> statfs and fstatfs will match statfs64 and fstatfs64.  So this patch
> follows what was already done for xstat and fxstat in making the 64
> bit entry points aliases of the regular versions.  Right now this will
> not affect any existing platform because none of them define
> STATFS_IS_STATFS64 but aarch64 will define this later.
> 
> My main question is, is this an OK use of '#ifdef' or should the
> STATFS_IS_STATFS64 be defined on all platforms (presumably in kernel_stat.h)
> so that we can check the value instead of checking to see it is defined
> or not?  I know that we want to move in that direction but I wasn't
> sure if I should include that change in this patch or not.  I also wasn't
> sure if I should try to change how XSTAT_IS_XSTAT64 or STAT_IS_KERNEL_STAT
> are used.
> 
> There are 13 kernel_stat.h files in the glibc source tree, in addition
> to a number of _HAVE_* macros, some of them define XSTAT_IS_XSTAT64
> and some define STAT_IS_KERNEL_STAT.  Those are the only defines
> in those files right now.  So the magnitude of the change isn't too large
> if we do want to define those two macros everywhere.
> 
> I tested this patch on x86 to make sure nothing broke and I tested with
> the full ILP32 aarch64 patch to make sure this part of the patch worked
> with the rest of the ILP32 changes.
> 
> Is the patch OK like this or should it be redone?
> 
> Steve Ellcey
> sellcey@caviumnetworks.com

I have modified this patch, I missed a problem in the ILP32 glibc build
and so I had to add the #define of some symbols to hide their
prototypes when aliasing them.  This in turn required me to add some
includes of kernel_stat.h.  This also matches what is being done with
xs
tat.

Steve Ellcey
sellcey@caviumnetworks.com



2016-11-09  Steve Ellcey  <sellcey@caviumnetworks.com>

	* sysdeps/unix/sysv/linux/fstatfs64.c: Hide prototypes for fstatfs
	and __fstatfs.  Make them aliases of __fstatfs64 if
	__STATFS_IS_STATFS64 is set.
	* sysdeps/unix/sysv/linux/statfs64.c: Ditto for __statfs, statfs,
	and __statfs64.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c: Do not
	define __fstatfs and fstatfs if __STATFS_IS_STATFS64 is set.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c: Ditto
	for __statfs and statfs.

[-- Attachment #2: stat1.patch --]
[-- Type: text/x-patch, Size: 3526 bytes --]

diff --git a/sysdeps/unix/sysv/linux/fstatfs64.c b/sysdeps/unix/sysv/linux/fstatfs64.c
index a624de6..5f56e68 100644
--- a/sysdeps/unix/sysv/linux/fstatfs64.c
+++ b/sysdeps/unix/sysv/linux/fstatfs64.c
@@ -16,9 +16,18 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+/* Hide the prototypes for __fstatfs and fstatfs so that GCC will not
+   complain about the different function signatures if they are aliased
+   to  __fstat64.  If STATFS_IS_STATFS64 is set then the statfs and
+   statfs64 structures have an identical layout but different type names.  */
+
+#define __fstatfs __fstatfs_disable
+#define fstatfs fstatfs_disable
+
 #include <errno.h>
 #include <string.h>
 #include <sys/statfs.h>
+#include <kernel_stat.h>
 #include <stddef.h>
 #include <sysdep.h>
 #include <kernel-features.h>
@@ -70,3 +79,11 @@ __fstatfs64 (int fd, struct statfs64 *buf)
 #endif
 }
 weak_alias (__fstatfs64, fstatfs64)
+
+#undef __fstatfs
+#undef fstatfs
+
+#ifdef STATFS_IS_STATFS64
+weak_alias (__fstatfs64, __fstatfs)
+weak_alias (__fstatfs64, fstatfs)
+#endif
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c
index be9599a..3bada44 100644
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c
+++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c
@@ -18,8 +18,10 @@
 
 #include <errno.h>
 #include <sys/statfs.h>
+#include <kernel_stat.h>
 #include <stddef.h>
 
+#ifndef STATFS_IS_STATFS64
 #include "overflow.h"
 
 /* Return information about the filesystem on which FD resides.  */
@@ -30,3 +32,4 @@ __fstatfs (int fd, struct statfs *buf)
   return rc ?: statfs_overflow (buf);
 }
 weak_alias (__fstatfs, fstatfs)
+#endif
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c
index 1937f05..aab59fd 100644
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c
+++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c
@@ -18,8 +18,10 @@
 
 #include <errno.h>
 #include <sys/statfs.h>
+#include <kernel_stat.h>
 #include <stddef.h>
 
+#ifndef STATFS_IS_STATFS64
 #include "overflow.h"
 
 /* Return information about the filesystem on which FILE resides.  */
@@ -31,3 +33,4 @@ __statfs (const char *file, struct statfs *buf)
 }
 libc_hidden_def (__statfs)
 weak_alias (__statfs, statfs)
+#endif
diff --git a/sysdeps/unix/sysv/linux/statfs64.c b/sysdeps/unix/sysv/linux/statfs64.c
index de42261..0d881ed 100644
--- a/sysdeps/unix/sysv/linux/statfs64.c
+++ b/sysdeps/unix/sysv/linux/statfs64.c
@@ -16,9 +16,18 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+/* Hide the prototypes for __statfs and statfs so that GCC will not
+   complain about the different function signatures if they are aliased
+   to  __stat64.  If STATFS_IS_STATFS64 is set then the statfs and
+   statfs64 structures have an identical layout but different type names.  */
+
+#define __statfs __statfs_disable
+#define statfs statfs_disable
+
 #include <errno.h>
 #include <string.h>
 #include <sys/statfs.h>
+#include <kernel_stat.h>
 #include <stddef.h>
 #include <sysdep.h>
 #include <kernel-features.h>
@@ -72,3 +81,12 @@ __statfs64 (const char *file, struct statfs64 *buf)
 #endif
 }
 weak_alias (__statfs64, statfs64)
+
+#undef __statfs
+#undef statfs
+
+#ifdef STATFS_IS_STATFS64
+weak_alias (__statfs64, __statfs)
+weak_alias (__statfs64, statfs)
+libc_hidden_ver (__statfs64, __statfs)
+#endif

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Allow [f]statfs64 to alias [f]statfs
  2016-11-09 21:21 ` Steve Ellcey
@ 2016-11-16 22:55   ` Steve Ellcey
  0 siblings, 0 replies; 9+ messages in thread
From: Steve Ellcey @ 2016-11-16 22:55 UTC (permalink / raw)
  To: libc-alpha

Ping.

Steve Ellcey


On Wed, 2016-11-09 at 13:21 -0800, Steve Ellcey wrote:
> On Mon, 2016-11-07 at 14:13 -0800, Steve Ellcey wrote:
> > 
> > This is a preparatory patch for the ILP32 aarch64 patch.  On that
> > system statfs and fstatfs will match statfs64 and fstatfs64.  So
> > this patch follows what was already done for xstat and fxstat in
> > making the 64 bit entry points aliases of the regular
> > versions.  Right now this will not affect any existing platform
> > because none of them define STATFS_IS_STATFS64 but aarch64 will
> > define this later.
> > 
> > My main question is, is this an OK use of '#ifdef' or should the
> > STATFS_IS_STATFS64 be defined on all platforms (presumably in
> > kernel_stat.h) so that we can check the value instead of checking
> > to see it is defined or not?  I know that we want to move in that
> > direction but I wasn't sure if I should include that change in this
> > patch or not.  I also wasn't sure if I should try to change how
> > XSTAT_IS_XSTAT64 or STAT_IS_KERNEL_STAT are used.
> > 
> > There are 13 kernel_stat.h files in the glibc source tree, in
> > addition to a number of _HAVE_* macros, some of them define
> > XSTAT_IS_XSTAT64 and some define STAT_IS_KERNEL_STAT.  Those are
> > the only defines in those files right now.  So the magnitude of the
> > change isn't too large if we do want to define those two macros
> > everywhere.
> > 
> > I tested this patch on x86 to make sure nothing broke and I tested
> > with the full ILP32 aarch64 patch to make sure this part of the
> > patch worked with the rest of the ILP32 changes.
> > 
> > Is the patch OK like this or should it be redone?
> > 
> > Steve Ellcey
> > sellcey@caviumnetworks.com
> I have modified this patch, I missed a problem in the ILP32 glibc
> build and so I had to add the #define of some symbols to hide their
> prototypes when aliasing them.  This in turn required me to add some
> includes of kernel_stat.h.  This also matches what is being done with
> xstat.
> 
> Steve Ellcey
> sellcey@caviumnetworks.com
> 
> 
> 
> 2016-11-09  Steve Ellcey  <sellcey@caviumnetworks.com>
> 
> 	* sysdeps/unix/sysv/linux/fstatfs64.c: Hide prototypes for fstatfs
> 	and __fstatfs.  Make them aliases of __fstatfs64 if
> 	__STATFS_IS_STATFS64 is set.
> 	* sysdeps/unix/sysv/linux/statfs64.c: Ditto for __statfs, statfs,
> 	and __statfs64.
> 	* sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c: Do not
> 	define __fstatfs and fstatfs if __STATFS_IS_STATFS64 is set.
> 	* sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c: Ditto
> 	for __statfs and statfs.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Allow [f]statfs64 to alias [f]statfs
  2016-11-07 22:13 [PATCH] Allow [f]statfs64 to alias [f]statfs Steve Ellcey
  2016-11-09 21:21 ` Steve Ellcey
@ 2016-11-17  8:53 ` Andreas Schwab
  2016-11-17 18:34   ` Steve Ellcey
  2016-11-21 18:07   ` Steve Ellcey
  1 sibling, 2 replies; 9+ messages in thread
From: Andreas Schwab @ 2016-11-17  8:53 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: libc-alpha

On Nov 07 2016, Steve Ellcey <sellcey@cavium.com> wrote:

> My main question is, is this an OK use of '#ifdef' or should the
> STATFS_IS_STATFS64 be defined on all platforms (presumably in kernel_stat.h)
> so that we can check the value instead of checking to see it is defined
> or not?

Since it is a new symbol it should follow the policy of always being
defined.

> 	* sysdeps/unix/sysv/linux/fstatfs64.c: Make __fstatfs and fstatfs
> 	aliases of __fstatfs64 if __STATFS_IS_STATFS64 is set.
> 	* sysdeps/unix/sysv/linux/statfs64.c: Ditto for __statfs, statfs,
> 	and __statfs64.
> 	* sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c: Do not
> 	define __fstatfs and fstatfs if __STATFS_IS_STATFS64 is set.
> 	* sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c: Ditto
> 	for __statfs and statfs.

It's STATFS_IS_STATFS64, not __STATFS_IS_STATFS64.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Allow [f]statfs64 to alias [f]statfs
  2016-11-17  8:53 ` Andreas Schwab
@ 2016-11-17 18:34   ` Steve Ellcey
  2016-11-21 18:07   ` Steve Ellcey
  1 sibling, 0 replies; 9+ messages in thread
From: Steve Ellcey @ 2016-11-17 18:34 UTC (permalink / raw)
  To: Andreas Schwab, Steve Ellcey; +Cc: libc-alpha

On Thu, 2016-11-17 at 09:53 +0100, Andreas Schwab wrote:
> On Nov 07 2016, Steve Ellcey <sellcey@cavium.com> wrote:
> 
> > 
> > My main question is, is this an OK use of '#ifdef' or should the
> > STATFS_IS_STATFS64 be defined on all platforms (presumably in
> > kernel_stat.h)
> > so that we can check the value instead of checking to see it is
> > defined
> > or not?
> Since it is a new symbol it should follow the policy of always being
> defined.

OK, but since having STATFS_IS_STATFS64 be handled one way
and XSTAT_IS_XSTAT64 handled a different way bothers my sense of
consistency I am going to first submit a patch to always define
XSTAT_IS_XSTAT64, then redo this patch.  Hopefully a patch to always
define XSTAT_IS_XSTAT64 will be acceptable (after testing, etc).

Steve Ellcey
sellcey@caviumnetworks.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Allow [f]statfs64 to alias [f]statfs
  2016-11-17  8:53 ` Andreas Schwab
  2016-11-17 18:34   ` Steve Ellcey
@ 2016-11-21 18:07   ` Steve Ellcey
  2016-11-22 13:16     ` Andreas Schwab
  2016-11-23  1:20     ` Joseph Myers
  1 sibling, 2 replies; 9+ messages in thread
From: Steve Ellcey @ 2016-11-21 18:07 UTC (permalink / raw)
  To: Andreas Schwab, Steve Ellcey; +Cc: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 2310 bytes --]

On Thu, 2016-11-17 at 09:53 +0100, Andreas Schwab wrote:
> 
> Since it is a new symbol it should follow the policy of always being
> defined.
> 
> > 
> > 	* sysdeps/unix/sysv/linux/fstatfs64.c: Make __fstatfs and
> > fstatfs
> > 	aliases of __fstatfs64 if __STATFS_IS_STATFS64 is set.
> > 	* sysdeps/unix/sysv/linux/statfs64.c: Ditto for __statfs, statfs,
> > 	and __statfs64.
> > 	* sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c: Do not
> > 	define __fstatfs and fstatfs if __STATFS_IS_STATFS64 is set.
> > 	* sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c: Ditto
> > 	for __statfs and statfs.
> It's STATFS_IS_STATFS64, not __STATFS_IS_STATFS64.
> 
> Andreas.

Here is my updated patch, retested on x86 and aarch64.  It defines
STATFS_IS_STATFS64 to 0 on all platforms, when the ILP32 aarch code is
checked in it will have a new kernel_stat.h file and that will set it
to 1.  I also fixed and upated the ChangeLog entry.

Steve Ellcey
sellcey@caviumnetworks.com


2016-11-21  Steve Ellcey  <sellcey@caviumnetworks.com>

	* sysdeps/unix/sysv/linux/fstatfs64.c: Hide prototypes for fstatfs
	and __fstatfs.  Make them aliases of __fstatfs64 if
	STATFS_IS_STATFS64 is set to non-zero.
	* sysdeps/unix/sysv/linux/statfs64.c: Ditto for __statfs, statfs,
	and __statfs64.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c: Do not
	define __fstatfs and fstatfs if STATFS_IS_STATFS64 is non-zero.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c: Ditto
	for __statfs and statfs.
	* sysdeps/unix/sysv/linux/alpha/kernel_stat.h: Set STATFS_IS_STATFS64
	to 0.
	* sysdeps/unix/sysv/linux/generic/kernel_stat.h: Ditto.
	* sysdeps/unix/sysv/linux/hppa/kernel_stat.h: Ditto.
	* sysdeps/unix/sysv/linux/ia64/kernel_stat.h: Ditto.
	* sysdeps/unix/sysv/linux/kernel_stat.h: Ditto.
	* sysdeps/unix/sysv/linux/microblaze/kernel_stat.h: Ditto.
	* sysdeps/unix/sysv/linux/mips/kernel_stat.h: Ditto.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h: Ditto.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h: Ditto.
	* sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h: Ditto.
	* sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h: Ditto.
	* sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h: Ditto.
	* sysdeps/unix/sysv/linux/x86_64/kernel_stat.h: Ditto.

[-- Attachment #2: statfs.patch --]
[-- Type: text/x-patch, Size: 8180 bytes --]

diff --git a/sysdeps/unix/sysv/linux/alpha/kernel_stat.h b/sysdeps/unix/sysv/linux/alpha/kernel_stat.h
index 6708411..d637e09 100644
--- a/sysdeps/unix/sysv/linux/alpha/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/alpha/kernel_stat.h
@@ -86,3 +86,4 @@ struct glibc21_stat
   };
 
 #define XSTAT_IS_XSTAT64 1
+#define STATFS_IS_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/fstatfs64.c b/sysdeps/unix/sysv/linux/fstatfs64.c
index a624de6..a95fe18 100644
--- a/sysdeps/unix/sysv/linux/fstatfs64.c
+++ b/sysdeps/unix/sysv/linux/fstatfs64.c
@@ -16,9 +16,18 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+/* Hide the prototypes for __fstatfs and fstatfs so that GCC will not
+   complain about the different function signatures if they are aliased
+   to  __fstat64.  If STATFS_IS_STATFS64 is not zero then the statfs and
+   statfs64 structures have an identical layout but different type names.  */
+
+#define __fstatfs __fstatfs_disable
+#define fstatfs fstatfs_disable
+
 #include <errno.h>
 #include <string.h>
 #include <sys/statfs.h>
+#include <kernel_stat.h>
 #include <stddef.h>
 #include <sysdep.h>
 #include <kernel-features.h>
@@ -70,3 +79,11 @@ __fstatfs64 (int fd, struct statfs64 *buf)
 #endif
 }
 weak_alias (__fstatfs64, fstatfs64)
+
+#undef __fstatfs
+#undef fstatfs
+
+#if STATFS_IS_STATFS64
+weak_alias (__fstatfs64, __fstatfs)
+weak_alias (__fstatfs64, fstatfs)
+#endif
diff --git a/sysdeps/unix/sysv/linux/generic/kernel_stat.h b/sysdeps/unix/sysv/linux/generic/kernel_stat.h
index 5d5f04b..ee9ff03 100644
--- a/sysdeps/unix/sysv/linux/generic/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/generic/kernel_stat.h
@@ -26,3 +26,5 @@
 #else
 # define XSTAT_IS_XSTAT64 0
 #endif
+
+#define STATFS_IS_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c
index be9599a..c199938 100644
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c
+++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c
@@ -18,8 +18,10 @@
 
 #include <errno.h>
 #include <sys/statfs.h>
+#include <kernel_stat.h>
 #include <stddef.h>
 
+#if !STATFS_IS_STATFS64
 #include "overflow.h"
 
 /* Return information about the filesystem on which FD resides.  */
@@ -30,3 +32,4 @@ __fstatfs (int fd, struct statfs *buf)
   return rc ?: statfs_overflow (buf);
 }
 weak_alias (__fstatfs, fstatfs)
+#endif
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c
index 1937f05..6413a54 100644
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c
+++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c
@@ -18,8 +18,10 @@
 
 #include <errno.h>
 #include <sys/statfs.h>
+#include <kernel_stat.h>
 #include <stddef.h>
 
+#if !STATFS_IS_STATFS64
 #include "overflow.h"
 
 /* Return information about the filesystem on which FILE resides.  */
@@ -31,3 +33,4 @@ __statfs (const char *file, struct statfs *buf)
 }
 libc_hidden_def (__statfs)
 weak_alias (__statfs, statfs)
+#endif
diff --git a/sysdeps/unix/sysv/linux/hppa/kernel_stat.h b/sysdeps/unix/sysv/linux/hppa/kernel_stat.h
index 9ffa3ba..a3ac53a 100644
--- a/sysdeps/unix/sysv/linux/hppa/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/hppa/kernel_stat.h
@@ -31,3 +31,4 @@ struct kernel_stat {
 #define _HAVE_STAT64_NSEC
 
 #define XSTAT_IS_XSTAT64 0
+#define STATFS_IS_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/ia64/kernel_stat.h b/sysdeps/unix/sysv/linux/ia64/kernel_stat.h
index 2f6fbb2..9541bb5 100644
--- a/sysdeps/unix/sysv/linux/ia64/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/ia64/kernel_stat.h
@@ -18,3 +18,4 @@
 
 #define STAT_IS_KERNEL_STAT 1
 #define XSTAT_IS_XSTAT64 1
+#define STATFS_IS_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/kernel_stat.h b/sysdeps/unix/sysv/linux/kernel_stat.h
index 4354d14..eecc962 100644
--- a/sysdeps/unix/sysv/linux/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/kernel_stat.h
@@ -35,3 +35,4 @@ struct kernel_stat
 #define _HAVE_STAT64_NSEC
 
 #define XSTAT_IS_XSTAT64 0
+#define STATFS_IS_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/microblaze/kernel_stat.h b/sysdeps/unix/sysv/linux/microblaze/kernel_stat.h
index b6ae8c3..3ce58df 100644
--- a/sysdeps/unix/sysv/linux/microblaze/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/microblaze/kernel_stat.h
@@ -49,3 +49,4 @@ struct kernel_stat
 };
 
 #define XSTAT_IS_XSTAT64 0
+#define STATFS_IS_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/mips/kernel_stat.h b/sysdeps/unix/sysv/linux/mips/kernel_stat.h
index a41d15f..388df1b 100644
--- a/sysdeps/unix/sysv/linux/mips/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/mips/kernel_stat.h
@@ -57,3 +57,4 @@ struct kernel_stat
 #endif
 
 #define XSTAT_IS_XSTAT64 0
+#define STATFS_IS_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h b/sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h
index 0fbde98..5b76f67 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h
@@ -48,3 +48,4 @@ struct kernel_stat
 #define _HAVE_STAT64_NSEC
 
 #define XSTAT_IS_XSTAT64 0
+#define STATFS_IS_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h
index fce8fba..eec1ab1 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h
@@ -18,3 +18,4 @@
 
 #define STAT_IS_KERNEL_STAT 1
 #define XSTAT_IS_XSTAT64 1
+#define STATFS_IS_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h b/sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h
index 2f6fbb2..9541bb5 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h
@@ -18,3 +18,4 @@
 
 #define STAT_IS_KERNEL_STAT 1
 #define XSTAT_IS_XSTAT64 1
+#define STATFS_IS_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h b/sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h
index eb60236..a441600 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h
@@ -32,3 +32,4 @@ struct kernel_stat
 #define _HAVE_STAT64_NSEC
 
 #define XSTAT_IS_XSTAT64 0
+#define STATFS_IS_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h b/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h
index 2a26a78..30afb55 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h
@@ -45,3 +45,4 @@ struct kernel_stat64
   };
 
 #define XSTAT_IS_XSTAT64 1
+#define STATFS_IS_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/statfs64.c b/sysdeps/unix/sysv/linux/statfs64.c
index de42261..4315fe5 100644
--- a/sysdeps/unix/sysv/linux/statfs64.c
+++ b/sysdeps/unix/sysv/linux/statfs64.c
@@ -16,9 +16,18 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+/* Hide the prototypes for __statfs and statfs so that GCC will not
+   complain about the different function signatures if they are aliased
+   to  __stat64.  If STATFS_IS_STATFS64 is not zero then the statfs and
+   statfs64 structures have an identical layout but different type names.  */
+
+#define __statfs __statfs_disable
+#define statfs statfs_disable
+
 #include <errno.h>
 #include <string.h>
 #include <sys/statfs.h>
+#include <kernel_stat.h>
 #include <stddef.h>
 #include <sysdep.h>
 #include <kernel-features.h>
@@ -72,3 +81,12 @@ __statfs64 (const char *file, struct statfs64 *buf)
 #endif
 }
 weak_alias (__statfs64, statfs64)
+
+#undef __statfs
+#undef statfs
+
+#if STATFS_IS_STATFS64
+weak_alias (__statfs64, __statfs)
+weak_alias (__statfs64, statfs)
+libc_hidden_ver (__statfs64, __statfs)
+#endif
diff --git a/sysdeps/unix/sysv/linux/x86_64/kernel_stat.h b/sysdeps/unix/sysv/linux/x86_64/kernel_stat.h
index 2f6fbb2..9541bb5 100644
--- a/sysdeps/unix/sysv/linux/x86_64/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/x86_64/kernel_stat.h
@@ -18,3 +18,4 @@
 
 #define STAT_IS_KERNEL_STAT 1
 #define XSTAT_IS_XSTAT64 1
+#define STATFS_IS_STATFS64 0

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Allow [f]statfs64 to alias [f]statfs
  2016-11-21 18:07   ` Steve Ellcey
@ 2016-11-22 13:16     ` Andreas Schwab
  2016-11-23  1:20     ` Joseph Myers
  1 sibling, 0 replies; 9+ messages in thread
From: Andreas Schwab @ 2016-11-22 13:16 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: Steve Ellcey, libc-alpha

On Nov 21 2016, Steve Ellcey <sellcey@caviumnetworks.com> wrote:

> 2016-11-21  Steve Ellcey  <sellcey@caviumnetworks.com>
>
> 	* sysdeps/unix/sysv/linux/fstatfs64.c: Hide prototypes for fstatfs
> 	and __fstatfs.  Make them aliases of __fstatfs64 if
> 	STATFS_IS_STATFS64 is set to non-zero.
> 	* sysdeps/unix/sysv/linux/statfs64.c: Ditto for __statfs, statfs,
> 	and __statfs64.
> 	* sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c: Do not
> 	define __fstatfs and fstatfs if STATFS_IS_STATFS64 is non-zero.
> 	* sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c: Ditto
> 	for __statfs and statfs.
> 	* sysdeps/unix/sysv/linux/alpha/kernel_stat.h: Set STATFS_IS_STATFS64
> 	to 0.
> 	* sysdeps/unix/sysv/linux/generic/kernel_stat.h: Ditto.
> 	* sysdeps/unix/sysv/linux/hppa/kernel_stat.h: Ditto.
> 	* sysdeps/unix/sysv/linux/ia64/kernel_stat.h: Ditto.
> 	* sysdeps/unix/sysv/linux/kernel_stat.h: Ditto.
> 	* sysdeps/unix/sysv/linux/microblaze/kernel_stat.h: Ditto.
> 	* sysdeps/unix/sysv/linux/mips/kernel_stat.h: Ditto.
> 	* sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h: Ditto.
> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h: Ditto.
> 	* sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h: Ditto.
> 	* sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h: Ditto.
> 	* sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h: Ditto.
> 	* sysdeps/unix/sysv/linux/x86_64/kernel_stat.h: Ditto.

Ok.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Allow [f]statfs64 to alias [f]statfs
  2016-11-21 18:07   ` Steve Ellcey
  2016-11-22 13:16     ` Andreas Schwab
@ 2016-11-23  1:20     ` Joseph Myers
  2016-11-23 16:23       ` Steve Ellcey
  1 sibling, 1 reply; 9+ messages in thread
From: Joseph Myers @ 2016-11-23  1:20 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: Andreas Schwab, Steve Ellcey, libc-alpha

I'm seeing a build failure for alpha with build-many-glibcs.py that seems 
likely related to this change:

/scratch/jmyers/glibc/many6/build/glibcs/alpha-linux-gnu/glibc/libc_pic.os: In function `__statfs64':
/scratch/jmyers/glibc/many6/build/glibcs/alpha-linux-gnu/glibc-src/io/../sysdeps/unix/sysv/linux/statfs64.c:65: undefined reference to `__GI___statfs_disable'
/scratch/jmyers/glibc/many6/build/glibcs/alpha-linux-gnu/glibc/libc_pic.os: In function `__fstatfs64':
/scratch/jmyers/glibc/many6/build/glibcs/alpha-linux-gnu/glibc-src/io/../sysdeps/unix/sysv/linux/fstatfs64.c:63: undefined reference to `__fstatfs_disable'
/scratch/jmyers/glibc/many6/build/glibcs/alpha-linux-gnu/glibc-src/io/../sysdeps/unix/sysv/linux/fstatfs64.c:63: undefined reference to `__fstatfs_disable'
collect2: error: ld returned 1 exit status
../Makerules:703: recipe for target '/scratch/jmyers/glibc/many6/build/glibcs/alpha-linux-gnu/glibc/libc.so' failed

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Allow [f]statfs64 to alias [f]statfs
  2016-11-23  1:20     ` Joseph Myers
@ 2016-11-23 16:23       ` Steve Ellcey
  0 siblings, 0 replies; 9+ messages in thread
From: Steve Ellcey @ 2016-11-23 16:23 UTC (permalink / raw)
  To: Joseph Myers; +Cc: Andreas Schwab, Steve Ellcey, libc-alpha

On Wed, 2016-11-23 at 00:01 +0000, Joseph Myers wrote:
> I'm seeing a build failure for alpha with build-many-glibcs.py that
> seems 
> likely related to this change:
> 
> /scratch/jmyers/glibc/many6/build/glibcs/alpha-linux-
> gnu/glibc/libc_pic.os: In function `__statfs64':
> /scratch/jmyers/glibc/many6/build/glibcs/alpha-linux-gnu/glibc-
> src/io/../sysdeps/unix/sysv/linux/statfs64.c:65: undefined reference
> to `__GI___statfs_disable'
> /scratch/jmyers/glibc/many6/build/glibcs/alpha-linux-
> gnu/glibc/libc_pic.os: In function `__fstatfs64':
> /scratch/jmyers/glibc/many6/build/glibcs/alpha-linux-gnu/glibc-
> src/io/../sysdeps/unix/sysv/linux/fstatfs64.c:63: undefined reference
> to `__fstatfs_disable'
> /scratch/jmyers/glibc/many6/build/glibcs/alpha-linux-gnu/glibc-
> src/io/../sysdeps/unix/sysv/linux/fstatfs64.c:63: undefined reference
> to `__fstatfs_disable'
> collect2: error: ld returned 1 exit status
> ../Makerules:703: recipe for target
> '/scratch/jmyers/glibc/many6/build/glibcs/alpha-linux-
> gnu/glibc/libc.so' failed

Yes, this is due to my patch.  I have reproduced the problem and am
working on a patch.  I failed to notice that on alpha, the only
platform where __ASSUME_STATFS64 is 0, __statfs64 will call __statfs
and if we have renamed __statfs with a define to __statfs_disable then
it breaks.   I am looking at putting the define under '#if
STATFS_IS_STATFS64', but I can't do that until after I have included
kernel_stat.h and I have to do it before including sys/stat.h for the
define to have any effect.  Hopefully that will fix things, but I am
still testing.

Steve Ellcey
sellcey@caviumnetworks.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-11-23 16:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-07 22:13 [PATCH] Allow [f]statfs64 to alias [f]statfs Steve Ellcey
2016-11-09 21:21 ` Steve Ellcey
2016-11-16 22:55   ` Steve Ellcey
2016-11-17  8:53 ` Andreas Schwab
2016-11-17 18:34   ` Steve Ellcey
2016-11-21 18:07   ` Steve Ellcey
2016-11-22 13:16     ` Andreas Schwab
2016-11-23  1:20     ` Joseph Myers
2016-11-23 16:23       ` Steve Ellcey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).