1 /*
2  * SPDX-FileCopyrightText: 2015-2022 The Apache Software Foundation (ASF)
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * SPDX-FileContributor: 2019-2022 Espressif Systems (Shanghai) CO LTD
7  */
8 /*
9  * Licensed to the Apache Software Foundation (ASF) under one
10  * or more contributor license agreements.  See the NOTICE file
11  * distributed with this work for additional information
12  * regarding copyright ownership.  The ASF licenses this file
13  * to you under the Apache License, Version 2.0 (the
14  * "License"); you may not use this file except in compliance
15  * with the License.  You may obtain a copy of the License at
16  *
17  *  http://www.apache.org/licenses/LICENSE-2.0
18  *
19  * Unless required by applicable law or agreed to in writing,
20  * software distributed under the License is distributed on an
21  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
22  * KIND, either express or implied.  See the License for the
23  * specific language governing permissions and limitations
24  * under the License.
25  */
26 
27 #ifndef _OS_H
28 #define _OS_H
29 
30 #include <assert.h>
31 #include "esp_assert.h"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #if !defined __cplusplus && !defined static_assert
38 #define static_assert _Static_assert
39 #endif
40 
41 #include "nimble/nimble_npl.h"
42 
43 #define OS_ALIGN(__n, __a) (                             \
44         (((__n) & ((__a) - 1)) == 0)                   ? \
45             (__n)                                      : \
46             ((__n) + ((__a) - ((__n) & ((__a) - 1))))    \
47         )
48 #define OS_ALIGNMENT    (BLE_NPL_OS_ALIGNMENT)
49 
50 typedef uint32_t os_sr_t;
51 #define OS_ENTER_CRITICAL(_sr) (_sr = ble_npl_hw_enter_critical())
52 #define OS_EXIT_CRITICAL(_sr) (ble_npl_hw_exit_critical(_sr))
53 #define OS_ASSERT_CRITICAL() assert(ble_npl_hw_is_in_critical())
54 
55 /* Mynewt components (not abstracted in NPL) */
56 #include "os/endian.h"
57 #include "os/queue.h"
58 #include "os/os_error.h"
59 #include "os/os_mbuf.h"
60 #include "os/os_mempool.h"
61 
62 #ifdef __cplusplus
63 }
64 #endif
65 
66 #endif /* _OS_H */
67