2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
2018-10-25 12:06:00 +02:00
|
|
|
#pragma once
|
|
|
|
|
2018-11-06 14:13:16 +01:00
|
|
|
#include <errno_numbers.h>
|
2019-05-28 11:53:16 +02:00
|
|
|
#include <sys/cdefs.h>
|
2018-10-25 12:06:00 +02:00
|
|
|
|
|
|
|
#define __RETURN_WITH_ERRNO(rc, good_ret, bad_ret) \
|
2019-05-28 11:53:16 +02:00
|
|
|
do { \
|
|
|
|
if (rc < 0) { \
|
|
|
|
errno = -rc; \
|
|
|
|
return (bad_ret); \
|
|
|
|
} \
|
2019-08-15 20:25:27 +02:00
|
|
|
return (good_ret); \
|
2019-05-28 11:53:16 +02:00
|
|
|
} while (0)
|
2018-10-25 12:06:00 +02:00
|
|
|
|
2018-10-31 02:09:11 +01:00
|
|
|
__BEGIN_DECLS
|
2018-10-25 12:06:00 +02:00
|
|
|
|
2019-10-17 09:18:01 +02:00
|
|
|
extern const char* const sys_errlist[];
|
2018-11-06 14:13:16 +01:00
|
|
|
extern int sys_nerr;
|
2020-10-10 17:48:27 +03:00
|
|
|
|
|
|
|
#ifdef NO_TLS
|
|
|
|
extern int errno;
|
|
|
|
#else
|
2019-09-07 15:55:41 +02:00
|
|
|
extern __thread int errno;
|
2020-10-10 17:48:27 +03:00
|
|
|
#endif
|
2018-10-25 12:06:00 +02:00
|
|
|
|
2019-09-08 14:20:13 +02:00
|
|
|
#define errno errno
|
|
|
|
|
2018-10-31 02:09:11 +01:00
|
|
|
__END_DECLS
|