os_error.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 H_OS_ERROR_
  27. #define H_OS_ERROR_
  28. #include "os/os.h"
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. /* OS error enumerations */
  33. enum os_error {
  34. OS_OK = 0,
  35. OS_ENOMEM = 1,
  36. OS_EINVAL = 2,
  37. OS_INVALID_PARM = 3,
  38. OS_MEM_NOT_ALIGNED = 4,
  39. OS_BAD_MUTEX = 5,
  40. OS_TIMEOUT = 6,
  41. OS_ERR_IN_ISR = 7, /* Function cannot be called from ISR */
  42. OS_ERR_PRIV = 8, /* Privileged access error */
  43. OS_NOT_STARTED = 9, /* OS must be started to call this function, but isn't */
  44. OS_ENOENT = 10, /* No such thing */
  45. OS_EBUSY = 11, /* Resource busy */
  46. OS_ERROR = 12, /* Generic Error */
  47. };
  48. typedef enum os_error os_error_t;
  49. /**
  50. * @brief Converts an OS error code (`OS_[...]`) to an equivalent system error
  51. * code (`SYS_E[...]`).
  52. *
  53. * @param os_error The OS error code to convert.
  54. *
  55. * @return The equivalent system error code.
  56. */
  57. int os_error_to_sys(os_error_t os_error);
  58. #ifdef __cplusplus
  59. }
  60. #endif
  61. #endif