# XXX ltrace misses long double support
typedef ldouble = double;

# This should generally work, I'm not aware of any arch, where the
# parameter passing of complex arguments differs from that for
# structure of two floats.
typedef double_complex = struct(double, double);
typedef float_complex = struct(float, float);
typedef ldouble_complex = struct(ldouble, ldouble);

# arpa/inet.h
typedef in_addr = struct(hex(uint));

# dirent.h

# We can't portably rely on DIR internals at all.  Ideally this would
# be implemented in a per-OS config file, but even on Linux, we don't
# know whether there's a lock in the structure or not.  Luckily the
# one interesting datum, file descriptor, we can access reliably.
# Having the structure half-defined like this is potentially
# problematic as structure size influences parameter passing.  But
# POSIX always uses pointer to the structure, so it's fine.

typedef DIR = struct(int);
typedef FILE = addr;

typedef ino_t = ulong;
typedef ino_t64 = ullong;
typedef off_t = ulong;
typedef off_t64 = ullong;
typedef size_t = ulong;
typedef ssize_t = long;

typedef dirent = struct(ino_t, hide(off_t), hide(ushort), hide(char), string(array(char, zero(256))));
typedef dirent64 = struct(ino_t64, hide(off_t64), hide(ushort), hide(char), string(array(char, zero(256))));

# mntent.h
typedef mntent = struct(string, string, string, string, int, int);

# sched.h
typedef sched_param = struct(int);
typedef sched_policy_e = enum[int](SCHED_FIFO=1, SCHED_RR=2, SCHED_OTHER=0);

# signal.h
typedef signum = enum(SIGHUP=1, SIGINT=2, SIGQUIT=3, SIGILL=4, SIGTRAP=5, SIGABRT=6, SIGBUS=7, SIGFPE=8, SIGKILL=9, SIGUSR1=10, SIGSEGV=11, SIGUSR2=12, SIGPIPE=13, SIGALRM=14, SIGTERM=15, SIGSTKFLT=16, SIGCHLD=17, SIGCONT=18, SIGSTOP=19, SIGTSTP=20, SIGTTIN=21, SIGTTOU=22, SIGURG=23, SIGXCPU=24, SIGXFSZ=25, SIGVTALRM=26, SIGPROF=27, SIGWINCH=28, SIGIO=29, SIGPWR=30, SIGSYS=31, SIGRTMIN_0=32, SIGRTMIN_1=33, SIGRTMIN_2=34, SIGRTMIN_3=35, SIGRTMIN_4=36, SIGRTMIN_5=37, SIGRTMIN_6=38, SIGRTMIN_7=39, SIGRTMIN_8=40, SIGRTMIN_9=41, SIGRTMIN_10=42, SIGRTMIN_11=43, SIGRTMIN_12=44, SIGRTMIN_13=45, SIGRTMIN_14=46, SIGRTMIN_15=47, SIGRTMIN_16=48, SIGRTMIN_17=49, SIGRTMIN_18=50, SIGRTMIN_19=51, SIGRTMIN_20=52, SIGRTMIN_21=53, SIGRTMIN_22=54, SIGRTMIN_23=55, SIGRTMIN_24=56, SIGRTMIN_25=57, SIGRTMIN_26=58, SIGRTMIN_27=59, SIGRTMIN_28=60, SIGRTMIN_29=61, SIGRTMIN_30=62, SIGRTMIN_31=63);
typedef sigset_t = bitvec(ulong);
# elm3 should be flags
typedef sigaction = struct(addr, sigset_t, hex(int), addr);

# sys/mman.h
typedef mmap_flags_t = enum(MAP_SHARED=1, MAP_PRIVATE=2);

# time.h
typedef clockid_t = int;
typedef timespec = struct(llong, long);

# wchar.h
typedef wchar_t = string(uint);
typedef wint_t = string(int);
typedef wstring_t = string(array(uint, zero)*);
typedef wstring2_t = string(array(uint, zero(arg2))*);
typedef wstring3_t = string(array(uint, zero(arg3))*);

# xlocale.h
typedef locale_t = void*;
