Commit 3a66deae authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

add get_pid() which returns getpid().

2008-02-07  Michael Natterer  <mitch@gimp.org>

	* 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. Also
	remove some perl cruft in the include handling which is not needed
	any longer.

	* app/pdb/misc_cmds.c: regenerated.


svn path=/trunk/; revision=24827
parent ce7e0c22
2008-02-07 Michael Natterer <mitch@gimp.org>
* 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. Also
remove some perl cruft in the include handling which is not needed
any longer.
* app/pdb/misc_cmds.c: regenerated.
2008-02-07 Michael Natterer <mitch@gimp.org> 2008-02-07 Michael Natterer <mitch@gimp.org>
* app/app.c: #include <gegl.h> instead of <glib-object.h> * app/app.c: #include <gegl.h> instead of <glib-object.h>
......
...@@ -27,14 +27,23 @@ ...@@ -27,14 +27,23 @@
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
#define _WIN32_WINNT 0x0500 #define _WIN32_WINNT 0x0500
#include <windows.h> #include <windows.h>
#include <process.h>
#endif #endif
#include "base-utils.h" #include "base-utils.h"
#define NUM_PROCESSORS_DEFAULT 1 #define NUM_PROCESSORS_DEFAULT 1
/* public functions */ /* public functions */
GPid
get_pid (void)
{
return getpid ();
}
gint gint
get_number_of_processors (void) get_number_of_processors (void)
{ {
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#define __BASE_H__ #define __BASE_H__
GPid get_pid (void);
gint get_number_of_processors (void); gint get_number_of_processors (void);
guint64 get_physical_memory_size (void); guint64 get_physical_memory_size (void);
......
...@@ -21,18 +21,12 @@ ...@@ -21,18 +21,12 @@
#include <signal.h> #include <signal.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/types.h> #include <sys/types.h>
#include <glib-object.h> #include <glib-object.h>
#include <glib/gstdio.h> #include <glib/gstdio.h>
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
#include <process.h> /* for _getpid() */
#include "libgimpbase/gimpwin32-io.h" #include "libgimpbase/gimpwin32-io.h"
#endif #endif
......
...@@ -35,8 +35,6 @@ ...@@ -35,8 +35,6 @@
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
#include <windows.h> #include <windows.h>
#include "libgimpbase/gimpwin32-io.h" #include "libgimpbase/gimpwin32-io.h"
#include <process.h>
#define getpid _getpid
#endif #endif
#include "base-types.h" #include "base-types.h"
...@@ -48,6 +46,7 @@ ...@@ -48,6 +46,7 @@
#define _O_TEMPORARY 0 #define _O_TEMPORARY 0
#endif #endif
#include "base-utils.h"
#include "tile.h" #include "tile.h"
#include "tile-rowhints.h" #include "tile-rowhints.h"
#include "tile-swap.h" #include "tile-swap.h"
...@@ -169,7 +168,7 @@ tile_swap_init (const gchar *path) ...@@ -169,7 +168,7 @@ tile_swap_init (const gchar *path)
g_return_if_fail (path != NULL); g_return_if_fail (path != NULL);
dirname = gimp_config_path_expand (path, TRUE, 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 */ /* create the swap directory if it doesn't exist */
if (! g_file_test (dirname, G_FILE_TEST_EXISTS)) if (! g_file_test (dirname, G_FILE_TEST_EXISTS))
......
...@@ -26,18 +26,6 @@ ...@@ -26,18 +26,6 @@
#include <langinfo.h> #include <langinfo.h>
#endif #endif
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <glib.h>
#ifdef G_OS_WIN32
#include <process.h>
#endif
#include <glib-object.h> #include <glib-object.h>
#include <gobject/gvaluecollector.h> #include <gobject/gvaluecollector.h>
...@@ -48,6 +36,8 @@ ...@@ -48,6 +36,8 @@
#include "core-types.h" #include "core-types.h"
#include "base/base-utils.h"
#include "config/gimpbaseconfig.h" #include "config/gimpbaseconfig.h"
#include "gimp.h" #include "gimp.h"
...@@ -491,7 +481,7 @@ gimp_get_temp_filename (Gimp *gimp, ...@@ -491,7 +481,7 @@ gimp_get_temp_filename (Gimp *gimp,
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
if (id == 0) if (id == 0)
pid = getpid (); pid = get_pid ();
if (extension) if (extension)
basename = g_strdup_printf ("gimp-temp-%d%d.%s", pid, id++, extension); basename = g_strdup_printf ("gimp-temp-%d%d.%s", pid, id++, extension);
......
...@@ -20,18 +20,6 @@ ...@@ -20,18 +20,6 @@
#include "config.h" #include "config.h"
#include <glib.h>
#ifdef G_OS_WIN32
#include <process.h>
#endif
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <glib-object.h> #include <glib-object.h>
...@@ -42,6 +30,7 @@ ...@@ -42,6 +30,7 @@
#include "gimpprocedure.h" #include "gimpprocedure.h"
#include "core/gimpparamspecs.h" #include "core/gimpparamspecs.h"
#include "base/base-utils.h"
#include "core/gimp.h" #include "core/gimp.h"
#include "internal_procs.h" #include "internal_procs.h"
...@@ -77,7 +66,7 @@ getpid_invoker (GimpProcedure *procedure, ...@@ -77,7 +66,7 @@ getpid_invoker (GimpProcedure *procedure,
GValueArray *return_vals; GValueArray *return_vals;
gint32 pid = 0; gint32 pid = 0;
pid = getpid (); pid = get_pid ();
return_vals = gimp_procedure_get_return_values (procedure, TRUE); return_vals = gimp_procedure_get_return_values (procedure, TRUE);
g_value_set_int (&return_vals->values[1], pid); g_value_set_int (&return_vals->values[1], pid);
......
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
#include "plug-in-types.h" #include "plug-in-types.h"
#include "base/base-utils.h"
#include "base/tile.h" #include "base/tile.h"
#include "gimppluginshm.h" #include "gimppluginshm.h"
...@@ -180,7 +181,7 @@ gimp_plug_in_shm_new (void) ...@@ -180,7 +181,7 @@ gimp_plug_in_shm_new (void)
gint shm_fd; gint shm_fd;
/* Our shared memory id will be our process ID */ /* Our shared memory id will be our process ID */
pid = getpid (); pid = get_pid ();
/* From the id, derive the file map name */ /* From the id, derive the file map name */
g_snprintf (shm_handle, sizeof (shm_handle), "/gimp-shm-%d", pid); g_snprintf (shm_handle, sizeof (shm_handle), "/gimp-shm-%d", pid);
......
...@@ -18,24 +18,16 @@ ...@@ -18,24 +18,16 @@
#include "config.h" #include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <gtk/gtk.h> #include <gtk/gtk.h>
#ifdef G_OS_WIN32
#include <process.h> /* getpid() : defined from _getpid by GLib */
#endif
#include "libgimpcolor/gimpcolor.h" #include "libgimpcolor/gimpcolor.h"
#include "widgets-types.h" #include "widgets-types.h"
#include "base/base-utils.h"
#include "core/gimp.h" #include "core/gimp.h"
#include "core/gimpbrush.h" #include "core/gimpbrush.h"
#include "core/gimpcontainer.h" #include "core/gimpcontainer.h"
...@@ -365,7 +357,7 @@ gimp_selection_data_set_image (GtkSelectionData *selection, ...@@ -365,7 +357,7 @@ gimp_selection_data_set_image (GtkSelectionData *selection,
g_return_if_fail (selection != NULL); g_return_if_fail (selection != NULL);
g_return_if_fail (GIMP_IS_IMAGE (image)); 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, gtk_selection_data_set (selection, selection->target,
8, (guchar *) str, strlen (str) + 1); 8, (guchar *) str, strlen (str) + 1);
...@@ -390,7 +382,7 @@ gimp_selection_data_get_image (GtkSelectionData *selection, ...@@ -390,7 +382,7 @@ gimp_selection_data_get_image (GtkSelectionData *selection,
return NULL; return NULL;
if (sscanf (str, "%i:%i", &pid, &ID) == 2 && if (sscanf (str, "%i:%i", &pid, &ID) == 2 &&
pid == getpid ()) pid == get_pid ())
{ {
image = gimp_image_get_by_ID (gimp, ID); image = gimp_image_get_by_ID (gimp, ID);
} }
...@@ -410,7 +402,7 @@ gimp_selection_data_set_component (GtkSelectionData *selection, ...@@ -410,7 +402,7 @@ gimp_selection_data_set_component (GtkSelectionData *selection,
g_return_if_fail (selection != NULL); g_return_if_fail (selection != NULL);
g_return_if_fail (GIMP_IS_IMAGE (image)); 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); (gint) channel);
gtk_selection_data_set (selection, selection->target, gtk_selection_data_set (selection, selection->target,
...@@ -441,7 +433,7 @@ gimp_selection_data_get_component (GtkSelectionData *selection, ...@@ -441,7 +433,7 @@ gimp_selection_data_get_component (GtkSelectionData *selection,
return NULL; return NULL;
if (sscanf (str, "%i:%i:%i", &pid, &ID, &ch) == 3 && if (sscanf (str, "%i:%i:%i", &pid, &ID, &ch) == 3 &&
pid == getpid ()) pid == get_pid ())
{ {
image = gimp_image_get_by_ID (gimp, ID); image = gimp_image_get_by_ID (gimp, ID);
...@@ -463,7 +455,7 @@ gimp_selection_data_set_item (GtkSelectionData *selection, ...@@ -463,7 +455,7 @@ gimp_selection_data_set_item (GtkSelectionData *selection,
g_return_if_fail (selection != NULL); g_return_if_fail (selection != NULL);
g_return_if_fail (GIMP_IS_ITEM (item)); 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, gtk_selection_data_set (selection, selection->target,
8, (guchar *) str, strlen (str) + 1); 8, (guchar *) str, strlen (str) + 1);
...@@ -488,7 +480,7 @@ gimp_selection_data_get_item (GtkSelectionData *selection, ...@@ -488,7 +480,7 @@ gimp_selection_data_get_item (GtkSelectionData *selection,
return NULL; return NULL;
if (sscanf (str, "%i:%i", &pid, &ID) == 2 && if (sscanf (str, "%i:%i", &pid, &ID) == 2 &&
pid == getpid ()) pid == get_pid ())
{ {
item = gimp_item_get_by_ID (gimp, ID); item = gimp_item_get_by_ID (gimp, ID);
} }
...@@ -513,7 +505,7 @@ gimp_selection_data_set_object (GtkSelectionData *selection, ...@@ -513,7 +505,7 @@ gimp_selection_data_set_object (GtkSelectionData *selection,
{ {
gchar *str; 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, gtk_selection_data_set (selection, selection->target,
8, (guchar *) str, strlen (str) + 1); 8, (guchar *) str, strlen (str) + 1);
g_free (str); g_free (str);
...@@ -680,7 +672,7 @@ gimp_selection_data_get_object (GtkSelectionData *selection, ...@@ -680,7 +672,7 @@ gimp_selection_data_get_object (GtkSelectionData *selection,
return NULL; return NULL;
if (sscanf (str, "%i:%p:%n", &pid, &object_addr, &name_offset) >= 2 && 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; gchar *name = str + name_offset;
......
...@@ -681,23 +681,9 @@ GPL ...@@ -681,23 +681,9 @@ GPL
} }
$x cmp $y; $x cmp $y;
} keys %{$out->{headers}}; } keys %{$out->{headers}};
my $headers = ""; my $lib = 0; my $seen = 0; my $nl = 0; my $headers = "";
my $sys = 0; my $base = 0; my $lib = 0; my $seen = 0; my $sys = 0; my $base = 0;
foreach (@headers) { foreach (@headers) {
$headers .= "\n" if $nl;
$nl = 0;
if ($_ eq '<unistd.h>') {
$headers .= "\n" if $seen;
$headers .= "#ifdef HAVE_UNISTD_H\n";
}
if ($_ eq '<process.h>') {
$headers .= "\n" if $seen;
$headers .= "#include <glib.h>\n\n";
$headers .= "#ifdef G_OS_WIN32\n";
}
$seen++ if /^</; $seen++ if /^</;
if ($sys == 0 && !/^</) { if ($sys == 0 && !/^</) {
...@@ -731,20 +717,6 @@ GPL ...@@ -731,20 +717,6 @@ GPL
} }
$headers .= "#include $_\n"; $headers .= "#include $_\n";
if ($_ eq '<unistd.h>') {
$headers .= "#endif\n";
$seen = 0;
$nl = 1;
}
if ($_ eq '<process.h>') {
$headers .= "#endif\n";
$seen = 0;
$nl = 1;
}
$headers .= "\n" if $_ eq '"config.h"';
} }
$headers .= "\n#include \"internal_procs.h\"\n"; $headers .= "\n#include \"internal_procs.h\"\n";
......
...@@ -56,10 +56,10 @@ HELP ...@@ -56,10 +56,10 @@ HELP
); );
%invoke = ( %invoke = (
headers => [ qw(<sys/types.h> <unistd.h> <process.h>) ], headers => [ qw("base/base-utils.h") ],
code => <<'CODE' code => <<'CODE'
{ {
pid = getpid (); pid = get_pid ();
} }
CODE CODE
); );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment