Kaa client C SDK
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
avro_private.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to you under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. 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
14  * implied. See the License for the specific language governing
15  * permissions and limitations under the License.
16  */
17 #ifndef AVRO_PRIVATE_H
18 #define AVRO_PRIVATE_H
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 #include <errno.h>
24 
25 #include "avro/platform.h"
26 
27 #ifdef HAVE_CONFIG_H
28 /* This is only true for now in the autotools build */
29 #include "config.h"
30 #endif
31 
32 #ifdef _WIN32
33 #define snprintf _snprintf
34 #endif
35 
36 /* Note that AVRO_PLATFORM_IS_BIG_ENDIAN is *always* defined. It is
37  * either TRUE (1) or FALSE (0).
38  */
39 #ifdef _WIN32
40  #define AVRO_PLATFORM_IS_BIG_ENDIAN (0)
41 #else // UNIX
42  #include <sys/param.h>
43  #if BYTE_ORDER == BIG_ENDIAN
44  #define AVRO_PLATFORM_IS_BIG_ENDIAN (1)
45  #else
46  #define AVRO_PLATFORM_IS_BIG_ENDIAN (0)
47  #endif
48 #endif
49 
50 /* Add definition of EILSEQ if it is not defined in errno.h. */
51 #include <errno.h>
52 #ifndef EILSEQ
53 #define EILSEQ 138
54 #endif
55 
56 
57 #define check(rval, call) { rval = call; if(rval) return rval; }
58 
59 #define check_set(rval, call, ...) \
60  { \
61  rval = call; \
62  if (rval) { \
63  return rval; \
64  } \
65  }
66 
67 #define check_prefix(rval, call, ...) \
68  { \
69  rval = call; \
70  if (rval) { \
71  return rval; \
72  } \
73  }
74 
75 #define check_param(result, test, name) \
76  { \
77  if (!(test)) { \
78  return result; \
79  } \
80  }
81 
82 #define AVRO_UNUSED(var) (void)var;
83 
84 #define container_of(ptr_, type_, member_) \
85  ((type_ *)((char *)ptr_ - (size_t)&((type_ *)0)->member_))
86 
87 #define nullstrcmp(s1, s2) \
88  (((s1) && (s2)) ? strcmp(s1, s2) : ((s1) || (s2)))
89 
90 #ifdef __cplusplus
91 } // extern "C"
92 #endif
93 #endif