--- a/gio/gcredentials.c
+++ b/gio/gcredentials.c
@@ -79,7 +79,7 @@
 
 #ifdef __linux__
   struct ucred native;
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__GNU__)
   struct cmsgcred native;
 #elif defined(__OpenBSD__)
   struct sockpeercred native;
@@ -131,7 +131,7 @@
   credentials->native.pid = getpid ();
   credentials->native.uid = geteuid ();
   credentials->native.gid = getegid ();
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__GNU__)
   memset (&credentials->native, 0, sizeof (struct cmsgcred));
   credentials->native.cmcred_pid  = getpid ();
   credentials->native.cmcred_euid = geteuid ();
@@ -193,7 +193,7 @@
     g_string_append_printf (ret, "gid=%" G_GINT64_FORMAT ",", (gint64) credentials->native.gid);
   if (ret->str[ret->len - 1] == ',')
     ret->str[ret->len - 1] = '\0';
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__GNU__)
   g_string_append (ret, "freebsd-cmsgcred:");
   if (credentials->native.cmcred_pid != -1)
     g_string_append_printf (ret, "pid=%" G_GINT64_FORMAT ",", (gint64) credentials->native.cmcred_pid);
@@ -251,7 +251,7 @@
 #ifdef __linux__
   if (credentials->native.uid == other_credentials->native.uid)
     ret = TRUE;
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__GNU__)
   if (credentials->native.cmcred_euid == other_credentials->native.cmcred_euid)
     ret = TRUE;
 #elif defined(__OpenBSD__)
@@ -307,7 +307,7 @@
     {
       ret = &credentials->native;
     }
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__GNU__)
   if (native_type != G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED)
     {
       g_warning ("g_credentials_get_native: Trying to get credentials of type %d but only "
@@ -368,7 +368,7 @@
     {
       memcpy (&credentials->native, native, sizeof (struct ucred));
     }
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__GNU__)
   if (native_type != G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED)
     {
       g_warning ("g_credentials_set_native: Trying to set credentials of type %d "
@@ -426,7 +426,7 @@
 
 #ifdef __linux__
   ret = credentials->native.uid;
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__GNU__)
   ret = credentials->native.cmcred_euid;
 #elif defined(__OpenBSD__)
   ret = credentials->native.uid;
@@ -468,7 +468,7 @@
 
 #ifdef __linux__
   ret = credentials->native.pid;
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__GNU__)
   ret = credentials->native.cmcred_pid;
 #elif defined(__OpenBSD__)
   ret = credentials->native.pid;
@@ -515,7 +515,7 @@
 #ifdef __linux__
   credentials->native.uid = uid;
   ret = TRUE;
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__GNU__)
   credentials->native.cmcred_euid = uid;
   ret = TRUE;
 #elif defined(__OpenBSD__)
--- a/gio/gunixcredentialsmessage.c
+++ b/gio/gunixcredentialsmessage.c
@@ -38,7 +38,7 @@
 /* ---------------------------------------------------------------------------------------------------- */
 #ifdef __linux__
 #define G_UNIX_CREDENTIALS_MESSAGE_SUPPORTED 1
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__GNU__)
 #define G_UNIX_CREDENTIALS_MESSAGE_SUPPORTED 1
 #else
 /* TODO: please add support for your UNIX flavor */
@@ -75,7 +75,7 @@
 {
 #ifdef __linux__
   return sizeof (struct ucred);
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__GNU__)
   return sizeof (struct cmsgcred);
 #else
   return 0;
@@ -87,7 +87,7 @@
 {
 #ifdef __linux__
   return SOL_SOCKET;
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__GNU__)
   return SOL_SOCKET;
 #else
   return 0;
@@ -99,7 +99,7 @@
 {
 #ifdef __linux__
   return SCM_CREDENTIALS;
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__GNU__)
   return SCM_CREDS;
 #else
   return 0;
@@ -149,7 +149,7 @@
  out:
     ;
   }
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__GNU__)
   {
     GCredentials *credentials;
     struct cmsgcred *cred;
@@ -191,7 +191,7 @@
           g_credentials_get_native (message->priv->credentials,
                                     G_CREDENTIALS_TYPE_LINUX_UCRED),
           sizeof (struct ucred));
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__GNU__)
   memcpy (data,
           g_credentials_get_native (message->priv->credentials,
                                     G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED),
--- a/gio/tests/credentials.c
+++ b/gio/tests/credentials.c
@@ -30,6 +30,7 @@
 # if (defined(__linux__) || \
   defined(__FreeBSD__) || \
   defined(__FreeBSD_kernel__) || \
+  defined(__GNU__) || \
   defined(__OpenBSD__))
 #   define SHOULD_HAVE_CREDENTIALS
 # endif
@@ -91,7 +92,7 @@
           g_assert_cmpuint (native->uid, ==, geteuid ());
           g_assert_cmpuint (native->pid, ==, getpid ());
         }
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)|| defined(__GNU__)
         {
           struct cmsgcred *native = g_credentials_get_native (creds,
               G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED);
--- a/gio/tests/gdbus-peer.c
+++ b/gio/tests/gdbus-peer.c
@@ -47,6 +47,7 @@
 #if (defined(__linux__) || \
   defined(__FreeBSD__) || \
   defined(__FreeBSD_kernel__) || \
+  defined(__GNU__) || \
   defined(__OpenBSD__))
 #define SHOULD_HAVE_CREDENTIALS_PASSING
 #endif
