# Generated by detect.nim



# <errno.h>
var E2BIG* {.importc: "E2BIG", header: "<errno.h>".}: cint
var EACCES* {.importc: "EACCES", header: "<errno.h>".}: cint
var EADDRINUSE* {.importc: "EADDRINUSE", header: "<errno.h>".}: cint
var EADDRNOTAVAIL* {.importc: "EADDRNOTAVAIL", header: "<errno.h>".}: cint
var EAFNOSUPPORT* {.importc: "EAFNOSUPPORT", header: "<errno.h>".}: cint
var EAGAIN* {.importc: "EAGAIN", header: "<errno.h>".}: cint
var EALREADY* {.importc: "EALREADY", header: "<errno.h>".}: cint
var EBADF* {.importc: "EBADF", header: "<errno.h>".}: cint
var EBADMSG* {.importc: "EBADMSG", header: "<errno.h>".}: cint
var EBUSY* {.importc: "EBUSY", header: "<errno.h>".}: cint
var ECANCELED* {.importc: "ECANCELED", header: "<errno.h>".}: cint
var ECHILD* {.importc: "ECHILD", header: "<errno.h>".}: cint
var ECONNABORTED* {.importc: "ECONNABORTED", header: "<errno.h>".}: cint
var ECONNREFUSED* {.importc: "ECONNREFUSED", header: "<errno.h>".}: cint
var ECONNRESET* {.importc: "ECONNRESET", header: "<errno.h>".}: cint
var EDEADLK* {.importc: "EDEADLK", header: "<errno.h>".}: cint
var EDESTADDRREQ* {.importc: "EDESTADDRREQ", header: "<errno.h>".}: cint
var EDOM* {.importc: "EDOM", header: "<errno.h>".}: cint
var EDQUOT* {.importc: "EDQUOT", header: "<errno.h>".}: cint
var EEXIST* {.importc: "EEXIST", header: "<errno.h>".}: cint
var EFAULT* {.importc: "EFAULT", header: "<errno.h>".}: cint
var EFBIG* {.importc: "EFBIG", header: "<errno.h>".}: cint
var EHOSTUNREACH* {.importc: "EHOSTUNREACH", header: "<errno.h>".}: cint
var EIDRM* {.importc: "EIDRM", header: "<errno.h>".}: cint
var EILSEQ* {.importc: "EILSEQ", header: "<errno.h>".}: cint
var EINPROGRESS* {.importc: "EINPROGRESS", header: "<errno.h>".}: cint
var EINTR* {.importc: "EINTR", header: "<errno.h>".}: cint
var EINVAL* {.importc: "EINVAL", header: "<errno.h>".}: cint
var EIO* {.importc: "EIO", header: "<errno.h>".}: cint
var EISCONN* {.importc: "EISCONN", header: "<errno.h>".}: cint
var EISDIR* {.importc: "EISDIR", header: "<errno.h>".}: cint
var ELOOP* {.importc: "ELOOP", header: "<errno.h>".}: cint
var EMFILE* {.importc: "EMFILE", header: "<errno.h>".}: cint
var EMLINK* {.importc: "EMLINK", header: "<errno.h>".}: cint
var EMSGSIZE* {.importc: "EMSGSIZE", header: "<errno.h>".}: cint
var EMULTIHOP* {.importc: "EMULTIHOP", header: "<errno.h>".}: cint
var ENAMETOOLONG* {.importc: "ENAMETOOLONG", header: "<errno.h>".}: cint
var ENETDOWN* {.importc: "ENETDOWN", header: "<errno.h>".}: cint
var ENETRESET* {.importc: "ENETRESET", header: "<errno.h>".}: cint
var ENETUNREACH* {.importc: "ENETUNREACH", header: "<errno.h>".}: cint
var ENFILE* {.importc: "ENFILE", header: "<errno.h>".}: cint
var ENOBUFS* {.importc: "ENOBUFS", header: "<errno.h>".}: cint
var ENODATA* {.importc: "ENODATA", header: "<errno.h>".}: cint
var ENODEV* {.importc: "ENODEV", header: "<errno.h>".}: cint
var ENOENT* {.importc: "ENOENT", header: "<errno.h>".}: cint
var ENOEXEC* {.importc: "ENOEXEC", header: "<errno.h>".}: cint
var ENOLCK* {.importc: "ENOLCK", header: "<errno.h>".}: cint
var ENOLINK* {.importc: "ENOLINK", header: "<errno.h>".}: cint
var ENOMEM* {.importc: "ENOMEM", header: "<errno.h>".}: cint
var ENOMSG* {.importc: "ENOMSG", header: "<errno.h>".}: cint
var ENOPROTOOPT* {.importc: "ENOPROTOOPT", header: "<errno.h>".}: cint
var ENOSPC* {.importc: "ENOSPC", header: "<errno.h>".}: cint
var ENOSR* {.importc: "ENOSR", header: "<errno.h>".}: cint
var ENOSTR* {.importc: "ENOSTR", header: "<errno.h>".}: cint
var ENOSYS* {.importc: "ENOSYS", header: "<errno.h>".}: cint
var ENOTCONN* {.importc: "ENOTCONN", header: "<errno.h>".}: cint
var ENOTDIR* {.importc: "ENOTDIR", header: "<errno.h>".}: cint
var ENOTEMPTY* {.importc: "ENOTEMPTY", header: "<errno.h>".}: cint
var ENOTSOCK* {.importc: "ENOTSOCK", header: "<errno.h>".}: cint
var ENOTSUP* {.importc: "ENOTSUP", header: "<errno.h>".}: cint
var ENOTTY* {.importc: "ENOTTY", header: "<errno.h>".}: cint
var ENXIO* {.importc: "ENXIO", header: "<errno.h>".}: cint
var EOPNOTSUPP* {.importc: "EOPNOTSUPP", header: "<errno.h>".}: cint
var EOVERFLOW* {.importc: "EOVERFLOW", header: "<errno.h>".}: cint
var EPERM* {.importc: "EPERM", header: "<errno.h>".}: cint
var EPIPE* {.importc: "EPIPE", header: "<errno.h>".}: cint
var EPROTO* {.importc: "EPROTO", header: "<errno.h>".}: cint
var EPROTONOSUPPORT* {.importc: "EPROTONOSUPPORT", header: "<errno.h>".}: cint
var EPROTOTYPE* {.importc: "EPROTOTYPE", header: "<errno.h>".}: cint
var ERANGE* {.importc: "ERANGE", header: "<errno.h>".}: cint
var EROFS* {.importc: "EROFS", header: "<errno.h>".}: cint
var ESPIPE* {.importc: "ESPIPE", header: "<errno.h>".}: cint
var ESRCH* {.importc: "ESRCH", header: "<errno.h>".}: cint
var ESTALE* {.importc: "ESTALE", header: "<errno.h>".}: cint
var ETIME* {.importc: "ETIME", header: "<errno.h>".}: cint
var ETIMEDOUT* {.importc: "ETIMEDOUT", header: "<errno.h>".}: cint
var ETXTBSY* {.importc: "ETXTBSY", header: "<errno.h>".}: cint
var EWOULDBLOCK* {.importc: "EWOULDBLOCK", header: "<errno.h>".}: cint
var EXDEV* {.importc: "EXDEV", header: "<errno.h>".}: cint

# <sys/fcntl.h>
var F_GETFD* {.importc: "F_GETFD", header: "<sys/fcntl.h>".}: cint
# var F_SETFD* {.importc: "F_SETFD", header: "<sys/fcntl.h>".}: cint
var F_GETFL* {.importc: "F_GETFL", header: "<sys/fcntl.h>".}: cint
var F_SETFL* {.importc: "F_SETFL", header: "<sys/fcntl.h>".}: cint
# var F_GETLK* {.importc: "F_GETLK", header: "<sys/fcntl.h>".}: cint
# var F_SETLK* {.importc: "F_SETLK", header: "<sys/fcntl.h>".}: cint
# var F_SETLKW* {.importc: "F_SETLKW", header: "<sys/fcntl.h>".}: cint
# var F_GETOWN* {.importc: "F_GETOWN", header: "<sys/fcntl.h>".}: cint
# var F_SETOWN* {.importc: "F_SETOWN", header: "<sys/fcntl.h>".}: cint
# var FD_CLOEXEC* {.importc: "FD_CLOEXEC", header: "<sys/fcntl.h>".}: cint
# var F_RDLCK* {.importc: "F_RDLCK", header: "<sys/fcntl.h>".}: cint
# var F_UNLCK* {.importc: "F_UNLCK", header: "<sys/fcntl.h>".}: cint
# var F_WRLCK* {.importc: "F_WRLCK", header: "<sys/fcntl.h>".}: cint
var O_CREAT* {.importc: "O_CREAT", header: "<sys/fcntl.h>".}: cint
var O_EXCL* {.importc: "O_EXCL", header: "<sys/fcntl.h>".}: cint
# var O_NOCTTY* {.importc: "O_NOCTTY", header: "<sys/fcntl.h>".}: cint
var O_TRUNC* {.importc: "O_TRUNC", header: "<sys/fcntl.h>".}: cint
var O_APPEND* {.importc: "O_APPEND", header: "<sys/fcntl.h>".}: cint
# var O_DSYNC* {.importc: "O_DSYNC", header: "<sys/fcntl.h>".}: cint
var O_NONBLOCK* {.importc: "O_NONBLOCK", header: "<sys/fcntl.h>".}: cint
# var O_RSYNC* {.importc: "O_RSYNC", header: "<sys/fcntl.h>".}: cint
# var O_SYNC* {.importc: "O_SYNC", header: "<sys/fcntl.h>".}: cint
# var O_ACCMODE* {.importc: "O_ACCMODE", header: "<sys/fcntl.h>".}: cint
var O_RDONLY* {.importc: "O_RDONLY", header: "<sys/fcntl.h>".}: cint
var O_RDWR* {.importc: "O_RDWR", header: "<sys/fcntl.h>".}: cint
var O_WRONLY* {.importc: "O_WRONLY", header: "<sys/fcntl.h>".}: cint
# var O_CLOEXEC* {.importc: "O_CLOEXEC", header: "<sys/fcntl.h>".}: cint

# # <locale.h>
# var LC_ALL* {.importc: "LC_ALL", header: "<locale.h>".}: cint
# var LC_COLLATE* {.importc: "LC_COLLATE", header: "<locale.h>".}: cint
# var LC_CTYPE* {.importc: "LC_CTYPE", header: "<locale.h>".}: cint
# var LC_MESSAGES* {.importc: "LC_MESSAGES", header: "<locale.h>".}: cint
# var LC_MONETARY* {.importc: "LC_MONETARY", header: "<locale.h>".}: cint
# var LC_NUMERIC* {.importc: "LC_NUMERIC", header: "<locale.h>".}: cint
# var LC_TIME* {.importc: "LC_TIME", header: "<locale.h>".}: cint

# <netdb.h>
var HOST_NOT_FOUND* {.importc: "HOST_NOT_FOUND", header: "<netdb.h>".}: cint
var NO_DATA* {.importc: "NO_DATA", header: "<netdb.h>".}: cint
var NO_RECOVERY* {.importc: "NO_RECOVERY", header: "<netdb.h>".}: cint
var TRY_AGAIN* {.importc: "TRY_AGAIN", header: "<netdb.h>".}: cint
var AI_PASSIVE* {.importc: "AI_PASSIVE", header: "<netdb.h>".}: cint
var AI_CANONNAME* {.importc: "AI_CANONNAME", header: "<netdb.h>".}: cint
var AI_NUMERICHOST* {.importc: "AI_NUMERICHOST", header: "<netdb.h>".}: cint
var AI_NUMERICSERV* {.importc: "AI_NUMERICSERV", header: "<netdb.h>".}: cint
var AI_V4MAPPED* {.importc: "AI_V4MAPPED", header: "<netdb.h>".}: cint
var AI_ALL* {.importc: "AI_ALL", header: "<netdb.h>".}: cint
var AI_ADDRCONFIG* {.importc: "AI_ADDRCONFIG", header: "<netdb.h>".}: cint
var NI_NOFQDN* {.importc: "NI_NOFQDN", header: "<netdb.h>".}: cint
var NI_NUMERICHOST* {.importc: "NI_NUMERICHOST", header: "<netdb.h>".}: cint
var NI_NAMEREQD* {.importc: "NI_NAMEREQD", header: "<netdb.h>".}: cint
var NI_NUMERICSERV* {.importc: "NI_NUMERICSERV", header: "<netdb.h>".}: cint
var NI_DGRAM* {.importc: "NI_DGRAM", header: "<netdb.h>".}: cint
var EAI_AGAIN* {.importc: "EAI_AGAIN", header: "<netdb.h>".}: cint
var EAI_BADFLAGS* {.importc: "EAI_BADFLAGS", header: "<netdb.h>".}: cint
var EAI_FAIL* {.importc: "EAI_FAIL", header: "<netdb.h>".}: cint
var EAI_FAMILY* {.importc: "EAI_FAMILY", header: "<netdb.h>".}: cint
var EAI_MEMORY* {.importc: "EAI_MEMORY", header: "<netdb.h>".}: cint
var EAI_NONAME* {.importc: "EAI_NONAME", header: "<netdb.h>".}: cint
var EAI_SERVICE* {.importc: "EAI_SERVICE", header: "<netdb.h>".}: cint
var EAI_SOCKTYPE* {.importc: "EAI_SOCKTYPE", header: "<netdb.h>".}: cint

var LWIP_DNS_API_DECLARE_H_ERRNO* {.importc: "LWIP_DNS_API_DECLARE_H_ERRNO", header: "<netdb.h>".}: cint
var LWIP_DNS_API_DEFINE_ERRORS* {.importc: "LWIP_DNS_API_DEFINE_ERRORS", header: "<netdb.h>".}: cint
var LWIP_DNS_API_DEFINE_FLAGS* {.importc: "LWIP_DNS_API_DEFINE_FLAGS", header: "<netdb.h>".}: cint
var LWIP_DNS_API_DECLARE_STRUCTS* {.importc: "LWIP_DNS_API_DECLARE_STRUCTS", header: "<netdb.h>".}: cint
var NETDB_ELEM_SIZE* {.importc: "NETDB_ELEM_SIZE", header: "<netdb.h>".}: cint


# <netif.h>
var ENABLE_LOOPBACK* {.importc: "ENABLE_LOOPBACK", header: "<netif.h>".}: cint
var NETIF_MAX_HWADDR_LEN* {.importc: "NETIF_MAX_HWADDR_LEN", header: "<netif.h>".}: cint
var NETIF_NAMESIZE* {.importc: "NETIF_NAMESIZE", header: "<netif.h>".}: cint
var NETIF_FLAG_UP* {.importc: "NETIF_FLAG_UP", header: "<netif.h>".}: cint
var NETIF_FLAG_BROADCAST* {.importc: "NETIF_FLAG_BROADCAST", header: "<netif.h>".}: cint
var NETIF_FLAG_LINK_UP* {.importc: "NETIF_FLAG_LINK_UP", header: "<netif.h>".}: cint
var NETIF_FLAG_ETHARP* {.importc: "NETIF_FLAG_ETHARP", header: "<netif.h>".}: cint
var NETIF_FLAG_ETHERNET* {.importc: "NETIF_FLAG_ETHERNET", header: "<netif.h>".}: cint
var NETIF_FLAG_IGMP* {.importc: "NETIF_FLAG_IGMP", header: "<netif.h>".}: cint
var NETIF_FLAG_MLD6* {.importc: "NETIF_FLAG_MLD6", header: "<netif.h>".}: cint
var NETIF_FLAG_GARP* {.importc: "NETIF_FLAG_GARP", header: "<netif.h>".}: cint
var NETIF_CHECKSUM_GEN_IP* {.importc: "NETIF_CHECKSUM_GEN_IP", header: "<netif.h>".}: cint
var NETIF_CHECKSUM_GEN_UDP* {.importc: "NETIF_CHECKSUM_GEN_UDP", header: "<netif.h>".}: cint
var NETIF_CHECKSUM_GEN_TCP* {.importc: "NETIF_CHECKSUM_GEN_TCP", header: "<netif.h>".}: cint
var NETIF_CHECKSUM_GEN_ICMP* {.importc: "NETIF_CHECKSUM_GEN_ICMP", header: "<netif.h>".}: cint
var NETIF_CHECKSUM_GEN_ICMP6* {.importc: "NETIF_CHECKSUM_GEN_ICMP6", header: "<netif.h>".}: cint
var NETIF_CHECKSUM_CHECK_IP* {.importc: "NETIF_CHECKSUM_CHECK_IP", header: "<netif.h>".}: cint
var NETIF_CHECKSUM_CHECK_UDP* {.importc: "NETIF_CHECKSUM_CHECK_UDP", header: "<netif.h>".}: cint
var NETIF_CHECKSUM_CHECK_TCP* {.importc: "NETIF_CHECKSUM_CHECK_TCP", header: "<netif.h>".}: cint
var NETIF_CHECKSUM_CHECK_ICMP* {.importc: "NETIF_CHECKSUM_CHECK_ICMP", header: "<netif.h>".}: cint
var NETIF_CHECKSUM_CHECK_ICMP6* {.importc: "NETIF_CHECKSUM_CHECK_ICMP6", header: "<netif.h>".}: cint
var NETIF_CHECKSUM_ENABLE_ALL* {.importc: "NETIF_CHECKSUM_ENABLE_ALL", header: "<netif.h>".}: cint
var NETIF_CHECKSUM_DISABLE_ALL* {.importc: "NETIF_CHECKSUM_DISABLE_ALL", header: "<netif.h>".}: cint
var NETIF_ADDR_IDX_MAX* {.importc: "NETIF_ADDR_IDX_MAX", header: "<netif.h>".}: cint
var LWIP_NETIF_USE_HINTS* {.importc: "LWIP_NETIF_USE_HINTS", header: "<netif.h>".}: cint
var NETIF_NO_INDEX* {.importc: "NETIF_NO_INDEX", header: "<netif.h>".}: cint
var LWIP_NSC_NONE* {.importc: "LWIP_NSC_NONE", header: "<netif.h>".}: cint
var LWIP_NSC_NETIF_ADDED* {.importc: "LWIP_NSC_NETIF_ADDED", header: "<netif.h>".}: cint
var LWIP_NSC_NETIF_REMOVED* {.importc: "LWIP_NSC_NETIF_REMOVED", header: "<netif.h>".}: cint
var LWIP_NSC_LINK_CHANGED* {.importc: "LWIP_NSC_LINK_CHANGED", header: "<netif.h>".}: cint
var LWIP_NSC_STATUS_CHANGED* {.importc: "LWIP_NSC_STATUS_CHANGED", header: "<netif.h>".}: cint
var LWIP_NSC_IPV4_ADDRESS_CHANGED* {.importc: "LWIP_NSC_IPV4_ADDRESS_CHANGED", header: "<netif.h>".}: cint
var LWIP_NSC_IPV4_GATEWAY_CHANGED* {.importc: "LWIP_NSC_IPV4_GATEWAY_CHANGED", header: "<netif.h>".}: cint
var LWIP_NSC_IPV4_NETMASK_CHANGED* {.importc: "LWIP_NSC_IPV4_NETMASK_CHANGED", header: "<netif.h>".}: cint
var LWIP_NSC_IPV4_SETTINGS_CHANGED* {.importc: "LWIP_NSC_IPV4_SETTINGS_CHANGED", header: "<netif.h>".}: cint
var LWIP_NSC_IPV6_SET* {.importc: "LWIP_NSC_IPV6_SET", header: "<netif.h>".}: cint
var LWIP_NSC_IPV6_ADDR_STATE_CHANGED* {.importc: "LWIP_NSC_IPV6_ADDR_STATE_CHANGED", header: "<netif.h>".}: cint
#define NETIF_DECLARE_EXT_CALLBACK(name)


# <net/if.h>
var IF_NAMESIZE* {.importc: "IF_NAMESIZE", header: "<net/if.h>".}: cint

# <sys/socket.h>
var IPPROTO_IP* {.importc: "IPPROTO_IP", header: "<sys/socket.h>".}: cint
var IPPROTO_IPV6* {.importc: "IPPROTO_IPV6", header: "<sys/socket.h>".}: cint
var IPPROTO_ICMP* {.importc: "IPPROTO_ICMP", header: "<sys/socket.h>".}: cint
var IPPROTO_ICMPV6* {.importc: "IPPROTO_ICMPV6", header: "<sys/socket.h>".}: cint
var IPPROTO_RAW* {.importc: "IPPROTO_RAW", header: "<sys/socket.h>".}: cint
var IPPROTO_TCP* {.importc: "IPPROTO_TCP", header: "<sys/socket.h>".}: cint
var IPPROTO_UDP* {.importc: "IPPROTO_UDP", header: "<sys/socket.h>".}: cint
var INADDR_ANY* {.importc: "INADDR_ANY", header: "<sys/socket.h>".}: InAddrScalar
var INADDR_LOOPBACK* {.importc: "INADDR_LOOPBACK", header: "<sys/socket.h>".}: InAddrScalar
var INADDR_BROADCAST* {.importc: "INADDR_BROADCAST", header: "<sys/socket.h>".}: InAddrScalar
var INET_ADDRSTRLEN* {.importc: "INET_ADDRSTRLEN", header: "<sys/socket.h>".}: cint
var INET6_ADDRSTRLEN* {.importc: "INET6_ADDRSTRLEN", header: "<sys/socket.h>".}: cint
var IPV6_JOIN_GROUP* {.importc: "IPV6_JOIN_GROUP", header: "<sys/socket.h>".}: cint
var IPV6_LEAVE_GROUP* {.importc: "IPV6_LEAVE_GROUP", header: "<sys/socket.h>".}: cint
var IPV6_MULTICAST_HOPS* {.importc: "IPV6_MULTICAST_HOPS", header: "<sys/socket.h>".}: cint
var IPV6_MULTICAST_IF* {.importc: "IPV6_MULTICAST_IF", header: "<sys/socket.h>".}: cint
var IPV6_MULTICAST_LOOP* {.importc: "IPV6_MULTICAST_LOOP", header: "<sys/socket.h>".}: cint
var IPV6_UNICAST_HOPS* {.importc: "IPV6_UNICAST_HOPS", header: "<sys/socket.h>".}: cint
var IPV6_V6ONLY* {.importc: "IPV6_V6ONLY", header: "<sys/socket.h>".}: cint

# <netinet/tcp.h>
const TCP_NODELAY*    = 0x01    # don't delay send to coalesce packets
const TCP_KEEPALIVE*  = 0x02    # send KEEPALIVE probes when idle for pcb->keep_idle milliseconds
const TCP_KEEPIDLE*   = 0x03    # set pcb->keep_idle  - Same as TCP_KEEPALIVE, but use seconds for get/setsockopt
const TCP_KEEPINTVL*  = 0x04    # set pcb->keep_intvl - Use seconds for get/setsockopt
const TCP_KEEPCNT*    = 0x05    # set pcb->keep_cnt   - Use number of probes sent for get/setsockopt

# <nl_types.h>
# var NL_SETD* {.importc: "NL_SETD", header: "<nl_types.h>".}: cint
# var NL_CAT_LOCALE* {.importc: "NL_CAT_LOCALE", header: "<nl_types.h>".}: cint

# <sys/poll.h>
# var POLLIN* {.importc: "POLLIN", header: "<sys/poll.h>".}: cshort
# var POLLRDNORM* {.importc: "POLLRDNORM", header: "<sys/poll.h>".}: cshort
# var POLLRDBAND* {.importc: "POLLRDBAND", header: "<sys/poll.h>".}: cshort
# var POLLPRI* {.importc: "POLLPRI", header: "<sys/poll.h>".}: cshort
# var POLLOUT* {.importc: "POLLOUT", header: "<sys/poll.h>".}: cshort
# var POLLWRNORM* {.importc: "POLLWRNORM", header: "<sys/poll.h>".}: cshort
# var POLLWRBAND* {.importc: "POLLWRBAND", header: "<sys/poll.h>".}: cshort
# var POLLERR* {.importc: "POLLERR", header: "<sys/poll.h>".}: cshort
# var POLLHUP* {.importc: "POLLHUP", header: "<sys/poll.h>".}: cshort
# var POLLNVAL* {.importc: "POLLNVAL", header: "<sys/poll.h>".}: cshort

# <pthread.h>
var PTHREAD_STACK_MIN* {.importc: "PTHREAD_STACK_MIN", header: "<pthread.h>".}: cint
# var PTHREAD_BARRIER_SERIAL_THREAD* {.importc: "PTHREAD_BARRIER_SERIAL_THREAD", header: "<pthread.h>".}: cint
# var PTHREAD_CANCEL_ASYNCHRONOUS* {.importc: "PTHREAD_CANCEL_ASYNCHRONOUS", header: "<pthread.h>".}: cint
# var PTHREAD_CANCEL_ENABLE* {.importc: "PTHREAD_CANCEL_ENABLE", header: "<pthread.h>".}: cint
# var PTHREAD_CANCEL_DEFERRED* {.importc: "PTHREAD_CANCEL_DEFERRED", header: "<pthread.h>".}: cint
# var PTHREAD_CANCEL_DISABLE* {.importc: "PTHREAD_CANCEL_DISABLE", header: "<pthread.h>".}: cint
# var PTHREAD_CREATE_DETACHED* {.importc: "PTHREAD_CREATE_DETACHED", header: "<pthread.h>".}: cint
# var PTHREAD_CREATE_JOINABLE* {.importc: "PTHREAD_CREATE_JOINABLE", header: "<pthread.h>".}: cint
# var PTHREAD_EXPLICIT_SCHED* {.importc: "PTHREAD_EXPLICIT_SCHED", header: "<pthread.h>".}: cint
# var PTHREAD_INHERIT_SCHED* {.importc: "PTHREAD_INHERIT_SCHED", header: "<pthread.h>".}: cint
# var PTHREAD_MUTEX_DEFAULT* {.importc: "PTHREAD_MUTEX_DEFAULT", header: "<pthread.h>".}: cint
# var PTHREAD_MUTEX_ERRORCHECK* {.importc: "PTHREAD_MUTEX_ERRORCHECK", header: "<pthread.h>".}: cint
# var PTHREAD_MUTEX_NORMAL* {.importc: "PTHREAD_MUTEX_NORMAL", header: "<pthread.h>".}: cint
# var PTHREAD_MUTEX_RECURSIVE* {.importc: "PTHREAD_MUTEX_RECURSIVE", header: "<pthread.h>".}: cint
# var PTHREAD_PRIO_INHERIT* {.importc: "PTHREAD_PRIO_INHERIT", header: "<pthread.h>".}: cint
# var PTHREAD_PRIO_NONE* {.importc: "PTHREAD_PRIO_NONE", header: "<pthread.h>".}: cint
# var PTHREAD_PRIO_PROTECT* {.importc: "PTHREAD_PRIO_PROTECT", header: "<pthread.h>".}: cint
# var PTHREAD_PROCESS_SHARED* {.importc: "PTHREAD_PROCESS_SHARED", header: "<pthread.h>".}: cint
# var PTHREAD_PROCESS_PRIVATE* {.importc: "PTHREAD_PROCESS_PRIVATE", header: "<pthread.h>".}: cint
# var PTHREAD_SCOPE_PROCESS* {.importc: "PTHREAD_SCOPE_PROCESS", header: "<pthread.h>".}: cint
# var PTHREAD_SCOPE_SYSTEM* {.importc: "PTHREAD_SCOPE_SYSTEM", header: "<pthread.h>".}: cint

# # <sched.h>
# var SCHED_FIFO* {.importc: "SCHED_FIFO", header: "<sched.h>".}: cint
# var SCHED_RR* {.importc: "SCHED_RR", header: "<sched.h>".}: cint
# var SCHED_SPORADIC* {.importc: "SCHED_SPORADIC", header: "<sched.h>".}: cint
# var SCHED_OTHER* {.importc: "SCHED_OTHER", header: "<sched.h>".}: cint

# <semaphore.h>
var SEM_FAILED* {.importc: "SEM_FAILED", header: "<semaphore.h>".}: pointer

# # <signal.h>
# var SIGEV_NONE* {.importc: "SIGEV_NONE", header: "<signal.h>".}: cint
# var SIGEV_SIGNAL* {.importc: "SIGEV_SIGNAL", header: "<signal.h>".}: cint
# var SIGEV_THREAD* {.importc: "SIGEV_THREAD", header: "<signal.h>".}: cint
# var SIGABRT* {.importc: "SIGABRT", header: "<signal.h>".}: cint
# var SIGALRM* {.importc: "SIGALRM", header: "<signal.h>".}: cint
# var SIGBUS* {.importc: "SIGBUS", header: "<signal.h>".}: cint
# var SIGCHLD* {.importc: "SIGCHLD", header: "<signal.h>".}: cint
# var SIGCONT* {.importc: "SIGCONT", header: "<signal.h>".}: cint
# var SIGFPE* {.importc: "SIGFPE", header: "<signal.h>".}: cint
# var SIGHUP* {.importc: "SIGHUP", header: "<signal.h>".}: cint
# var SIGILL* {.importc: "SIGILL", header: "<signal.h>".}: cint
# var SIGINT* {.importc: "SIGINT", header: "<signal.h>".}: cint
# var SIGKILL* {.importc: "SIGKILL", header: "<signal.h>".}: cint
# var SIGPIPE* {.importc: "SIGPIPE", header: "<signal.h>".}: cint
# var SIGQUIT* {.importc: "SIGQUIT", header: "<signal.h>".}: cint
# var SIGSEGV* {.importc: "SIGSEGV", header: "<signal.h>".}: cint
# var SIGSTOP* {.importc: "SIGSTOP", header: "<signal.h>".}: cint
# var SIGTERM* {.importc: "SIGTERM", header: "<signal.h>".}: cint
# var SIGTSTP* {.importc: "SIGTSTP", header: "<signal.h>".}: cint
# var SIGTTIN* {.importc: "SIGTTIN", header: "<signal.h>".}: cint
# var SIGTTOU* {.importc: "SIGTTOU", header: "<signal.h>".}: cint
# var SIGUSR1* {.importc: "SIGUSR1", header: "<signal.h>".}: cint
# var SIGUSR2* {.importc: "SIGUSR2", header: "<signal.h>".}: cint
# var SIGPOLL* {.importc: "SIGPOLL", header: "<signal.h>".}: cint
# var SIGPROF* {.importc: "SIGPROF", header: "<signal.h>".}: cint
# var SIGSYS* {.importc: "SIGSYS", header: "<signal.h>".}: cint
# var SIGTRAP* {.importc: "SIGTRAP", header: "<signal.h>".}: cint
# var SIGURG* {.importc: "SIGURG", header: "<signal.h>".}: cint
# var SIGVTALRM* {.importc: "SIGVTALRM", header: "<signal.h>".}: cint
# var SIGXCPU* {.importc: "SIGXCPU", header: "<signal.h>".}: cint
# var SIGXFSZ* {.importc: "SIGXFSZ", header: "<signal.h>".}: cint
# var SA_NOCLDSTOP* {.importc: "SA_NOCLDSTOP", header: "<signal.h>".}: cint
# var SIG_BLOCK* {.importc: "SIG_BLOCK", header: "<signal.h>".}: cint
# var SIG_UNBLOCK* {.importc: "SIG_UNBLOCK", header: "<signal.h>".}: cint
# var SIG_SETMASK* {.importc: "SIG_SETMASK", header: "<signal.h>".}: cint
# var SA_ONSTACK* {.importc: "SA_ONSTACK", header: "<signal.h>".}: cint
# var SA_RESETHAND* {.importc: "SA_RESETHAND", header: "<signal.h>".}: cint
# var SA_RESTART* {.importc: "SA_RESTART", header: "<signal.h>".}: cint
# var SA_SIGINFO* {.importc: "SA_SIGINFO", header: "<signal.h>".}: cint
# var SA_NOCLDWAIT* {.importc: "SA_NOCLDWAIT", header: "<signal.h>".}: cint
# var SA_NODEFER* {.importc: "SA_NODEFER", header: "<signal.h>".}: cint
# var SS_ONSTACK* {.importc: "SS_ONSTACK", header: "<signal.h>".}: cint
# var SS_DISABLE* {.importc: "SS_DISABLE", header: "<signal.h>".}: cint
# var MINSIGSTKSZ* {.importc: "MINSIGSTKSZ", header: "<signal.h>".}: cint
# var SIGSTKSZ* {.importc: "SIGSTKSZ", header: "<signal.h>".}: cint
# var SIG_HOLD* {.importc: "SIG_HOLD", header: "<signal.h>".}: Sighandler
# var SIG_DFL* {.importc: "SIG_DFL", header: "<signal.h>".}: Sighandler
# var SIG_ERR* {.importc: "SIG_ERR", header: "<signal.h>".}: Sighandler
# var SIG_IGN* {.importc: "SIG_IGN", header: "<signal.h>".}: Sighandler

# # <sys/ipc.h>
# var IPC_CREAT* {.importc: "IPC_CREAT", header: "<sys/ipc.h>".}: cint
# var IPC_EXCL* {.importc: "IPC_EXCL", header: "<sys/ipc.h>".}: cint
# var IPC_NOWAIT* {.importc: "IPC_NOWAIT", header: "<sys/ipc.h>".}: cint
# var IPC_PRIVATE* {.importc: "IPC_PRIVATE", header: "<sys/ipc.h>".}: cint
# var IPC_RMID* {.importc: "IPC_RMID", header: "<sys/ipc.h>".}: cint
# var IPC_SET* {.importc: "IPC_SET", header: "<sys/ipc.h>".}: cint
# var IPC_STAT* {.importc: "IPC_STAT", header: "<sys/ipc.h>".}: cint

# # <sys/mman.h>
# var PROT_READ* {.importc: "PROT_READ", header: "<sys/mman.h>".}: cint
# var PROT_WRITE* {.importc: "PROT_WRITE", header: "<sys/mman.h>".}: cint
# var PROT_EXEC* {.importc: "PROT_EXEC", header: "<sys/mman.h>".}: cint
# var PROT_NONE* {.importc: "PROT_NONE", header: "<sys/mman.h>".}: cint
# var MAP_ANONYMOUS* {.importc: "MAP_ANONYMOUS", header: "<sys/mman.h>".}: cint
# var MAP_FIXED_NOREPLACE* {.importc: "MAP_FIXED_NOREPLACE", header: "<sys/mman.h>".}: cint
# var MAP_NORESERVE* {.importc: "MAP_NORESERVE", header: "<sys/mman.h>".}: cint
# var MAP_SHARED* {.importc: "MAP_SHARED", header: "<sys/mman.h>".}: cint
# var MAP_PRIVATE* {.importc: "MAP_PRIVATE", header: "<sys/mman.h>".}: cint
# var MAP_FIXED* {.importc: "MAP_FIXED", header: "<sys/mman.h>".}: cint
# var MS_ASYNC* {.importc: "MS_ASYNC", header: "<sys/mman.h>".}: cint
# var MS_SYNC* {.importc: "MS_SYNC", header: "<sys/mman.h>".}: cint
# var MS_INVALIDATE* {.importc: "MS_INVALIDATE", header: "<sys/mman.h>".}: cint
# var MCL_CURRENT* {.importc: "MCL_CURRENT", header: "<sys/mman.h>".}: cint
# var MCL_FUTURE* {.importc: "MCL_FUTURE", header: "<sys/mman.h>".}: cint
# var MAP_FAILED* {.importc: "MAP_FAILED", header: "<sys/mman.h>".}: pointer
# var POSIX_MADV_NORMAL* {.importc: "POSIX_MADV_NORMAL", header: "<sys/mman.h>".}: cint
# var POSIX_MADV_SEQUENTIAL* {.importc: "POSIX_MADV_SEQUENTIAL", header: "<sys/mman.h>".}: cint
# var POSIX_MADV_RANDOM* {.importc: "POSIX_MADV_RANDOM", header: "<sys/mman.h>".}: cint
# var POSIX_MADV_WILLNEED* {.importc: "POSIX_MADV_WILLNEED", header: "<sys/mman.h>".}: cint
# var POSIX_MADV_DONTNEED* {.importc: "POSIX_MADV_DONTNEED", header: "<sys/mman.h>".}: cint
# var POSIX_TYPED_MEM_ALLOCATE* {.importc: "POSIX_TYPED_MEM_ALLOCATE", header: "<sys/mman.h>".}: cint
# var POSIX_TYPED_MEM_ALLOCATE_CONTIG* {.importc: "POSIX_TYPED_MEM_ALLOCATE_CONTIG", header: "<sys/mman.h>".}: cint
# var POSIX_TYPED_MEM_MAP_ALLOCATABLE* {.importc: "POSIX_TYPED_MEM_MAP_ALLOCATABLE", header: "<sys/mman.h>".}: cint

# <sys/resource.h>
# var RLIMIT_NOFILE* {.importc: "RLIMIT_NOFILE", header: "<sys/resource.h>".}: cint

var FD_MAX* {.importc: "CONFIG_LWIP_MAX_SOCKETS", header: "<lwipopts.h>".}: cint

# <sys/select.h>
var FD_SETSIZE* {.importc: "FD_SETSIZE", header: "<sys/select.h>".}: cint

# <sys/socket.h>
# struct msghdr->msg_flags bit field values 
const MSG_TRUNC*   = 0x04
const MSG_CTRUNC*  = 0x08

# Flags we can use with send and recv.
const MSG_PEEK*       = 0x01    # Peeks at an incoming message
const MSG_WAITALL*    = 0x02    # Unimplemented: Requests that the function block until the full amount of data requested can be returned
const MSG_OOB*        = 0x04    # Unimplemented: Requests out-of-band data. The significance and semantics of out-of-band data are protocol-specific
const MSG_DONTWAIT*   = 0x08    # Nonblocking i/o for this operation only
const MSG_MORE*       = 0x10    # Sender will send more
# const MSG_NOSIGNAL*   = 0x20    # Uninmplemented: Requests not to send the SIGPIPE signal if an attempt to send is made on a stream-oriented socket that is no longer connected.

# Alternately, they can defined like this, but the above seems better when they're known/stable values:
# var MSG_TRUNC* {.importc: "MSG_TRUNC", header: "<sys/socket.h>".}: cint
# var MSG_CTRUNC* {.importc: "MSG_CTRUNC", header: "<sys/socket.h>".}: cint
# var MSG_DONTROUTE* {.importc: "MSG_DONTROUTE", header: "<sys/socket.h>".}: cint # not defined in lwip
# var MSG_EOR* {.importc: "MSG_EOR", header: "<sys/socket.h>".}: cint # not defined in lwip
# var MSG_OOB* {.importc: "MSG_OOB", header: "<sys/socket.h>".}: cint


# var SCM_RIGHTS* {.importc: "SCM_RIGHTS", header: "<sys/socket.h>".}: cint
var SO_ACCEPTCONN* {.importc: "SO_ACCEPTCONN", header: "<sys/socket.h>".}: cint
var SO_BROADCAST* {.importc: "SO_BROADCAST", header: "<sys/socket.h>".}: cint
var SO_DEBUG* {.importc: "SO_DEBUG", header: "<sys/socket.h>".}: cint
var SO_DONTROUTE* {.importc: "SO_DONTROUTE", header: "<sys/socket.h>".}: cint
var SO_ERROR* {.importc: "SO_ERROR", header: "<sys/socket.h>".}: cint
var SO_KEEPALIVE* {.importc: "SO_KEEPALIVE", header: "<sys/socket.h>".}: cint
var SO_LINGER* {.importc: "SO_LINGER", header: "<sys/socket.h>".}: cint
var SO_OOBINLINE* {.importc: "SO_OOBINLINE", header: "<sys/socket.h>".}: cint
var SO_RCVBUF* {.importc: "SO_RCVBUF", header: "<sys/socket.h>".}: cint
var SO_RCVLOWAT* {.importc: "SO_RCVLOWAT", header: "<sys/socket.h>".}: cint
var SO_RCVTIMEO* {.importc: "SO_RCVTIMEO", header: "<sys/socket.h>".}: cint
var SO_REUSEADDR* {.importc: "SO_REUSEADDR", header: "<sys/socket.h>".}: cint
var SO_SNDBUF* {.importc: "SO_SNDBUF", header: "<sys/socket.h>".}: cint
var SO_SNDLOWAT* {.importc: "SO_SNDLOWAT", header: "<sys/socket.h>".}: cint
var SO_SNDTIMEO* {.importc: "SO_SNDTIMEO", header: "<sys/socket.h>".}: cint
var SO_TYPE* {.importc: "SO_TYPE", header: "<sys/socket.h>".}: cint
var SOCK_DGRAM* {.importc: "SOCK_DGRAM", header: "<sys/socket.h>".}: cint
var SOCK_RAW* {.importc: "SOCK_RAW", header: "<sys/socket.h>".}: cint

# var SOCK_SEQPACKET* {.importc: "SOCK_SEQPACKET", header: "<sys/socket.h>".}: cint
const SOCK_SEQPACKET* = cint(5)

var SOCK_STREAM* {.importc: "SOCK_STREAM", header: "<sys/socket.h>".}: cint
var SOL_SOCKET* {.importc: "SOL_SOCKET", header: "<sys/socket.h>".}: cint

const SocketMaxConnections {.intdefine.}: int = 32
var SOMAXCONN*: cint = SocketMaxConnections.cint

var AF_INET* {.importc: "AF_INET", header: "<sys/socket.h>".}: cint
var AF_INET6* {.importc: "AF_INET6", header: "<sys/socket.h>".}: cint
# var AF_UNIX* {.importc: "AF_UNIX", header: "<sys/socket.h>".}: cint
const AF_UNIX*: cint = 1 # for compat with Nim libraries, doesn't exist on freertos
var AF_UNSPEC* {.importc: "AF_UNSPEC", header: "<sys/socket.h>".}: cint
var SHUT_RD* {.importc: "SHUT_RD", header: "<sys/socket.h>".}: cint
var SHUT_RDWR* {.importc: "SHUT_RDWR", header: "<sys/socket.h>".}: cint
var SHUT_WR* {.importc: "SHUT_WR", header: "<sys/socket.h>".}: cint

# # <sys/stat.h>
# <sys/stat.h>

# var S_IFBLK* {.importc: "S_IFBLK", header: "<sys/stat.h>".}: cint
# var S_IFCHR* {.importc: "S_IFCHR", header: "<sys/stat.h>".}: cint
# var S_IFDIR* {.importc: "S_IFDIR", header: "<sys/stat.h>".}: cint
# var S_IFIFO* {.importc: "S_IFIFO", header: "<sys/stat.h>".}: cint
# var S_IFLNK* {.importc: "S_IFLNK", header: "<sys/stat.h>".}: cint
# var S_IFMT* {.importc: "S_IFMT", header: "<sys/stat.h>".}: cint
# var S_IFREG* {.importc: "S_IFREG", header: "<sys/stat.h>".}: cint
# var S_IFSOCK* {.importc: "S_IFSOCK", header: "<sys/stat.h>".}: cint
var S_IRGRP* {.importc: "S_IRGRP", header: "<sys/stat.h>".}: cint
var S_IROTH* {.importc: "S_IROTH", header: "<sys/stat.h>".}: cint
var S_IRUSR* {.importc: "S_IRUSR", header: "<sys/stat.h>".}: cint
# var S_IRWXG* {.importc: "S_IRWXG", header: "<sys/stat.h>".}: cint
# var S_IRWXO* {.importc: "S_IRWXO", header: "<sys/stat.h>".}: cint
# var S_IRWXU* {.importc: "S_IRWXU", header: "<sys/stat.h>".}: cint
# var S_ISGID* {.importc: "S_ISGID", header: "<sys/stat.h>".}: cint
# var S_ISUID* {.importc: "S_ISUID", header: "<sys/stat.h>".}: cint
# var S_ISVTX* {.importc: "S_ISVTX", header: "<sys/stat.h>".}: cint
var S_IWGRP* {.importc: "S_IWGRP", header: "<sys/stat.h>".}: cint
var S_IWOTH* {.importc: "S_IWOTH", header: "<sys/stat.h>".}: cint
var S_IWUSR* {.importc: "S_IWUSR", header: "<sys/stat.h>".}: cint
var S_IXGRP* {.importc: "S_IXGRP", header: "<sys/stat.h>".}: cint
var S_IXOTH* {.importc: "S_IXOTH", header: "<sys/stat.h>".}: cint
var S_IXUSR* {.importc: "S_IXUSR", header: "<sys/stat.h>".}: cint

# # <sys/statvfs.h>
# var ST_RDONLY* {.importc: "ST_RDONLY", header: "<sys/statvfs.h>".}: cint
# var ST_NOSUID* {.importc: "ST_NOSUID", header: "<sys/statvfs.h>".}: cint

# # <sys/wait.h>
# var WNOHANG* {.importc: "WNOHANG", header: "<sys/wait.h>".}: cint
# var WUNTRACED* {.importc: "WUNTRACED", header: "<sys/wait.h>".}: cint
# var WEXITED* {.importc: "WEXITED", header: "<sys/wait.h>".}: cint
# var WSTOPPED* {.importc: "WSTOPPED", header: "<sys/wait.h>".}: cint
# var WCONTINUED* {.importc: "WCONTINUED", header: "<sys/wait.h>".}: cint
# var WNOWAIT* {.importc: "WNOWAIT", header: "<sys/wait.h>".}: cint
# var P_ALL* {.importc: "P_ALL", header: "<sys/wait.h>".}: cint
# var P_PID* {.importc: "P_PID", header: "<sys/wait.h>".}: cint
# var P_PGID* {.importc: "P_PGID", header: "<sys/wait.h>".}: cint

# # <spawn.h>
# var POSIX_SPAWN_RESETIDS* {.importc: "POSIX_SPAWN_RESETIDS", header: "<spawn.h>".}: cint
# var POSIX_SPAWN_SETPGROUP* {.importc: "POSIX_SPAWN_SETPGROUP", header: "<spawn.h>".}: cint
# var POSIX_SPAWN_SETSCHEDPARAM* {.importc: "POSIX_SPAWN_SETSCHEDPARAM", header: "<spawn.h>".}: cint
# var POSIX_SPAWN_SETSCHEDULER* {.importc: "POSIX_SPAWN_SETSCHEDULER", header: "<spawn.h>".}: cint
# var POSIX_SPAWN_SETSIGDEF* {.importc: "POSIX_SPAWN_SETSIGDEF", header: "<spawn.h>".}: cint
# var POSIX_SPAWN_SETSIGMASK* {.importc: "POSIX_SPAWN_SETSIGMASK", header: "<spawn.h>".}: cint

## <stdio.h>
# var IOFBF* {.importc: "_IOFBF", header: "<stdio.h>".}: cint
# var IONBF* {.importc: "_IONBF", header: "<stdio.h>".}: cint

# <time.h>
var CLOCKS_PER_SEC* {.importc: "CLOCKS_PER_SEC", header: "<time.h>".}: clong
var CLOCK_PROCESS_CPUTIME_ID* {.importc: "CLOCK_PROCESS_CPUTIME_ID", header: "<time.h>".}: cint
var CLOCK_THREAD_CPUTIME_ID* {.importc: "CLOCK_THREAD_CPUTIME_ID", header: "<time.h>".}: cint
var CLOCK_REALTIME* {.importc: "CLOCK_REALTIME", header: "<time.h>".}: cint
var TIMER_ABSTIME* {.importc: "TIMER_ABSTIME", header: "<time.h>".}: cint
var CLOCK_MONOTONIC* {.importc: "CLOCK_MONOTONIC", header: "<time.h>".}: cint

# <unistd.h>

const F_OK* = cint(0)
const R_OK* = cint(4)
const W_OK* = cint(2)
const X_OK* = cint(1)
const F_LOCK* = cint(1)
const F_TEST* = cint(3)
const F_TLOCK* = cint(2)
const F_ULOCK* = cint(0)

# <stdio.h>
const SEEK_SET* = cint(0)
const SEEK_CUR* = cint(1)
const SEEK_END* = cint(2)
