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)
34 # define network_init()
37 # include <inttypes.h>
40 #include <sys/types.h>
42 /* had better be before atol/atoll redefinition */
49 typedef long long long_long;
50 typedef unsigned long long u_long_long;
51 # if ! DECLARES_STRTOLL
52 long long strtoll(const char *, char **, int);
55 long long atoll(const char *);
58 typedef long long_long;
59 typedef unsigned long u_long_long;
61 # define strtoll strtol
65 /* apple define these to j[dxu], which gcc -std=c99 -pedantic then rejects */
76 typedef long long intmax_t;
77 # define PRIdMAX "lld"
79 typedef long intmax_t;
91 typedef unsigned long long uintmax_t;
92 # define PRIuMAX "llu"
93 # define PRIxMAX "llx"
95 typedef unsigned long uintmax_t;
102 typedef unsigned char uint8_t;
104 # error cannot determine uint8_t
109 # if UINT_MAX == 4294967295
110 typedef unsigned int uint32_t;
111 # elif ULONG_MAX == 4294967295
112 typedef unsigned long uint32_t;
113 # elif USHRT_MAX == 4294967295
114 typedef unsigned short uint32_t;
115 # elif UCHAR_MAX == 4294967295
116 typedef unsigned char uint32_t;
118 # error cannot determine uint32_t
123 # if USHRT_MAX == 65535
124 typedef unsigned short uint16_t;
126 # error cannot determine uint16_t
130 #if !HAVE_CLOSESOCKET
131 # define closesocket close
134 #endif /* COMMENT_H */