1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 05:45:06 +00:00
serenity/Libraries/LibC/errno.h
Andreas Kling af14b8dc59 LibC: Make "errno" thread-specific
Now that the kernel supports thread-local storage, we can declare errno
with the __thread keyword, which causes it to be per-thread.

This should fix all the stupid issues that happen when many threads use
the same errno. :^)
2019-09-07 15:57:02 +02:00

22 lines
616 B
C

#pragma once
#include <errno_numbers.h>
#include <sys/cdefs.h>
#define __RETURN_WITH_ERRNO(rc, good_ret, bad_ret) \
do { \
if (rc < 0) { \
errno = -rc; \
return (bad_ret); \
} \
errno = 0; \
return (good_ret); \
} while (0)
__BEGIN_DECLS
extern const char* sys_errlist[];
extern int sys_nerr;
extern __thread int errno;
__END_DECLS