[glib] gmain: Add G_PID_FORMAT



commit 7ea4949cdac8f7a4636f92e9e9efceec90ff09e6
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Thu Jun 16 18:28:14 2016 -0400

    gmain: Add G_PID_FORMAT
    
    This will be useful for printing out GPids in printf()-style functions.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=767765

 configure.ac                          |    4 ++++
 docs/reference/glib/glib-sections.txt |    1 +
 glib/glibconfig.h.win32.in            |    1 +
 glib/gmain.h                          |   11 +++++++++++
 4 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 3d0daf2..9552b99 100644
--- a/configure.ac
+++ b/configure.ac
@@ -125,6 +125,7 @@ case "$host" in
   *-*-mingw*)
     glib_native_win32=yes
     glib_pid_type='void *'
+    glib_pid_format='p'
     glib_pollfd_format='%#x'
     glib_cv_stack_grows=no
     # Unfortunately the mingw implementations of C99-style snprintf and vsnprintf
@@ -148,6 +149,7 @@ case "$host" in
   *)
     glib_native_win32=no
     glib_pid_type=int
+    glib_pid_format='i'
     glib_pollfd_format='%d'
     ;;
 esac
@@ -2884,6 +2886,7 @@ _______EOF
 #define G_MODULE_SUFFIX "$g_module_suffix"
 
 typedef $g_pid_type GPid;
+#define G_PID_FORMAT $g_pid_format
 
 #define GLIB_SYSDEF_AF_UNIX $g_af_unix
 #define GLIB_SYSDEF_AF_INET $g_af_inet
@@ -3166,6 +3169,7 @@ g_gcc_atomic_ops="$glib_cv_gcc_has_builtin_atomic_operations"
 
 g_module_suffix="$glib_gmodule_suffix"
 g_pid_type="$glib_pid_type"
+g_pid_format="\"$glib_pid_format\""
 g_pollfd_format="\"$glib_pollfd_format\""
 
 case $host in
diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt
index dae86a6..398ca95 100644
--- a/docs/reference/glib/glib-sections.txt
+++ b/docs/reference/glib/glib-sections.txt
@@ -571,6 +571,7 @@ g_idle_remove_by_data
 
 <SUBSECTION>
 GPid
+G_PID_FORMAT
 GChildWatchFunc
 g_child_watch_source_new
 g_child_watch_add
diff --git a/glib/glibconfig.h.win32.in b/glib/glibconfig.h.win32.in
index 302d8df..ab7e68d 100644
--- a/glib/glibconfig.h.win32.in
+++ b/glib/glibconfig.h.win32.in
@@ -242,6 +242,7 @@ typedef unsigned __int64 guintptr;
  * not a process identifier.
  */
 typedef void * GPid;
+#define G_PID_FORMAT "p"
 
 #define GLIB_SYSDEF_AF_UNIX 1
 #define GLIB_SYSDEF_AF_INET 2
diff --git a/glib/gmain.h b/glib/gmain.h
index 746edd7..1eaf9f7 100644
--- a/glib/gmain.h
+++ b/glib/gmain.h
@@ -140,6 +140,17 @@ typedef struct _GSourceFuncs            GSourceFuncs;
  * GPid is used in GLib only for descendant processes spawned with
  * the g_spawn functions.
  */
+/* defined in glibconfig.h */
+
+/**
+ * G_PID_FORMAT:
+ *
+ * A format specifier that can be used in printf()-style format strings
+ * when printing a #GPid.
+ *
+ * Since: 2.50
+ */
+/* defined in glibconfig.h */
 
 /**
  * GSourceFunc:


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