Skip to content

Commit eaa1152

Browse files
[libc] fix -Wmacro-redefined (#75261)
When building with compiler-rt enabled, warnings such as the following are observed: llvm-project/llvm/build/projects/compiler-rt/../libc/include/llvm-libc-macros/linux/sys-stat-macros.h:46:9: warning: 'S_IXOTH' macro redefined [-Wmacro-redefined] #define S_IXOTH 00001 ^ llvm-project/llvm/build/projects/compiler-rt/../libc/include/llvm-libc-macros/linux/fcntl-macros.h:61:9: note: previous definition is here #define S_IXOTH 01 ^ It looks like we have these multiply defined. Deduplicate these flags; users should expect to find them in sys/stat.h. S_FIFO was wrong anyways (should have been S_IFIFO).
1 parent d871919 commit eaa1152

File tree

3 files changed

+2
-26
lines changed

3 files changed

+2
-26
lines changed

libc/include/llvm-libc-macros/linux/fcntl-macros.h

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -46,31 +46,6 @@
4646
#define O_RDWR 00000002
4747
#define O_WRONLY 00000001
4848

49-
// File mode flags
50-
#define S_IRWXU 0700
51-
#define S_IRUSR 0400
52-
#define S_IWUSR 0200
53-
#define S_IXUSR 0100
54-
#define S_IRWXG 070
55-
#define S_IRGRP 040
56-
#define S_IWGRP 020
57-
#define S_IXGRP 010
58-
#define S_IRWXO 07
59-
#define S_IROTH 04
60-
#define S_IWOTH 02
61-
#define S_IXOTH 01
62-
#define S_ISUID 04000
63-
#define S_ISGID 02000
64-
65-
// File type flags
66-
#define S_IFMT 0170000
67-
#define S_IFDIR 0040000
68-
#define S_IFCHR 0020000
69-
#define S_IFBLK 0060000
70-
#define S_IFREG 0100000
71-
#define S_FIFO 0010000
72-
#define S_IFLNK 0120000
73-
7449
// Special directory FD to indicate that the path argument to
7550
// openat is relative to the current directory.
7651
#define AT_FDCWD -100

libc/include/llvm-libc-macros/linux/sys-stat-macros.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#define __LLVM_LIBC_MACROS_LINUX_SYS_STAT_MACROS_H
1111

1212
// Definitions from linux/stat.h
13-
#define S_IFMT 00170000
13+
#define S_IFMT 0170000
1414
#define S_IFSOCK 0140000
1515
#define S_IFLNK 0120000
1616
#define S_IFREG 0100000

libc/src/__support/File/linux/file.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include <fcntl.h> // For mode_t and other flags to the open syscall
1919
#include <stdio.h>
20+
#include <sys/stat.h> // For S_IS*, S_IF*, and S_IR* flags.
2021
#include <sys/syscall.h> // For syscall numbers
2122

2223
namespace LIBC_NAMESPACE {

0 commit comments

Comments
 (0)