Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions libc/hdr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,13 @@ add_proxy_header_library(
libc.include.llvm-libc-macros.sys_stat_macros
)

add_header_library(unistd_overlay HDRS unistd_overlay.h)
add_proxy_header_library(
unistd_macros
HDRS
unistd_macros.h
DEPENDS
.unistd_overlay
FULL_BUILD_DEPENDS
libc.include.unistd
libc.include.llvm-libc-macros.unistd_macros
Expand Down
16 changes: 16 additions & 0 deletions libc/hdr/types/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ add_proxy_header_library(
libc.include.llvm-libc-types.size_t
)

add_proxy_header_library(
ssize_t
HDRS
ssize_t.h
FULL_BUILD_DEPENDS
libc.include.llvm-libc-types.ssize_t
)

add_proxy_header_library(
mode_t
HDRS
Expand Down Expand Up @@ -311,3 +319,11 @@ add_proxy_header_library(
libc.include.llvm-libc-types.wint_t
libc.include.wchar
)

add_proxy_header_library(
uid_t
HDRS
uid_t.h
FULL_BUILD_DEPENDS
libc.include.llvm-libc-types.uid_t
)
22 changes: 22 additions & 0 deletions libc/hdr/types/uid_t.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//===-- Proxy for uid_t ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_HDR_TYPES_UID_T_H
#define LLVM_LIBC_HDR_TYPES_UID_T_H

#ifdef LIBC_FULL_BUILD

#include "include/llvm-libc-types/uid_t.h"

#else // Overlay mode

#include <sys/types.h>

#endif // LLVM_LIBC_FULL_BUILD

#endif // LLVM_LIBC_HDR_TYPES_UID_T_H
2 changes: 1 addition & 1 deletion libc/hdr/unistd_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#else // Overlay mode

#include <unistd.h>
#include "unistd_overlay.h"

#endif // LLVM_LIBC_FULL_BUILD

Expand Down
69 changes: 69 additions & 0 deletions libc/hdr/unistd_overlay.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//===-- Including unistd.h in overlay mode -------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_HDR_UNISTD_OVERLAY_H
#define LLVM_LIBC_HDR_UNISTD_OVERLAY_H

#ifdef LIBC_FULL_BUILD
#error "This header should only be included in overlay mode"
#endif

// Overlay mode

// glibc <unistd.h> header might provide extern inline definitions for few
// functions, causing external alias errors. They are guarded by
// `__USE_EXTERN_INLINES` macro. We temporarily disable `__USE_EXTERN_INLINES`
// macro by defining `__NO_INLINE__` before including <stdio.h>.
// And the same with `__USE_FORTIFY_LEVEL`, which will be temporarily disabled
// with `_FORTIFY_SOURCE`.

#ifdef _FORTIFY_SOURCE
#define LIBC_OLD_FORTIFY_SOURCE _FORTIFY_SOURCE
#undef _FORTIFY_SOURCE
#endif

#ifdef __USE_EXTERN_INLINES
#define LIBC_OLD_USE_EXTERN_INLINES
#undef __USE_EXTERN_INLINES
#endif

#ifdef __USE_FORTIFY_LEVEL
#define LIBC_OLD_USE_FORTIFY_LEVEL __USE_FORTIFY_LEVEL
#undef __USE_FORTIFY_LEVEL
#define __USE_FORTIFY_LEVEL 0
#endif

#ifndef __NO_INLINE__
#define __NO_INLINE__ 1
#define LIBC_SET_NO_INLINE
#endif

#include <unistd.h>

#ifdef LIBC_OLD_FORTIFY_SOURCE
#define _FORTIFY_SOURCE LIBC_OLD_FORTIFY_SOURCE
#undef LIBC_OLD_FORTIFY_SOURCE
#endif

#ifdef LIBC_SET_NO_INLINE
#undef __NO_INLINE__
#undef LIBC_SET_NO_INLINE
#endif

#ifdef LIBC_OLD_USE_FORTIFY_LEVEL
#undef __USE_FORTIFY_LEVEL
#define __USE_FORTIFY_LEVEL LIBC_OLD_USE_FORTIFY_LEVEL
#undef LIBC_OLD_USE_FORTIFY_LEVEL
#endif

#ifdef LIBC_OLD_USE_EXTERN_INLINES
#define __USE_EXTERN_INLINES
#undef LIBC_OLD_USE_EXTERN_INLINES
#endif

#endif // LLVM_LIBC_HDR_UNISTD_OVERLAY_H
2 changes: 1 addition & 1 deletion libc/src/unistd/dup.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#ifndef LLVM_LIBC_SRC_UNISTD_DUP_H
#define LLVM_LIBC_SRC_UNISTD_DUP_H

#include "hdr/unistd_macros.h"
#include "src/__support/macros/config.h"
#include <unistd.h>

namespace LIBC_NAMESPACE_DECL {

Expand Down
2 changes: 1 addition & 1 deletion libc/src/unistd/dup2.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#ifndef LLVM_LIBC_SRC_UNISTD_DUP2_H
#define LLVM_LIBC_SRC_UNISTD_DUP2_H

#include "hdr/unistd_macros.h"
#include "src/__support/macros/config.h"
#include <unistd.h>

namespace LIBC_NAMESPACE_DECL {

Expand Down
2 changes: 1 addition & 1 deletion libc/src/unistd/dup3.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#ifndef LLVM_LIBC_SRC_UNISTD_DUP3_H
#define LLVM_LIBC_SRC_UNISTD_DUP3_H

#include "hdr/unistd_macros.h"
#include "src/__support/macros/config.h"
#include <unistd.h>

namespace LIBC_NAMESPACE_DECL {

Expand Down
3 changes: 2 additions & 1 deletion libc/src/unistd/fork.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
#ifndef LLVM_LIBC_SRC_UNISTD_FORK_H
#define LLVM_LIBC_SRC_UNISTD_FORK_H

#include "hdr/types/pid_t.h"
#include "hdr/unistd_macros.h"
#include "src/__support/macros/config.h"
#include <unistd.h>

namespace LIBC_NAMESPACE_DECL {

Expand Down
3 changes: 2 additions & 1 deletion libc/src/unistd/ftruncate.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
#ifndef LLVM_LIBC_SRC_UNISTD_FTRUNCATE_H
#define LLVM_LIBC_SRC_UNISTD_FTRUNCATE_H

#include "hdr/types/off_t.h"
#include "hdr/unistd_macros.h"
#include "src/__support/macros/config.h"
#include <unistd.h>

namespace LIBC_NAMESPACE_DECL {

Expand Down
3 changes: 2 additions & 1 deletion libc/src/unistd/getcwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
#ifndef LLVM_LIBC_SRC_UNISTD_GETCWD_H
#define LLVM_LIBC_SRC_UNISTD_GETCWD_H

#include "hdr/types/size_t.h"
#include "hdr/unistd_macros.h"
#include "src/__support/macros/config.h"
#include <unistd.h>

namespace LIBC_NAMESPACE_DECL {

Expand Down
3 changes: 2 additions & 1 deletion libc/src/unistd/geteuid.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
#ifndef LLVM_LIBC_SRC_UNISTD_GETEUID_H
#define LLVM_LIBC_SRC_UNISTD_GETEUID_H

#include "hdr/types/uid_t.h"
#include "hdr/unistd_macros.h"
#include "src/__support/macros/config.h"
#include <unistd.h>

namespace LIBC_NAMESPACE_DECL {

Expand Down
2 changes: 1 addition & 1 deletion libc/src/unistd/getopt.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#define LLVM_LIBC_SRC_UNISTD_GETOPT_H

#include "hdr/types/FILE.h"
#include "hdr/unistd_macros.h"
#include "src/__support/macros/config.h"
#include <unistd.h>

namespace LIBC_NAMESPACE_DECL {

Expand Down
3 changes: 2 additions & 1 deletion libc/src/unistd/getpid.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
#ifndef LLVM_LIBC_SRC_UNISTD_GETPID_H
#define LLVM_LIBC_SRC_UNISTD_GETPID_H

#include "hdr/types/pid_t.h"
#include "hdr/unistd_macros.h"
#include "src/__support/macros/config.h"
#include <unistd.h>

namespace LIBC_NAMESPACE_DECL {

Expand Down
3 changes: 2 additions & 1 deletion libc/src/unistd/getppid.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
#ifndef LLVM_LIBC_SRC_UNISTD_GETPPID_H
#define LLVM_LIBC_SRC_UNISTD_GETPPID_H

#include "hdr/types/pid_t.h"
#include "hdr/unistd_macros.h"
#include "src/__support/macros/config.h"
#include <unistd.h>

namespace LIBC_NAMESPACE_DECL {

Expand Down
3 changes: 2 additions & 1 deletion libc/src/unistd/getuid.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
#ifndef LLVM_LIBC_SRC_UNISTD_GETUID_H
#define LLVM_LIBC_SRC_UNISTD_GETUID_H

#include "hdr/types/uid_t.h"
#include "hdr/unistd_macros.h"
#include "src/__support/macros/config.h"
#include <unistd.h>

namespace LIBC_NAMESPACE_DECL {

Expand Down
2 changes: 1 addition & 1 deletion libc/src/unistd/isatty.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#ifndef LLVM_LIBC_SRC_UNISTD_ISATTY_H
#define LLVM_LIBC_SRC_UNISTD_ISATTY_H

#include "hdr/unistd_macros.h"
#include "src/__support/macros/config.h"
#include <unistd.h>

namespace LIBC_NAMESPACE_DECL {

Expand Down
2 changes: 1 addition & 1 deletion libc/src/unistd/link.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#ifndef LLVM_LIBC_SRC_UNISTD_LINK_H
#define LLVM_LIBC_SRC_UNISTD_LINK_H

#include "hdr/unistd_macros.h"
#include "src/__support/macros/config.h"
#include <unistd.h>

namespace LIBC_NAMESPACE_DECL {

Expand Down
Loading
Loading