Re: [scc-dev] [PATCH 1/3] make/posix: fix feature test macros

From: <lhr_at_disroot.org>
Date: Thu, 27 Feb 2025 19:36:45 +0000

> Can you be more explicit about what macros? I don't think we use
> anything that is XSI [...]

S_IFMT and S_IFDIR are used in scc-make/posix.c; glibc requires _XOPEN_SOURCE
for all S_IF* macros, but not the S_IS* macros, although the GNU/Linux stat(2)
manpage doesn't document this. POSIX does say[1] the S_IF* macros are part of
the XSI (except for S_IFMT), while the S_IS* macros are core POSIX, so maybe
for portability it should be:

---
diff --git a/src/cmd/scc-make/posix.c b/src/cmd/scc-make/posix.c
index bf0764a6..8f7bfb4e 100644
--- a/src/cmd/scc-make/posix.c
+++ b/src/cmd/scc-make/posix.c
_at_@ -18,7 +18,7 @@ is_dir(char *fname)
 	if (stat(fname, &st) < 0)
 		return 0;
-	return (st.st_mode & S_IFMT) == S_IFDIR;
+	return S_ISDIR(st.st_mode);
 }
 void
---
Which means _XOPEN_SOURCE is no longer needed. glibc will still want
_POSIX_C_SOURCE >= 1 for sigaction and kill. I'm not sure what feature
test macros may be needed on other systems, so it can't hurt to define
_POSIX_C_SOURCE however high you like.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_stat.h.html
--
To unsubscribe send a mail to scc-dev+unsubscribe_at_simple-cc.org
Received on Thu 27 Feb 2025 - 20:36:45 CET

This archive was generated by hypermail 2.3.0 : Thu 27 Feb 2025 - 20:40:01 CET