Commit 7b320c7b authored by Michael Natterer's avatar Michael Natterer 😴

Get rid of DOS line endings

parent 223ae53f
/* GIMP - The GNU Image Manipulation Program /* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis * Copyright (C) 1995 Spencer Kimball and Peter Mattis
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "config.h" #include "config.h"
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
#include <glib.h> #include <glib.h>
#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> #include <process.h>
#endif #endif
#ifdef G_OS_UNIX #ifdef G_OS_UNIX
/* For get_backtrace() */ /* For get_backtrace() */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <execinfo.h> #include <execinfo.h>
#endif #endif
#include "base-utils.h" #include "base-utils.h"
#define NUM_PROCESSORS_DEFAULT 1 #define NUM_PROCESSORS_DEFAULT 1
#define MAX_FUNC 100 #define MAX_FUNC 100
/* public functions */ /* public functions */
gint gint
get_pid (void) get_pid (void)
{ {
return (gint) getpid (); return (gint) getpid ();
} }
gint gint
get_number_of_processors (void) get_number_of_processors (void)
{ {
gint retval = NUM_PROCESSORS_DEFAULT; gint retval = NUM_PROCESSORS_DEFAULT;
#ifdef G_OS_UNIX #ifdef G_OS_UNIX
#if defined(HAVE_UNISTD_H) && defined(_SC_NPROCESSORS_ONLN) #if defined(HAVE_UNISTD_H) && defined(_SC_NPROCESSORS_ONLN)
retval = sysconf (_SC_NPROCESSORS_ONLN); retval = sysconf (_SC_NPROCESSORS_ONLN);
#endif #endif
#endif #endif
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
SYSTEM_INFO system_info; SYSTEM_INFO system_info;
GetSystemInfo (&system_info); GetSystemInfo (&system_info);
retval = system_info.dwNumberOfProcessors; retval = system_info.dwNumberOfProcessors;
#endif #endif
return retval; return retval;
} }
guint64 guint64
get_physical_memory_size (void) get_physical_memory_size (void)
{ {
#ifdef G_OS_UNIX #ifdef G_OS_UNIX
#if defined(HAVE_UNISTD_H) && defined(_SC_PHYS_PAGES) && defined (_SC_PAGE_SIZE) #if defined(HAVE_UNISTD_H) && defined(_SC_PHYS_PAGES) && defined (_SC_PAGE_SIZE)
return (guint64) sysconf (_SC_PHYS_PAGES) * sysconf (_SC_PAGE_SIZE); return (guint64) sysconf (_SC_PHYS_PAGES) * sysconf (_SC_PAGE_SIZE);
#endif #endif
#endif #endif
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
# if defined(_MSC_VER) && (_MSC_VER <= 1200) # if defined(_MSC_VER) && (_MSC_VER <= 1200)
MEMORYSTATUS memory_status; MEMORYSTATUS memory_status;
memory_status.dwLength = sizeof (memory_status); memory_status.dwLength = sizeof (memory_status);
GlobalMemoryStatus (&memory_status); GlobalMemoryStatus (&memory_status);
return memory_status.dwTotalPhys; return memory_status.dwTotalPhys;
# else # else
/* requires w2k and newer SDK than provided with msvc6 */ /* requires w2k and newer SDK than provided with msvc6 */
MEMORYSTATUSEX memory_status; MEMORYSTATUSEX memory_status;
memory_status.dwLength = sizeof (memory_status); memory_status.dwLength = sizeof (memory_status);
if (GlobalMemoryStatusEx (&memory_status)) if (GlobalMemoryStatusEx (&memory_status))
return memory_status.ullTotalPhys; return memory_status.ullTotalPhys;
# endif # endif
#endif #endif
return 0; return 0;
} }
/** /**
* get_backtrace: * get_backtrace:
* *
* Returns: The current stack trace. Free with g_free(). Mainly meant * Returns: The current stack trace. Free with g_free(). Mainly meant
* for debugging, for example storing the allocation stack traces for * for debugging, for example storing the allocation stack traces for
* objects to hunt down leaks. * objects to hunt down leaks.
**/ **/
char * char *
get_backtrace (void) get_backtrace (void)
{ {
#ifdef G_OS_UNIX #ifdef G_OS_UNIX
void *functions[MAX_FUNC]; void *functions[MAX_FUNC];
char **function_names; char **function_names;
int n_functions; int n_functions;
int i; int i;
GString *result; GString *result;
/* Get symbols */ /* Get symbols */
n_functions = backtrace (functions, MAX_FUNC); n_functions = backtrace (functions, MAX_FUNC);
function_names = backtrace_symbols (functions, n_functions); function_names = backtrace_symbols (functions, n_functions);
/* Construct stack trace */ /* Construct stack trace */
result = g_string_new (""); result = g_string_new ("");
for (i = 0; i < n_functions; i++) for (i = 0; i < n_functions; i++)
g_string_append_printf (result, "%s\n", function_names[i]); g_string_append_printf (result, "%s\n", function_names[i]);
/* We must not free the function names themselves, we only need to /* We must not free the function names themselves, we only need to
* free the array that points to them * free the array that points to them
*/ */
free (function_names); free (function_names);
return g_string_free (result, FALSE/*free_segment*/); return g_string_free (result, FALSE/*free_segment*/);
#else #else
return g_strdup ("backtrace() only available with GNU libc\n"); return g_strdup ("backtrace() only available with GNU libc\n");
#endif #endif
} }
/* GIMP - The GNU Image Manipulation Program /* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis * Copyright (C) 1995 Spencer Kimball and Peter Mattis
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef __BASE_H__ #ifndef __BASE_H__
#define __BASE_H__ #define __BASE_H__
gint get_pid (void); gint 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);
char * get_backtrace (void); char * get_backtrace (void);
#endif /* __BASE_H__ */ #endif /* __BASE_H__ */
/Makefile /Makefile
/Makefile.in /Makefile.in
\ No newline at end of file
SUBDIRS = \ SUBDIRS = \
windows windows
\ No newline at end of file
# Version resources for Microsoft Windows # Version resources for Microsoft Windows
SUFFIXES = .rc .rc.o SUFFIXES = .rc .rc.o
.rc.rc.o: $(top_srcdir)/build/windows/gimp.rc .rc.rc.o: $(top_srcdir)/build/windows/gimp.rc
$(WINDRES) --define ORIGINALFILENAME_STR="$*$(EXEEXT)" \ $(WINDRES) --define ORIGINALFILENAME_STR="$*$(EXEEXT)" \
--define INTERNALNAME_STR="$*" \ --define INTERNALNAME_STR="$*" \
--define TOP_SRCDIR="$(top_srcdir)" \ --define TOP_SRCDIR="$(top_srcdir)" \
-I$(top_srcdir)/app \ -I$(top_srcdir)/app \
$< $@ $< $@
This diff is collapsed.
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