public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix for [f]statfs64/[f]statfs aliasing patch
@ 2016-11-23 18:21 Steve Ellcey
  2016-11-24  8:53 ` Andreas Schwab
  0 siblings, 1 reply; 2+ messages in thread
From: Steve Ellcey @ 2016-11-23 18:21 UTC (permalink / raw)
  To: libc-alpha; +Cc: Joseph Myers, Andreas Schwab

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

This patch is a fix to my earlier statfs patch 
(https://sourceware.org/ml/libc-alpha/2016-11/msg00360.html) that allowed
statfs/fstatfs to be aliases of statfs64/fstatfs64 but broke the alpha
build.  When doing this aliasing it is necessary that the prototypes of
[f]statfs not be seen because they differ from that of [f]statfs64.  They
have the same structures but different names, so GCC will complain when
doing the aliasing.  My initial patch used a #define to hide the prototypes
of [f]statfs and __[f]statfs when defining [f]statfs64 but I hadn't noticed
that when __ASSUME_STATFS64 is 0, the [f]statfs64 function calls __[f]statfs
and if we have changed the name of this with a define then [f]statfs64 will
call the wrong (and undefined) function.  This only happens on alpha which is
the only platform where __ASSUME_STATFS64 is 0.

This patch fixes the problem by only hiding the [f]statfs definitions if
STATFS_IS_STATFS64 is set to non-zero, which is also the only time we do the
aliasing.  To do this I had to change the order of the includes because we
cannot check STATFS_IS_STATFS64 until after we have included kernel_stat.h
but we must do it before including sys/stat.h which is where the [f]statfs
prototypes are defined.

I have tested this and verified that it builds for alpha (using the
build-many-glibcs.py script) and also verified it builds and has no testsuite
regressions on x86 and aarch64.

OK to checkin?

Steve Ellcey
sellcey@caviumnetworks.com

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

	* sysdeps/unix/sysv/linux/fstatfs64.c: Reorder include files,
	only alias fstatfs and __fstatfs if STATFS_IS_STATFS64 is non-zero.
	* sysdeps/unix/sysv/linux/statfs64.c: Ditto for statfs and __statfs.

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

diff --git a/sysdeps/unix/sysv/linux/fstatfs64.c b/sysdeps/unix/sysv/linux/fstatfs64.c
index a95fe18..42b2257 100644
--- a/sysdeps/unix/sysv/linux/fstatfs64.c
+++ b/sysdeps/unix/sysv/linux/fstatfs64.c
@@ -16,20 +16,23 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#include <errno.h>
+#include <string.h>
+#include <stddef.h>
+#include <sysdep.h>
+#include <kernel_stat.h>
+
 /* 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>
+#if STATFS_IS_STATFS64
+# define __fstatfs __fstatfs_disable
+# define fstatfs fstatfs_disable
+#endif
 #include <sys/statfs.h>
-#include <kernel_stat.h>
-#include <stddef.h>
-#include <sysdep.h>
+
 #include <kernel-features.h>
 
 /* Defined in statfs64.c.  */
diff --git a/sysdeps/unix/sysv/linux/statfs64.c b/sysdeps/unix/sysv/linux/statfs64.c
index 4315fe5..9dbd61f 100644
--- a/sysdeps/unix/sysv/linux/statfs64.c
+++ b/sysdeps/unix/sysv/linux/statfs64.c
@@ -16,20 +16,23 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#include <errno.h>
+#include <string.h>
+#include <stddef.h>
+#include <sysdep.h>
+#include <kernel_stat.h>
+
 /* 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>
+#if STATFS_IS_STATFS64
+# define __statfs __statfs_disable
+# define statfs statfs_disable
+#endif
 #include <sys/statfs.h>
-#include <kernel_stat.h>
-#include <stddef.h>
-#include <sysdep.h>
+
 #include <kernel-features.h>
 
 

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

* Re: [PATCH] Fix for [f]statfs64/[f]statfs aliasing patch
  2016-11-23 18:21 [PATCH] Fix for [f]statfs64/[f]statfs aliasing patch Steve Ellcey
@ 2016-11-24  8:53 ` Andreas Schwab
  0 siblings, 0 replies; 2+ messages in thread
From: Andreas Schwab @ 2016-11-24  8:53 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: libc-alpha, Joseph Myers

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

> This patch fixes the problem by only hiding the [f]statfs definitions if
> STATFS_IS_STATFS64 is set to non-zero, which is also the only time we do the
> aliasing.  To do this I had to change the order of the includes because we
> cannot check STATFS_IS_STATFS64 until after we have included kernel_stat.h
> but we must do it before including sys/stat.h which is where the [f]statfs
> prototypes are defined.

A simpler approach would probably be to move the #undef up directly
after the include.

Ok either way.

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] 2+ messages in thread

end of thread, other threads:[~2016-11-24  8:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-23 18:21 [PATCH] Fix for [f]statfs64/[f]statfs aliasing patch Steve Ellcey
2016-11-24  8:53 ` Andreas Schwab

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).