Skip to content

Commit 44c645f

Browse files
authored
[libc] Fix overlay mode inclusion for fcntl.h header. (#119159)
1 parent be2df95 commit 44c645f

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

libc/hdr/fcntl_overlay.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
// `__USE_FORTIFY_LEVEL`, which will be temporarily disabled
2121
// with `_FORTIFY_SOURCE`.
2222

23+
#ifdef _FORTIFY_SOURCE
24+
#define LIBC_OLD_FORTIFY_SOURCE _FORTIFY_SOURCE
25+
#undef _FORTIFY_SOURCE
26+
#endif
27+
2328
#ifdef __USE_FORTIFY_LEVEL
2429
#define LIBC_OLD_USE_FORTIFY_LEVEL __USE_FORTIFY_LEVEL
2530
#undef __USE_FORTIFY_LEVEL
@@ -28,6 +33,11 @@
2833

2934
#include <fcntl.h>
3035

36+
#ifdef LIBC_OLD_FORTIFY_SOURCE
37+
#define _FORTIFY_SOURCE LIBC_OLD_FORTIFY_SOURCE
38+
#undef LIBC_OLD_FORTIFY_SOURCE
39+
#endif
40+
3141
#ifdef LIBC_OLD_USE_FORTIFY_LEVEL
3242
#undef __USE_FORTIFY_LEVEL
3343
#define __USE_FORTIFY_LEVEL LIBC_OLD_USE_FORTIFY_LEVEL

libc/hdr/types/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ add_proxy_header_library(
5151
struct_flock
5252
HDRS
5353
struct_flock.h
54+
DEPENDS
55+
libc.hdr.fcntl_overlay
5456
FULL_BUILD_DEPENDS
5557
libc.include.llvm-libc-types.struct_flock
5658
)
@@ -59,6 +61,8 @@ add_proxy_header_library(
5961
struct_flock64
6062
HDRS
6163
struct_flock64.h
64+
DEPENDS
65+
libc.hdr.fcntl_overlay
6266
FULL_BUILD_DEPENDS
6367
libc.include.llvm-libc-types.struct_flock64
6468
)
@@ -67,6 +71,8 @@ add_proxy_header_library(
6771
struct_f_owner_ex
6872
HDRS
6973
struct_f_owner_ex.h
74+
DEPENDS
75+
libc.hdr.fcntl_overlay
7076
FULL_BUILD_DEPENDS
7177
libc.include.llvm-libc-types.struct_f_owner_ex
7278
)

libc/hdr/types/struct_f_owner_ex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#else
1616

17-
#include <fcntl.h>
17+
#include "hdr/fcntl_overlay.h"
1818

1919
#endif // LIBC_FULL_BUILD
2020

libc/hdr/types/struct_flock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#else
1616

17-
#include <fcntl.h>
17+
#include "hdr/fcntl_overlay.h"
1818

1919
#endif // LIBC_FULL_BUILD
2020

libc/hdr/types/struct_flock64.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#else
1616

17-
#include <fcntl.h>
17+
#include "hdr/fcntl_overlay.h"
1818

1919
#endif // LIBC_FULL_BUILD
2020

0 commit comments

Comments
 (0)