errno.h 753 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <errno_numbers.h>
  8. #include <sys/cdefs.h>
  9. #define __RETURN_WITH_ERRNO(rc, good_ret, bad_ret) \
  10. do { \
  11. if (rc < 0) { \
  12. errno = -rc; \
  13. return (bad_ret); \
  14. } \
  15. return (good_ret); \
  16. } while (0)
  17. __BEGIN_DECLS
  18. extern const char* const sys_errlist[];
  19. extern int sys_nerr;
  20. #ifdef NO_TLS
  21. extern int errno;
  22. #else
  23. extern __thread int errno;
  24. #endif
  25. #define errno errno
  26. __END_DECLS