[libc-commits] [libc] [libc] Implement sockatmark (PR #205400)

Pavel Labath via libc-commits libc-commits at lists.llvm.org
Tue Jun 30 03:19:28 PDT 2026


================
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Linux implementation of sockatmark.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/sys/socket/sockatmark.h"
+#include "src/__support/OSUtil/linux/syscall_wrappers/ioctl.h"
+#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
+
+// For SIOCATMARK. Can't use hdr/sys_ioctl_macros, as not all system library
+// versions define it.
+#include <linux/sockios.h> // For SIOCATMARK.
----------------
labath wrote:

The kernel headers do tend to include too much, but the ioctl headers specifically are pretty clean, and our implementation of sys_ioctl_macros already delegates this responsibility to them (as of #204555).

However, that's not the question here (at least as I understand it). The question is what to do in overlay mode where glibc's sys/ioctl.h (some versions of it) does not define a particular ioctl. The options are:
- include the linux header in the .cpp file (this isn't something we need to export, we just need *someone* to define the constant for our internal purposes). That's what this patch does.
- Make the proxy header include the linux header in overlay mode. This is what Michael alluded to. I think that could work, but it's potentially problematic due to multiple sources (glibc and kernel) trying to define the same constants
- remove the proxy header completely and always include the linux headers (what I proposed in the next comment, a more principled version of what this patch does).

I think the solution in this patch is sufficient,  but I'm okay with either of the other solutions if you think that's better.

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


More information about the libc-commits mailing list