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 # include "disorder-win32.h"
33 # define INVALID_SOCKET (-1)
35 # define socket_error() (errno)
36 # define system_error() (errno)
37 # define network_init()
41 # include <inttypes.h>
44 #include <sys/types.h>
46 /* had better be before atol/atoll redefinition */
53 typedef long long long_long;
54 typedef unsigned long long u_long_long;
55 # if ! DECLARES_STRTOLL
56 long long strtoll(const char *, char **, int);
59 long long atoll(const char *);
62 typedef long long_long;
63 typedef unsigned long u_long_long;
65 # define strtoll strtol
69 /* apple define these to j[dxu], which gcc -std=c99 -pedantic then rejects */
80 typedef long long intmax_t;
81 # define PRIdMAX "lld"
83 typedef long intmax_t;
95 typedef unsigned long long uintmax_t;
96 # define PRIuMAX "llu"
97 # define PRIxMAX "llx"
99 typedef unsigned long uintmax_t;
100 # define PRIuMAX "lu"
101 # define PRIxMAX "lx"
106 typedef unsigned char uint8_t;
108 # error cannot determine uint8_t
113 # if UINT_MAX == 4294967295
114 typedef unsigned int uint32_t;
115 # elif ULONG_MAX == 4294967295
116 typedef unsigned long uint32_t;
117 # elif USHRT_MAX == 4294967295
118 typedef unsigned short uint32_t;
119 # elif UCHAR_MAX == 4294967295
120 typedef unsigned char uint32_t;
122 # error cannot determine uint32_t
127 # if USHRT_MAX == 65535
128 typedef unsigned short uint16_t;
130 # error cannot determine uint16_t
134 #if !HAVE_CLOSESOCKET
135 # define closesocket close
138 #endif /* COMMENT_H */