hurd: Replace threadvars with TLS
[glibc.git] / sysdeps / mach / hurd / errno-loc.c
blob95d0fe47c4cc09b2e23a72d8c2bc00a68d1e1034
1 /* __errno_location -- helper function for locating per-thread errno value
2 Copyright (C) 2002-2018 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #if IS_IN (rtld)
21 * rtld can not access TLS too early, thus rtld_errno.
23 * Instead of making __open/__close pass errno from TLS to rtld_errno, simply
24 * use a weak __errno_location using rtld_errno, which will be overriden by the
25 * libc definition.
27 static int rtld_errno;
28 int * weak_function
29 __errno_location (void)
31 return &rtld_errno;
33 libc_hidden_weak (__errno_location)
34 #else
35 #include "../../../csu/errno-loc.c"
36 #endif