1/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2#pragma once
3
4#cmakedefine HAVE_NETINET_IN_H ${HAVE_NETINET_IN_H}
5#cmakedefine HAVE_ARPA_INET_H ${HAVE_ARPA_INET_H}
6#cmakedefine HAVE_INTTYPES_H ${HAVE_INTTYPES_H}
7#cmakedefine HAVE_UNISTD_H ${HAVE_UNISTD_H}
8#cmakedefine HAVE_FDATASYNC ${HAVE_FDATASYNC}
9#cmakedefine HAVE_QSORT_R ${HAVE_QSORT_R}
10
11/* Large File Support */
12#define _LARGE_FILE 1
13#ifndef _FILE_OFFSET_BITS
14#  define _FILE_OFFSET_BITS 64
15#elif (_FILE_OFFSET_BITS != 64)
16#error "bad things"
17#endif
18#define _LARGEFILE_SOURCE 1
19#ifndef O_LARGEFILE
20# define O_LARGEFILE 0
21#endif
22
23#include <sys/types.h>
24
25#ifdef HAVE_NETINET_IN_H
26#include <netinet/in.h>
27#endif
28
29#ifdef HAVE_ARPA_INET_H
30#include <arpa/inet.h>
31#endif
32
33#ifdef HAVE_INTTYPES_H
34#include <inttypes.h>
35#endif
36
37#ifdef HAVE_UNISTD_H
38#include <unistd.h>
39#endif
40
41#ifdef __APPLE__
42/* autoconf things OS X has fdatasync but it doesn't */
43#define fdatasync(FD) fsync(FD)
44#endif /* __APPLE__ */
45
46#ifdef linux
47#undef ntohs
48#undef ntohl
49#undef htons
50#undef htonl
51#endif
52
53#if defined(WIN32) || defined(_WIN32)
54#define WINDOWS
55/* Mute:
56 * "The POSIX name for this item is deprecated. Instead, use the ISO
57 * C++ conformant name: _strdup."
58*/
59#pragma warning(disable: 4996)
60
61/* we need ntohl with friends (included through arpa/inet.h for *nix */
62#include <Winsock2.h>
63
64#endif
65
66// Sanitizer annotations
67#if defined(__has_attribute)
68#  if __has_attribute(no_sanitize_undefined)
69     // GCC only supports the top-level "no_sanitize_undefined"; so have to
70     // turn off all UBSan checks just to disable vptr checks :(
71#    define NO_SANITIZE_VPTR __attribute__((no_sanitize_undefined))
72#  elif __has_attribute(no_sanitize)
73     // Can turn off the specific vptr sanitizer.
74#    define NO_SANITIZE_VPTR __attribute__((no_sanitize("vptr")))
75#  endif
76#endif
77#if !defined(NO_SANITIZE_VPTR)
78#  define NO_SANITIZE_VPTR
79#endif
80