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: [RFC] Make _FILE_OFFSET_BITS=64 default.


On 03/19/2014 02:14 AM, Mike Frysinger wrote:
i have gotten complaints in the past that glibc provided half-baked support
for static assert when building with <gcc-4.6.  so this would make those
people happy too:).
OK, I'm attaching the patch in more formal form, broken into two parts (one for _Static_assert, one for fts.h, the latter dependent on the former), for further review. I'd like to install it unless further objections turn up.

>From 336847aecca1c90fb7f1ec000d47648d7221fa1c Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Wed, 19 Mar 2014 10:59:31 -0700
Subject: [PATCH 1/2] Approximate _Static_assert for pre-C11 compilers.

* misc/sys/cdefs.h (_Static_assert) [__STDC_VERSION__ < 201112L]:
New macro, for convenience with pre-C11 compilers.
---
 ChangeLog        | 6 ++++++
 misc/sys/cdefs.h | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index f48f6bb..3d4c88d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-03-19  Paul Eggert  <eggert@cs.ucla.edu>
+
+	Approximate _Static_assert for pre-C11 compilers.
+	* misc/sys/cdefs.h (_Static_assert) [__STDC_VERSION__ < 201112L]:
+	New macro, for convenience with pre-C11 compilers.
+
 2014-03-19  Joseph Myers  <joseph@codesourcery.com>
 
 	* math/libm-test.inc (fdim_test): Use ALL_RM_TEST.
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 4d958ea..7e42d49 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -382,6 +382,12 @@
 # define __glibc_likely(cond)	(cond)
 #endif
 
+#if (!defined _Static_assert \
+     && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L))
+# define _Static_assert(e, s) extern int (*__glibc_Static_assert (void)) \
+    [sizeof (struct { unsigned int _Static_assert_failure: (e) ? 1 : -1; })]
+#endif
+
 #include <bits/wordsize.h>
 
 #if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
-- 
1.8.5.3

>From 2d6753840038501ff2be16672e5e12e6ff90b0ad Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Wed, 19 Mar 2014 11:01:42 -0700
Subject: [PATCH 2/2] fts: allow _FILE_OFFSET_BITS=64 on 64-bit hosts

* io/fts.h: Use _Static_assert to check for _FILE_OFFSET_BITS problem,
so that we don't unnecessarily reject compilations with
_FILE_OFFSET_BITS=64 on 64-bit hosts.
---
 ChangeLog | 5 +++++
 io/fts.h  | 8 +++++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3d4c88d..834a973 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2014-03-19  Paul Eggert  <eggert@cs.ucla.edu>
 
+	fts: allow _FILE_OFFSET_BITS=64 on 64-bit hosts
+	* io/fts.h: Use _Static_assert to check for _FILE_OFFSET_BITS problem,
+	so that we don't unnecessarily reject compilations with
+	_FILE_OFFSET_BITS=64 on 64-bit hosts.
+
 	Approximate _Static_assert for pre-C11 compilers.
 	* misc/sys/cdefs.h (_Static_assert) [__STDC_VERSION__ < 201112L]:
 	New macro, for convenience with pre-C11 compilers.
diff --git a/io/fts.h b/io/fts.h
index 0a070ba..f71f550 100644
--- a/io/fts.h
+++ b/io/fts.h
@@ -35,10 +35,12 @@
 #include <features.h>
 #include <sys/types.h>
 
-/* The fts interface is incompatible with the LFS interface which
-   transparently uses the 64-bit file access functions.  */
+/* When off_t is not 64 bits, the fts interface is incompatible with
+   the LFS interface which transparently uses the 64-bit file access
+   functions.  */
 #ifdef __USE_FILE_OFFSET64
-# error "<fts.h> cannot be used with -D_FILE_OFFSET_BITS==64"
+_Static_assert (sizeof (__off_t) == sizeof (__off64_t),
+		"<fts.h> cannot be used with 64-bit off_t on this platform");
 #endif
 
 
-- 
1.8.5.3


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