Permalink
Fetching contributors…
Cannot retrieve contributors at this time
249 lines (228 sloc) 7.81 KB
// These are all the symbols defined by the legacy Nmake/iffe based build
// system I could identify. Some of them may no longer be relevant because we
// have pruned a lot of the code that is not relevant to building the `ksh`
// and related binaries and libraries. Nonetheless, those symbols are included
// here just in case we've overlooked something in the transition to the Meson
// build tool.
//
// I am explicitly including all such symbols to help us identify areas where we
// may be missing a platform feature test. Such symbols will show up as
// `#undef` comments after the Meson config step has been run to produce the
// `build/config_ast.h` header. There will be a lot of false positives until
// we have removed symbols that are known to no longer be relevant.
//
// TODO: At some point in the future (e.g., 2019-01-01) irrelevant items in
// the following list can be removed and the preceding paragraph removed.
// The following symbols are in lexical order within a given prefix; e.g.,
// `_lib_`. But the prefix groups are not in lexical order. The esoteric
// prefix groups are listed first. The standard prefix symbols (e.g., `_sys_`,
// `_hdr_`, etc.) based on tests like `cc.has_function()` or `cc.has_header()`
// are enumerated later.
#ifndef _CONFIG_AST_H
#define _CONFIG_AST_H 1
#define _GNU_SOURCE 1
// These are atypical platform symbols with respect to how they are
// determined. They are either hardcoded or not determined via the usual
// platform feature detection and naming conventions.
#mesondefine DEBUG_BUILD
#mesondefine MESON_BUILD
#mesondefine OSNAME
#mesondefine HOSTTYPE
#mesondefine BASH_MACHTYPE
#mesondefine STAT_ST_MTIM
#mesondefine STAT_ST_MTIMESPEC
#mesondefine CONF_LIBPATH
#mesondefine _PROC_PROG
#mesondefine _DARWIN_C_SOURCE
#mesondefine _WSL_
#mesondefine _ast_sizeof_int
#mesondefine _ast_sizeof_long
#mesondefine _ast_sizeof_off_t
#mesondefine _ast_sizeof_pointer
#mesondefine _ast_sizeof_size_t
#mesondefine _ast_sizeof_int32_t
#mesondefine _ast_sizeof_wchar_t
#mesondefine _cmd_nfsd
#mesondefine _cmd_tput
#mesondefine _dll_DYNAMIC
#mesondefine _DLL_NEXT_PATH
#mesondefine _map_libc
#mesondefine _may_use_threads
#mesondefine _more_long_int
#mesondefine _more_void_int
#mesondefine _wchar_t_is_int
#mesondefine _pth_ed
#mesondefine _pipe_rw
#mesondefine _ptr_bits
#mesondefine _socketpair_shutdown_mode
#mesondefine isnanl
#mesondefine const_const_fts_open
#mesondefine MAX_SIGNUM
#mesondefine has_dev_fd
// What follows are all the symbols that should be based on Meson feature
// tests like `cc.has_header()` and `cc.find_library()`.
#mesondefine _hdr_dl
#mesondefine _hdr_dlfcn
#mesondefine _hdr_dll
#mesondefine _hdr_execargs
#mesondefine _hdr_execinfo
#mesondefine _hdr_filio
#mesondefine _hdr_float
#mesondefine _hdr_jioctl
#mesondefine _hdr_mach_o_dyld
#mesondefine _hdr_malloc
#mesondefine _hdr_math
#mesondefine _hdr_mman
#mesondefine _hdr_rld_interface
#mesondefine _hdr_stdlib
#mesondefine _hdr_unistd
#mesondefine _hdr_values
#mesondefine _lib_clock_gettime
#mesondefine _lib_creat64
#mesondefine _lib_dllload
#mesondefine _lib_dlopen
#mesondefine _lib_eaccess
#mesondefine _lib_euidaccess
#mesondefine _lib_faccessat
#mesondefine _lib_fdopendir
#mesondefine _lib_fstat64
#mesondefine _lib_fstatvfs64
#mesondefine _lib_ftruncate
#mesondefine _lib_ftruncate64
#mesondefine _lib_getexecname
#mesondefine _lib_gettimeofday
#mesondefine _lib_iswalnum
#mesondefine _lib_iswprint
#mesondefine _lib_lchmod
#mesondefine _lib_loadbind
#mesondefine _lib_lseek64
#mesondefine _lib_lstat
#mesondefine _lib_lstat64
#mesondefine _lib_memcntl
#mesondefine _lib_mmap64
#mesondefine _lib_mkostemp
#mesondefine _lib_open64
#mesondefine _lib_opendir
#mesondefine _lib_pathnative
#mesondefine _lib_pathposix
#mesondefine _lib_pipe2
#mesondefine _lib_poll
#mesondefine _lib_poll_notimer
#mesondefine _lib_posix_spawn
#mesondefine _lib_posix_spawnattr_setfchdir
#mesondefine _lib_posix_spawnattr_setsid
#mesondefine _lib_posix_spawnattr_setumask
#mesondefine _lib_pstat
#mesondefine _lib_rewinddir
#mesondefine _lib_sigqueue
#mesondefine _lib_socket
#mesondefine _lib_socketpair
#mesondefine _lib_spawn
#mesondefine _lib_spawn_mode
#mesondefine _lib_spawnve
#mesondefine _lib_spawnvex
#mesondefine _lib_statvfs
#mesondefine _lib_statvfs64
#mesondefine _lib_strlcat
#mesondefine _lib_sync
#mesondefine _lib_syncfs
#mesondefine _lib_sysinfo
#mesondefine _lib_towlower
#mesondefine _lib_towupper
#mesondefine _lib_truncate64
#mesondefine _lib_universe
#mesondefine _lib_utime
#mesondefine _lib_utimensat
#mesondefine _lib_wcrtomb
#mesondefine _lib_wcscpy
#mesondefine _mem_base_rel_utsname
#mesondefine _mem_d_fileno_dirent
#mesondefine _mem_d_ino_dirent
#mesondefine _mem_d_namlen_dirent
#mesondefine _mem_d_off_dirent
#mesondefine _mem_d_reclen_direct
#mesondefine _mem_d_reclen_dirent
#mesondefine _mem_d_type_dirent
#mesondefine _mem_idnumber_utsname
#mesondefine _mem_m_type_utsname
#mesondefine _mem_pgroup_inheritance
#mesondefine _sys_filio
#mesondefine _sys_jioctl
#mesondefine _sys_ldr
#mesondefine _sys_pstat
#mesondefine _sys_ptem
#mesondefine _sys_stream
#mesondefine _typ_ino64_t
#mesondefine _typ_long_double
#mesondefine _typ_off64_t
// These symbols are from src/lib/libast/include/ast_common.h that was
// generated on a Linux platform by the legacay IFFE mechanism. They may not
// be correct for other platforms.
//
// TODO: Convert these to proper feature tests.
#define _ast_int8_t long
#define _ast_intmax_t _ast_int8_t
#mesondefine _ast_intmax_long
#define _ast_fltmax_t long double
//
// This defintion has been taken from the IFFE feature test for pipes.
// This definition used to be in the src/cmd/ksh93/include/defs.h header but
// we're trying to remove that header and in any case the definition really
// belongs here.
//
// TODO: Verify this assumption is safe.
// The original test for this capability can be found in the
// src/cmd/ksh93/features/poll file. See the `tst pipe_socketpair` section.
//
#define _pipe_socketpair 1 // use socketpair() for peekable pipe()
#if DEBUG_BUILD
// If we're doing a debug build don't have any static (module private) functions.
// This is needed on most platforms for dladdr() to give us an accurate backtrace.
#define static_fn
#else
#define static_fn static
#endif
/// This is a macro that can be used to silence "unused parameter" warnings from the compiler for
/// functions which need to accept parameters they do not use because they need to be compatible
/// with an interface. It's similar to the Python idiom of doing `_ = param` at the top of a
/// function in the same situation.
///
/// Do not use this for `param` values that have side-effects when evaluated.
/// It should only be used for function parameters.
#define UNUSED(param) \
do { \
(void)(param); \
} while (0)
//
// We need to wrap the malloc family of functions. That's because the
// `job_waitsafe()` function is called from an interrupt context and
// indirectly calls `malloc()`. See issue #563.
//
#include <stdbool.h>
extern volatile bool vmbusy_flag;
#define vmbusy() vmbusy_flag
#if !NO_MALLOC_WRAPPERS
#include <sys/types.h>
extern void *ast_malloc(size_t size);
extern void *ast_calloc(size_t count, size_t size);
extern void *ast_realloc(void *ptr, size_t size);
extern void ast_free(void *ptr);
#define malloc(s) ast_malloc(s)
#define calloc(c, s) ast_calloc(c, s)
#define realloc(p, s) ast_realloc(p, s)
#define free(p) ast_free(p)
// This is not used and is not expected to be used so make sure if it is used
// it causes a problem.
#define valloc(s) valloc_has_no_ast_wrapper(s)
#endif // !NO_MALLOC_WRAPPERS
extern char *sh_getenv(const char *name);
#define getenv(x) sh_getenv(x)
// We need prototypes for each fallback implementation if the system doesn't
// provide the function.
#if !_lib_eaccess
int eaccess(const char *pathname, int mode);
#endif
#if !_lib_mkostemp
int mkostemp(char *template, int oflags);
#endif
#endif