[glib/wip/3v1n0/more-unix-oses: 4/5] glib: Add generic G_OS_BSD definition on such platforms
- From: Marco Trevisan <marcotrevi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/3v1n0/more-unix-oses: 4/5] glib: Add generic G_OS_BSD definition on such platforms
- Date: Wed, 19 Oct 2022 14:49:47 +0000 (UTC)
commit 623ac88d995c9c9551f6db3f677cb9bc20ebb17c
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Wed Oct 19 16:28:18 2022 +0200
glib: Add generic G_OS_BSD definition on such platforms
There is some downstream code and our tests that may at times need to
check for all BSD kinds, so just a more generic way to handle this
glib/docs.c | 17 ++++++++++++++---
glib/gspawn.c | 4 ++--
glib/tests/date.c | 2 +-
meson.build | 3 +++
4 files changed, 20 insertions(+), 6 deletions(-)
---
diff --git a/glib/docs.c b/glib/docs.c
index e317ea8c7d..9f6fe0cde2 100644
--- a/glib/docs.c
+++ b/glib/docs.c
@@ -1647,13 +1647,24 @@
* These macros provide a few commonly-used features.
*/
+/**
+ * G_OS_BSD:
+ *
+ * This macro is defined only on BSD operating systems. So you can bracket
+ * BSD-specific code in `\#ifdef G_OS_BSD`.
+ *
+ * Note that %G_OS_UNIX is also set.
+ *
+ * Since: 2.76
+ */
+
/**
* G_OS_DARWIN:
*
* This macro is defined only on macOS (OS X or iOS). So you can bracket
* Apple-specific code in `\#ifdef G_OS_DARWIN`.
*
- * Note that %G_OS_UNIX is also set.
+ * Note that %G_OS_UNIX and %G_OS_BSD is also set.
*
* Since: 2.76
*/
@@ -1664,7 +1675,7 @@
* This macro is defined only on FreeBSD operating system. So you can bracket
* FreeBSD-specific code in `\#ifdef G_OS_FREEBSD`.
*
- * Note that %G_OS_UNIX is also set.
+ * Note that %G_OS_UNIX and %G_OS_BSD is also set.
*
* Since: 2.76
*/
@@ -1686,7 +1697,7 @@
* This macro is defined only on OpenBSD operating system. So you can bracket
* OpenBSD-specific code in `\#ifdef G_OS_OPENBSD`.
*
- * Note that %G_OS_UNIX is also set.
+ * Note that %G_OS_UNIX and %G_OS_BSD is also set.
*
* Since: 2.76
*/
diff --git a/glib/gspawn.c b/glib/gspawn.c
index c2007d99a8..9501ed981a 100644
--- a/glib/gspawn.c
+++ b/glib/gspawn.c
@@ -1493,7 +1493,7 @@ safe_fdwalk (int (*cb)(void *data, int fd), void *data)
if (getrlimit (RLIMIT_NOFILE, &rl) == 0 && rl.rlim_max != RLIM_INFINITY)
open_max = rl.rlim_max;
#endif
-#if defined(G_OS_FREEBSD) || defined(G_OS_OPENBSD) || defined(G_OS_DARWIN)
+#ifdef G_OS_BSD
/* Use sysconf() function provided by the system if it is known to be
* async-signal safe.
*
@@ -1508,7 +1508,7 @@ safe_fdwalk (int (*cb)(void *data, int fd), void *data)
*/
if (open_max < 0)
open_max = sysconf (_SC_OPEN_MAX);
-#endif
+#endif /* G_OS_BSD */
/* Hardcoded fallback: the default process hard limit in Linux as of 2020 */
if (open_max < 0)
open_max = 4096;
diff --git a/glib/tests/date.c b/glib/tests/date.c
index 41ef5b6a92..4419bac41c 100644
--- a/glib/tests/date.c
+++ b/glib/tests/date.c
@@ -725,7 +725,7 @@ test_strftime (void)
#else
{ "%B", "January" },
{ "%b", "Jan" },
-#if defined(G_OS_FREEBSD) || defined(G_OS_OPENBSD) || defined(G_OS_DARWIN)
+#ifdef G_OS_BSD
{ "%C", "00" },
{ "%c", "Mon Jan 1 00:00:00 0001" },
{ "%E", "E" },
diff --git a/meson.build b/meson.build
index 6025c1ea3a..d636d7f0b0 100644
--- a/meson.build
+++ b/meson.build
@@ -250,6 +250,9 @@ elif host_system == 'openbsd'
else
glib_os = '#define G_OS_UNIX'
endif
+if host_system == 'darwin' or host_system.to_lower().endswith('bsd')
+ glib_os += '\n#define G_OS_BSD'
+endif
glibconfig_conf.set('glib_os', glib_os)
# We need to know the CRT being used to determine what .lib files we need on
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]