Skip to content

Commit 39ab961

Browse files
[libc] stop including unistd.h in src/
It's not hermetic to include the system libc's headers and is one of the reasons why our linter bot has been very red for a long time. This is starting to be an issue for new contributors as well, since we're now getting conflicts between the parts of our codebase that are hermetic, vs parts that aren't. I need to think about a rule of thumb or policy that can be publicly documented so that we don't backslide. I should probably clean up test/ as well, but let's clean up just src/ to unblock fellow contributors. Link: llvm#85514 (comment)
1 parent c63a291 commit 39ab961

32 files changed

+38
-46
lines changed

libc/src/unistd/dup.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#ifndef LLVM_LIBC_SRC_UNISTD_DUP_H
1010
#define LLVM_LIBC_SRC_UNISTD_DUP_H
1111

12-
#include <unistd.h>
13-
1412
namespace LIBC_NAMESPACE {
1513

1614
int dup(int fd);

libc/src/unistd/dup2.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#ifndef LLVM_LIBC_SRC_UNISTD_DUP2_H
1010
#define LLVM_LIBC_SRC_UNISTD_DUP2_H
1111

12-
#include <unistd.h>
13-
1412
namespace LIBC_NAMESPACE {
1513

1614
int dup2(int oldfd, int newfd);

libc/src/unistd/dup3.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#ifndef LLVM_LIBC_SRC_UNISTD_DUP3_H
1010
#define LLVM_LIBC_SRC_UNISTD_DUP3_H
1111

12-
#include <unistd.h>
13-
1412
namespace LIBC_NAMESPACE {
1513

1614
int dup3(int oldfd, int newfd, int flags);

libc/src/unistd/fork.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef LLVM_LIBC_SRC_UNISTD_FORK_H
1010
#define LLVM_LIBC_SRC_UNISTD_FORK_H
1111

12-
#include <unistd.h>
12+
#include "include/llvm-libc-types/pid_t.h"
1313

1414
namespace LIBC_NAMESPACE {
1515

libc/src/unistd/ftruncate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef LLVM_LIBC_SRC_UNISTD_FTRUNCATE_H
1010
#define LLVM_LIBC_SRC_UNISTD_FTRUNCATE_H
1111

12-
#include <unistd.h>
12+
#include "include/llvm-libc-types/off_t.h"
1313

1414
namespace LIBC_NAMESPACE {
1515

libc/src/unistd/getcwd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef LLVM_LIBC_SRC_UNISTD_GETCWD_H
1010
#define LLVM_LIBC_SRC_UNISTD_GETCWD_H
1111

12-
#include <unistd.h>
12+
#include "include/llvm-libc-types/size_t.h"
1313

1414
namespace LIBC_NAMESPACE {
1515

libc/src/unistd/geteuid.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef LLVM_LIBC_SRC_UNISTD_GETEUID_H
1010
#define LLVM_LIBC_SRC_UNISTD_GETEUID_H
1111

12-
#include <unistd.h>
12+
#include "include/llvm-libc-types/uid_t.h"
1313

1414
namespace LIBC_NAMESPACE {
1515

libc/src/unistd/getopt.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#ifndef LLVM_LIBC_SRC_UNISTD_GETOPT_H
1010
#define LLVM_LIBC_SRC_UNISTD_GETOPT_H
1111

12-
#include <stdio.h>
13-
#include <unistd.h>
12+
#include "include/llvm-libc-types/FILE.h"
13+
#include "src/__support/common.h"
1414

1515
namespace LIBC_NAMESPACE {
1616

libc/src/unistd/getpid.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef LLVM_LIBC_SRC_UNISTD_GETPID_H
1010
#define LLVM_LIBC_SRC_UNISTD_GETPID_H
1111

12-
#include <unistd.h>
12+
#include "include/llvm-libc-types/pid_t.h"
1313

1414
namespace LIBC_NAMESPACE {
1515

libc/src/unistd/getppid.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef LLVM_LIBC_SRC_UNISTD_GETPPID_H
1010
#define LLVM_LIBC_SRC_UNISTD_GETPPID_H
1111

12-
#include <unistd.h>
12+
#include "include/llvm-libc-types/pid_t.h"
1313

1414
namespace LIBC_NAMESPACE {
1515

0 commit comments

Comments
 (0)