diff --git a/include/errno.h b/include/errno.h index 691236a..e603073 100644 --- a/include/errno.h +++ b/include/errno.h @@ -2,6 +2,11 @@ #ifndef __ERRNO_H__ #define __ERRNO_H__ +#ifndef _KERNEL +int *__error(); +#define errno (* __error()) +#endif + #define EIO 0x1BAD0001 #define EBADF 0x1BAD0002 #define EINVAL 0x1BAD0003 diff --git a/lib/libc/posix/pthread.c b/lib/libc/posix/pthread.c index 3aa0c57..9b73058 100644 --- a/lib/libc/posix/pthread.c +++ b/lib/libc/posix/pthread.c @@ -20,7 +20,7 @@ struct pthread_attr { struct pthread { uint64_t tid; - int errno; + int error; // errno TAILQ_ENTRY(pthread) threadTable; // Initialization @@ -41,6 +41,14 @@ typedef TAILQ_HEAD(pthreadList, pthread) pthreadList; static CoreMutex __threadTableLock; static pthreadList __threads[THREAD_HASH_SLOTS]; +int * +__error(void) +{ + struct pthread *pth = pthread_self(); + + return &(pth->error); +} + void __pthread_init(void) { @@ -56,6 +64,7 @@ __pthread_init(void) } thr->tid = OSGetTID(); + thr->error = 0; thr->entry = NULL; thr->arg = 0;