#define _FILE_OFFSET_BITS 64
#ifdef __APPLE__
#define _DARWIN_C_SOURCE
#define st_atim st_atimespec
#define st_ctim st_ctimespec
#define st_mtim st_mtimespec
#endif
#define _ALL_SOURCE
#include <regex.h>
#ifndef REG_STARTEND
#define REG_STARTEND 0
#endif
#include <fnmatch.h>
#ifndef FNM_LEADING_DIR
#define FNM_LEADING_DIR 8
#endif
#ifndef FNM_CASEFOLD
#define FNM_CASEFOLD 16
#endif
#ifdef __GNUC__
#define QUIET = 0
#define printf_format __attribute__((format(printf, 1, 2)))
#else
#define QUIET
#define printf_format
#endif
#include <sys/types.h>
#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
#ifndef RLIMIT_RTTIME
#define RLIMIT_RTTIME 15
#endif
#ifndef SEEK_DATA
#define SEEK_DATA 3
#endif
#ifndef SEEK_HOLE
#define SEEK_HOLE 4
#endif
#if defined(__GLIBC__)
char *crypt(const char *key, const char *salt);
#include <wchar.h>
int wcwidth(wchar_t wc);
#include <time.h>
char *strptime(const char *buf, const char *format, struct tm *tm);
char *dirname(char *path);
char *__xpg_basename(char *path);
static inline char *basename(char *path) { return __xpg_basename(path); }
char *strcasestr(const char *haystack, const char *needle);
void *memmem(const void *haystack, size_t haystack_length,
const void *needle, size_t needle_length);
#endif
#if !defined(__GLIBC__)
#include <libgen.h>
#endif
#define IS_LITTLE_ENDIAN (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
#define IS_BIG_ENDIAN (!IS_LITTLE_ENDIAN)
#ifdef __APPLE__
#include <libkern/OSByteOrder.h>
#define bswap_16(x) OSSwapInt16(x)
#define bswap_32(x) OSSwapInt32(x)
#define bswap_64(x) OSSwapInt64(x)
#elif defined(__FreeBSD__) || defined(__OpenBSD__)
#include <sys/endian.h>
#define bswap_16(x) bswap16(x)
#define bswap_32(x) bswap32(x)
#define bswap_64(x) bswap64(x)
#else
#include <byteswap.h>
#endif
#if IS_BIG_ENDIAN
#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 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
#include <sys/mount.h>
#ifdef __linux__
#include <sys/statfs.h>
#include <sys/swap.h>
#include <sys/sysinfo.h>
#endif
#ifdef __APPLE__
#include <util.h>
#elif !defined(__FreeBSD__) && !defined(__OpenBSD__)
#include <pty.h>
#else
#include <termios.h>
#ifndef IUTF8
#define IUTF8 0
#endif
#endif
#ifdef __linux__
#include <sys/personality.h>
#else
#define PER_LINUX32 0
int personality(int);
#endif
#if defined(__APPLE__) || defined(__linux__)
#include <sys/xattr.h>
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
#if defined(__APPLE__)
int mknodat(int, const char*, mode_t, dev_t);
int posix_fallocate(int, off_t, off_t);
#include <xlocale.h>
#endif
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
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; }
#endif
#if __has_include(<shadow.h>)
#include <shadow.h>
#endif
#if __has_include(<utmpx.h>)
#include <utmpx.h>
#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) {;}
#endif
#include <fcntl.h>
#if defined(__APPLE__)
#define O_PATH 0
#else
#ifndef O_NOFOLLOW
#define O_NOFOLLOW 0
#endif
#ifndef O_NOATIME
#define O_NOATIME 01000000
#endif
#ifndef O_CLOEXEC
#define O_CLOEXEC 02000000
#endif
#ifndef O_PATH
#define O_PATH 010000000
#endif
#ifndef SCHED_RESET_ON_FORK
#define SCHED_RESET_ON_FORK (1<<30)
#endif
#endif
#ifndef F_SETPIPE_SZ
#define F_SETPIPE_SZ 1031
#endif
#ifndef F_GETPIPE_SZ
#define F_GETPIPE_SZ 1032
#endif
#if defined(__SIZEOF_DOUBLE__) && defined(__SIZEOF_LONG__) \
&& __SIZEOF_DOUBLE__ <= __SIZEOF_LONG__
typedef double FLOAT;
#else
typedef float FLOAT;
#endif
#ifndef __uClinux__
pid_t xfork(void);
#endif
#define strncat(...) strncatisbadmmkay(__VA_ARGS__)
#ifdef __BIONIC__
#include <android/log.h>
#else
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;
#endif
#if !defined(__BIONIC__) || defined(__ANDROID_NDK__)
static inline int stub_out_log_write(int pri, const char *tag, const char *msg)
{
return -1;
}
#ifdef __ANDROID_NDK__
#define __android_log_write(a, b, c) stub_out_log_write(a, b, c)
#endif
#endif
#ifndef SYSLOG_NAMES
typedef struct {char *c_name; int c_val;} CODE;
extern CODE prioritynames[], facilitynames[];
#endif
#if __has_include (<sys/random.h>)
#include <sys/random.h>
#endif
void xgetrandom(void *buf, unsigned len);
#ifdef __BIONIC__
#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
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);
int sig_to_num(char *s);
char *num_to_sig(int sig);
struct signame {
int num;
char *name;
};
void xsignal_all_killers(void *handler);
int dev_minor(int dev);
int dev_major(int dev);
int dev_makedev(int major, int minor);
char *fs_type_name(struct statfs *statfs);
int get_block_device_size(int fd, unsigned long long *size);
int rename_exchange(char *file1, char *file2);
#ifdef __APPLE__
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);
#elif defined(__GLIBC__)
#include <syscall.h>
#include <signal.h>
#include <time.h>
int timer_create_wrap(clockid_t c, struct sigevent *se, timer_t *t);
#define timer_create(...) timer_create_wrap(__VA_ARGS__)
int timer_settime_wrap(timer_t t, int flags, struct itimerspec *val,
struct itimerspec *old);
#define timer_settime(...) timer_settime_wrap(__VA_ARGS__)
#endif