[glib/wip/3v1n0/more-unix-oses: 22/26] meson: Define G_OS_LINUX when host system is Linux




commit 1f99218fd34c0aba2a12bce5d15b0cd82d282715
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Wed Oct 19 15:33:42 2022 +0200

    meson: Define G_OS_LINUX when host system is Linux
    
    We happen to have some linux-only code also in generic unix
    code, so expose it as an OS macro and unix-subtype.

 docs/reference/glib/glib-overrides.txt   |  5 +++++
 docs/reference/glib/glib-sections.txt.in |  1 +
 glib/docs.c                              | 11 +++++++++++
 glib/tests/macros.c                      | 13 +++++++++++++
 meson.build                              |  4 +++-
 5 files changed, 33 insertions(+), 1 deletion(-)
---
diff --git a/docs/reference/glib/glib-overrides.txt b/docs/reference/glib/glib-overrides.txt
index 8f29a48d4b..ea53ea1b7b 100644
--- a/docs/reference/glib/glib-overrides.txt
+++ b/docs/reference/glib/glib-overrides.txt
@@ -201,6 +201,11 @@ GCond *cond
 #define G_OS_DARWIN
 </MACRO>
 
+<MACRO>
+<NAME>G_OS_LINUX</NAME>
+#define G_OS_LINUX
+</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 90b0f32585..5478c47951 100644
--- a/docs/reference/glib/glib-sections.txt.in
+++ b/docs/reference/glib/glib-sections.txt.in
@@ -141,6 +141,7 @@ GLIB_VERSION_PREV_STABLE
 <FILE>macros</FILE>
 <SUBSECTION>
 G_OS_DARWIN
+G_OS_LINUX
 G_OS_WIN32
 G_OS_UNIX
 
diff --git a/glib/docs.c b/glib/docs.c
index f93ce80483..ff01b86c74 100644
--- a/glib/docs.c
+++ b/glib/docs.c
@@ -1658,6 +1658,17 @@
  * Since: 2.76
  */
 
+/**
+ * G_OS_LINUX:
+ *
+ * This macro is defined only on Linux operating systems. So you can bracket
+ * Linux-specific code in `\#ifdef G_OS_LINUX`.
+ *
+ * Note that %G_OS_UNIX is also set.
+ *
+ * Since: 2.76
+ */
+
 /**
  * G_OS_WIN32:
  *
diff --git a/glib/tests/macros.c b/glib/tests/macros.c
index cbbc0f6def..545e4e805f 100644
--- a/glib/tests/macros.c
+++ b/glib/tests/macros.c
@@ -24,6 +24,15 @@
 
 #include <glib.h>
 
+#if defined (__linux__) || defined (__linux) || defined (__gnu_linux__)
+# ifndef G_OS_UNIX
+  G_STATIC_ASSERT (FALSE);
+# endif
+# ifndef G_OS_LINUX
+  G_STATIC_ASSERT (FALSE);
+# endif
+#endif
+
 #if defined (__APPLE__) || defined (HAVE_COCOA) || defined (HAVE_CARBON)
 # ifndef G_OS_UNIX
   G_STATIC_ASSERT (FALSE);
@@ -33,6 +42,10 @@
 # endif
 #endif
 
+#if defined (G_OS_UNIX) && defined (G_OS_WIN32)
+  G_STATIC_ASSERT (FALSE);
+#endif
+
 /* Test that G_STATIC_ASSERT_EXPR can be used as an expression */
 static void
 test_assert_static (void)
diff --git a/meson.build b/meson.build
index 73285f7a8f..e721fb356c 100644
--- a/meson.build
+++ b/meson.build
@@ -237,7 +237,9 @@ if host_system == 'windows'
 else
   glib_os = ['G_OS_UNIX']
 
-  if host_system == 'cygwin'
+  if host_system == 'linux'
+    glib_os += 'G_OS_LINUX'
+  elif host_system == 'cygwin'
     glib_os += 'G_WITH_CYGWIN'
   elif host_system in ['darwin', 'ios']
     glib_os += 'G_OS_DARWIN'


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]