[glib/wip/3v1n0/more-unix-oses: 6/7] 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: 6/7] glib: Add G_OS_OPENBSD and G_OS_FREEBSD
- Date: Wed, 19 Oct 2022 15:53:30 +0000 (UTC)
commit e95b6b1ba6c23241fe822dbec78aaea5955ebb3a
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
docs/reference/glib/glib-overrides.txt | 10 ++++++++++
docs/reference/glib/glib-sections.txt.in | 2 ++
gio/gcredentialsprivate.h | 5 ++---
glib/docs.c | 22 ++++++++++++++++++++++
glib/gspawn.c | 4 ++--
glib/tests/date.c | 2 +-
glib/tests/macros.c | 18 ++++++++++++++++++
glib/tests/option-argv0.c | 2 +-
meson.build | 4 ++++
9 files changed, 62 insertions(+), 7 deletions(-)
---
diff --git a/docs/reference/glib/glib-overrides.txt b/docs/reference/glib/glib-overrides.txt
index ea53ea1b7b..20c6f8198c 100644
--- a/docs/reference/glib/glib-overrides.txt
+++ b/docs/reference/glib/glib-overrides.txt
@@ -196,6 +196,11 @@ GCond *cond
# Definitions for different operating systems
+<MACRO>
+<NAME>G_OS_FREEBSD</NAME>
+#define G_OS_FREEBSD
+</MACRO>
+
<MACRO>
<NAME>G_OS_DARWIN</NAME>
#define G_OS_DARWIN
@@ -206,6 +211,11 @@ GCond *cond
#define G_OS_LINUX
</MACRO>
+<MACRO>
+<NAME>G_OS_OPENBSD</NAME>
+#define G_OS_OPENBSD
+</MACRO>
+
<MACRO>
<NAME>G_OS_UNIX</NAME>
#define G_OS_UNIX
diff --git a/docs/reference/glib/glib-sections.txt.in b/docs/reference/glib/glib-sections.txt.in
index 5478c47951..9219b44267 100644
--- a/docs/reference/glib/glib-sections.txt.in
+++ b/docs/reference/glib/glib-sections.txt.in
@@ -141,7 +141,9 @@ GLIB_VERSION_PREV_STABLE
<FILE>macros</FILE>
<SUBSECTION>
G_OS_DARWIN
+G_OS_FREEBSD
G_OS_LINUX
+G_OS_OPENBSD
G_OS_WIN32
G_OS_UNIX
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/macros.c b/glib/tests/macros.c
index 545e4e805f..2a530182af 100644
--- a/glib/tests/macros.c
+++ b/glib/tests/macros.c
@@ -33,6 +33,24 @@
# endif
#endif
+#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
+# ifndef G_OS_UNIX
+ G_STATIC_ASSERT (FALSE);
+# endif
+# ifndef G_OS_FREEBSD
+ G_STATIC_ASSERT (FALSE);
+# endif
+#endif
+
+#if defined (__OpenBSD__)
+# ifndef G_OS_UNIX
+ G_STATIC_ASSERT (FALSE);
+# endif
+# ifndef G_OS_OPENBSD
+ G_STATIC_ASSERT (FALSE);
+# endif
+#endif
+
#if defined (__APPLE__) || defined (HAVE_COCOA) || defined (HAVE_CARBON)
# ifndef G_OS_UNIX
G_STATIC_ASSERT (FALSE);
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 d4f2610bff..fbfd4eff8f 100644
--- a/meson.build
+++ b/meson.build
@@ -243,6 +243,10 @@ else
glib_os += 'G_WITH_CYGWIN'
elif host_system == 'darwin'
glib_os += 'G_OS_DARWIN'
+ elif host_system == 'freebsd'
+ glib_os += 'G_OS_FREEBSD'
+ elif host_system == 'openbsd'
+ glib_os += 'G_OS_OPENBSD'
endif
endif
glib_os_defines = []
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]