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]

[PATCH roland/off64_t] clean up wordsize-64 off_t functions


This gets rid of the sysdeps/wordsize-64 files that exist for the case
of off_t matching off64_t.  I've added a macro to bits/typesizes.h,
__OFF_T_MATCHES_OFF64_T.  This indicates that off_t and off64_t are
really the same width, even if they have incompatible source types (like
off_t reducing to 'long int' and off64_t reducing to 'long long int').

I've verified that this makes no difference in the x86_64-linux-gnu
build.  It needs testing (or just eyeball sign-off) for sparc(64),
s390(x), and alpha, and perhaps for x32.

If there are any linux-generic configurations where off_t matches off64_t,
i.e. __SLONGWORD_TYPE matches __SQUAD_TYPE (tilegx64?), then that will need
some additional attention too.  I'm not sure how best to handle that.
It would be nice not to add another bits/typesizes.h, but it may be
unavoidable unless every such machine predefines __LP64__ or something
like that.  In trunk GCC it looks like that is done generically, but I
don't know if all relevant GCC versions did that.

ia64 and powerpc64 don't have their own bits/typesizes.h files.  So some
more work will be required there too and again I'm not entirely sure
what's best to do.  We can make the generic bits/typesizes.h test
__LP64__, but I'm not positive that all compiler versions that we
support for those targets defined that.  (Note that here we have to be
concerned with all compilers that we support for building applications
with libc headers, not just the compilers we support for building libc
itself.)

There is a lot more such consolidation that could be done to get rid of
code in sysdeps/unix/sysv/linux/wordsize-64.  But I am not planning to
tackle that myself any time soon.  If someone else wants to take it up,
that would be great.

I think the reduction in hair and code duplication done here is good.
It's been mentioned before that wordsize-64 conflates too many concepts
and paring it down to just mean "'long int' is 64 bits" seems good in
its own right.  But my own motivation for this now is to support new
configurations where 'long int' is 32 bits but off_t is 64 bits.


Thanks,
Roland


2012-08-02  Roland McGrath  <roland@hack.frob.com>

	* libio/fseeko.c [__OFF_T_MATCHES_OFF64_T]:
	Define fseeko64 as an alias.
	* libio/ftello.c [__OFF_T_MATCHES_OFF64_T]:
	Define ftello64 as an alias.
	* libio/iofgetpos.c [__OFF_T_MATCHES_OFF64_T]:
	Define _IO_fgetpos64 and fgetpos64 as aliases.
	* libio/iofsetpos.c [__OFF_T_MATCHES_OFF64_T]:
	Define _IO_fsetpos64 and fsetpos64 as aliases.
	* libio/fseeko64.c [!__OFF_T_MATCHES_OFF64_T]:
	Conditionalize body on this.
	* libio/ftello64.c: Likewise.
	* libio/iofgetpos64.c: Likewise.
	* libio/iofsetpos64.c: Likewise.
	* sysdeps/wordsize-64/fseeko.c: File removed.
	* sysdeps/wordsize-64/fseeko64.c: File removed.
	* sysdeps/wordsize-64/ftello.c: File removed.
	* sysdeps/wordsize-64/ftello64.c: File removed.
	* sysdeps/wordsize-64/iofgetpos.c: File removed.
	* sysdeps/wordsize-64/iofgetpos64.c: File removed.
	* sysdeps/wordsize-64/iofsetpos.c: File removed.
	* sysdeps/wordsize-64/iofsetpos64.c: File removed.

	* sysdeps/unix/sysv/linux/s390/bits/typesizes.h:
	[__s390x__] (__OFF_T_MATCHES_OFF64_T): New macro.
	* sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
	[defined __arch64__ || defined __sparcv9]
	(__OFF_T_MATCHES_OFF64_T): New macro.
	* sysdeps/unix/sysv/linux/x86/bits/typesizes.h
	[__x86_64__] (__OFF_T_MATCHES_OFF64_T): New macro.
	* sysdeps/unix/bsd/bsd4.4/freebsd/bits/typesizes.h
	(__OFF_T_MATCHES_OFF64_T): New macro.

ports/ChangeLog.alpha
2012-08-02  Roland McGrath  <roland@hack.frob.com>

	* sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
	(__OFF_T_MATCHES_OFF64_T): New macro.


diff --git a/libio/fseeko.c b/libio/fseeko.c
index 7a70636..6d37aea 100644
--- a/libio/fseeko.c
+++ b/libio/fseeko.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,1995,1996,1997,1998,2003 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -40,3 +40,7 @@ fseeko (fp, offset, whence)
   _IO_release_lock (fp);
   return result;
 }
+
+#ifdef __OFF_T_MATCHES_OFF64_T
+weak_alias (fseeko, fseeko64)
+#endif
diff --git a/libio/fseeko64.c b/libio/fseeko64.c
index 2291f61..9fbe308 100644
--- a/libio/fseeko64.c
+++ b/libio/fseeko64.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,1995,1996,1997,1998,2003 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -28,6 +28,9 @@
 #include "libioP.h"
 #include "stdio.h"
 
+/* fseeko.c defines this as an alias if __OFF_T_MATCHES_OFF64_T.  */
+#ifndef __OFF_T_MATCHES_OFF64_T
+
 int
 fseeko64 (fp, offset, whence)
      _IO_FILE* fp;
@@ -46,3 +49,5 @@ fseeko64 (fp, offset, whence)
   return -1;
 #endif
 }
+
+#endif
diff --git a/libio/ftello.c b/libio/ftello.c
index 1d85bc6..9052276 100644
--- a/libio/ftello.c
+++ b/libio/ftello.c
@@ -1,5 +1,4 @@
-/* Copyright (C) 1993, 1995-2001, 2002, 2003, 2004, 2007
-   Free Software Foundation, Inc.
+/* Copyright (C) 1993-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -63,3 +62,7 @@ ftello (fp)
   return pos;
 }
 libc_hidden_def (ftello)
+
+#ifdef __OFF_T_MATCHES_OFF64_T
+weak_alias (ftello, ftello64)
+#endif
diff --git a/libio/ftello64.c b/libio/ftello64.c
index 0f70c66..852ef71 100644
--- a/libio/ftello64.c
+++ b/libio/ftello64.c
@@ -1,5 +1,4 @@
-/* Copyright (C) 1993, 1995-2001, 2002, 2003, 2004
-   Free Software Foundation, Inc.
+/* Copyright (C) 1993-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -30,6 +29,7 @@
 #include <libioP.h>
 #include <errno.h>
 
+#ifndef __OFF_T_MATCHES_OFF64_T
 
 off64_t
 ftello64 (fp)
@@ -60,3 +60,5 @@ ftello64 (fp)
   return -1;
 #endif
 }
+
+#endif
diff --git a/libio/iofgetpos.c b/libio/iofgetpos.c
index 4338b50..a1d6bb6 100644
--- a/libio/iofgetpos.c
+++ b/libio/iofgetpos.c
@@ -1,5 +1,4 @@
-/* Copyright (C) 1993, 1995-2001, 2002, 2003, 2004
-   Free Software Foundation, Inc.
+/* Copyright (C) 1993-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -25,7 +24,17 @@
    This exception applies to code released by its copyright holders
    in files containing the exception.  */
 
+/* We need to avoid the header declarations of these, because
+   the types don't match _IO_fgetpos and then the compiler will
+   complain about the mismatch when we do the alias below.  */
+#define _IO_new_fgetpos64 __renamed__IO_new_fgetpos64
+#define _IO_fgetpos64 __renamed__IO_fgetpos64
+
 #include "libioP.h"
+
+#undef _IO_new_fgetpos64
+#undef _IO_fgetpos64
+
 #include <errno.h>
 #include <stdlib.h>
 #include <shlib-compat.h>
@@ -78,3 +87,10 @@ _IO_new_fgetpos (fp, posp)
 strong_alias (_IO_new_fgetpos, __new_fgetpos)
 versioned_symbol (libc, _IO_new_fgetpos, _IO_fgetpos, GLIBC_2_2);
 versioned_symbol (libc, __new_fgetpos, fgetpos, GLIBC_2_2);
+
+#ifdef __OFF_T_MATCHES_OFF64_T
+strong_alias (_IO_new_fgetpos, _IO_new_fgetpos64)
+strong_alias (_IO_new_fgetpos64, __new_fgetpos64)
+versioned_symbol (libc, _IO_new_fgetpos64, _IO_fgetpos64, GLIBC_2_2);
+versioned_symbol (libc, __new_fgetpos64, fgetpos64, GLIBC_2_2);
+#endif
diff --git a/libio/iofgetpos64.c b/libio/iofgetpos64.c
index 0cb141b..9755c32 100644
--- a/libio/iofgetpos64.c
+++ b/libio/iofgetpos64.c
@@ -1,5 +1,4 @@
-/* Copyright (C) 1993, 1995-2001, 2002, 2003, 2004
-   Free Software Foundation, Inc.
+/* Copyright (C) 1993-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -29,6 +28,7 @@
 #include <errno.h>
 #include <shlib-compat.h>
 
+#ifndef __OFF_T_MATCHES_OFF64_T
 
 int
 _IO_new_fgetpos64 (fp, posp)
@@ -75,3 +75,5 @@ _IO_new_fgetpos64 (fp, posp)
 strong_alias (_IO_new_fgetpos64, __new_fgetpos64)
 versioned_symbol (libc, _IO_new_fgetpos64, _IO_fgetpos64, GLIBC_2_2);
 versioned_symbol (libc, __new_fgetpos64, fgetpos64, GLIBC_2_2);
+
+#endif
diff --git a/libio/iofsetpos.c b/libio/iofsetpos.c
index 19bea3b..5e8d444 100644
--- a/libio/iofsetpos.c
+++ b/libio/iofsetpos.c
@@ -1,5 +1,4 @@
-/* Copyright (C) 1993, 1995, 1997, 1998, 1999, 2000, 2002, 2003
-   Free Software Foundation, Inc.
+/* Copyright (C) 1993-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -25,7 +24,17 @@
    This exception applies to code released by its copyright holders
    in files containing the exception.  */
 
+/* We need to avoid the header declarations of these, because
+   the types don't match _IO_fsetpos and then the compiler will
+   complain about the mismatch when we do the alias below.  */
+#define _IO_new_fsetpos64 __renamed__IO_new_fsetpos64
+#define _IO_fsetpos64 __renamed__IO_fsetpos64
+
 #include <libioP.h>
+
+#undef _IO_new_fsetpos64
+#undef _IO_fsetpos64
+
 #include <errno.h>
 #include <shlib-compat.h>
 
@@ -63,3 +72,10 @@ _IO_new_fsetpos (fp, posp)
 strong_alias (_IO_new_fsetpos, __new_fsetpos)
 versioned_symbol (libc, _IO_new_fsetpos, _IO_fsetpos, GLIBC_2_2);
 versioned_symbol (libc, __new_fsetpos, fsetpos, GLIBC_2_2);
+
+#ifdef __OFF_T_MATCHES_OFF64_T
+strong_alias (_IO_new_fsetpos, _IO_new_fsetpos64)
+strong_alias (_IO_new_fsetpos64, __new_fsetpos64)
+versioned_symbol (libc, __new_fsetpos64, fsetpos64, GLIBC_2_2);
+versioned_symbol (libc, _IO_new_fsetpos64, _IO_fsetpos64, GLIBC_2_2);
+#endif
diff --git a/libio/iofsetpos64.c b/libio/iofsetpos64.c
index 9835c12..20edd8d 100644
--- a/libio/iofsetpos64.c
+++ b/libio/iofsetpos64.c
@@ -1,5 +1,4 @@
-/* Copyright (C) 1993, 1995, 1997, 1998, 1999, 2000, 2002, 2003
-   Free Software Foundation, Inc.
+/* Copyright (C) 1993-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -29,6 +28,8 @@
 #include <errno.h>
 #include <shlib-compat.h>
 
+#ifndef __OFF_T_MATCHES_OFF64_T
+
 int
 _IO_new_fsetpos64 (fp, posp)
      _IO_FILE *fp;
@@ -68,3 +69,5 @@ _IO_new_fsetpos64 (fp, posp)
 strong_alias (_IO_new_fsetpos64, __new_fsetpos64)
 versioned_symbol (libc, __new_fsetpos64, fsetpos64, GLIBC_2_2);
 versioned_symbol (libc, _IO_new_fsetpos64, _IO_fsetpos64, GLIBC_2_2);
+
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h b/ports/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
index 2dbeb42..31258e4 100644
--- a/ports/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
+++ b/ports/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
@@ -1,5 +1,5 @@
 /* bits/typesizes.h -- underlying types for *_t.  Linux/Alpha version.
-   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2002-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -61,6 +61,10 @@
 #define __SYSCALL_ULONG_TYPE	__ULONGWORD_TYPE
 #define __FSWORD_T_TYPE		__S32_TYPE
 
+/* Tell the libc code that off_t and off64_t are actually the same type
+   for all ABI purposes, even if possibly expressed as different base types
+   for C type-checking purposes.  */
+#define __OFF_T_MATCHES_OFF64_T	1
 
 /* Number of descriptors that can fit in an `fd_set'.  */
 #define	__FD_SETSIZE		1024
diff --git a/sysdeps/unix/bsd/bsd4.4/freebsd/bits/typesizes.h b/sysdeps/unix/bsd/bsd4.4/freebsd/bits/typesizes.h
index 02c24e4..67d82e6 100644
--- a/sysdeps/unix/bsd/bsd4.4/freebsd/bits/typesizes.h
+++ b/sysdeps/unix/bsd/bsd4.4/freebsd/bits/typesizes.h
@@ -61,6 +61,11 @@
 #define __SYSCALL_SLONG_TYPE	__SLONGWORD_TYPE
 #define __SYSCALL_ULONG_TYPE	__ULONGWORD_TYPE
 
+
+/* Tell the libc code that off_t and off64_t are actually the same type.  */
+#define __OFF_T_MATCHES_OFF64_T	1
+
+
 /* Number of descriptors that can fit in an `fd_set'.  */
 #define	__FD_SETSIZE		1024
 
diff --git a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h
index def84cc..bf3d8b7 100644
--- a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h
@@ -67,6 +67,13 @@
 #define __SYSCALL_SLONG_TYPE	__SLONGWORD_TYPE
 #define __SYSCALL_ULONG_TYPE	__ULONGWORD_TYPE
 
+#ifdef __s390x__
+/* Tell the libc code that off_t and off64_t are actually the same type
+   for all ABI purposes, even if possibly expressed as different base types
+   for C type-checking purposes.  */
+# define __OFF_T_MATCHES_OFF64_T	1
+#endif
+
 /* Number of descriptors that can fit in an `fd_set'.  */
 #define	__FD_SETSIZE		1024
 
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
index b65a1a5..7b1f191 100644
--- a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
@@ -61,6 +61,13 @@
 #define __SYSCALL_SLONG_TYPE	__SLONGWORD_TYPE
 #define __SYSCALL_ULONG_TYPE	__ULONGWORD_TYPE
 
+#if defined __arch64__ || defined __sparcv9
+/* Tell the libc code that off_t and off64_t are actually the same type
+   for all ABI purposes, even if possibly expressed as different base types
+   for C type-checking purposes.  */
+# define __OFF_T_MATCHES_OFF64_T	1
+#endif
+
 /* Number of descriptors that can fit in an `fd_set'.  */
 #define	__FD_SETSIZE		1024
 
diff --git a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h
index be8985b..a477627 100644
--- a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h
@@ -73,6 +73,13 @@
 #define __FSID_T_TYPE		struct { int __val[2]; }
 #define __SSIZE_T_TYPE		__SWORD_TYPE
 
+#ifdef __x86_64__
+/* Tell the libc code that off_t and off64_t are actually the same type
+   for all ABI purposes, even if possibly expressed as different base types
+   for C type-checking purposes.  */
+# define __OFF_T_MATCHES_OFF64_T	1
+#endif
+
 /* Number of descriptors that can fit in an `fd_set'.  */
 #define __FD_SETSIZE		1024
 
diff --git a/sysdeps/wordsize-64/fseeko.c b/sysdeps/wordsize-64/fseeko.c
deleted file mode 100644
index 692885a..0000000
--- a/sysdeps/wordsize-64/fseeko.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "../../libio/fseeko.c"
-
-weak_alias (fseeko, fseeko64)
diff --git a/sysdeps/wordsize-64/fseeko64.c b/sysdeps/wordsize-64/fseeko64.c
deleted file mode 100644
index 73e011a..0000000
--- a/sysdeps/wordsize-64/fseeko64.c
+++ /dev/null
@@ -1 +0,0 @@
-/* Defined in fseeko.c.  */
diff --git a/sysdeps/wordsize-64/ftello.c b/sysdeps/wordsize-64/ftello.c
deleted file mode 100644
index fa05cfc..0000000
--- a/sysdeps/wordsize-64/ftello.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "../../libio/ftello.c"
-
-weak_alias (ftello, ftello64)
diff --git a/sysdeps/wordsize-64/ftello64.c b/sysdeps/wordsize-64/ftello64.c
deleted file mode 100644
index 2cbbe63..0000000
--- a/sysdeps/wordsize-64/ftello64.c
+++ /dev/null
@@ -1 +0,0 @@
-/* Defined in ftello.c.  */
diff --git a/sysdeps/wordsize-64/iofgetpos.c b/sysdeps/wordsize-64/iofgetpos.c
deleted file mode 100644
index ba8df67..0000000
--- a/sysdeps/wordsize-64/iofgetpos.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#define _IO_new_fgetpos64 __renamed__IO_new_fgetpos64
-#define _IO_fgetpos64 __renamed__IO_fgetpos64
-
-#include "../../libio/iofgetpos.c"
-
-#undef _IO_new_fgetpos64
-#undef _IO_fgetpos64
-
-strong_alias (_IO_new_fgetpos, _IO_new_fgetpos64)
-strong_alias (_IO_new_fgetpos64, __new_fgetpos64)
-versioned_symbol (libc, _IO_new_fgetpos64, _IO_fgetpos64, GLIBC_2_2);
-versioned_symbol (libc, __new_fgetpos64, fgetpos64, GLIBC_2_2);
diff --git a/sysdeps/wordsize-64/iofgetpos64.c b/sysdeps/wordsize-64/iofgetpos64.c
deleted file mode 100644
index 1748b810..0000000
--- a/sysdeps/wordsize-64/iofgetpos64.c
+++ /dev/null
@@ -1 +0,0 @@
-/* Defined in iofgetpos.c.  */
diff --git a/sysdeps/wordsize-64/iofsetpos.c b/sysdeps/wordsize-64/iofsetpos.c
deleted file mode 100644
index f2bb8ae..0000000
--- a/sysdeps/wordsize-64/iofsetpos.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#define _IO_new_fsetpos64 __renamed__IO_new_fsetpos64
-#define _IO_fsetpos64 __renamed__IO_fsetpos64
-
-#include "../../libio/iofsetpos.c"
-
-#undef _IO_new_fsetpos64
-#undef _IO_fsetpos64
-
-strong_alias (_IO_new_fsetpos, _IO_new_fsetpos64)
-strong_alias (_IO_new_fsetpos64, __new_fsetpos64)
-versioned_symbol (libc, __new_fsetpos64, fsetpos64, GLIBC_2_2);
-versioned_symbol (libc, _IO_new_fsetpos64, _IO_fsetpos64, GLIBC_2_2);
diff --git a/sysdeps/wordsize-64/iofsetpos64.c b/sysdeps/wordsize-64/iofsetpos64.c
deleted file mode 100644
index 5fbc732..0000000
--- a/sysdeps/wordsize-64/iofsetpos64.c
+++ /dev/null
@@ -1 +0,0 @@
-/* Defined in iofsetpos.c.  */


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