GNU libmicrohttpd  0.9.29
mhd_limits.h
Go to the documentation of this file.
1 /*
2  This file is part of libmicrohttpd
3  Copyright (C) 2015 Karlson2k (Evgeny Grin)
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library 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 GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 
26 #ifndef MHD_LIMITS_H
27 #define MHD_LIMITS_H
28 
29 #include "platform.h"
30 
31 #ifdef HAVE_LIMITS_H
32 #include <limits.h>
33 #endif /* HAVE_LIMITS_H */
34 
35 #ifndef UINT_MAX
36 #ifdef __UINT_MAX__
37 #define UINT_MAX __UINT_MAX__
38 #else /* ! __UINT_MAX__ */
39 #define UINT_MAX ((unsigned int) ~((unsigned int)0))
40 #endif /* ! __UINT_MAX__ */
41 #endif /* !UINT_MAX */
42 
43 #ifndef LONG_MAX
44 #ifdef __LONG_MAX__
45 #define LONG_MAX __LONG_MAX__
46 #else /* ! __LONG_MAX__ */
47 #define LONG_MAX ((long) ~(((uint64_t) 1) << (8 * sizeof(long) - 1)))
48 #endif /* ! __LONG_MAX__ */
49 #endif /* !OFF_T_MAX */
50 
51 #ifndef ULLONG_MAX
52 #define ULLONG_MAX ((MHD_UNSIGNED_LONG_LONG) ~((MHD_UNSIGNED_LONG_LONG)0))
53 #endif /* !ULLONG_MAX */
54 
55 #ifndef INT32_MAX
56 #ifdef __INT32_MAX__
57 #define INT32_MAX __INT32_MAX__
58 #else /* ! __INT32_MAX__ */
59 #define INT32_MAX ((int32_t)0x7FFFFFFF)
60 #endif /* ! __INT32_MAX__ */
61 #endif /* !INT32_MAX */
62 
63 #ifndef UINT32_MAX
64 #ifdef __UINT32_MAX__
65 #define UINT32_MAX __UINT32_MAX__
66 #else /* ! __UINT32_MAX__ */
67 #define UINT32_MAX ((int32_t)0xFFFFFFFF)
68 #endif /* ! __UINT32_MAX__ */
69 #endif /* !UNT32_MAX */
70 
71 #ifndef UINT64_MAX
72 #ifdef __UINT64_MAX__
73 #define UINT64_MAX __UINT64_MAX__
74 #else /* ! __UINT64_MAX__ */
75 #define UINT64_MAX ((uint64_t)0xFFFFFFFFFFFFFFFF)
76 #endif /* ! __UINT64_MAX__ */
77 #endif /* !INT32_MAX */
78 
79 #ifndef SIZE_MAX
80 #ifdef __SIZE_MAX__
81 #define SIZE_MAX __SIZE_MAX__
82 #else /* ! __SIZE_MAX__ */
83 #define SIZE_MAX ((size_t) ~((size_t)0))
84 #endif /* ! __SIZE_MAX__ */
85 #endif /* !SIZE_MAX */
86 
87 #ifndef OFF_T_MAX
88 #define OFF_T_MAX ((off_t) ~(((uint64_t) 1) << (8 * sizeof(off_t) - 1)))
89 #endif /* !OFF_T_MAX */
90 
91 #if defined(_LARGEFILE64_SOURCE) && !defined(OFF64_T_MAX)
92 #define OFF64_T_MAX ((off64_t) ~(((uint64_t) 1) << (8 * sizeof(off64_t) - 1)))
93 #endif /* _LARGEFILE64_SOURCE && !OFF64_T_MAX */
94 
95 #ifndef TIME_T_MAX
96 /* Assume that time_t is signed type. */
97 /* Even if time_t is unsigned, TIME_T_MAX will be safe limit */
98 #define TIME_T_MAX ( (time_t) ~(((uint64_t) 1) << (8 * sizeof(time_t) - 1)) )
99 #endif /* !TIME_T_MAX */
100 
101 #ifndef TIMEVAL_TV_SEC_MAX
102 #ifndef _WIN32
103 #define TIMEVAL_TV_SEC_MAX TIME_T_MAX
104 #else /* _WIN32 */
105 #define TIMEVAL_TV_SEC_MAX LONG_MAX
106 #endif /* _WIN32 */
107 #endif /* !TIMEVAL_TV_SEC_MAX */
108 
109 #endif /* MHD_LIMITS_H */
platform-specific includes for libmicrohttpd