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