Index: ChangeLog =================================================================== --- ChangeLog (revision 24826) +++ ChangeLog (working copy) @@ -1,5 +1,23 @@ 2008-02-07 Michael Natterer + * app/base/base-utils.[ch]: add get_pid() which returns getpid(). + + * app/base/base.c + * app/base/tile-swap.c + * app/core/gimp-utils.c + * app/plug-in/gimppluginshm.c + * app/widgets/gimpselectiondata.c + * tools/pdbgen/pdb/misc.pdb: use it instead of getpid() and remove + all the #ifdef'ed includes getpid() needs. + + * tools/pdbgen/app.pl: remove support for these includes. If you + need something obscure, create a function outside app/pdb/ and + call that instead. + + * app/pdb/misc_cmds.c: regenerated. + +2008-02-07 Michael Natterer + * app/app.c: #include instead of 2008-02-07 Sven Neumann Index: app/core/gimp-utils.c =================================================================== --- app/core/gimp-utils.c (revision 24825) +++ app/core/gimp-utils.c (working copy) @@ -26,18 +26,6 @@ #include #endif -#include - -#ifdef HAVE_UNISTD_H -#include -#endif - -#include - -#ifdef G_OS_WIN32 -#include -#endif - #include #include @@ -48,6 +36,8 @@ #include "core-types.h" +#include "base/base-utils.h" + #include "config/gimpbaseconfig.h" #include "gimp.h" @@ -491,7 +481,7 @@ gimp_get_temp_filename (Gimp *gim g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); if (id == 0) - pid = getpid (); + pid = get_pid (); if (extension) basename = g_strdup_printf ("gimp-temp-%d%d.%s", pid, id++, extension); Index: app/pdb/misc_cmds.c =================================================================== --- app/pdb/misc_cmds.c (revision 24825) +++ app/pdb/misc_cmds.c (working copy) @@ -20,18 +20,6 @@ #include "config.h" -#include - -#ifdef G_OS_WIN32 -#include -#endif - -#include - -#ifdef HAVE_UNISTD_H -#include -#endif - #include @@ -42,6 +30,7 @@ #include "gimpprocedure.h" #include "core/gimpparamspecs.h" +#include "base/base-utils.h" #include "core/gimp.h" #include "internal_procs.h" @@ -77,7 +66,7 @@ getpid_invoker (GimpProcedure *proc GValueArray *return_vals; gint32 pid = 0; - pid = getpid (); + pid = get_pid (); return_vals = gimp_procedure_get_return_values (procedure, TRUE); g_value_set_int (&return_vals->values[1], pid); Index: app/widgets/gimpselectiondata.c =================================================================== --- app/widgets/gimpselectiondata.c (revision 24825) +++ app/widgets/gimpselectiondata.c (working copy) @@ -18,24 +18,16 @@ #include "config.h" -#include -#include #include -#include -#ifdef HAVE_UNISTD_H -#include -#endif #include -#ifdef G_OS_WIN32 -#include /* getpid() : defined from _getpid by GLib */ -#endif - #include "libgimpcolor/gimpcolor.h" #include "widgets-types.h" +#include "base/base-utils.h" + #include "core/gimp.h" #include "core/gimpbrush.h" #include "core/gimpcontainer.h" @@ -365,7 +357,7 @@ gimp_selection_data_set_image (GtkSelect g_return_if_fail (selection != NULL); g_return_if_fail (GIMP_IS_IMAGE (image)); - str = g_strdup_printf ("%d:%d", getpid (), gimp_image_get_ID (image)); + str = g_strdup_printf ("%d:%d", get_pid (), gimp_image_get_ID (image)); gtk_selection_data_set (selection, selection->target, 8, (guchar *) str, strlen (str) + 1); @@ -390,7 +382,7 @@ gimp_selection_data_get_image (GtkSelect return NULL; if (sscanf (str, "%i:%i", &pid, &ID) == 2 && - pid == getpid ()) + pid == get_pid ()) { image = gimp_image_get_by_ID (gimp, ID); } @@ -410,7 +402,7 @@ gimp_selection_data_set_component (GtkSe g_return_if_fail (selection != NULL); g_return_if_fail (GIMP_IS_IMAGE (image)); - str = g_strdup_printf ("%d:%d:%d", getpid (), gimp_image_get_ID (image), + str = g_strdup_printf ("%d:%d:%d", get_pid (), gimp_image_get_ID (image), (gint) channel); gtk_selection_data_set (selection, selection->target, @@ -441,7 +433,7 @@ gimp_selection_data_get_component (GtkSe return NULL; if (sscanf (str, "%i:%i:%i", &pid, &ID, &ch) == 3 && - pid == getpid ()) + pid == get_pid ()) { image = gimp_image_get_by_ID (gimp, ID); @@ -463,7 +455,7 @@ gimp_selection_data_set_item (GtkSelecti g_return_if_fail (selection != NULL); g_return_if_fail (GIMP_IS_ITEM (item)); - str = g_strdup_printf ("%d:%d", getpid (), gimp_item_get_ID (item)); + str = g_strdup_printf ("%d:%d", get_pid (), gimp_item_get_ID (item)); gtk_selection_data_set (selection, selection->target, 8, (guchar *) str, strlen (str) + 1); @@ -488,7 +480,7 @@ gimp_selection_data_get_item (GtkSelecti return NULL; if (sscanf (str, "%i:%i", &pid, &ID) == 2 && - pid == getpid ()) + pid == get_pid ()) { item = gimp_item_get_by_ID (gimp, ID); } @@ -513,7 +505,7 @@ gimp_selection_data_set_object (GtkSelec { gchar *str; - str = g_strdup_printf ("%d:%p:%s", getpid (), object, name); + str = g_strdup_printf ("%d:%p:%s", get_pid (), object, name); gtk_selection_data_set (selection, selection->target, 8, (guchar *) str, strlen (str) + 1); g_free (str); @@ -680,7 +672,7 @@ gimp_selection_data_get_object (GtkSelec return NULL; if (sscanf (str, "%i:%p:%n", &pid, &object_addr, &name_offset) >= 2 && - pid == getpid () && name_offset > 0) + pid == get_pid () && name_offset > 0) { gchar *name = str + name_offset; Index: app/base/base-utils.c =================================================================== --- app/base/base-utils.c (revision 24825) +++ app/base/base-utils.c (working copy) @@ -27,6 +27,7 @@ #ifdef G_OS_WIN32 #define _WIN32_WINNT 0x0500 #include +#include #endif #include "base-utils.h" @@ -35,6 +36,12 @@ /* public functions */ +GPid +get_pid (void) +{ + return getpid (); +} + gint get_number_of_processors (void) { Index: app/base/base.c =================================================================== --- app/base/base.c (revision 24825) +++ app/base/base.c (working copy) @@ -21,21 +21,11 @@ #include #include #include - -#ifdef HAVE_UNISTD_H -#include -#endif - #include #include #include -#ifdef G_OS_WIN32 -#include /* for _getpid() */ -#include "libgimpbase/gimpwin32-io.h" -#endif - #include "libgimpconfig/gimpconfig.h" #include "base-types.h" Index: app/base/base-utils.h =================================================================== --- app/base/base-utils.h (revision 24825) +++ app/base/base-utils.h (working copy) @@ -20,6 +20,7 @@ #define __BASE_H__ +GPid get_pid (void); gint get_number_of_processors (void); guint64 get_physical_memory_size (void); Index: app/base/tile-swap.c =================================================================== --- app/base/tile-swap.c (revision 24825) +++ app/base/tile-swap.c (working copy) @@ -35,8 +35,6 @@ #ifdef G_OS_WIN32 #include #include "libgimpbase/gimpwin32-io.h" -#include -#define getpid _getpid #endif #include "base-types.h" @@ -48,6 +46,7 @@ #define _O_TEMPORARY 0 #endif +#include "base-utils.h" #include "tile.h" #include "tile-rowhints.h" #include "tile-swap.h" @@ -169,7 +168,7 @@ tile_swap_init (const gchar *path) g_return_if_fail (path != NULL); dirname = gimp_config_path_expand (path, TRUE, NULL); - basename = g_strdup_printf ("gimpswap.%lu", (unsigned long) getpid ()); + basename = g_strdup_printf ("gimpswap.%lu", (unsigned long) get_pid ()); /* create the swap directory if it doesn't exist */ if (! g_file_test (dirname, G_FILE_TEST_EXISTS)) Index: app/plug-in/gimppluginshm.c =================================================================== --- app/plug-in/gimppluginshm.c (revision 24825) +++ app/plug-in/gimppluginshm.c (working copy) @@ -64,6 +64,7 @@ #include "plug-in-types.h" +#include "base/base-utils.h" #include "base/tile.h" #include "gimppluginshm.h" @@ -180,7 +181,7 @@ gimp_plug_in_shm_new (void) gint shm_fd; /* Our shared memory id will be our process ID */ - pid = getpid (); + pid = get_pid (); /* From the id, derive the file map name */ g_snprintf (shm_handle, sizeof (shm_handle), "/gimp-shm-%d", pid); Index: tools/pdbgen/app.pl =================================================================== --- tools/pdbgen/app.pl (revision 24825) +++ tools/pdbgen/app.pl (working copy) @@ -687,17 +687,6 @@ GPL $headers .= "\n" if $nl; $nl = 0; - if ($_ eq '') { - $headers .= "\n" if $seen; - $headers .= "#ifdef HAVE_UNISTD_H\n"; - } - if ($_ eq '') { - $headers .= "\n" if $seen; - $headers .= "#include \n\n"; - $headers .= "#ifdef G_OS_WIN32\n"; - } - - $seen++ if /^ [ qw( ) ], + headers => [ qw("base/base-utils.h") ], code => <<'CODE' { - pid = getpid (); + pid = get_pid (); } CODE );