2012-11-13 04:32:03 -08:00
|
|
|
// Workarounds for horrible build environment idiosyncrasies.
|
2013-02-24 09:11:02 -08:00
|
|
|
|
2012-11-13 04:32:03 -08:00
|
|
|
// Instead of polluting the code with strange #ifdefs to work around bugs
|
|
|
|
// in specific compiler, library, or OS versions, localize all that here
|
|
|
|
// and in portability.c
|
|
|
|
|
2020-11-05 11:55:34 -08:00
|
|
|
// Always use long file support.
|
|
|
|
// This must come before we #include any system header file to take effect!
|
|
|
|
#define _FILE_OFFSET_BITS 64
|
|
|
|
|
2014-03-29 16:11:00 -07:00
|
|
|
// For musl
|
|
|
|
#define _ALL_SOURCE
|
2020-10-28 16:48:14 -07:00
|
|
|
#include <regex.h>
|
2019-05-06 11:16:24 -07:00
|
|
|
#ifndef REG_STARTEND
|
|
|
|
#define REG_STARTEND 0
|
|
|
|
#endif
|
2014-03-29 16:11:00 -07:00
|
|
|
|
2018-12-07 18:03:23 -08:00
|
|
|
#ifdef __APPLE__
|
|
|
|
// macOS 10.13 doesn't have the POSIX 2008 direct access to timespec in
|
|
|
|
// struct stat, but we can ask it to give us something equivalent...
|
|
|
|
// (This must come before any #include!)
|
|
|
|
#define _DARWIN_C_SOURCE
|
|
|
|
// ...and then use macros to paper over the difference.
|
|
|
|
#define st_atim st_atimespec
|
|
|
|
#define st_ctim st_ctimespec
|
|
|
|
#define st_mtim st_mtimespec
|
|
|
|
#endif
|
|
|
|
|
2013-02-24 09:11:02 -08:00
|
|
|
// Test for gcc (using compiler builtin #define)
|
|
|
|
|
|
|
|
#ifdef __GNUC__
|
2015-03-01 14:16:50 -08:00
|
|
|
#define printf_format __attribute__((format(printf, 1, 2)))
|
2013-02-24 09:11:02 -08:00
|
|
|
#else
|
2015-03-01 14:16:50 -08:00
|
|
|
#define printf_format
|
2013-02-24 09:11:02 -08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// This isn't in the spec, but it's how we determine what libc we're using.
|
2012-03-19 17:19:21 -07:00
|
|
|
|
2018-11-28 16:22:32 -08:00
|
|
|
// Types various replacement prototypes need.
|
|
|
|
// This also lets us determine what libc we're using. Systems that
|
|
|
|
// have <features.h> will transitively include it, and ones that don't --
|
|
|
|
// macOS -- won't break.
|
2015-05-03 14:20:27 -07:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
2013-02-04 06:07:32 -08:00
|
|
|
// Various constants old build environments might not have even if kernel does
|
|
|
|
|
|
|
|
#ifndef AT_FDCWD
|
|
|
|
#define AT_FDCWD -100
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef AT_SYMLINK_NOFOLLOW
|
|
|
|
#define AT_SYMLINK_NOFOLLOW 0x100
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef AT_REMOVEDIR
|
|
|
|
#define AT_REMOVEDIR 0x200
|
|
|
|
#endif
|
|
|
|
|
2016-02-18 18:31:22 -08:00
|
|
|
#ifndef RLIMIT_RTTIME
|
|
|
|
#define RLIMIT_RTTIME 15
|
|
|
|
#endif
|
|
|
|
|
2017-05-21 11:11:42 -07:00
|
|
|
// Introduced in Linux 3.1
|
2017-01-04 10:45:55 -08:00
|
|
|
#ifndef SEEK_DATA
|
|
|
|
#define SEEK_DATA 3
|
|
|
|
#endif
|
2017-05-21 11:11:42 -07:00
|
|
|
#ifndef SEEK_HOLE
|
|
|
|
#define SEEK_HOLE 4
|
|
|
|
#endif
|
2017-01-04 10:45:55 -08:00
|
|
|
|
2013-02-24 09:11:02 -08:00
|
|
|
// We don't define GNU_dammit because we're not part of the gnu project, and
|
|
|
|
// don't want to get any FSF on us. Unfortunately glibc (gnu libc)
|
|
|
|
// won't give us Linux syscall wrappers without claiming to be part of the
|
|
|
|
// gnu project (because Stallman's "GNU owns Linux" revisionist history
|
|
|
|
// crusade includes the kernel, even though Linux was inspired by Minix).
|
|
|
|
|
|
|
|
// We use most non-posix Linux syscalls directly through the syscall() wrapper,
|
|
|
|
// but even many posix-2008 functions aren't provided by glibc unless you
|
|
|
|
// claim it's in the name of Gnu.
|
|
|
|
|
2012-11-26 21:24:07 -08:00
|
|
|
#if defined(__GLIBC__)
|
|
|
|
// "Function prototypes shall be provided." but aren't.
|
|
|
|
// http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html
|
|
|
|
char *crypt(const char *key, const char *salt);
|
|
|
|
|
2014-07-20 14:34:36 -07:00
|
|
|
// According to posix, #include header, get a function definition. But glibc...
|
|
|
|
// http://pubs.opengroup.org/onlinepubs/9699919799/functions/wcwidth.html
|
|
|
|
#include <wchar.h>
|
|
|
|
int wcwidth(wchar_t wc);
|
|
|
|
|
2012-03-19 17:19:21 -07:00
|
|
|
// see http://pubs.opengroup.org/onlinepubs/9699919799/functions/strptime.html
|
|
|
|
#include <time.h>
|
|
|
|
char *strptime(const char *buf, const char *format, struct tm *tm);
|
2012-11-13 04:32:03 -08:00
|
|
|
|
2014-12-31 14:22:31 -08:00
|
|
|
// They didn't like posix basename so they defined another function with the
|
|
|
|
// same name and if you include libgen.h it #defines basename to something
|
|
|
|
// else (where they implemented the real basename), and that define breaks
|
|
|
|
// the table entry for the basename command. They didn't make a new function
|
|
|
|
// with a different name for their new behavior because gnu.
|
|
|
|
//
|
2015-01-18 11:44:24 -08:00
|
|
|
// Solution: don't use their broken header, provide an inline to redirect the
|
|
|
|
// correct name to the broken name.
|
|
|
|
|
|
|
|
char *dirname(char *path);
|
2015-07-11 12:20:31 -07:00
|
|
|
char *__xpg_basename(char *path);
|
2015-01-18 11:44:24 -08:00
|
|
|
static inline char *basename(char *path) { return __xpg_basename(path); }
|
2018-11-28 12:27:14 -08:00
|
|
|
char *strcasestr(const char *haystack, const char *needle);
|
2020-03-09 22:07:47 -07:00
|
|
|
void *memmem(const void *haystack, size_t haystack_length,
|
|
|
|
const void *needle, size_t needle_length);
|
2018-11-29 12:46:16 -08:00
|
|
|
#endif // defined(glibc)
|
2007-01-18 18:54:08 -08:00
|
|
|
|
2019-11-21 14:09:23 -08:00
|
|
|
// getopt_long(), getopt_long_only(), and struct option.
|
|
|
|
#include <getopt.h>
|
|
|
|
|
2016-04-08 16:25:59 -07:00
|
|
|
#if !defined(__GLIBC__)
|
2015-01-18 11:36:31 -08:00
|
|
|
// POSIX basename.
|
|
|
|
#include <libgen.h>
|
|
|
|
#endif
|
|
|
|
|
2013-02-24 09:11:02 -08:00
|
|
|
// Work out how to do endianness
|
2007-02-13 13:41:51 -08:00
|
|
|
|
2018-11-29 13:24:34 -08:00
|
|
|
#ifdef __APPLE__
|
2007-01-14 17:20:06 -08:00
|
|
|
|
2018-11-29 13:24:34 -08:00
|
|
|
#include <libkern/OSByteOrder.h>
|
|
|
|
|
|
|
|
#ifdef __BIG_ENDIAN__
|
2007-01-14 17:20:06 -08:00
|
|
|
#define IS_BIG_ENDIAN 1
|
2007-02-13 13:41:51 -08:00
|
|
|
#else
|
|
|
|
#define IS_BIG_ENDIAN 0
|
|
|
|
#endif
|
|
|
|
|
2018-11-29 13:24:34 -08:00
|
|
|
#define bswap_16(x) OSSwapInt16(x)
|
|
|
|
#define bswap_32(x) OSSwapInt32(x)
|
|
|
|
#define bswap_64(x) OSSwapInt64(x)
|
|
|
|
|
2021-05-01 03:50:13 -07:00
|
|
|
#elif defined(__FreeBSD__) || defined(__OpenBSD__)
|
2019-01-08 10:48:04 -08:00
|
|
|
|
|
|
|
#include <sys/endian.h>
|
|
|
|
|
|
|
|
#if _BYTE_ORDER == _BIG_ENDIAN
|
|
|
|
#define IS_BIG_ENDIAN 1
|
|
|
|
#else
|
|
|
|
#define IS_BIG_ENDIAN 0
|
|
|
|
#endif
|
|
|
|
|
2007-02-13 13:41:51 -08:00
|
|
|
#else
|
|
|
|
|
2018-11-29 13:24:34 -08:00
|
|
|
#include <byteswap.h>
|
|
|
|
#include <endian.h>
|
|
|
|
|
|
|
|
#if __BYTE_ORDER == __BIG_ENDIAN
|
2007-02-13 13:41:51 -08:00
|
|
|
#define IS_BIG_ENDIAN 1
|
|
|
|
#else
|
|
|
|
#define IS_BIG_ENDIAN 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if IS_BIG_ENDIAN
|
2007-01-14 17:20:06 -08:00
|
|
|
#define IS_LITTLE_ENDIAN 0
|
|
|
|
#define SWAP_BE16(x) (x)
|
|
|
|
#define SWAP_BE32(x) (x)
|
|
|
|
#define SWAP_BE64(x) (x)
|
|
|
|
#define SWAP_LE16(x) bswap_16(x)
|
|
|
|
#define SWAP_LE32(x) bswap_32(x)
|
|
|
|
#define SWAP_LE64(x) bswap_64(x)
|
|
|
|
#else
|
|
|
|
#define IS_LITTLE_ENDIAN 1
|
|
|
|
#define SWAP_BE16(x) bswap_16(x)
|
|
|
|
#define SWAP_BE32(x) bswap_32(x)
|
|
|
|
#define SWAP_BE64(x) bswap_64(x)
|
|
|
|
#define SWAP_LE16(x) (x)
|
|
|
|
#define SWAP_LE32(x) (x)
|
|
|
|
#define SWAP_LE64(x) (x)
|
|
|
|
#endif
|
2007-02-03 11:10:00 -08:00
|
|
|
|
2014-03-29 16:11:00 -07:00
|
|
|
// Linux headers not listed by POSIX or LSB
|
|
|
|
#include <sys/mount.h>
|
2018-11-30 13:31:33 -08:00
|
|
|
#ifdef __linux__
|
|
|
|
#include <sys/statfs.h>
|
2014-03-29 16:11:00 -07:00
|
|
|
#include <sys/swap.h>
|
2018-11-30 13:31:33 -08:00
|
|
|
#include <sys/sysinfo.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __APPLE__
|
|
|
|
#include <util.h>
|
2021-05-01 03:50:13 -07:00
|
|
|
#elif !defined(__FreeBSD__) && !defined(__OpenBSD__)
|
2018-11-30 13:31:33 -08:00
|
|
|
#include <pty.h>
|
2019-01-08 16:45:00 -08:00
|
|
|
#else
|
|
|
|
#include <termios.h>
|
|
|
|
#ifndef IUTF8
|
|
|
|
#define IUTF8 0
|
|
|
|
#endif
|
2018-11-30 13:31:33 -08:00
|
|
|
#endif
|
2014-03-29 16:11:00 -07:00
|
|
|
|
2021-09-27 18:38:41 -07:00
|
|
|
#ifdef __linux__
|
|
|
|
#include <sys/personality.h>
|
|
|
|
#else
|
2021-09-28 17:51:32 -07:00
|
|
|
#define PER_LINUX32 0
|
2021-09-28 18:11:36 -07:00
|
|
|
#define personality(x)
|
2021-09-27 18:38:41 -07:00
|
|
|
#endif
|
|
|
|
|
2019-06-07 16:18:00 -07:00
|
|
|
#if defined(__APPLE__) || defined(__linux__)
|
|
|
|
// Linux and macOS has both have getxattr and friends in <sys/xattr.h>, but
|
|
|
|
// they aren't compatible.
|
2019-01-08 16:37:15 -08:00
|
|
|
#include <sys/xattr.h>
|
2019-06-07 16:18:00 -07:00
|
|
|
ssize_t xattr_get(const char *, const char *, void *, size_t);
|
|
|
|
ssize_t xattr_lget(const char *, const char *, void *, size_t);
|
|
|
|
ssize_t xattr_fget(int fd, const char *, void *, size_t);
|
|
|
|
ssize_t xattr_list(const char *, char *, size_t);
|
|
|
|
ssize_t xattr_llist(const char *, char *, size_t);
|
|
|
|
ssize_t xattr_flist(int, char *, size_t);
|
|
|
|
ssize_t xattr_set(const char*, const char*, const void*, size_t, int);
|
|
|
|
ssize_t xattr_lset(const char*, const char*, const void*, size_t, int);
|
|
|
|
ssize_t xattr_fset(int, const char*, const void*, size_t, int);
|
|
|
|
#endif
|
|
|
|
|
2021-05-01 03:50:13 -07:00
|
|
|
#if defined(__APPLE__)
|
2021-01-05 14:14:39 -08:00
|
|
|
// macOS doesn't have these functions, but we can fake them.
|
2019-06-07 16:18:00 -07:00
|
|
|
int mknodat(int, const char*, mode_t, dev_t);
|
2019-10-22 16:04:55 -07:00
|
|
|
int posix_fallocate(int, off_t, off_t);
|
2021-01-05 14:14:39 -08:00
|
|
|
|
|
|
|
// macOS keeps newlocale(3) in the non-POSIX <xlocale.h> rather than <locale.h>.
|
|
|
|
#include <xlocale.h>
|
2021-05-01 03:50:13 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__APPLE__) || defined(__OpenBSD__)
|
2021-02-22 17:48:49 -08:00
|
|
|
static inline long statfs_bsize(struct statfs *sf) { return sf->f_iosize; }
|
|
|
|
static inline long statfs_frsize(struct statfs *sf) { return sf->f_bsize; }
|
|
|
|
#else
|
|
|
|
static inline long statfs_bsize(struct statfs *sf) { return sf->f_bsize; }
|
|
|
|
static inline long statfs_frsize(struct statfs *sf) { return sf->f_frsize; }
|
2019-01-08 16:37:15 -08:00
|
|
|
#endif
|
|
|
|
|
2021-01-05 14:14:39 -08:00
|
|
|
|
2014-11-19 14:38:46 -08:00
|
|
|
// Android is missing some headers and functions
|
|
|
|
// "generated/config.h" is included first
|
2014-11-19 14:55:12 -08:00
|
|
|
#if CFG_TOYBOX_SHADOW
|
2014-11-19 14:38:46 -08:00
|
|
|
#include <shadow.h>
|
|
|
|
#endif
|
2014-11-19 14:55:12 -08:00
|
|
|
#if CFG_TOYBOX_UTMPX
|
2014-11-19 14:38:46 -08:00
|
|
|
#include <utmpx.h>
|
2015-08-30 04:00:32 -07:00
|
|
|
#else
|
|
|
|
struct utmpx {int ut_type;};
|
|
|
|
#define USER_PROCESS 0
|
|
|
|
static inline struct utmpx *getutxent(void) {return 0;}
|
|
|
|
static inline void setutxent(void) {;}
|
|
|
|
static inline void endutxent(void) {;}
|
2014-11-19 14:38:46 -08:00
|
|
|
#endif
|
2015-01-16 11:49:23 -08:00
|
|
|
|
2014-04-15 19:59:42 -07:00
|
|
|
// Some systems don't define O_NOFOLLOW, and it varies by architecture, so...
|
|
|
|
#include <fcntl.h>
|
|
|
|
#ifndef O_NOFOLLOW
|
|
|
|
#define O_NOFOLLOW 0
|
|
|
|
#endif
|
2015-05-18 00:00:43 -07:00
|
|
|
#ifndef O_NOATIME
|
|
|
|
#define O_NOATIME 01000000
|
|
|
|
#endif
|
2014-08-12 05:09:01 -07:00
|
|
|
#ifndef O_CLOEXEC
|
|
|
|
#define O_CLOEXEC 02000000
|
|
|
|
#endif
|
2015-05-01 12:40:49 -07:00
|
|
|
#ifndef O_PATH
|
|
|
|
#define O_PATH 010000000
|
|
|
|
#endif
|
2017-05-21 11:11:42 -07:00
|
|
|
#ifndef SCHED_RESET_ON_FORK
|
|
|
|
#define SCHED_RESET_ON_FORK (1<<30)
|
|
|
|
#endif
|
2015-05-01 12:40:49 -07:00
|
|
|
|
2016-02-09 15:23:31 -08:00
|
|
|
// Glibc won't give you linux-kernel constants unless you say "no, a BUD lite"
|
|
|
|
// even though linux has nothing to do with the FSF and never has.
|
|
|
|
#ifndef F_SETPIPE_SZ
|
|
|
|
#define F_SETPIPE_SZ 1031
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef F_GETPIPE_SZ
|
|
|
|
#define F_GETPIPE_SZ 1032
|
|
|
|
#endif
|
|
|
|
|
2014-05-06 04:14:20 -07:00
|
|
|
#if defined(__SIZEOF_DOUBLE__) && defined(__SIZEOF_LONG__) \
|
|
|
|
&& __SIZEOF_DOUBLE__ <= __SIZEOF_LONG__
|
|
|
|
typedef double FLOAT;
|
|
|
|
#else
|
|
|
|
typedef float FLOAT;
|
|
|
|
#endif
|
|
|
|
|
2014-12-04 19:46:59 -08:00
|
|
|
#ifndef __uClinux__
|
|
|
|
pid_t xfork(void);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//#define strncpy(...) @@strncpyisbadmmkay@@
|
2015-05-08 18:20:29 -07:00
|
|
|
//#define strncat(...) @@strncatisbadmmkay@@
|
2015-01-16 11:36:53 -08:00
|
|
|
|
2018-09-27 16:34:49 -07:00
|
|
|
// Support building the Android tools on glibc, so hermetic AOSP builds can
|
|
|
|
// use toybox before they're ready to switch to host bionic.
|
|
|
|
#ifdef __BIONIC__
|
|
|
|
#include <android/log.h>
|
2016-04-29 18:04:20 -07:00
|
|
|
#else
|
2018-09-27 16:34:49 -07:00
|
|
|
typedef enum android_LogPriority {
|
|
|
|
ANDROID_LOG_UNKNOWN = 0,
|
|
|
|
ANDROID_LOG_DEFAULT,
|
|
|
|
ANDROID_LOG_VERBOSE,
|
|
|
|
ANDROID_LOG_DEBUG,
|
|
|
|
ANDROID_LOG_INFO,
|
|
|
|
ANDROID_LOG_WARN,
|
|
|
|
ANDROID_LOG_ERROR,
|
|
|
|
ANDROID_LOG_FATAL,
|
|
|
|
ANDROID_LOG_SILENT,
|
|
|
|
} android_LogPriority;
|
|
|
|
static inline int __android_log_write(int pri, const char *tag, const char *msg)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
2016-04-29 18:04:20 -07:00
|
|
|
#endif
|
2018-01-01 14:25:18 -08:00
|
|
|
|
2019-05-01 15:28:21 -07:00
|
|
|
// libprocessgroup is an Android platform library not included in the NDK.
|
2019-11-13 06:48:44 -08:00
|
|
|
#if defined(__BIONIC__)
|
|
|
|
#if __has_include(<processgroup/sched_policy.h>)
|
2019-05-01 15:28:21 -07:00
|
|
|
#include <processgroup/sched_policy.h>
|
2019-11-13 06:48:44 -08:00
|
|
|
#define GOT_IT
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#ifdef GOT_IT
|
|
|
|
#undef GOT_IT
|
2018-10-07 17:55:11 -07:00
|
|
|
#else
|
2018-10-07 09:29:17 -07:00
|
|
|
static inline int get_sched_policy(int tid, void *policy) {return 0;}
|
|
|
|
static inline char *get_sched_policy_name(int policy) {return "unknown";}
|
|
|
|
#endif
|
|
|
|
|
2018-10-20 12:40:20 -07:00
|
|
|
// Android NDKv18 has liblog.so but not liblog.c for static builds,
|
|
|
|
// stub it out for now.
|
2018-10-10 16:18:59 -07:00
|
|
|
#ifdef __ANDROID_NDK__
|
2018-10-20 12:40:20 -07:00
|
|
|
#define __android_log_write(a, b, c) (0)
|
2018-10-10 16:18:59 -07:00
|
|
|
#endif
|
|
|
|
|
2018-01-01 14:25:18 -08:00
|
|
|
#ifndef SYSLOG_NAMES
|
|
|
|
typedef struct {char *c_name; int c_val;} CODE;
|
|
|
|
extern CODE prioritynames[], facilitynames[];
|
|
|
|
#endif
|
2018-07-04 16:49:03 -07:00
|
|
|
|
|
|
|
#if CFG_TOYBOX_GETRANDOM
|
|
|
|
#include <sys/random.h>
|
|
|
|
#endif
|
2018-12-07 17:11:16 -08:00
|
|
|
int xgetrandom(void *buf, unsigned len, unsigned flags);
|
2018-09-08 13:42:02 -07:00
|
|
|
|
2018-09-14 09:54:45 -07:00
|
|
|
// Android's bionic libc doesn't have confstr.
|
|
|
|
#ifdef __BIONIC__
|
2018-09-08 13:42:02 -07:00
|
|
|
#define _CS_PATH 0
|
|
|
|
#define _CS_V7_ENV 1
|
|
|
|
#include <string.h>
|
|
|
|
static inline void confstr(int a, char *b, int c) {strcpy(b, a ? "POSIXLY_CORRECT=1" : "/bin:/usr/bin");}
|
|
|
|
#endif
|
2019-05-23 16:28:19 -07:00
|
|
|
|
|
|
|
// Paper over the differences between BSD kqueue and Linux inotify for tail.
|
2019-05-25 17:48:33 -07:00
|
|
|
|
|
|
|
struct xnotify {
|
|
|
|
char **paths;
|
|
|
|
int max, *fds, count, kq;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct xnotify *xnotify_init(int max);
|
|
|
|
int xnotify_add(struct xnotify *not, int fd, char *path);
|
|
|
|
int xnotify_wait(struct xnotify *not, char **path);
|
2019-06-07 16:18:00 -07:00
|
|
|
|
2019-06-11 14:57:06 -07:00
|
|
|
int sig_to_num(char *s);
|
|
|
|
char *num_to_sig(int sig);
|
|
|
|
|
|
|
|
struct signame {
|
|
|
|
int num;
|
|
|
|
char *name;
|
|
|
|
};
|
|
|
|
void xsignal_all_killers(void *handler);
|
2019-11-22 12:48:35 -08:00
|
|
|
|
|
|
|
// Different OSes encode major/minor device numbers differently.
|
|
|
|
int dev_minor(int dev);
|
|
|
|
int dev_major(int dev);
|
|
|
|
int dev_makedev(int major, int minor);
|
2019-12-05 14:53:43 -08:00
|
|
|
|
|
|
|
char *fs_type_name(struct statfs *statfs);
|
2020-03-10 09:18:22 -07:00
|
|
|
|
|
|
|
int get_block_device_size(int fd, unsigned long long *size);
|
2021-09-24 14:36:18 -07:00
|
|
|
|
2021-09-24 18:57:42 -07:00
|
|
|
#ifdef __APPLE__
|
2021-09-24 14:36:18 -07:00
|
|
|
// Apple doesn't have POSIX timers; this is "just enough" for timeout(1).
|
|
|
|
typedef int timer_t;
|
|
|
|
struct itimerspec {
|
|
|
|
struct timespec it_value;
|
|
|
|
};
|
|
|
|
int timer_create(clock_t c, struct sigevent *se, timer_t *t);
|
|
|
|
int timer_settime(timer_t t, int flags, struct itimerspec *new, void *old);
|
|
|
|
#endif
|