chiark / gitweb /
More error string formatting.
[disorder] / lib / common.h
CommitLineData
460b9539 1/*
2 * This file is part of DisOrder.
cca89d7c 3 * Copyright (C) 2004, 2005, 2007, 2008, 2013 Richard Kettlewell
460b9539 4 *
e7eb3a27 5 * This program is free software: you can redistribute it and/or modify
460b9539 6 * it under the terms of the GNU General Public License as published by
e7eb3a27 7 * the Free Software Foundation, either version 3 of the License, or
460b9539 8 * (at your option) any later version.
e7eb3a27
RK
9 *
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.
14 *
460b9539 15 * You should have received a copy of the GNU General Public License
e7eb3a27 16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
460b9539 17 */
05b75f8d
RK
18/** @file lib/common.h
19 * @brief Common includes and definitions
20 */
21
22#ifndef COMMON_H
23#define COMMON_H
460b9539 24
cca89d7c
RK
25#if HAVE_CONFIG_H
26# include <config.h>
27#endif
460b9539 28
29#if HAVE_INTTYPES_H
30# include <inttypes.h>
31#endif
32#include <limits.h>
33#include <sys/types.h>
34
35/* had better be before atol/atoll redefinition */
36#include <stdlib.h>
05b75f8d
RK
37#include <string.h>
38#include <stdio.h>
39#include <assert.h>
460b9539 40
41#if HAVE_LONG_LONG
42typedef long long long_long;
43typedef unsigned long long u_long_long;
44# if ! DECLARES_STRTOLL
45long long strtoll(const char *, char **, int);
46# endif
47# if ! DECLARES_ATOLL
48long long atoll(const char *);
49# endif
50#else
51typedef long long_long;
52typedef unsigned long u_long_long;
53# define atoll atol
54# define strtoll strtol
55#endif
56
57#if __APPLE__
58/* apple define these to j[dxu], which gcc -std=c99 -pedantic then rejects */
59# undef PRIdMAX
60# undef PRIxMAX
61# undef PRIuMAX
62#endif
63
64#if HAVE_INTMAX_T
65# ifndef PRIdMAX
66# define PRIdMAX "jd"
67# endif
68#elif HAVE_LONG_LONG
69typedef long long intmax_t;
70# define PRIdMAX "lld"
71#else
72typedef long intmax_t;
73# define PRIdMAX "ld"
74#endif
75
76#if HAVE_UINTMAX_T
77# ifndef PRIuMAX
78# define PRIuMAX "ju"
79# endif
80# ifndef PRIxMAX
81# define PRIxMAX "jx"
82# endif
83#elif HAVE_LONG_LONG
84typedef unsigned long long uintmax_t;
85# define PRIuMAX "llu"
86# define PRIxMAX "llx"
87#else
88typedef unsigned long uintmax_t;
89# define PRIuMAX "lu"
90# define PRIxMAX "lx"
91#endif
92
93#if ! HAVE_UINT8_T
94# if CHAR_BIT == 8
95typedef unsigned char uint8_t;
96# else
97# error cannot determine uint8_t
98# endif
99#endif
100
101#if ! HAVE_UINT32_T
102# if UINT_MAX == 4294967295
103typedef unsigned int uint32_t;
104# elif ULONG_MAX == 4294967295
105typedef unsigned long uint32_t;
106# elif USHRT_MAX == 4294967295
107typedef unsigned short uint32_t;
108# elif UCHAR_MAX == 4294967295
109typedef unsigned char uint32_t;
110# else
111# error cannot determine uint32_t
112# endif
113#endif
114
05b75f8d 115#endif /* COMMENT_H */
460b9539 116
117/*
118Local Variables:
119c-basic-offset:2
120comment-column:40
121End:
122*/