EtcPal  HEAD (unstable)
ETC Platform Abstraction Layer (EtcPal)
View other versions:
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
common.h
1 /******************************************************************************
2  * Copyright 2022 ETC Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *******************************************************************************
16  * This file is a part of EtcPal. For more information, go to:
17  * https://github.com/ETCLabs/EtcPal
18  ******************************************************************************/
19 
20 /* etcpal/common.h: Common definitions for EtcPal modules. */
21 
22 #ifndef ETCPAL_COMMON_H_
23 #define ETCPAL_COMMON_H_
24 
25 #include <stdint.h>
26 #include "etcpal/error.h"
27 
87 #ifdef __cplusplus
88 extern "C" {
89 #endif
90 
93 /* Suppress deprecated function warnings on Windows/MSVC. This is mostly used in situations where
94  * Microsoft warns us that a function like strncpy() could be unsafe, but we want to be portable
95  * and have made sure that we're using it in a safe way (e.g. by manually inserting null
96  * terminators). */
97 #ifdef _MSC_VER
98 
99 #define ETCPAL_MSVC_NO_DEP_WRN __pragma(warning(suppress : 4996))
100 
101 #define ETCPAL_MSVC_BEGIN_NO_DEP_WARNINGS() __pragma(warning(push)) __pragma(warning(disable : 4996))
102 #define ETCPAL_MSVC_END_NO_DEP_WARNINGS() __pragma(warning(pop))
103 
104 #else /* _MSC_VER */
105 
106 #define ETCPAL_MSVC_NO_DEP_WRN
107 #define ETCPAL_MSVC_BEGIN_NO_DEP_WARNINGS()
108 #define ETCPAL_MSVC_END_NO_DEP_WARNINGS()
109 
110 #endif /* _MSC_VER */
111 
112 /* Meaningful macro to suppress warnings on unused arguments */
113 #define ETCPAL_UNUSED_ARG(arg) ((void)arg)
114 
118 #define ETCPAL_WAIT_FOREVER -1
119 
121 #define ETCPAL_NO_WAIT 0
122 
124 typedef uint32_t etcpal_features_t;
125 
137 #define ETCPAL_FEATURE_SOCKETS ((etcpal_features_t)(1u << 0))
138 #define ETCPAL_FEATURE_NETINTS ((etcpal_features_t)(1u << 1))
139 #define ETCPAL_FEATURE_TIMERS ((etcpal_features_t)(1u << 2))
140 #define ETCPAL_FEATURE_LOGGING ((etcpal_features_t)(1u << 3))
141 #define ETCPAL_FEATURES_ALL 0xffffffffu
148 #define ETCPAL_FEATURES_ALL_BUT(mask) (((uint32_t)ETCPAL_FEATURES_ALL) & ((uint32_t)(~((uint32_t)(mask)))))
149 
155 void etcpal_deinit(etcpal_features_t features);
156 
157 #ifdef __cplusplus
158 }
159 #endif
160 
165 #endif /* ETCPAL_COMMON_H_ */
etcpal_error_t
A set of error codes that can be returned by library functions.
Definition: error.h:49
void etcpal_deinit(etcpal_features_t features)
Deinitialize the EtcPal library.
Definition: common.c:193
etcpal_error_t etcpal_init(etcpal_features_t features)
Initialize the EtcPal library.
Definition: common.c:112
uint32_t etcpal_features_t
A mask of desired EtcPal features.
Definition: common.h:124