1 //===-- Implementation of __errno_location --------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "src/errno/__errno_location.h"
10 
11 #include "src/__support/common.h"
12 
13 namespace __llvm_libc {
14 
15 static thread_local int __errno = 0;
16 
17 // __errno_location is not really an entry point but we still want it to behave
18 // like an entry point because the errno macro resolves to the C symbol
19 // "__errno_location".
LLVM_LIBC_ENTRYPOINT(__errno_location)20 int *LLVM_LIBC_ENTRYPOINT(__errno_location)() { return &__errno; }
21 
22 } // namespace __llvm_libc
23