2 * This file is part of DisOrder.
3 * Copyright (C) 2004, 2005, 2007, 2008, 2013 Richard Kettlewell
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 /** @file lib/common.h
19 * @brief Common includes and definitions
30 # define INVALID_SOCKET (-1)
32 # define socket_error() (errno)
33 # define system_error() (errno)
35 # include <inttypes.h>
38 #include <sys/types.h>
40 /* had better be before atol/atoll redefinition */
47 typedef long long long_long;
48 typedef unsigned long long u_long_long;
49 # if ! DECLARES_STRTOLL
50 long long strtoll(const char *, char **, int);
53 long long atoll(const char *);
56 typedef long long_long;
57 typedef unsigned long u_long_long;
59 # define strtoll strtol
63 /* apple define these to j[dxu], which gcc -std=c99 -pedantic then rejects */
74 typedef long long intmax_t;
75 # define PRIdMAX "lld"
77 typedef long intmax_t;
89 typedef unsigned long long uintmax_t;
90 # define PRIuMAX "llu"
91 # define PRIxMAX "llx"
93 typedef unsigned long uintmax_t;
100 typedef unsigned char uint8_t;
102 # error cannot determine uint8_t
107 # if UINT_MAX == 4294967295
108 typedef unsigned int uint32_t;
109 # elif ULONG_MAX == 4294967295
110 typedef unsigned long uint32_t;
111 # elif USHRT_MAX == 4294967295
112 typedef unsigned short uint32_t;
113 # elif UCHAR_MAX == 4294967295
114 typedef unsigned char uint32_t;
116 # error cannot determine uint32_t
121 # if USHRT_MAX == 65535
122 typedef unsigned short uint16_t;
124 # error cannot determine uint16_t
128 #if !HAVE_CLOSESOCKET
129 # define closesocket close
132 #endif /* COMMENT_H */