1999e7ef5STrond Norbye/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
20c640a13STrond Norbye#pragma once
30c640a13STrond Norbye
40c640a13STrond Norbye#cmakedefine HAVE_NETINET_IN_H ${HAVE_NETINET_IN_H}
50c640a13STrond Norbye#cmakedefine HAVE_ARPA_INET_H ${HAVE_ARPA_INET_H}
60c640a13STrond Norbye#cmakedefine HAVE_INTTYPES_H ${HAVE_INTTYPES_H}
7462b7a82STrond Norbye#cmakedefine HAVE_UNISTD_H ${HAVE_UNISTD_H}
80c640a13STrond Norbye#cmakedefine HAVE_FDATASYNC ${HAVE_FDATASYNC}
923b42d51SSarath Lakshman#cmakedefine HAVE_QSORT_R ${HAVE_QSORT_R}
100c640a13STrond Norbye
11999e7ef5STrond Norbye/* Large File Support */
12999e7ef5STrond Norbye#define _LARGE_FILE 1
13999e7ef5STrond Norbye#ifndef _FILE_OFFSET_BITS
14999e7ef5STrond Norbye#  define _FILE_OFFSET_BITS 64
15999e7ef5STrond Norbye#elif (_FILE_OFFSET_BITS != 64)
16999e7ef5STrond Norbye#error "bad things"
17999e7ef5STrond Norbye#endif
18999e7ef5STrond Norbye#define _LARGEFILE_SOURCE 1
19999e7ef5STrond Norbye#ifndef O_LARGEFILE
20999e7ef5STrond Norbye# define O_LARGEFILE 0
21999e7ef5STrond Norbye#endif
22999e7ef5STrond Norbye
23999e7ef5STrond Norbye#include <sys/types.h>
24999e7ef5STrond Norbye
25999e7ef5STrond Norbye#ifdef HAVE_NETINET_IN_H
26999e7ef5STrond Norbye#include <netinet/in.h>
27999e7ef5STrond Norbye#endif
28999e7ef5STrond Norbye
29999e7ef5STrond Norbye#ifdef HAVE_ARPA_INET_H
30999e7ef5STrond Norbye#include <arpa/inet.h>
31999e7ef5STrond Norbye#endif
32999e7ef5STrond Norbye
33999e7ef5STrond Norbye#ifdef HAVE_INTTYPES_H
34999e7ef5STrond Norbye#include <inttypes.h>
35999e7ef5STrond Norbye#endif
36999e7ef5STrond Norbye
37999e7ef5STrond Norbye#ifdef HAVE_UNISTD_H
38999e7ef5STrond Norbye#include <unistd.h>
39999e7ef5STrond Norbye#endif
40999e7ef5STrond Norbye
41999e7ef5STrond Norbye#ifdef __APPLE__
42999e7ef5STrond Norbye/* autoconf things OS X has fdatasync but it doesn't */
43999e7ef5STrond Norbye#define fdatasync(FD) fsync(FD)
44999e7ef5STrond Norbye#endif /* __APPLE__ */
45999e7ef5STrond Norbye
46999e7ef5STrond Norbye#ifdef linux
47999e7ef5STrond Norbye#undef ntohs
48999e7ef5STrond Norbye#undef ntohl
49999e7ef5STrond Norbye#undef htons
50999e7ef5STrond Norbye#undef htonl
51999e7ef5STrond Norbye#endif
52999e7ef5STrond Norbye
53999e7ef5STrond Norbye#if defined(WIN32) || defined(_WIN32)
54999e7ef5STrond Norbye#define WINDOWS
55999e7ef5STrond Norbye/* Mute:
56999e7ef5STrond Norbye * "The POSIX name for this item is deprecated. Instead, use the ISO
57999e7ef5STrond Norbye * C++ conformant name: _strdup."
58999e7ef5STrond Norbye*/
59999e7ef5STrond Norbye#pragma warning(disable: 4996)
60909e8a5cSTrond Norbye
61909e8a5cSTrond Norbye/* we need ntohl with friends (included through arpa/inet.h for *nix */
62909e8a5cSTrond Norbye#include <Winsock2.h>
63909e8a5cSTrond Norbye
64999e7ef5STrond Norbye#endif
656b256085SDave Rigby
666b256085SDave Rigby// Sanitizer annotations
676b256085SDave Rigby#if defined(__has_attribute)
686b256085SDave Rigby#  if __has_attribute(no_sanitize_undefined)
696b256085SDave Rigby     // GCC only supports the top-level "no_sanitize_undefined"; so have to
706b256085SDave Rigby     // turn off all UBSan checks just to disable vptr checks :(
716b256085SDave Rigby#    define NO_SANITIZE_VPTR __attribute__((no_sanitize_undefined))
726b256085SDave Rigby#  elif __has_attribute(no_sanitize)
736b256085SDave Rigby     // Can turn off the specific vptr sanitizer.
746b256085SDave Rigby#    define NO_SANITIZE_VPTR __attribute__((no_sanitize("vptr")))
756b256085SDave Rigby#  endif
766b256085SDave Rigby#endif
776b256085SDave Rigby#if !defined(NO_SANITIZE_VPTR)
786b256085SDave Rigby#  define NO_SANITIZE_VPTR
796b256085SDave Rigby#endif
80