Skip to content

Commit 3184724

Browse files
committed
Extract errno macros proxy header
1 parent 892714a commit 3184724

File tree

5 files changed

+39
-6
lines changed

5 files changed

+39
-6
lines changed

libc/hdr/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ add_proxy_header_library(
3232
libc.include.math
3333
)
3434

35+
add_proxy_header_library(
36+
errno_macros
37+
HDRS
38+
errno_macros.h
39+
FULL_BUILD_DEPENDS
40+
libc.include.errno
41+
libc.include.llvm-libc-macros.error_number_macros
42+
libc.include.llvm-libc-macros.generic_error_number_macros
43+
)
44+
3545
add_proxy_header_library(
3646
fcntl_macros
3747
HDRS

libc/hdr/errno_macros.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//===-- Definition of macros from errno.h ---------------------------------===//
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+
#ifndef LLVM_LIBC_HDR_ERRNO_MACROS_H
10+
#define LLVM_LIBC_HDR_ERRNO_MACROS_H
11+
12+
#ifdef LIBC_FULL_BUILD
13+
14+
#ifdef __linux__
15+
#include "llvm-libc-macros/error-number-macros.h"
16+
#else // __linux__
17+
#include "llvm-libc-macros/generic-error-number-macros.h"
18+
#endif
19+
20+
#else // Overlay mode
21+
22+
#include <errno.h>
23+
24+
#endif // LLVM_LIBC_FULL_BUILD
25+
26+
#endif // LLVM_LIBC_HDR_ERRNO_MACROS_H

libc/src/errno/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ add_entrypoint_object(
1818
COMPILE_OPTIONS
1919
${full_build_flag}
2020
DEPENDS
21-
libc.include.errno
22-
libc.include.llvm-libc-macros.error_number_macros
23-
libc.include.llvm-libc-macros.generic_error_number_macros
21+
libc.hdr.errno_macros
2422
libc.src.__support.common
2523
)

libc/src/errno/libc_errno.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ LIBC_NAMESPACE::Errno::operator int() { return __llvmlibc_errno; }
3737

3838
#else
3939
// In overlay mode, we simply use the system errno.
40-
#include <errno.h>
40+
#include "hdr/errno_macros.h"
4141

4242
void LIBC_NAMESPACE::Errno::operator=(int a) { errno = a; }
4343
LIBC_NAMESPACE::Errno::operator int() { return errno; }

libc/src/errno/libc_errno.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
#include "src/__support/macros/attributes.h"
1313
#include "src/__support/macros/properties/architectures.h"
1414

15-
#include <include/llvm-libc-macros/error-number-macros.h>
16-
#include <include/llvm-libc-macros/generic-error-number-macros.h>
15+
#include "hdr/errno_macros.h"
1716

1817
// This header is to be consumed by internal implementations, in which all of
1918
// them should refer to `libc_errno` instead of using `errno` directly from

0 commit comments

Comments
 (0)