1 /*
2  * Copyright (C) 2019 The Android Open Source Project
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 
17 #pragma once
18 /*=============================================================================
19   @file sns_osa.h
20 
21   Several Operating System Abstractions to be used by the sns_qsocket client
22   library.
23 
24   ===========================================================================*/
25 
26 /*=============================================================================
27   Include Files
28   ===========================================================================*/
29 #include <stdio.h>
30 #include <stdlib.h>
31 
32 #include "chre/platform/log.h"
33 #include "err.h"
34 
35 /*=============================================================================
36   Macros
37   ===========================================================================*/
38 
39 /* Log a string message */
40 #define SNS_LOG_VERBOSE(...)
41 #define SNS_LOG_DEBUG LOGD
42 #define SNS_LOG_WARN LOGW
43 #define SNS_LOG_ERROR LOGE
44 #define SNS_LOG(prio, ...) SNS_LOG_##prio(__VA_ARGS__)
45 
46 /* See assert() */
47 #define SNS_ASSERT(value) \
48   if (!(value)) ERR_FATAL(#value, 0, 0, 0)
49 
50 /* Allocate and free memory */
51 #define sns_malloc(x) malloc(x)
52 #define sns_free(x) free(x)
53 
54 #ifndef ARR_SIZE
55 #define ARR_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
56 #endif
57 
58 #ifndef UNUSED_VAR
59 #define UNUSED_VAR(var) ((void)(var));
60 #endif