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>
* app/app.c: #include <gegl.h> instead of <glib-object.h>
......
......@@ -27,14 +27,23 @@
#ifdef G_OS_WIN32
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <process.h>
#endif
#include "base-utils.h"
#define NUM_PROCESSORS_DEFAULT 1
/* public functions */
GPid
get_pid (void)
{
return getpid ();
}
gint
get_number_of_processors (void)
{
......
......@@ -20,6 +20,7 @@
#define __BASE_H__
GPid get_pid (void);
gint get_number_of_processors (void);
guint64 get_physical_memory_size (void);
......
......@@ -21,18 +21,12 @@
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/types.h>
#include <glib-object.h>
#include <glib/gstdio.h>
#ifdef G_OS_WIN32
#include <process.h> /* for _getpid() */
#include "libgimpbase/gimpwin32-io.h"
#endif
......
......@@ -35,8 +35,6 @@
#ifdef G_OS_WIN32
#include <windows.h>
#include "libgimpbase/gimpwin32-io.h"
#include <process.h>
#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))
......
......@@ -26,18 +26,6 @@
#include <langinfo.h>
#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 <gobject/gvaluecollector.h>
......@@ -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 *gimp,
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);
......
......@@ -20,18 +20,6 @@
#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>
......@@ -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 *procedure,
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);
......
......@@ -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);
......
......@@ -18,24 +18,16 @@
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <gtk/gtk.h>
#ifdef G_OS_WIN32
#include <process.h> /* 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 (GtkSelectionData *selection,
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 (GtkSelectionData *selection,
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 (GtkSelectionData *selection,
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 (GtkSelectionData *selection,
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 (GtkSelectionData *selection,
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 (GtkSelectionData *selection,
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 (GtkSelectionData *selection,
{
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 (GtkSelectionData *selection,
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;
......
......@@ -681,23 +681,9 @@ GPL
}
$x cmp $y;
} keys %{$out->{headers}};
my $headers = ""; my $lib = 0; my $seen = 0; my $nl = 0;
my $sys = 0; my $base = 0;
my $headers = "";
my $lib = 0; my $seen = 0; my $sys = 0; my $base = 0;
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 /^</;
if ($sys == 0 && !/^</) {
......@@ -731,20 +717,6 @@ GPL
}
$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";
......
......@@ -56,10 +56,10 @@ HELP
);
%invoke = (
headers => [ qw(<sys/types.h> <unistd.h> <process.h>) ],
headers => [ qw("base/base-utils.h") ],
code => <<'CODE'
{
pid = getpid ();
pid = get_pid ();
}
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