mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
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.
156 lines
3.9 KiB
C
156 lines
3.9 KiB
C
/***********************************************************************
|
|
* *
|
|
* This software is part of the ast package *
|
|
* Copyright (c) 1985-2011 AT&T Intellectual Property *
|
|
* Copyright (c) 2020-2021 Contributors to ksh 93u+m *
|
|
* and is licensed under the *
|
|
* Eclipse Public License, Version 1.0 *
|
|
* by AT&T Intellectual Property *
|
|
* *
|
|
* A copy of the License is available at *
|
|
* http://www.eclipse.org/org/documents/epl-v10.html *
|
|
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
|
|
* *
|
|
* Information and Software Systems Research *
|
|
* AT&T Research *
|
|
* Florham Park NJ *
|
|
* *
|
|
* Glenn Fowler <gsf@research.att.com> *
|
|
* David Korn <dgk@research.att.com> *
|
|
* Phong Vo <kpv@research.att.com> *
|
|
* *
|
|
***********************************************************************/
|
|
/*
|
|
* AT&T Research
|
|
*
|
|
* directory stream access library private definitions
|
|
* library routines should include this file rather than <dirent.h>
|
|
*/
|
|
|
|
#ifndef _DIRLIB_H
|
|
#define _DIRLIB_H
|
|
|
|
#if defined(__STDPP__directive) && defined(__STDPP__hide)
|
|
__STDPP__directive pragma pp:hide getdents getdirentries
|
|
#else
|
|
#undef getdents
|
|
#define getdents ______getdents
|
|
#undef getdirentries
|
|
#define getdirentries ______getdirentries
|
|
#endif
|
|
|
|
#include <ast.h>
|
|
#include <errno.h>
|
|
|
|
#if _lib_opendir && ( _hdr_dirent || _hdr_ndir || _sys_dir )
|
|
|
|
#define _dir_ok 1
|
|
|
|
#include <ls.h>
|
|
|
|
#ifndef _DIRENT_H
|
|
#if _hdr_dirent
|
|
#include <dirent.h>
|
|
#else
|
|
#if _hdr_ndir
|
|
#include <ndir.h>
|
|
#else
|
|
#include <sys/dir.h>
|
|
#endif
|
|
#ifndef dirent
|
|
#define dirent direct
|
|
#endif
|
|
#endif
|
|
#endif
|
|
|
|
#define DIRdirent dirent
|
|
|
|
#else
|
|
|
|
#define dirent DIRdirent
|
|
|
|
#if defined(__STDPP__directive) && defined(__STDPP__hide)
|
|
__STDPP__directive pragma pp:hide DIR closedir opendir readdir seekdir telldir
|
|
#else
|
|
#undef DIR
|
|
#define DIR ______DIR
|
|
#undef closedir
|
|
#define closedir ______closedir
|
|
#undef opendir
|
|
#define opendir ______opendir
|
|
#undef readdir
|
|
#define readdir ______readdir
|
|
#undef seekdir
|
|
#define seekdir ______seekdir
|
|
#undef telldir
|
|
#define telldir ______telldir
|
|
#endif
|
|
|
|
#include <ast_param.h>
|
|
|
|
#include <ls.h>
|
|
#include <limits.h>
|
|
|
|
#ifndef _DIRENT_H
|
|
#if _hdr_dirent
|
|
#include <dirent.h>
|
|
#else
|
|
#if _hdr_direntry
|
|
#include <direntry.h>
|
|
#else
|
|
#include <sys/dir.h>
|
|
#endif
|
|
#endif
|
|
#endif
|
|
|
|
#undef dirent
|
|
#if defined(__STDPP__directive) && defined(__STDPP__hide)
|
|
__STDPP__directive pragma pp:nohide DIR closedir opendir readdir seekdir telldir
|
|
#else
|
|
#undef DIR
|
|
#undef closedir
|
|
#undef opendir
|
|
#undef readdir
|
|
#undef seekdir
|
|
#undef telldir
|
|
#endif
|
|
|
|
#define _DIR_PRIVATE_ \
|
|
int dd_loc; /* offset in block */ \
|
|
int dd_size; /* valid data in block */ \
|
|
char* dd_buf; /* directory block */
|
|
|
|
#undef _DIRENT_H
|
|
#include "dirstd.h"
|
|
#ifndef _DIRENT_H
|
|
#define _DIRENT_H 1
|
|
#endif
|
|
|
|
#ifndef DIRBLKSIZ
|
|
#ifdef DIRBLK
|
|
#define DIRBLKSIZ DIRBLK
|
|
#else
|
|
#ifdef DIRBUF
|
|
#define DIRBLKSIZ DIRBUF
|
|
#else
|
|
#define DIRBLKSIZ 8192
|
|
#endif
|
|
#endif
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#if defined(__STDPP__directive) && defined(__STDPP__hide)
|
|
__STDPP__directive pragma pp:nohide getdents getdirentries
|
|
#else
|
|
#undef getdents
|
|
#undef getdirentries
|
|
#endif
|
|
|
|
#ifndef errno
|
|
extern int errno;
|
|
#endif
|
|
|
|
extern ssize_t getdents(int, void*, size_t);
|
|
|
|
#endif
|