[glib/wip/3v1n0/more-unix-oses: 3/5] glib: Add G_OS_OPENBSD and G_OS_FREEBSD
- From: Marco Trevisan <marcotrevi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/3v1n0/more-unix-oses: 3/5] glib: Add G_OS_OPENBSD and G_OS_FREEBSD
- Date: Wed, 19 Oct 2022 14:49:47 +0000 (UTC)
commit 3490c157864858f0f29bd9344b7f3749d1db46ca
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Wed Oct 19 16:14:34 2022 +0200
glib: Add G_OS_OPENBSD and G_OS_FREEBSD
Add the most common types of BSD systems as public apis
gio/gcredentialsprivate.h | 5 ++---
glib/docs.c | 22 ++++++++++++++++++++++
glib/gspawn.c | 4 ++--
glib/tests/date.c | 2 +-
glib/tests/option-argv0.c | 2 +-
meson.build | 6 ++++++
6 files changed, 34 insertions(+), 7 deletions(-)
---
diff --git a/gio/gcredentialsprivate.h b/gio/gcredentialsprivate.h
index f692f1af7c..0d83bf01a3 100644
--- a/gio/gcredentialsprivate.h
+++ b/gio/gcredentialsprivate.h
@@ -114,8 +114,7 @@
#define G_CREDENTIALS_SPOOFING_SUPPORTED 1
#define G_CREDENTIALS_HAS_PID 1
-#elif defined(__FreeBSD__) || \
- defined(__FreeBSD_kernel__) /* Debian GNU/kFreeBSD */ || \
+#elif defined(G_OS_FREEBSD) || \
defined(__GNU__) /* GNU Hurd */ || \
defined(__DragonFly__) /* DragonFly BSD */
#define G_CREDENTIALS_SUPPORTED 1
@@ -141,7 +140,7 @@
#define G_CREDENTIALS_SPOOFING_SUPPORTED 1
#define G_CREDENTIALS_HAS_PID 1
-#elif defined(__OpenBSD__)
+#elif defined(G_OS_OPENBSD)
#define G_CREDENTIALS_SUPPORTED 1
#define G_CREDENTIALS_USE_OPENBSD_SOCKPEERCRED 1
#define G_CREDENTIALS_NATIVE_TYPE G_CREDENTIALS_TYPE_OPENBSD_SOCKPEERCRED
diff --git a/glib/docs.c b/glib/docs.c
index 0a671bb9ed..e317ea8c7d 100644
--- a/glib/docs.c
+++ b/glib/docs.c
@@ -1658,6 +1658,17 @@
* Since: 2.76
*/
+/**
+ * G_OS_FREEBSD:
+ *
+ * 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.
+ *
+ * Since: 2.76
+ */
+
/**
* G_OS_LINUX:
*
@@ -1669,6 +1680,17 @@
* Since: 2.76
*/
+/**
+ * G_OS_OPENBSD:
+ *
+ * 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.
+ *
+ * Since: 2.76
+ */
+
/**
* G_OS_WIN32:
*
diff --git a/glib/gspawn.c b/glib/gspawn.c
index 3300ec8e22..c2007d99a8 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(__FreeBSD__) || defined(__OpenBSD__) || defined(G_OS_DARWIN)
+#if defined(G_OS_FREEBSD) || defined(G_OS_OPENBSD) || defined(G_OS_DARWIN)
/* Use sysconf() function provided by the system if it is known to be
* async-signal safe.
*
@@ -1552,7 +1552,7 @@ safe_fdwalk_set_cloexec (int lowfd)
static int
safe_closefrom (int lowfd)
{
-#if defined(__FreeBSD__) || defined(__OpenBSD__) || \
+#if defined(G_OS_FREEBSD) || defined(G_OS_OPENBSD) || \
(defined(__sun__) && defined(F_CLOSEFROM))
/* Use closefrom function provided by the system if it is known to be
* async-signal safe.
diff --git a/glib/tests/date.c b/glib/tests/date.c
index 8113ad574b..41ef5b6a92 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(__FreeBSD__) || defined(__OpenBSD__) || defined(G_OS_DARWIN)
+#if defined(G_OS_FREEBSD) || defined(G_OS_OPENBSD) || defined(G_OS_DARWIN)
{ "%C", "00" },
{ "%c", "Mon Jan 1 00:00:00 0001" },
{ "%E", "E" },
diff --git a/glib/tests/option-argv0.c b/glib/tests/option-argv0.c
index 70e25d946a..47f18daddf 100644
--- a/glib/tests/option-argv0.c
+++ b/glib/tests/option-argv0.c
@@ -61,7 +61,7 @@ test_platform_argv0 (void)
* and make them call g_test_skip() instead.
*/
#if !defined HAVE_PROC_SELF_CMDLINE && \
- !defined __OpenBSD__ && \
+ !defined G_OS_OPENBSD && \
!defined G_OS_LINUX && \
!defined G_OS_WIN32
fatal_errors = FALSE;
diff --git a/meson.build b/meson.build
index 73e61dacd7..6025c1ea3a 100644
--- a/meson.build
+++ b/meson.build
@@ -241,6 +241,12 @@ elif host_system == 'cygwin'
elif host_system == 'darwin'
glib_os = '''#define G_OS_UNIX
#define G_OS_DARWIN'''
+elif host_system == 'freebsd'
+ glib_os = '''#define G_OS_UNIX
+#define G_OS_FREEBSD'''
+elif host_system == 'openbsd'
+ glib_os = '''#define G_OS_UNIX
+#define G_OS_OPENBSD'''
else
glib_os = '#define G_OS_UNIX'
endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]