[glib/wip/3v1n0/more-unix-oses: 2/5] glib/gio: Use G_OS_LINUX in public APIs




commit 4a72d2e8808dc516f4c35a61d657a8a7938dc36e
Author: Marco Trevisan (Treviño) <mail 3v1n0 net>
Date:   Wed Oct 19 16:00:01 2022 +0200

    glib/gio: Use G_OS_LINUX in public APIs
    
    We don't change internals as it could be dangerous given that __linux__
    is defined earlier than we defined G_OS_LINUX and thus we could not run
    code.

 gio/tests/file.c              | 8 ++++----
 gio/tests/gdbus-server-auth.c | 2 +-
 gio/tests/live-g-file.c       | 2 +-
 gio/tests/pollable.c          | 2 +-
 gio/tests/resources.c         | 6 +++---
 glib/tests/cond.c             | 2 +-
 glib/tests/error.c            | 6 +++---
 glib/tests/gdatetime.c        | 4 ++--
 glib/tests/option-argv0.c     | 2 +-
 9 files changed, 17 insertions(+), 17 deletions(-)
---
diff --git a/gio/tests/file.c b/gio/tests/file.c
index 6a63a344f7..0c528858e9 100644
--- a/gio/tests/file.c
+++ b/gio/tests/file.c
@@ -1075,7 +1075,7 @@ test_replace_symlink_using_etag (void)
 /* FIXME: These tests have only been checked on Linux. Most of them are probably
  * applicable on Windows, too, but that has not been tested yet.
  * See https://gitlab.gnome.org/GNOME/glib/-/issues/2325 */
-#ifdef __linux__
+#ifdef G_OS_LINUX
 
 /* Different kinds of file which create_test_file() can create. */
 typedef enum
@@ -1308,7 +1308,7 @@ check_test_file (GFile             *test_file,
   g_free (target_basename);
 }
 
-#endif  /* __linux__ */
+#endif  /* G_OS_LINUX */
 
 /* A big test for g_file_replace() and g_file_replace_readwrite(). The
  * @test_data is a boolean: %TRUE to test g_file_replace_readwrite(), %FALSE to
@@ -1329,7 +1329,7 @@ check_test_file (GFile             *test_file,
 static void
 test_replace (gconstpointer test_data)
 {
-#ifdef __linux__
+#ifdef G_OS_LINUX
   gboolean read_write = GPOINTER_TO_UINT (test_data);
   const gchar *new_contents = "this is a new test message which should be written to source";
   const gchar *original_source_contents = "this is some test content in source";
@@ -1973,7 +1973,7 @@ test_replace (gconstpointer test_data)
       g_clear_object (&source_file);
       g_clear_object (&tmpdir);
     }
-#else  /* if !__linux__ */
+#else  /* if !G_OS_LINUX */
   g_test_skip ("File replacement tests can only be run on Linux");
 #endif
 }
diff --git a/gio/tests/gdbus-server-auth.c b/gio/tests/gdbus-server-auth.c
index 9c56aac725..1969bb87f1 100644
--- a/gio/tests/gdbus-server-auth.c
+++ b/gio/tests/gdbus-server-auth.c
@@ -242,7 +242,7 @@ assert_expected_uid_pid (InteropFlags flags,
     }
   else    /* We should prefer EXTERNAL whenever it is allowed. */
     {
-#ifdef __linux__
+#ifdef G_OS_LINUX
       /* We know that both GDBus and libdbus support full credentials-passing
        * on Linux. */
       g_assert_cmpint (uid, ==, getuid ());
diff --git a/gio/tests/live-g-file.c b/gio/tests/live-g-file.c
index 9e2cc0c276..0537d72a5b 100644
--- a/gio/tests/live-g-file.c
+++ b/gio/tests/live-g-file.c
@@ -1457,7 +1457,7 @@ main (int argc, char *argv[])
       g_test_add_data_func ("/live-g-file/test_unix_is_mountpoint/sysroot",
                             "/",
                             test_unix_is_mountpoint);
-#ifdef __linux__
+#ifdef G_OS_LINUX
       g_test_add_data_func ("/live-g-file/test_unix_is_mountpoint/proc",
                             "/proc",
                             test_unix_is_mountpoint);
diff --git a/gio/tests/pollable.c b/gio/tests/pollable.c
index 56dfa3a31f..f61b701eea 100644
--- a/gio/tests/pollable.c
+++ b/gio/tests/pollable.c
@@ -34,7 +34,7 @@
 
 /* openpty() is non-standard and might not be available on all kernels
  * and libc implementations, but glibc on Linux definitely has it */
-#if defined(__linux__) && defined(__GNUC__) && !defined(HAVE_OPENPTY)
+#if defined(G_OS_LINUX) && defined(__GNUC__) && !defined(HAVE_OPENPTY)
 #error Should have been able to find openpty on GNU/Linux
 #endif
 
diff --git a/gio/tests/resources.c b/gio/tests/resources.c
index 910b189120..b341ad0179 100644
--- a/gio/tests/resources.c
+++ b/gio/tests/resources.c
@@ -642,10 +642,10 @@ test_resource_manual2 (void)
 static void
 test_resource_binary_linked (void)
 {
-  #ifndef __linux__
+  #ifndef G_OS_LINUX
   g_test_skip ("--external-data test only works on Linux");
   return;
-  #else /* if __linux__ */
+  #else /* if G_OS_LINUX */
   GError *error = NULL;
   gboolean found;
   gsize size;
@@ -669,7 +669,7 @@ test_resource_binary_linked (void)
   g_assert_cmpint (size, ==, 6);
   g_assert_cmpstr (g_bytes_get_data (data, NULL), ==, "test1\n");
   g_bytes_unref (data);
-  #endif /* if __linux__ */
+  #endif /* if G_OS_LINUX */
 }
 
 /* Test resource whose xml file starts with more than one digit
diff --git a/glib/tests/cond.c b/glib/tests/cond.c
index b179b3deeb..b97b5ac062 100644
--- a/glib/tests/cond.c
+++ b/glib/tests/cond.c
@@ -272,7 +272,7 @@ test_wait_until (void)
   g_cond_clear (&local_cond);
 }
 
-#ifdef __linux__
+#ifdef G_OS_LINUX
 
 #include <pthread.h>
 #include <signal.h>
diff --git a/glib/tests/error.c b/glib/tests/error.c
index fa3a25969d..3001ecc07e 100644
--- a/glib/tests/error.c
+++ b/glib/tests/error.c
@@ -123,7 +123,7 @@ static void
 test_new_valist_invalid_va (gpointer dummy,
                          ...)
 {
-#if defined(__linux__) && defined(__GLIBC__)
+#if defined(G_OS_LINUX) && defined(__GLIBC__)
   /* Only worth testing this on Linux with glibc; if other platforms regress on
    * this legacy behaviour, we don’t care. In particular, calling
    * g_error_new_valist() with a %NULL format will crash on FreeBSD as its
@@ -182,9 +182,9 @@ test_new_valist_invalid_va (gpointer dummy,
 
       va_end (ap);
     }
-#else  /* if !__linux__ || !__GLIBC__ */
+#else  /* if !G_OS_LINUX || !__GLIBC__ */
   g_test_skip ("g_error_new_valist() programmer error handling is only relevant on Linux with glibc");
-#endif /* !__linux__ || ! __GLIBC__ */
+#endif /* !G_OS_LINUX || ! __GLIBC__ */
 }
 
 static void
diff --git a/glib/tests/gdatetime.c b/glib/tests/gdatetime.c
index 3a0d2bd289..3228e95916 100644
--- a/glib/tests/gdatetime.c
+++ b/glib/tests/gdatetime.c
@@ -2465,7 +2465,7 @@ test_format_time_mixed_utf8 (gconstpointer data)
 #endif
 }
 
-#ifdef __linux__
+#ifdef G_OS_LINUX
 static gchar *
 str_utf8_replace (const gchar *str,
                   gunichar     from,
@@ -2488,7 +2488,7 @@ str_utf8_replace (const gchar *str,
 static void
 test_strftime (void)
 {
-#ifdef __linux__
+#ifdef G_OS_LINUX
 #define TEST_FORMAT \
   "a%a A%A b%b B%B c%c C%C d%d e%e F%F g%g G%G h%h H%H I%I j%j m%m M%M " \
   "n%n p%p r%r R%R S%S t%t T%T u%u V%V w%w x%x X%X y%y Y%Y z%z Z%Z %%"
diff --git a/glib/tests/option-argv0.c b/glib/tests/option-argv0.c
index a18e686764..70e25d946a 100644
--- a/glib/tests/option-argv0.c
+++ b/glib/tests/option-argv0.c
@@ -62,7 +62,7 @@ test_platform_argv0 (void)
    */
 #if !defined HAVE_PROC_SELF_CMDLINE && \
     !defined __OpenBSD__ && \
-    !defined __linux && \
+    !defined G_OS_LINUX && \
     !defined G_OS_WIN32
   fatal_errors = FALSE;
 #endif


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