mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
build: include standards macros for all AST code (re: 7fb814e1)
Turns out that the standards macros set by features/standards (such as _GNU_SOURCE for Linux or _DARWIN_SOURCE for macOS) were still *not* included for most C source files! Instead, they were selectively included for some files only, sometimes via FEATURE/standards (the output of features/standards), sometimes via ast_standards.h which is copied from FEATURE/standards. Consequently, there were still inconsistencies in the system header interfaces exposed on Linux, macOS, Solaris, et al. It's no wonder it sometimes took so much hackery to keep everything building. Of course, making this consistent had to break things somewhere. Breakage occurred on 32-bit Linux due to a lot of ugly hackery involving direct use of internal GNU types like off64_t and functions like fseek64(). This is now all removed and they are activated by setting the appropriate feature macro instead, so these types and functions can be used with their standard names (off_t, fseek, etc.) Before committing I've tested these changes on the following i386/x86_64 systems: Linux (glibc 32 and 64 bit, musl libc 64 bit), Solaris (32 and 64 bit), illumos (32 and 64 bit), FreeBSD (64 bit), macOS (64 bit), Cygwin (32 bit), and Haiku (64 bit). (Note: ast_standards.h is copied from FEATURE/standards, whereas ast_common.h is copied from FEATURE/common.) src/lib/libast/include/ast_std.h, src/lib/libast/stdio/stdhdr.h: - Include <ast_standards.h> first. This should cause all the AST and dependent code (such as ksh) to get the standards macros. src/lib/libast/features/standards: - For GNU (glibc), #define _FILE_OFFSET_BITS 64 to get large file support with 64-bit offsets. - Stop GNU and Cygwin <string.h> form defining the GNU version of basename(3); on Cygwin, that declaration conflicts with the AST version (and with POSIX) by using a const char* argument instead of char*. It is deactivated by defining the macro 'basename' (as 'basename'); this causes GNU string.h to consider it to be already defined by the standard libgen.h header. All other changed files: - Remove direct use of *64* types and functions and a lot of related hackery.
This commit is contained in:
parent
fb8e239cb4
commit
289dd46c05
43 changed files with 78 additions and 872 deletions
|
|
@ -128,23 +128,14 @@ elif tst note{ SunOS (Solaris, illumos) }end compile{
|
|||
}
|
||||
elif tst note{ GNU (glibc) or Cygwin }end compile{
|
||||
/*
|
||||
* GNU (GNU's Not UNIX). From feature_test_macros(7) on a GNU/Linux system with glibc 2.32:
|
||||
*
|
||||
* _GNU_SOURCE
|
||||
* Defining this macro (with any value) implicitly defines _ATFILE_SOURCE, _LARGE‐
|
||||
* FILE64_SOURCE, _ISOC99_SOURCE, _XOPEN_SOURCE_EXTENDED, _POSIX_SOURCE,
|
||||
* _POSIX_C_SOURCE with the value 200809L (200112L in glibc versions before 2.10;
|
||||
* 199506L in glibc versions before 2.5; 199309L in glibc versions before 2.1) and
|
||||
* _XOPEN_SOURCE with the value 700 (600 in glibc versions before 2.10; 500 in
|
||||
* glibc versions before 2.2). In addition, various GNU-specific extensions are
|
||||
* also exposed.
|
||||
* Since glibc 2.19, defining _GNU_SOURCE also has the effect of implicitly defin‐
|
||||
* ing _DEFAULT_SOURCE. In glibc versions before 2.20, defining _GNU_SOURCE also
|
||||
* had the effect of implicitly defining _BSD_SOURCE and _SVID_SOURCE.
|
||||
*
|
||||
* Additionally, on Cygwin we must use _GNU_SOURCE to enable all features required by libast.
|
||||
* On GNU (GNU's Not UNIX) and Cygwin, _GNU_SOURCE is the "everything and the kitchen sink" macro
|
||||
* (see feature_test_macros(7)), but on GNU we also need to define _FILE_OFFSET_BITS to get large
|
||||
* file support. We also need to define 'basename' to stop string.h from declaring a GNU-specific
|
||||
* version of basename(3) which on Cygwin has a declaration that conflicts with AST basename(3).
|
||||
*/
|
||||
#define _GNU_SOURCE 1
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
#define basename basename
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
#include <features.h>
|
||||
|
|
@ -164,9 +155,9 @@ elif tst note{ GNU (glibc) or Cygwin }end compile{
|
|||
return 0;
|
||||
}
|
||||
}end {
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
#define basename basename /* avoid string.h defining this in conflict with AST basename(3) */
|
||||
}
|
||||
elif tst note{ _ALL_SOURCE & _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works }end compile{
|
||||
#define _ALL_SOURCE 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue