-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[libc] implement pathconf/fpathconf (#87165)
- Loading branch information
1 parent
d043e4c
commit 7f3c40a
Showing
21 changed files
with
516 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//===-- Definition of macros from limits.h --------------------------------===// | ||
// | ||
// 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_LIMITS_MACROS_H | ||
#define LLVM_LIBC_HDR_LIMITS_MACROS_H | ||
|
||
#ifdef LIBC_FULL_BUILD | ||
|
||
#include "include/llvm-libc-macros/limits-macros.h" | ||
|
||
#else // Overlay mode | ||
|
||
#include <limits.h> | ||
|
||
#endif // LLVM_LIBC_FULL_BUILD | ||
|
||
#endif // LLVM_LIBC_HDR_LIMITS_MACROS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//===-- Definition of macros from sys/stat.h ------------------------------===// | ||
// | ||
// 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_SYS_STAT_MACROS_H | ||
#define LLVM_LIBC_HDR_SYS_STAT_MACROS_H | ||
|
||
#ifdef LIBC_FULL_BUILD | ||
|
||
#include "include/llvm-libc-macros/sys-stat-macros.h" | ||
|
||
#else // Overlay mode | ||
|
||
#include <sys/stat.h> | ||
|
||
#endif // LLVM_LIBC_FULL_BUILD | ||
|
||
#endif // LLVM_LIBC_HDR_SYS_STAT_MACROS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//===-- Definition of macros from unistd.h --------------------------------===// | ||
// | ||
// 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_MACROS_H | ||
#define LLVM_LIBC_HDR_UNISTD_MACROS_H | ||
|
||
#ifdef LIBC_FULL_BUILD | ||
|
||
#include "include/llvm-libc-macros/unistd-macros.h" | ||
|
||
#else // Overlay mode | ||
|
||
#include <unistd.h> | ||
|
||
#endif // LLVM_LIBC_FULL_BUILD | ||
|
||
#endif // LLVM_LIBC_HDR_UNISTD_MACROS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//===-- Implementation header for fpathconf ---------------------*- C++ -*-===// | ||
// | ||
// 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_SRC_UNISTD_FPATHCONF_H | ||
#define LLVM_LIBC_SRC_UNISTD_FPATHCONF_H | ||
|
||
namespace LIBC_NAMESPACE { | ||
|
||
long fpathconf(int fd, int name); | ||
|
||
} // namespace LIBC_NAMESPACE | ||
|
||
#endif // LLVM_LIBC_SRC_UNISTD_FSYNC_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//===-- Linux implementation of fpathconf ---------------------------------===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "src/unistd/fpathconf.h" | ||
#include "src/__support/OSUtil/syscall.h" // For internal syscall function. | ||
#include "src/__support/common.h" | ||
#include "src/sys/statvfs/linux/statfs_utils.h" | ||
#include "src/unistd/linux/pathconf_utils.h" | ||
|
||
namespace LIBC_NAMESPACE { | ||
|
||
LLVM_LIBC_FUNCTION(long, fpathconf, (int fd, int name)) { | ||
if (cpp::optional<statfs_utils::LinuxStatFs> result = | ||
statfs_utils::linux_fstatfs(fd)) | ||
return pathconfig(result.value(), name); | ||
return -1; | ||
} | ||
|
||
} // namespace LIBC_NAMESPACE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//===-- Linux implementation of pathconf ----------------------------------===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "src/unistd/pathconf.h" | ||
#include "src/errno/libc_errno.h" | ||
#include "src/sys/statvfs/linux/statfs_utils.h" | ||
#include "src/unistd/linux/pathconf_utils.h" | ||
|
||
namespace LIBC_NAMESPACE { | ||
|
||
LLVM_LIBC_FUNCTION(long, pathconf, (const char *path, int name)) { | ||
if (cpp::optional<statfs_utils::LinuxStatFs> result = | ||
statfs_utils::linux_statfs(path)) | ||
return pathconfig(result.value(), name); | ||
return -1; | ||
} | ||
|
||
} // namespace LIBC_NAMESPACE |
Oops, something went wrong.