os.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #ifndef _OS_H
  27. #define _OS_H
  28. #include <assert.h>
  29. #include "esp_assert.h"
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. #if !defined __cplusplus && !defined static_assert
  34. #define static_assert _Static_assert
  35. #endif
  36. #include "nimble/nimble_npl.h"
  37. #define OS_ALIGN(__n, __a) ( \
  38. (((__n) & ((__a) - 1)) == 0) ? \
  39. (__n) : \
  40. ((__n) + ((__a) - ((__n) & ((__a) - 1)))) \
  41. )
  42. #define OS_ALIGNMENT (BLE_NPL_OS_ALIGNMENT)
  43. typedef uint32_t os_sr_t;
  44. #define OS_ENTER_CRITICAL(_sr) (_sr = ble_npl_hw_enter_critical())
  45. #define OS_EXIT_CRITICAL(_sr) (ble_npl_hw_exit_critical(_sr))
  46. #define OS_ASSERT_CRITICAL() assert(ble_npl_hw_is_in_critical())
  47. /* Mynewt components (not abstracted in NPL) */
  48. #include "os/endian.h"
  49. #include "os/queue.h"
  50. #include "os/os_error.h"
  51. #include "os/os_mbuf.h"
  52. #include "os/os_mempool.h"
  53. #ifdef __cplusplus
  54. }
  55. #endif
  56. #endif /* _OS_H */