1 /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /*
3  *     Copyright 2010-2012 Couchbase, Inc.
4  *
5  *   Licensed under the Apache License, Version 2.0 (the "License");
6  *   you may not use this file except in compliance with the License.
7  *   You may obtain a copy of the License at
8  *
9  *       http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *   Unless required by applicable law or agreed to in writing, software
12  *   distributed under the License is distributed on an "AS IS" BASIS,
13  *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *   See the License for the specific language governing permissions and
15  *   limitations under the License.
16  */
17 
18 /**
19  * Basic platform includes.
20  */
21 #ifndef LCB_SYSDEFS_H
22 #define LCB_SYSDEFS_H
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #ifdef _WIN32
29     #include <stddef.h>
30     #include <winsock2.h>
31     #include <basetsd.h>
32 
33     typedef __int64 lcb_int64_t;
34     typedef __int32 lcb_int32_t;
35     typedef SIZE_T lcb_size_t;
36     typedef SSIZE_T lcb_ssize_t;
37     typedef unsigned __int8 lcb_uint8_t;
38     typedef unsigned __int16 lcb_vbucket_t;
39     typedef unsigned __int16 lcb_uint16_t;
40     typedef unsigned __int32 lcb_uint32_t;
41     typedef unsigned __int64 lcb_cas_t;
42     typedef unsigned __int64 lcb_uint64_t;
43 
44     /** FIXME: This should be a native type, but it's already defined here.. */
45     typedef unsigned __int32 lcb_time_t;
46 #else
47     #include <sys/types.h>
48     #include <stdint.h>
49     #include <time.h>
50 
51     #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
52     #include <stddef.h>
53     #endif
54 
55     typedef int64_t lcb_int64_t;
56     typedef int32_t lcb_int32_t;
57     typedef size_t lcb_size_t;
58     typedef ssize_t lcb_ssize_t;
59     typedef uint16_t lcb_vbucket_t;
60     typedef uint8_t lcb_uint8_t;
61     typedef uint16_t lcb_uint16_t;
62     typedef uint32_t lcb_uint32_t;
63     typedef uint64_t lcb_cas_t;
64     typedef uint64_t lcb_uint64_t;
65     typedef time_t lcb_time_t;
66 #endif
67 
68 typedef lcb_int64_t lcb_S64; /**< @brief Signed 64 bit type */
69 typedef lcb_uint64_t lcb_U64; /**< @brief Unsigned 64 bit type */
70 typedef lcb_uint32_t lcb_U32; /**< @brief Unsigned 32 bit type */
71 typedef lcb_int32_t lcb_S32; /**< @brief Signed 32 bit type */
72 typedef lcb_uint16_t lcb_U16; /**< @brief Unsigned 16 bit type */
73 typedef lcb_uint8_t lcb_U8; /**< @brief unsigned 8 bit type */
74 typedef lcb_size_t lcb_SIZE; /**< @brief Unsigned size type */
75 typedef lcb_ssize_t lcb_SSIZE; /**<@brief Signed size type */
76 typedef lcb_time_t lcb_SECS; /**< @brief Unsigned 'seconds time' type */
77 typedef lcb_cas_t lcb_CAS;
78 
79 #ifdef __GNUC__
80 #define LCB_DEPRECATED(X) X __attribute__((deprecated))
81     #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)
82     #define LCB_DEPRECATED2(X, reason) X __attribute__((deprecated(reason)))
83     #else
84     #define LCB_DEPRECATED2(X, reason) LCB_DEPRECATED(X)
85     #endif
86 #elif defined(_MSC_VER)
87 #define LCB_DEPRECATED(X) __declspec(deprecated) X
88 #define LCB_DEPRECATED2(X, reason) __declspec(deprecated(reason)) X
89 #else
90 #define LCB_DEPRECATED(X) X
91 #define LCB_DEPRECATED2(X, reason)
92 #endif
93 
94 #ifdef __cplusplus
95 }
96 #endif
97 
98 #endif /* LCB_SYSDEFS_H */
99