From ccfdaba3e9dde9d9be403454639bac465d179c0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 7 Jan 2003 09:08:44 +0000 Subject: [PATCH] Moved the errnop() function to the new TLS stuff. We now have a separate errnop() for the kernel, which just references a field in the thread structure. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2376 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/libroot/posix/Jamfile | 7 ++++++- src/kernel/libroot/posix/errno.c | 17 ++++++++++------- src/kernel/libroot/posix/kerrno.c | 21 +++++++++++++++++++++ 3 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 src/kernel/libroot/posix/kerrno.c 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; +} +