[libc-commits] [libc] [libc] Implement fcntl() function (PR #89507)

Michael Jones via libc-commits libc-commits at lists.llvm.org
Mon Apr 22 14:43:57 PDT 2024


================
@@ -0,0 +1,96 @@
+//===-- Implementation of fcntl -------------------------------------------===//
+//
+// 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/fcntl/fcntl.h"
+
+#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "src/__support/common.h"
+#include "src/errno/libc_errno.h"
+
----------------
michaelrj-google wrote:

We want to avoid including public API headers when possible, and by that I mean avoiding using `#include <fcntl.h>`. Instead the design we're currently moving to is only including things in `libc/hdr` from the source files. You can see an example of this in this patch: https://github.com/llvm/llvm-project/pull/84587/files#diff-0d107f2b3067e045736b456ccc6d3523aedade072afc031562b9103cb1972805

Basically what to do is make type headers for `flock` and `flock64` in `include/llvm-libc-types/` as well as corresponding headers in `hdr/types/` that will inlcude either those type headers directly, or `<fenv.h>` depending on `LIBC_FULL_BUILD`. Same for the macros.

https://github.com/llvm/llvm-project/pull/89507


More information about the libc-commits mailing list