diff --git a/src/kernel/libroot/posix/Jamfile b/src/kernel/libroot/posix/Jamfile index 2d88482ea9..c8da0c3e3a 100644 --- a/src/kernel/libroot/posix/Jamfile +++ b/src/kernel/libroot/posix/Jamfile @@ -13,8 +13,13 @@ KernelMergeObject posix_main.o : -fPIC -DPIC ; +# extra kernel objects needed +KernelObjects + <$(SOURCE_GRIST)>kerrno.c + ; + MergeObjectFromObjects kernel_posix_main.o : - <$(SOURCE_GRIST)>errno.o + <$(SOURCE_GRIST)>kerrno.o <$(SOURCE_GRIST)>poll.o <$(SOURCE_GRIST)>utime.o ; diff --git a/src/kernel/libroot/posix/errno.c b/src/kernel/libroot/posix/errno.c index 5f80523c88..b0435cc15d 100644 --- a/src/kernel/libroot/posix/errno.c +++ b/src/kernel/libroot/posix/errno.c @@ -1,17 +1,20 @@ -/* errno.c - * - * Simple file to get errno defined!! +/* +** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. +*/ + +/* Provides user space storage for "errno", located in TLS */ #include -/* XXX - Fix this once TLS works */ +#include "support/TLS.h" +#include "tls.h" -static int errno_storage; -int* +int * _errnop(void) { - return &errno_storage; + return (int *)tls_address(TLS_ERRNO_SLOT); } diff --git a/src/kernel/libroot/posix/kerrno.c b/src/kernel/libroot/posix/kerrno.c new file mode 100644 index 0000000000..289ede41ae --- /dev/null +++ b/src/kernel/libroot/posix/kerrno.c @@ -0,0 +1,21 @@ +/* +** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. +*/ + +/* Kernel space storage for "errno", located in the thread structure + * (user "errno" can't be changed from kernel internal POSIX calls) + */ + +#include +#include "thread.h" + + +int * +_errnop(void) +{ + struct thread *thread = thread_get_current_thread(); + + return &thread->kernel_errno; +} +