diff --git a/ChangeLog b/ChangeLog index cc6ca6ce84..f1abcd4e56 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2007-11-01 Tor Lillqvist + + * app/base/base-utils.c + * app/base/base-utils.h: New files, with just one function so far, + get_number_of_processors(). Include implementation also for Win32. + + * app/base/Makefile.am (libappbase_a_SOURCES): Add new files. + + * app/config/gimpbaseconfig.c (gimp_base_config_class_init): Use + get_number_of_processors(). + 2007-11-01 Manish Singh * app/core/gimpcontainer-filter.c diff --git a/app/base/Makefile.am b/app/base/Makefile.am index 224f588129..ffd5a2512f 100644 --- a/app/base/Makefile.am +++ b/app/base/Makefile.am @@ -8,6 +8,8 @@ libappbase_a_SOURCES = \ base-enums.c \ base-enums.h \ base-types.h \ + base-utils.c \ + base-utils.h \ boundary.c \ boundary.h \ color-balance.c \ diff --git a/app/base/base-utils.c b/app/base/base-utils.c new file mode 100644 index 0000000000..f9d05ae4f7 --- /dev/null +++ b/app/base/base-utils.c @@ -0,0 +1,56 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "config.h" + +#ifdef HAVE_UNISTD_H +#include +#endif + +#include + +#ifdef G_OS_WIN32 +#include +#endif + +#include "base-utils.h" + +#define NUM_PROCESSORS_DEFAULT 1 + +/* public functions */ + +gint +get_number_of_processors (void) +{ + gint retval = NUM_PROCESSORS_DEFAULT; + +#ifdef G_OS_UNIX +#if defined(HAVE_UNISTD_H) && defined(_SC_NPROCESSORS_ONLN) + retval = sysconf (_SC_NPROCESSORS_ONLN); +#endif +#endif +#ifdef G_OS_WIN32 + SYSTEM_INFO system_info; + + GetSystemInfo (&system_info); + + retval = system_info.dwNumberOfProcessors; +#endif + + return retval; +} diff --git a/app/base/base-utils.h b/app/base/base-utils.h new file mode 100644 index 0000000000..cd57fb2c64 --- /dev/null +++ b/app/base/base-utils.h @@ -0,0 +1,24 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __BASE_H__ +#define __BASE_H__ + +gint get_number_of_processors (void); + +#endif /* __BASE_H__ */ diff --git a/app/config/gimpbaseconfig.c b/app/config/gimpbaseconfig.c index 53fa347aa0..d8cc4bc00e 100644 --- a/app/config/gimpbaseconfig.c +++ b/app/config/gimpbaseconfig.c @@ -32,6 +32,7 @@ #include "config-types.h" +#include "base/base-utils.h" #include "base/pixel-processor.h" #include "gimprc-blurbs.h" @@ -39,8 +40,6 @@ #include "gimp-intl.h" -#define NUM_PROCESSORS_DEFAULT 1 - enum { @@ -94,11 +93,7 @@ gimp_base_config_class_init (GimpBaseConfigClass *klass) GIMP_PARAM_STATIC_STRINGS | GIMP_CONFIG_PARAM_RESTART); -#if defined(HAVE_UNISTD_H) && defined(_SC_NPROCESSORS_ONLN) - num_processors = sysconf (_SC_NPROCESSORS_ONLN); -#else - num_processors = NUM_PROCESSORS_DEFAULT; -#endif + num_processors = get_number_of_processors (); #ifdef GIMP_UNSTABLE num_processors = num_processors * 2;