1998-06-10 23:21:14 +00:00
|
|
|
/* GLIB - Library of useful routines for C programming
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 11:02:02 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1998-06-10 23:21:14 +00:00
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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
|
2000-07-26 11:02:02 +00:00
|
|
|
* Lesser General Public License for more details.
|
1998-06-10 23:21:14 +00:00
|
|
|
*
|
2000-07-26 11:02:02 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
1998-06-10 23:21:14 +00:00
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
1998-11-01 04:19:54 +00:00
|
|
|
|
1999-02-24 06:14:27 +00:00
|
|
|
/*
|
2000-07-26 11:02:02 +00:00
|
|
|
* Modified by the GLib Team and others 1997-2000. See the AUTHORS
|
1999-02-24 06:14:27 +00:00
|
|
|
* file for a list of people on the GLib Team. See the ChangeLog
|
|
|
|
* files for a list of changes. These files are distributed with
|
|
|
|
* GLib at ftp://ftp.gtk.org/pub/gtk/.
|
|
|
|
*/
|
|
|
|
|
1998-12-15 05:28:02 +00:00
|
|
|
/*
|
|
|
|
* MT safe
|
|
|
|
*/
|
|
|
|
|
2002-12-04 01:27:44 +00:00
|
|
|
#include "config.h"
|
2002-12-05 20:33:26 +00:00
|
|
|
#include "glibconfig.h"
|
1998-11-01 04:19:54 +00:00
|
|
|
|
2006-03-23 02:54:29 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
removed dummy structure definitions for struct _GCache, _GTree, _GTimer,
Tue Oct 27 03:00:50 1998 Tim Janik <timj@gtk.org>
* glib.h: removed dummy structure definitions for struct _GCache,
_GTree, _GTimer, _GMemChunk, _GListAllocator and _GStringChunk.
* gutils.c: implement glib's inline functions _after_ all include
statements have been processed.
removed Tor's MAXPATHLEN check since there already was one supplied
further down in this file.
(LibMain): special cased the #ifdef __LCC__ case for NATIVE_WIN32,
since lcc maybe used on other platforms as well. why in hell is this
stuff required?
(g_get_any_init): for windows, if the user name is supplied, use it as
realname also.
in general, if there is no homedir specified, use the tmpdir that
we already figured.
* gtimer.c (g_timer_elapsed): changed a g_assert() statement to
g_return_if_fail().
* applied glib-tml-981020-0.patch for WIN32 portability, added some
comments and g_return_if_fail() statements, minor indentation fixes.
ChangeLog entry from Tor Lillqvist is appended.
* glib.h (struct dirent): use lower case structure members.
* glib.h:
* makefile.lcc:
* makefile.msc:
s/COMPILING_GLIB/GLIB_COMPILATION/
1998-10-20: Tor Lillqvist <tml@iki.fi>
* README.win32 glib.def gmodule.def
* glibconfig.h.win32 gmodule/gmoduleconf.h.win32:
New files for the Windows port. The .def files list exported
symbols for the Microsoft linker and compatibles.
* configure.in:
Added checks for some platform-dependent headers: pwd.h sys/param.h
sys/select.h sys/time.h sys/times.h unistd.h, and the function lstat.
* gerror.c:
Conditionalized inclusion of system-dependent headers. Changes
for Windows: no gdb to do a stack trace. Just call abort().
* glib.h:
Changes for Windows:
Added macros G_DIR_SEPARATOR, G_DIR_SEPARATOR_S for
platform-dependent file name syntax elements. Added macros
G_SEARCHPATH_SEPARATOR, G_SEARCHPATH_SEPARATOR_S for
platform-dependent search path syntax conventions.
Added pragmas for Microsoft C to make it more pedantic.
Marked GLib's global variables for export from DLL.
Added the function g_strescape that escapes backslashes.
Added functions g_path_is_absolute and g_path_skip_root to
handle platform-dependent file name syntax.
Added the function g_getenv that expands environment variables
that contain references to other environment variables, as is
typical on Windows NT.
Added the GIOChannel structure which is used to encapsulate the
IPC mechanism used by the GIMP's plug-ins, and possibly other
things later. On Unix a GIOChannel encapsulates just a file
descriptor. On Windows it contains a file handle from _pipe() and a
few other things related to the implementation of gdk_input_add
and GIMP plug-in communication. Subject to change.
Removed duplicate declarations of the version variables.
For the Microsoft compiler, declare own implementation of
ftruncate and the <dirent.h> functions.
* gmem.c:
Define a symbolic name for the profiling table size.
* gmessages.c:
Conditionalized inclusion of unistd.h. On Windows, output using
stdio to stdout.
* gscanner.c:
Conditionalized inclusion of unistd.h. Added changes for
Microsoft C. Added CR to the skipped character set. Added small
workaround for MSC compiler bug in g_scanner_cur_value.
* gstrfuncs.c:
Added the function g_strescape, which escapes the backslash
character. Needed especially when printing Windows filenames.
* gtimer.c:
Conditionalized inclusion of unistd.h and sys/time.h. Added
implementations for Windows.
* gutils.c:
Conditionalized inclusion of platform-dependent headers. Use
the platform-independent file name syntax macros.
Conditionalize code on platform-dependent features. Added the
functions g_path_is_absolute g_path_skip_root and g_getenv.
Added the GIOChannel-related functions. Added
compiler-dependent Unix compatibility functions for Windows.
* makefile.lcc makefile.msc:
New files. Compiler-specific makefiles for LCC-Win32 and
Microsoft C. Only Microsoft C is actually supported currently.
* testglib.c:
Added pathname check cases for Windows. Added workaround for
bug in the Microsoft runtime library. Improved some tests a bit.
Tue Oct 27 04:00:11 1998 Tim Janik <timj@gtk.org>
* testgmodule.c (main): changed the #ifdef WIN32 test to NATIVE_WIN32,
this needs to be more constistent throughout the code, do we go for
NATIVE_WIN32 or WIN32?
* gmodule.c (LibMain): special cased the #ifdef __LCC__ case for
NATIVE_WIN32, since lcc maybe used on other platforms as well.
* libgplugin_a.c (LibMain):
* libgplugin_b.c (LibMain):
likewise. not sure i like this special requirement for lcc in here.
* gmodule-dl.c (_g_module_build_path):
feature empty "" directories and prepend the module name with "lib".
* gmodule-dld.c (_g_module_build_path):
* gmodule-win32.c (_g_module_build_path):
feature empty "" directories.
* we need some more magic in the _g_module_build_path variants
so we don't append/prepend lib and .so, .sl or .dll for those names
that already contain it.
* applied patch from Tor Lillqvist for g_module_build_path() and
windows support.
1998-10-20: Tor Lillqvist <tml@iki.fi>
* gmodule/gmodule-win32.c:
New file.
* gmodule/gmodule.c gmodule/gmodule.h:
Added the funcion g_module_build_path that builds the path to
a module file, decorating the name according to the system's
conventions. Added the Windows implementation.
* gmodule/libgplugin_a.c gmodule/libgplugin_b.c:
Added LibMain for LCC-Win32.
* gmodule/testgmodule.c:
Handle Windows dll names.
1998-10-27 04:11:34 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif /* HAVE_UNISTD_H */
|
2002-12-05 20:33:26 +00:00
|
|
|
|
1999-10-04 02:32:50 +00:00
|
|
|
#ifndef G_OS_WIN32
|
removed dummy structure definitions for struct _GCache, _GTree, _GTimer,
Tue Oct 27 03:00:50 1998 Tim Janik <timj@gtk.org>
* glib.h: removed dummy structure definitions for struct _GCache,
_GTree, _GTimer, _GMemChunk, _GListAllocator and _GStringChunk.
* gutils.c: implement glib's inline functions _after_ all include
statements have been processed.
removed Tor's MAXPATHLEN check since there already was one supplied
further down in this file.
(LibMain): special cased the #ifdef __LCC__ case for NATIVE_WIN32,
since lcc maybe used on other platforms as well. why in hell is this
stuff required?
(g_get_any_init): for windows, if the user name is supplied, use it as
realname also.
in general, if there is no homedir specified, use the tmpdir that
we already figured.
* gtimer.c (g_timer_elapsed): changed a g_assert() statement to
g_return_if_fail().
* applied glib-tml-981020-0.patch for WIN32 portability, added some
comments and g_return_if_fail() statements, minor indentation fixes.
ChangeLog entry from Tor Lillqvist is appended.
* glib.h (struct dirent): use lower case structure members.
* glib.h:
* makefile.lcc:
* makefile.msc:
s/COMPILING_GLIB/GLIB_COMPILATION/
1998-10-20: Tor Lillqvist <tml@iki.fi>
* README.win32 glib.def gmodule.def
* glibconfig.h.win32 gmodule/gmoduleconf.h.win32:
New files for the Windows port. The .def files list exported
symbols for the Microsoft linker and compatibles.
* configure.in:
Added checks for some platform-dependent headers: pwd.h sys/param.h
sys/select.h sys/time.h sys/times.h unistd.h, and the function lstat.
* gerror.c:
Conditionalized inclusion of system-dependent headers. Changes
for Windows: no gdb to do a stack trace. Just call abort().
* glib.h:
Changes for Windows:
Added macros G_DIR_SEPARATOR, G_DIR_SEPARATOR_S for
platform-dependent file name syntax elements. Added macros
G_SEARCHPATH_SEPARATOR, G_SEARCHPATH_SEPARATOR_S for
platform-dependent search path syntax conventions.
Added pragmas for Microsoft C to make it more pedantic.
Marked GLib's global variables for export from DLL.
Added the function g_strescape that escapes backslashes.
Added functions g_path_is_absolute and g_path_skip_root to
handle platform-dependent file name syntax.
Added the function g_getenv that expands environment variables
that contain references to other environment variables, as is
typical on Windows NT.
Added the GIOChannel structure which is used to encapsulate the
IPC mechanism used by the GIMP's plug-ins, and possibly other
things later. On Unix a GIOChannel encapsulates just a file
descriptor. On Windows it contains a file handle from _pipe() and a
few other things related to the implementation of gdk_input_add
and GIMP plug-in communication. Subject to change.
Removed duplicate declarations of the version variables.
For the Microsoft compiler, declare own implementation of
ftruncate and the <dirent.h> functions.
* gmem.c:
Define a symbolic name for the profiling table size.
* gmessages.c:
Conditionalized inclusion of unistd.h. On Windows, output using
stdio to stdout.
* gscanner.c:
Conditionalized inclusion of unistd.h. Added changes for
Microsoft C. Added CR to the skipped character set. Added small
workaround for MSC compiler bug in g_scanner_cur_value.
* gstrfuncs.c:
Added the function g_strescape, which escapes the backslash
character. Needed especially when printing Windows filenames.
* gtimer.c:
Conditionalized inclusion of unistd.h and sys/time.h. Added
implementations for Windows.
* gutils.c:
Conditionalized inclusion of platform-dependent headers. Use
the platform-independent file name syntax macros.
Conditionalize code on platform-dependent features. Added the
functions g_path_is_absolute g_path_skip_root and g_getenv.
Added the GIOChannel-related functions. Added
compiler-dependent Unix compatibility functions for Windows.
* makefile.lcc makefile.msc:
New files. Compiler-specific makefiles for LCC-Win32 and
Microsoft C. Only Microsoft C is actually supported currently.
* testglib.c:
Added pathname check cases for Windows. Added workaround for
bug in the Microsoft runtime library. Improved some tests a bit.
Tue Oct 27 04:00:11 1998 Tim Janik <timj@gtk.org>
* testgmodule.c (main): changed the #ifdef WIN32 test to NATIVE_WIN32,
this needs to be more constistent throughout the code, do we go for
NATIVE_WIN32 or WIN32?
* gmodule.c (LibMain): special cased the #ifdef __LCC__ case for
NATIVE_WIN32, since lcc maybe used on other platforms as well.
* libgplugin_a.c (LibMain):
* libgplugin_b.c (LibMain):
likewise. not sure i like this special requirement for lcc in here.
* gmodule-dl.c (_g_module_build_path):
feature empty "" directories and prepend the module name with "lib".
* gmodule-dld.c (_g_module_build_path):
* gmodule-win32.c (_g_module_build_path):
feature empty "" directories.
* we need some more magic in the _g_module_build_path variants
so we don't append/prepend lib and .so, .sl or .dll for those names
that already contain it.
* applied patch from Tor Lillqvist for g_module_build_path() and
windows support.
1998-10-20: Tor Lillqvist <tml@iki.fi>
* gmodule/gmodule-win32.c:
New file.
* gmodule/gmodule.c gmodule/gmodule.h:
Added the funcion g_module_build_path that builds the path to
a module file, decorating the name according to the system's
conventions. Added the Windows implementation.
* gmodule/libgplugin_a.c gmodule/libgplugin_b.c:
Added LibMain for LCC-Win32.
* gmodule/testgmodule.c:
Handle Windows dll names.
1998-10-27 04:11:34 +00:00
|
|
|
#include <sys/time.h>
|
2001-06-07 13:46:14 +00:00
|
|
|
#include <time.h>
|
|
|
|
#include <errno.h>
|
1999-10-04 02:32:50 +00:00
|
|
|
#endif /* G_OS_WIN32 */
|
1998-06-10 23:21:14 +00:00
|
|
|
|
1999-10-04 02:32:50 +00:00
|
|
|
#ifdef G_OS_WIN32
|
removed dummy structure definitions for struct _GCache, _GTree, _GTimer,
Tue Oct 27 03:00:50 1998 Tim Janik <timj@gtk.org>
* glib.h: removed dummy structure definitions for struct _GCache,
_GTree, _GTimer, _GMemChunk, _GListAllocator and _GStringChunk.
* gutils.c: implement glib's inline functions _after_ all include
statements have been processed.
removed Tor's MAXPATHLEN check since there already was one supplied
further down in this file.
(LibMain): special cased the #ifdef __LCC__ case for NATIVE_WIN32,
since lcc maybe used on other platforms as well. why in hell is this
stuff required?
(g_get_any_init): for windows, if the user name is supplied, use it as
realname also.
in general, if there is no homedir specified, use the tmpdir that
we already figured.
* gtimer.c (g_timer_elapsed): changed a g_assert() statement to
g_return_if_fail().
* applied glib-tml-981020-0.patch for WIN32 portability, added some
comments and g_return_if_fail() statements, minor indentation fixes.
ChangeLog entry from Tor Lillqvist is appended.
* glib.h (struct dirent): use lower case structure members.
* glib.h:
* makefile.lcc:
* makefile.msc:
s/COMPILING_GLIB/GLIB_COMPILATION/
1998-10-20: Tor Lillqvist <tml@iki.fi>
* README.win32 glib.def gmodule.def
* glibconfig.h.win32 gmodule/gmoduleconf.h.win32:
New files for the Windows port. The .def files list exported
symbols for the Microsoft linker and compatibles.
* configure.in:
Added checks for some platform-dependent headers: pwd.h sys/param.h
sys/select.h sys/time.h sys/times.h unistd.h, and the function lstat.
* gerror.c:
Conditionalized inclusion of system-dependent headers. Changes
for Windows: no gdb to do a stack trace. Just call abort().
* glib.h:
Changes for Windows:
Added macros G_DIR_SEPARATOR, G_DIR_SEPARATOR_S for
platform-dependent file name syntax elements. Added macros
G_SEARCHPATH_SEPARATOR, G_SEARCHPATH_SEPARATOR_S for
platform-dependent search path syntax conventions.
Added pragmas for Microsoft C to make it more pedantic.
Marked GLib's global variables for export from DLL.
Added the function g_strescape that escapes backslashes.
Added functions g_path_is_absolute and g_path_skip_root to
handle platform-dependent file name syntax.
Added the function g_getenv that expands environment variables
that contain references to other environment variables, as is
typical on Windows NT.
Added the GIOChannel structure which is used to encapsulate the
IPC mechanism used by the GIMP's plug-ins, and possibly other
things later. On Unix a GIOChannel encapsulates just a file
descriptor. On Windows it contains a file handle from _pipe() and a
few other things related to the implementation of gdk_input_add
and GIMP plug-in communication. Subject to change.
Removed duplicate declarations of the version variables.
For the Microsoft compiler, declare own implementation of
ftruncate and the <dirent.h> functions.
* gmem.c:
Define a symbolic name for the profiling table size.
* gmessages.c:
Conditionalized inclusion of unistd.h. On Windows, output using
stdio to stdout.
* gscanner.c:
Conditionalized inclusion of unistd.h. Added changes for
Microsoft C. Added CR to the skipped character set. Added small
workaround for MSC compiler bug in g_scanner_cur_value.
* gstrfuncs.c:
Added the function g_strescape, which escapes the backslash
character. Needed especially when printing Windows filenames.
* gtimer.c:
Conditionalized inclusion of unistd.h and sys/time.h. Added
implementations for Windows.
* gutils.c:
Conditionalized inclusion of platform-dependent headers. Use
the platform-independent file name syntax macros.
Conditionalize code on platform-dependent features. Added the
functions g_path_is_absolute g_path_skip_root and g_getenv.
Added the GIOChannel-related functions. Added
compiler-dependent Unix compatibility functions for Windows.
* makefile.lcc makefile.msc:
New files. Compiler-specific makefiles for LCC-Win32 and
Microsoft C. Only Microsoft C is actually supported currently.
* testglib.c:
Added pathname check cases for Windows. Added workaround for
bug in the Microsoft runtime library. Improved some tests a bit.
Tue Oct 27 04:00:11 1998 Tim Janik <timj@gtk.org>
* testgmodule.c (main): changed the #ifdef WIN32 test to NATIVE_WIN32,
this needs to be more constistent throughout the code, do we go for
NATIVE_WIN32 or WIN32?
* gmodule.c (LibMain): special cased the #ifdef __LCC__ case for
NATIVE_WIN32, since lcc maybe used on other platforms as well.
* libgplugin_a.c (LibMain):
* libgplugin_b.c (LibMain):
likewise. not sure i like this special requirement for lcc in here.
* gmodule-dl.c (_g_module_build_path):
feature empty "" directories and prepend the module name with "lib".
* gmodule-dld.c (_g_module_build_path):
* gmodule-win32.c (_g_module_build_path):
feature empty "" directories.
* we need some more magic in the _g_module_build_path variants
so we don't append/prepend lib and .so, .sl or .dll for those names
that already contain it.
* applied patch from Tor Lillqvist for g_module_build_path() and
windows support.
1998-10-20: Tor Lillqvist <tml@iki.fi>
* gmodule/gmodule-win32.c:
New file.
* gmodule/gmodule.c gmodule/gmodule.h:
Added the funcion g_module_build_path that builds the path to
a module file, decorating the name according to the system's
conventions. Added the Windows implementation.
* gmodule/libgplugin_a.c gmodule/libgplugin_b.c:
Added LibMain for LCC-Win32.
* gmodule/testgmodule.c:
Handle Windows dll names.
1998-10-27 04:11:34 +00:00
|
|
|
#include <windows.h>
|
1999-10-04 02:32:50 +00:00
|
|
|
#endif /* G_OS_WIN32 */
|
1998-06-10 23:21:14 +00:00
|
|
|
|
2002-12-04 01:27:44 +00:00
|
|
|
#include "glib.h"
|
2005-03-14 04:26:57 +00:00
|
|
|
#include "galias.h"
|
2002-12-04 01:27:44 +00:00
|
|
|
|
|
|
|
|
2001-09-19 18:08:19 +00:00
|
|
|
struct _GTimer
|
1998-06-10 23:21:14 +00:00
|
|
|
{
|
1999-10-04 02:32:50 +00:00
|
|
|
#ifdef G_OS_WIN32
|
2005-03-20 11:35:48 +00:00
|
|
|
guint64 start;
|
|
|
|
guint64 end;
|
1999-10-04 02:32:50 +00:00
|
|
|
#else /* !G_OS_WIN32 */
|
1998-06-10 23:21:14 +00:00
|
|
|
struct timeval start;
|
|
|
|
struct timeval end;
|
1999-10-04 02:32:50 +00:00
|
|
|
#endif /* !G_OS_WIN32 */
|
1998-06-10 23:21:14 +00:00
|
|
|
|
removed dummy structure definitions for struct _GCache, _GTree, _GTimer,
Tue Oct 27 03:00:50 1998 Tim Janik <timj@gtk.org>
* glib.h: removed dummy structure definitions for struct _GCache,
_GTree, _GTimer, _GMemChunk, _GListAllocator and _GStringChunk.
* gutils.c: implement glib's inline functions _after_ all include
statements have been processed.
removed Tor's MAXPATHLEN check since there already was one supplied
further down in this file.
(LibMain): special cased the #ifdef __LCC__ case for NATIVE_WIN32,
since lcc maybe used on other platforms as well. why in hell is this
stuff required?
(g_get_any_init): for windows, if the user name is supplied, use it as
realname also.
in general, if there is no homedir specified, use the tmpdir that
we already figured.
* gtimer.c (g_timer_elapsed): changed a g_assert() statement to
g_return_if_fail().
* applied glib-tml-981020-0.patch for WIN32 portability, added some
comments and g_return_if_fail() statements, minor indentation fixes.
ChangeLog entry from Tor Lillqvist is appended.
* glib.h (struct dirent): use lower case structure members.
* glib.h:
* makefile.lcc:
* makefile.msc:
s/COMPILING_GLIB/GLIB_COMPILATION/
1998-10-20: Tor Lillqvist <tml@iki.fi>
* README.win32 glib.def gmodule.def
* glibconfig.h.win32 gmodule/gmoduleconf.h.win32:
New files for the Windows port. The .def files list exported
symbols for the Microsoft linker and compatibles.
* configure.in:
Added checks for some platform-dependent headers: pwd.h sys/param.h
sys/select.h sys/time.h sys/times.h unistd.h, and the function lstat.
* gerror.c:
Conditionalized inclusion of system-dependent headers. Changes
for Windows: no gdb to do a stack trace. Just call abort().
* glib.h:
Changes for Windows:
Added macros G_DIR_SEPARATOR, G_DIR_SEPARATOR_S for
platform-dependent file name syntax elements. Added macros
G_SEARCHPATH_SEPARATOR, G_SEARCHPATH_SEPARATOR_S for
platform-dependent search path syntax conventions.
Added pragmas for Microsoft C to make it more pedantic.
Marked GLib's global variables for export from DLL.
Added the function g_strescape that escapes backslashes.
Added functions g_path_is_absolute and g_path_skip_root to
handle platform-dependent file name syntax.
Added the function g_getenv that expands environment variables
that contain references to other environment variables, as is
typical on Windows NT.
Added the GIOChannel structure which is used to encapsulate the
IPC mechanism used by the GIMP's plug-ins, and possibly other
things later. On Unix a GIOChannel encapsulates just a file
descriptor. On Windows it contains a file handle from _pipe() and a
few other things related to the implementation of gdk_input_add
and GIMP plug-in communication. Subject to change.
Removed duplicate declarations of the version variables.
For the Microsoft compiler, declare own implementation of
ftruncate and the <dirent.h> functions.
* gmem.c:
Define a symbolic name for the profiling table size.
* gmessages.c:
Conditionalized inclusion of unistd.h. On Windows, output using
stdio to stdout.
* gscanner.c:
Conditionalized inclusion of unistd.h. Added changes for
Microsoft C. Added CR to the skipped character set. Added small
workaround for MSC compiler bug in g_scanner_cur_value.
* gstrfuncs.c:
Added the function g_strescape, which escapes the backslash
character. Needed especially when printing Windows filenames.
* gtimer.c:
Conditionalized inclusion of unistd.h and sys/time.h. Added
implementations for Windows.
* gutils.c:
Conditionalized inclusion of platform-dependent headers. Use
the platform-independent file name syntax macros.
Conditionalize code on platform-dependent features. Added the
functions g_path_is_absolute g_path_skip_root and g_getenv.
Added the GIOChannel-related functions. Added
compiler-dependent Unix compatibility functions for Windows.
* makefile.lcc makefile.msc:
New files. Compiler-specific makefiles for LCC-Win32 and
Microsoft C. Only Microsoft C is actually supported currently.
* testglib.c:
Added pathname check cases for Windows. Added workaround for
bug in the Microsoft runtime library. Improved some tests a bit.
Tue Oct 27 04:00:11 1998 Tim Janik <timj@gtk.org>
* testgmodule.c (main): changed the #ifdef WIN32 test to NATIVE_WIN32,
this needs to be more constistent throughout the code, do we go for
NATIVE_WIN32 or WIN32?
* gmodule.c (LibMain): special cased the #ifdef __LCC__ case for
NATIVE_WIN32, since lcc maybe used on other platforms as well.
* libgplugin_a.c (LibMain):
* libgplugin_b.c (LibMain):
likewise. not sure i like this special requirement for lcc in here.
* gmodule-dl.c (_g_module_build_path):
feature empty "" directories and prepend the module name with "lib".
* gmodule-dld.c (_g_module_build_path):
* gmodule-win32.c (_g_module_build_path):
feature empty "" directories.
* we need some more magic in the _g_module_build_path variants
so we don't append/prepend lib and .so, .sl or .dll for those names
that already contain it.
* applied patch from Tor Lillqvist for g_module_build_path() and
windows support.
1998-10-20: Tor Lillqvist <tml@iki.fi>
* gmodule/gmodule-win32.c:
New file.
* gmodule/gmodule.c gmodule/gmodule.h:
Added the funcion g_module_build_path that builds the path to
a module file, decorating the name according to the system's
conventions. Added the Windows implementation.
* gmodule/libgplugin_a.c gmodule/libgplugin_b.c:
Added LibMain for LCC-Win32.
* gmodule/testgmodule.c:
Handle Windows dll names.
1998-10-27 04:11:34 +00:00
|
|
|
guint active : 1;
|
|
|
|
};
|
1998-06-10 23:21:14 +00:00
|
|
|
|
2001-03-09 21:31:21 +00:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
# define GETTIME(v) \
|
2005-03-20 11:35:48 +00:00
|
|
|
GetSystemTimeAsFileTime ((FILETIME *)&v)
|
2001-03-09 21:31:21 +00:00
|
|
|
#else /* !G_OS_WIN32 */
|
|
|
|
# define GETTIME(v) \
|
|
|
|
gettimeofday (&v, NULL)
|
|
|
|
#endif /* !G_OS_WIN32 */
|
|
|
|
|
1998-06-10 23:21:14 +00:00
|
|
|
GTimer*
|
|
|
|
g_timer_new (void)
|
|
|
|
{
|
2001-09-19 18:08:19 +00:00
|
|
|
GTimer *timer;
|
1998-06-10 23:21:14 +00:00
|
|
|
|
2001-09-19 18:08:19 +00:00
|
|
|
timer = g_new (GTimer, 1);
|
1998-06-10 23:21:14 +00:00
|
|
|
timer->active = TRUE;
|
|
|
|
|
2001-03-09 21:31:21 +00:00
|
|
|
GETTIME (timer->start);
|
1998-06-10 23:21:14 +00:00
|
|
|
|
2001-09-19 18:08:19 +00:00
|
|
|
return timer;
|
1998-06-10 23:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
g_timer_destroy (GTimer *timer)
|
|
|
|
{
|
1999-03-17 01:05:49 +00:00
|
|
|
g_return_if_fail (timer != NULL);
|
1998-06-10 23:21:14 +00:00
|
|
|
|
|
|
|
g_free (timer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
g_timer_start (GTimer *timer)
|
|
|
|
{
|
1999-03-17 01:05:49 +00:00
|
|
|
g_return_if_fail (timer != NULL);
|
1998-06-10 23:21:14 +00:00
|
|
|
|
2001-09-19 18:08:19 +00:00
|
|
|
timer->active = TRUE;
|
removed dummy structure definitions for struct _GCache, _GTree, _GTimer,
Tue Oct 27 03:00:50 1998 Tim Janik <timj@gtk.org>
* glib.h: removed dummy structure definitions for struct _GCache,
_GTree, _GTimer, _GMemChunk, _GListAllocator and _GStringChunk.
* gutils.c: implement glib's inline functions _after_ all include
statements have been processed.
removed Tor's MAXPATHLEN check since there already was one supplied
further down in this file.
(LibMain): special cased the #ifdef __LCC__ case for NATIVE_WIN32,
since lcc maybe used on other platforms as well. why in hell is this
stuff required?
(g_get_any_init): for windows, if the user name is supplied, use it as
realname also.
in general, if there is no homedir specified, use the tmpdir that
we already figured.
* gtimer.c (g_timer_elapsed): changed a g_assert() statement to
g_return_if_fail().
* applied glib-tml-981020-0.patch for WIN32 portability, added some
comments and g_return_if_fail() statements, minor indentation fixes.
ChangeLog entry from Tor Lillqvist is appended.
* glib.h (struct dirent): use lower case structure members.
* glib.h:
* makefile.lcc:
* makefile.msc:
s/COMPILING_GLIB/GLIB_COMPILATION/
1998-10-20: Tor Lillqvist <tml@iki.fi>
* README.win32 glib.def gmodule.def
* glibconfig.h.win32 gmodule/gmoduleconf.h.win32:
New files for the Windows port. The .def files list exported
symbols for the Microsoft linker and compatibles.
* configure.in:
Added checks for some platform-dependent headers: pwd.h sys/param.h
sys/select.h sys/time.h sys/times.h unistd.h, and the function lstat.
* gerror.c:
Conditionalized inclusion of system-dependent headers. Changes
for Windows: no gdb to do a stack trace. Just call abort().
* glib.h:
Changes for Windows:
Added macros G_DIR_SEPARATOR, G_DIR_SEPARATOR_S for
platform-dependent file name syntax elements. Added macros
G_SEARCHPATH_SEPARATOR, G_SEARCHPATH_SEPARATOR_S for
platform-dependent search path syntax conventions.
Added pragmas for Microsoft C to make it more pedantic.
Marked GLib's global variables for export from DLL.
Added the function g_strescape that escapes backslashes.
Added functions g_path_is_absolute and g_path_skip_root to
handle platform-dependent file name syntax.
Added the function g_getenv that expands environment variables
that contain references to other environment variables, as is
typical on Windows NT.
Added the GIOChannel structure which is used to encapsulate the
IPC mechanism used by the GIMP's plug-ins, and possibly other
things later. On Unix a GIOChannel encapsulates just a file
descriptor. On Windows it contains a file handle from _pipe() and a
few other things related to the implementation of gdk_input_add
and GIMP plug-in communication. Subject to change.
Removed duplicate declarations of the version variables.
For the Microsoft compiler, declare own implementation of
ftruncate and the <dirent.h> functions.
* gmem.c:
Define a symbolic name for the profiling table size.
* gmessages.c:
Conditionalized inclusion of unistd.h. On Windows, output using
stdio to stdout.
* gscanner.c:
Conditionalized inclusion of unistd.h. Added changes for
Microsoft C. Added CR to the skipped character set. Added small
workaround for MSC compiler bug in g_scanner_cur_value.
* gstrfuncs.c:
Added the function g_strescape, which escapes the backslash
character. Needed especially when printing Windows filenames.
* gtimer.c:
Conditionalized inclusion of unistd.h and sys/time.h. Added
implementations for Windows.
* gutils.c:
Conditionalized inclusion of platform-dependent headers. Use
the platform-independent file name syntax macros.
Conditionalize code on platform-dependent features. Added the
functions g_path_is_absolute g_path_skip_root and g_getenv.
Added the GIOChannel-related functions. Added
compiler-dependent Unix compatibility functions for Windows.
* makefile.lcc makefile.msc:
New files. Compiler-specific makefiles for LCC-Win32 and
Microsoft C. Only Microsoft C is actually supported currently.
* testglib.c:
Added pathname check cases for Windows. Added workaround for
bug in the Microsoft runtime library. Improved some tests a bit.
Tue Oct 27 04:00:11 1998 Tim Janik <timj@gtk.org>
* testgmodule.c (main): changed the #ifdef WIN32 test to NATIVE_WIN32,
this needs to be more constistent throughout the code, do we go for
NATIVE_WIN32 or WIN32?
* gmodule.c (LibMain): special cased the #ifdef __LCC__ case for
NATIVE_WIN32, since lcc maybe used on other platforms as well.
* libgplugin_a.c (LibMain):
* libgplugin_b.c (LibMain):
likewise. not sure i like this special requirement for lcc in here.
* gmodule-dl.c (_g_module_build_path):
feature empty "" directories and prepend the module name with "lib".
* gmodule-dld.c (_g_module_build_path):
* gmodule-win32.c (_g_module_build_path):
feature empty "" directories.
* we need some more magic in the _g_module_build_path variants
so we don't append/prepend lib and .so, .sl or .dll for those names
that already contain it.
* applied patch from Tor Lillqvist for g_module_build_path() and
windows support.
1998-10-20: Tor Lillqvist <tml@iki.fi>
* gmodule/gmodule-win32.c:
New file.
* gmodule/gmodule.c gmodule/gmodule.h:
Added the funcion g_module_build_path that builds the path to
a module file, decorating the name according to the system's
conventions. Added the Windows implementation.
* gmodule/libgplugin_a.c gmodule/libgplugin_b.c:
Added LibMain for LCC-Win32.
* gmodule/testgmodule.c:
Handle Windows dll names.
1998-10-27 04:11:34 +00:00
|
|
|
|
2001-09-19 18:08:19 +00:00
|
|
|
GETTIME (timer->start);
|
1998-06-10 23:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
g_timer_stop (GTimer *timer)
|
|
|
|
{
|
1999-03-17 01:05:49 +00:00
|
|
|
g_return_if_fail (timer != NULL);
|
1998-06-10 23:21:14 +00:00
|
|
|
|
2001-09-19 18:08:19 +00:00
|
|
|
timer->active = FALSE;
|
removed dummy structure definitions for struct _GCache, _GTree, _GTimer,
Tue Oct 27 03:00:50 1998 Tim Janik <timj@gtk.org>
* glib.h: removed dummy structure definitions for struct _GCache,
_GTree, _GTimer, _GMemChunk, _GListAllocator and _GStringChunk.
* gutils.c: implement glib's inline functions _after_ all include
statements have been processed.
removed Tor's MAXPATHLEN check since there already was one supplied
further down in this file.
(LibMain): special cased the #ifdef __LCC__ case for NATIVE_WIN32,
since lcc maybe used on other platforms as well. why in hell is this
stuff required?
(g_get_any_init): for windows, if the user name is supplied, use it as
realname also.
in general, if there is no homedir specified, use the tmpdir that
we already figured.
* gtimer.c (g_timer_elapsed): changed a g_assert() statement to
g_return_if_fail().
* applied glib-tml-981020-0.patch for WIN32 portability, added some
comments and g_return_if_fail() statements, minor indentation fixes.
ChangeLog entry from Tor Lillqvist is appended.
* glib.h (struct dirent): use lower case structure members.
* glib.h:
* makefile.lcc:
* makefile.msc:
s/COMPILING_GLIB/GLIB_COMPILATION/
1998-10-20: Tor Lillqvist <tml@iki.fi>
* README.win32 glib.def gmodule.def
* glibconfig.h.win32 gmodule/gmoduleconf.h.win32:
New files for the Windows port. The .def files list exported
symbols for the Microsoft linker and compatibles.
* configure.in:
Added checks for some platform-dependent headers: pwd.h sys/param.h
sys/select.h sys/time.h sys/times.h unistd.h, and the function lstat.
* gerror.c:
Conditionalized inclusion of system-dependent headers. Changes
for Windows: no gdb to do a stack trace. Just call abort().
* glib.h:
Changes for Windows:
Added macros G_DIR_SEPARATOR, G_DIR_SEPARATOR_S for
platform-dependent file name syntax elements. Added macros
G_SEARCHPATH_SEPARATOR, G_SEARCHPATH_SEPARATOR_S for
platform-dependent search path syntax conventions.
Added pragmas for Microsoft C to make it more pedantic.
Marked GLib's global variables for export from DLL.
Added the function g_strescape that escapes backslashes.
Added functions g_path_is_absolute and g_path_skip_root to
handle platform-dependent file name syntax.
Added the function g_getenv that expands environment variables
that contain references to other environment variables, as is
typical on Windows NT.
Added the GIOChannel structure which is used to encapsulate the
IPC mechanism used by the GIMP's plug-ins, and possibly other
things later. On Unix a GIOChannel encapsulates just a file
descriptor. On Windows it contains a file handle from _pipe() and a
few other things related to the implementation of gdk_input_add
and GIMP plug-in communication. Subject to change.
Removed duplicate declarations of the version variables.
For the Microsoft compiler, declare own implementation of
ftruncate and the <dirent.h> functions.
* gmem.c:
Define a symbolic name for the profiling table size.
* gmessages.c:
Conditionalized inclusion of unistd.h. On Windows, output using
stdio to stdout.
* gscanner.c:
Conditionalized inclusion of unistd.h. Added changes for
Microsoft C. Added CR to the skipped character set. Added small
workaround for MSC compiler bug in g_scanner_cur_value.
* gstrfuncs.c:
Added the function g_strescape, which escapes the backslash
character. Needed especially when printing Windows filenames.
* gtimer.c:
Conditionalized inclusion of unistd.h and sys/time.h. Added
implementations for Windows.
* gutils.c:
Conditionalized inclusion of platform-dependent headers. Use
the platform-independent file name syntax macros.
Conditionalize code on platform-dependent features. Added the
functions g_path_is_absolute g_path_skip_root and g_getenv.
Added the GIOChannel-related functions. Added
compiler-dependent Unix compatibility functions for Windows.
* makefile.lcc makefile.msc:
New files. Compiler-specific makefiles for LCC-Win32 and
Microsoft C. Only Microsoft C is actually supported currently.
* testglib.c:
Added pathname check cases for Windows. Added workaround for
bug in the Microsoft runtime library. Improved some tests a bit.
Tue Oct 27 04:00:11 1998 Tim Janik <timj@gtk.org>
* testgmodule.c (main): changed the #ifdef WIN32 test to NATIVE_WIN32,
this needs to be more constistent throughout the code, do we go for
NATIVE_WIN32 or WIN32?
* gmodule.c (LibMain): special cased the #ifdef __LCC__ case for
NATIVE_WIN32, since lcc maybe used on other platforms as well.
* libgplugin_a.c (LibMain):
* libgplugin_b.c (LibMain):
likewise. not sure i like this special requirement for lcc in here.
* gmodule-dl.c (_g_module_build_path):
feature empty "" directories and prepend the module name with "lib".
* gmodule-dld.c (_g_module_build_path):
* gmodule-win32.c (_g_module_build_path):
feature empty "" directories.
* we need some more magic in the _g_module_build_path variants
so we don't append/prepend lib and .so, .sl or .dll for those names
that already contain it.
* applied patch from Tor Lillqvist for g_module_build_path() and
windows support.
1998-10-20: Tor Lillqvist <tml@iki.fi>
* gmodule/gmodule-win32.c:
New file.
* gmodule/gmodule.c gmodule/gmodule.h:
Added the funcion g_module_build_path that builds the path to
a module file, decorating the name according to the system's
conventions. Added the Windows implementation.
* gmodule/libgplugin_a.c gmodule/libgplugin_b.c:
Added LibMain for LCC-Win32.
* gmodule/testgmodule.c:
Handle Windows dll names.
1998-10-27 04:11:34 +00:00
|
|
|
|
2001-09-19 18:08:19 +00:00
|
|
|
GETTIME(timer->end);
|
1998-06-10 23:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
g_timer_reset (GTimer *timer)
|
|
|
|
{
|
1999-03-17 01:05:49 +00:00
|
|
|
g_return_if_fail (timer != NULL);
|
1998-06-10 23:21:14 +00:00
|
|
|
|
2001-09-19 18:08:19 +00:00
|
|
|
GETTIME (timer->start);
|
1998-06-10 23:21:14 +00:00
|
|
|
}
|
|
|
|
|
2004-01-22 19:56:28 +00:00
|
|
|
void
|
|
|
|
g_timer_continue (GTimer *timer)
|
|
|
|
{
|
|
|
|
#ifdef G_OS_WIN32
|
2005-03-20 11:35:48 +00:00
|
|
|
guint64 elapsed;
|
2004-01-22 19:56:28 +00:00
|
|
|
#else
|
|
|
|
struct timeval elapsed;
|
|
|
|
#endif /* G_OS_WIN32 */
|
|
|
|
|
|
|
|
g_return_if_fail (timer != NULL);
|
|
|
|
g_return_if_fail (timer->active == FALSE);
|
|
|
|
|
|
|
|
/* Get elapsed time and reset timer start time
|
|
|
|
* to the current time minus the previously
|
|
|
|
* elapsed interval.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
|
|
|
|
elapsed = timer->end - timer->start;
|
|
|
|
|
|
|
|
GETTIME (timer->start);
|
|
|
|
|
|
|
|
timer->start -= elapsed;
|
|
|
|
|
|
|
|
#else /* !G_OS_WIN32 */
|
|
|
|
|
|
|
|
if (timer->start.tv_usec > timer->end.tv_usec)
|
|
|
|
{
|
|
|
|
timer->end.tv_usec += G_USEC_PER_SEC;
|
|
|
|
timer->end.tv_sec--;
|
|
|
|
}
|
|
|
|
|
|
|
|
elapsed.tv_usec = timer->end.tv_usec - timer->start.tv_usec;
|
|
|
|
elapsed.tv_sec = timer->end.tv_sec - timer->start.tv_sec;
|
|
|
|
|
|
|
|
GETTIME (timer->start);
|
|
|
|
|
|
|
|
if (timer->start.tv_usec < elapsed.tv_usec)
|
|
|
|
{
|
|
|
|
timer->start.tv_usec += G_USEC_PER_SEC;
|
|
|
|
timer->start.tv_sec--;
|
|
|
|
}
|
|
|
|
|
|
|
|
timer->start.tv_usec -= elapsed.tv_usec;
|
|
|
|
timer->start.tv_sec -= elapsed.tv_sec;
|
|
|
|
|
|
|
|
#endif /* !G_OS_WIN32 */
|
|
|
|
|
|
|
|
timer->active = TRUE;
|
|
|
|
}
|
|
|
|
|
1998-06-10 23:21:14 +00:00
|
|
|
gdouble
|
|
|
|
g_timer_elapsed (GTimer *timer,
|
|
|
|
gulong *microseconds)
|
|
|
|
{
|
|
|
|
gdouble total;
|
2005-03-20 11:35:48 +00:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
gint64 elapsed;
|
|
|
|
#else
|
removed dummy structure definitions for struct _GCache, _GTree, _GTimer,
Tue Oct 27 03:00:50 1998 Tim Janik <timj@gtk.org>
* glib.h: removed dummy structure definitions for struct _GCache,
_GTree, _GTimer, _GMemChunk, _GListAllocator and _GStringChunk.
* gutils.c: implement glib's inline functions _after_ all include
statements have been processed.
removed Tor's MAXPATHLEN check since there already was one supplied
further down in this file.
(LibMain): special cased the #ifdef __LCC__ case for NATIVE_WIN32,
since lcc maybe used on other platforms as well. why in hell is this
stuff required?
(g_get_any_init): for windows, if the user name is supplied, use it as
realname also.
in general, if there is no homedir specified, use the tmpdir that
we already figured.
* gtimer.c (g_timer_elapsed): changed a g_assert() statement to
g_return_if_fail().
* applied glib-tml-981020-0.patch for WIN32 portability, added some
comments and g_return_if_fail() statements, minor indentation fixes.
ChangeLog entry from Tor Lillqvist is appended.
* glib.h (struct dirent): use lower case structure members.
* glib.h:
* makefile.lcc:
* makefile.msc:
s/COMPILING_GLIB/GLIB_COMPILATION/
1998-10-20: Tor Lillqvist <tml@iki.fi>
* README.win32 glib.def gmodule.def
* glibconfig.h.win32 gmodule/gmoduleconf.h.win32:
New files for the Windows port. The .def files list exported
symbols for the Microsoft linker and compatibles.
* configure.in:
Added checks for some platform-dependent headers: pwd.h sys/param.h
sys/select.h sys/time.h sys/times.h unistd.h, and the function lstat.
* gerror.c:
Conditionalized inclusion of system-dependent headers. Changes
for Windows: no gdb to do a stack trace. Just call abort().
* glib.h:
Changes for Windows:
Added macros G_DIR_SEPARATOR, G_DIR_SEPARATOR_S for
platform-dependent file name syntax elements. Added macros
G_SEARCHPATH_SEPARATOR, G_SEARCHPATH_SEPARATOR_S for
platform-dependent search path syntax conventions.
Added pragmas for Microsoft C to make it more pedantic.
Marked GLib's global variables for export from DLL.
Added the function g_strescape that escapes backslashes.
Added functions g_path_is_absolute and g_path_skip_root to
handle platform-dependent file name syntax.
Added the function g_getenv that expands environment variables
that contain references to other environment variables, as is
typical on Windows NT.
Added the GIOChannel structure which is used to encapsulate the
IPC mechanism used by the GIMP's plug-ins, and possibly other
things later. On Unix a GIOChannel encapsulates just a file
descriptor. On Windows it contains a file handle from _pipe() and a
few other things related to the implementation of gdk_input_add
and GIMP plug-in communication. Subject to change.
Removed duplicate declarations of the version variables.
For the Microsoft compiler, declare own implementation of
ftruncate and the <dirent.h> functions.
* gmem.c:
Define a symbolic name for the profiling table size.
* gmessages.c:
Conditionalized inclusion of unistd.h. On Windows, output using
stdio to stdout.
* gscanner.c:
Conditionalized inclusion of unistd.h. Added changes for
Microsoft C. Added CR to the skipped character set. Added small
workaround for MSC compiler bug in g_scanner_cur_value.
* gstrfuncs.c:
Added the function g_strescape, which escapes the backslash
character. Needed especially when printing Windows filenames.
* gtimer.c:
Conditionalized inclusion of unistd.h and sys/time.h. Added
implementations for Windows.
* gutils.c:
Conditionalized inclusion of platform-dependent headers. Use
the platform-independent file name syntax macros.
Conditionalize code on platform-dependent features. Added the
functions g_path_is_absolute g_path_skip_root and g_getenv.
Added the GIOChannel-related functions. Added
compiler-dependent Unix compatibility functions for Windows.
* makefile.lcc makefile.msc:
New files. Compiler-specific makefiles for LCC-Win32 and
Microsoft C. Only Microsoft C is actually supported currently.
* testglib.c:
Added pathname check cases for Windows. Added workaround for
bug in the Microsoft runtime library. Improved some tests a bit.
Tue Oct 27 04:00:11 1998 Tim Janik <timj@gtk.org>
* testgmodule.c (main): changed the #ifdef WIN32 test to NATIVE_WIN32,
this needs to be more constistent throughout the code, do we go for
NATIVE_WIN32 or WIN32?
* gmodule.c (LibMain): special cased the #ifdef __LCC__ case for
NATIVE_WIN32, since lcc maybe used on other platforms as well.
* libgplugin_a.c (LibMain):
* libgplugin_b.c (LibMain):
likewise. not sure i like this special requirement for lcc in here.
* gmodule-dl.c (_g_module_build_path):
feature empty "" directories and prepend the module name with "lib".
* gmodule-dld.c (_g_module_build_path):
* gmodule-win32.c (_g_module_build_path):
feature empty "" directories.
* we need some more magic in the _g_module_build_path variants
so we don't append/prepend lib and .so, .sl or .dll for those names
that already contain it.
* applied patch from Tor Lillqvist for g_module_build_path() and
windows support.
1998-10-20: Tor Lillqvist <tml@iki.fi>
* gmodule/gmodule-win32.c:
New file.
* gmodule/gmodule.c gmodule/gmodule.h:
Added the funcion g_module_build_path that builds the path to
a module file, decorating the name according to the system's
conventions. Added the Windows implementation.
* gmodule/libgplugin_a.c gmodule/libgplugin_b.c:
Added LibMain for LCC-Win32.
* gmodule/testgmodule.c:
Handle Windows dll names.
1998-10-27 04:11:34 +00:00
|
|
|
struct timeval elapsed;
|
1999-10-04 02:32:50 +00:00
|
|
|
#endif /* G_OS_WIN32 */
|
1998-06-10 23:21:14 +00:00
|
|
|
|
removed dummy structure definitions for struct _GCache, _GTree, _GTimer,
Tue Oct 27 03:00:50 1998 Tim Janik <timj@gtk.org>
* glib.h: removed dummy structure definitions for struct _GCache,
_GTree, _GTimer, _GMemChunk, _GListAllocator and _GStringChunk.
* gutils.c: implement glib's inline functions _after_ all include
statements have been processed.
removed Tor's MAXPATHLEN check since there already was one supplied
further down in this file.
(LibMain): special cased the #ifdef __LCC__ case for NATIVE_WIN32,
since lcc maybe used on other platforms as well. why in hell is this
stuff required?
(g_get_any_init): for windows, if the user name is supplied, use it as
realname also.
in general, if there is no homedir specified, use the tmpdir that
we already figured.
* gtimer.c (g_timer_elapsed): changed a g_assert() statement to
g_return_if_fail().
* applied glib-tml-981020-0.patch for WIN32 portability, added some
comments and g_return_if_fail() statements, minor indentation fixes.
ChangeLog entry from Tor Lillqvist is appended.
* glib.h (struct dirent): use lower case structure members.
* glib.h:
* makefile.lcc:
* makefile.msc:
s/COMPILING_GLIB/GLIB_COMPILATION/
1998-10-20: Tor Lillqvist <tml@iki.fi>
* README.win32 glib.def gmodule.def
* glibconfig.h.win32 gmodule/gmoduleconf.h.win32:
New files for the Windows port. The .def files list exported
symbols for the Microsoft linker and compatibles.
* configure.in:
Added checks for some platform-dependent headers: pwd.h sys/param.h
sys/select.h sys/time.h sys/times.h unistd.h, and the function lstat.
* gerror.c:
Conditionalized inclusion of system-dependent headers. Changes
for Windows: no gdb to do a stack trace. Just call abort().
* glib.h:
Changes for Windows:
Added macros G_DIR_SEPARATOR, G_DIR_SEPARATOR_S for
platform-dependent file name syntax elements. Added macros
G_SEARCHPATH_SEPARATOR, G_SEARCHPATH_SEPARATOR_S for
platform-dependent search path syntax conventions.
Added pragmas for Microsoft C to make it more pedantic.
Marked GLib's global variables for export from DLL.
Added the function g_strescape that escapes backslashes.
Added functions g_path_is_absolute and g_path_skip_root to
handle platform-dependent file name syntax.
Added the function g_getenv that expands environment variables
that contain references to other environment variables, as is
typical on Windows NT.
Added the GIOChannel structure which is used to encapsulate the
IPC mechanism used by the GIMP's plug-ins, and possibly other
things later. On Unix a GIOChannel encapsulates just a file
descriptor. On Windows it contains a file handle from _pipe() and a
few other things related to the implementation of gdk_input_add
and GIMP plug-in communication. Subject to change.
Removed duplicate declarations of the version variables.
For the Microsoft compiler, declare own implementation of
ftruncate and the <dirent.h> functions.
* gmem.c:
Define a symbolic name for the profiling table size.
* gmessages.c:
Conditionalized inclusion of unistd.h. On Windows, output using
stdio to stdout.
* gscanner.c:
Conditionalized inclusion of unistd.h. Added changes for
Microsoft C. Added CR to the skipped character set. Added small
workaround for MSC compiler bug in g_scanner_cur_value.
* gstrfuncs.c:
Added the function g_strescape, which escapes the backslash
character. Needed especially when printing Windows filenames.
* gtimer.c:
Conditionalized inclusion of unistd.h and sys/time.h. Added
implementations for Windows.
* gutils.c:
Conditionalized inclusion of platform-dependent headers. Use
the platform-independent file name syntax macros.
Conditionalize code on platform-dependent features. Added the
functions g_path_is_absolute g_path_skip_root and g_getenv.
Added the GIOChannel-related functions. Added
compiler-dependent Unix compatibility functions for Windows.
* makefile.lcc makefile.msc:
New files. Compiler-specific makefiles for LCC-Win32 and
Microsoft C. Only Microsoft C is actually supported currently.
* testglib.c:
Added pathname check cases for Windows. Added workaround for
bug in the Microsoft runtime library. Improved some tests a bit.
Tue Oct 27 04:00:11 1998 Tim Janik <timj@gtk.org>
* testgmodule.c (main): changed the #ifdef WIN32 test to NATIVE_WIN32,
this needs to be more constistent throughout the code, do we go for
NATIVE_WIN32 or WIN32?
* gmodule.c (LibMain): special cased the #ifdef __LCC__ case for
NATIVE_WIN32, since lcc maybe used on other platforms as well.
* libgplugin_a.c (LibMain):
* libgplugin_b.c (LibMain):
likewise. not sure i like this special requirement for lcc in here.
* gmodule-dl.c (_g_module_build_path):
feature empty "" directories and prepend the module name with "lib".
* gmodule-dld.c (_g_module_build_path):
* gmodule-win32.c (_g_module_build_path):
feature empty "" directories.
* we need some more magic in the _g_module_build_path variants
so we don't append/prepend lib and .so, .sl or .dll for those names
that already contain it.
* applied patch from Tor Lillqvist for g_module_build_path() and
windows support.
1998-10-20: Tor Lillqvist <tml@iki.fi>
* gmodule/gmodule-win32.c:
New file.
* gmodule/gmodule.c gmodule/gmodule.h:
Added the funcion g_module_build_path that builds the path to
a module file, decorating the name according to the system's
conventions. Added the Windows implementation.
* gmodule/libgplugin_a.c gmodule/libgplugin_b.c:
Added LibMain for LCC-Win32.
* gmodule/testgmodule.c:
Handle Windows dll names.
1998-10-27 04:11:34 +00:00
|
|
|
g_return_val_if_fail (timer != NULL, 0);
|
1998-06-10 23:21:14 +00:00
|
|
|
|
1999-10-04 02:32:50 +00:00
|
|
|
#ifdef G_OS_WIN32
|
2001-09-19 18:08:19 +00:00
|
|
|
if (timer->active)
|
2005-03-20 11:35:48 +00:00
|
|
|
GETTIME (timer->end);
|
removed dummy structure definitions for struct _GCache, _GTree, _GTimer,
Tue Oct 27 03:00:50 1998 Tim Janik <timj@gtk.org>
* glib.h: removed dummy structure definitions for struct _GCache,
_GTree, _GTimer, _GMemChunk, _GListAllocator and _GStringChunk.
* gutils.c: implement glib's inline functions _after_ all include
statements have been processed.
removed Tor's MAXPATHLEN check since there already was one supplied
further down in this file.
(LibMain): special cased the #ifdef __LCC__ case for NATIVE_WIN32,
since lcc maybe used on other platforms as well. why in hell is this
stuff required?
(g_get_any_init): for windows, if the user name is supplied, use it as
realname also.
in general, if there is no homedir specified, use the tmpdir that
we already figured.
* gtimer.c (g_timer_elapsed): changed a g_assert() statement to
g_return_if_fail().
* applied glib-tml-981020-0.patch for WIN32 portability, added some
comments and g_return_if_fail() statements, minor indentation fixes.
ChangeLog entry from Tor Lillqvist is appended.
* glib.h (struct dirent): use lower case structure members.
* glib.h:
* makefile.lcc:
* makefile.msc:
s/COMPILING_GLIB/GLIB_COMPILATION/
1998-10-20: Tor Lillqvist <tml@iki.fi>
* README.win32 glib.def gmodule.def
* glibconfig.h.win32 gmodule/gmoduleconf.h.win32:
New files for the Windows port. The .def files list exported
symbols for the Microsoft linker and compatibles.
* configure.in:
Added checks for some platform-dependent headers: pwd.h sys/param.h
sys/select.h sys/time.h sys/times.h unistd.h, and the function lstat.
* gerror.c:
Conditionalized inclusion of system-dependent headers. Changes
for Windows: no gdb to do a stack trace. Just call abort().
* glib.h:
Changes for Windows:
Added macros G_DIR_SEPARATOR, G_DIR_SEPARATOR_S for
platform-dependent file name syntax elements. Added macros
G_SEARCHPATH_SEPARATOR, G_SEARCHPATH_SEPARATOR_S for
platform-dependent search path syntax conventions.
Added pragmas for Microsoft C to make it more pedantic.
Marked GLib's global variables for export from DLL.
Added the function g_strescape that escapes backslashes.
Added functions g_path_is_absolute and g_path_skip_root to
handle platform-dependent file name syntax.
Added the function g_getenv that expands environment variables
that contain references to other environment variables, as is
typical on Windows NT.
Added the GIOChannel structure which is used to encapsulate the
IPC mechanism used by the GIMP's plug-ins, and possibly other
things later. On Unix a GIOChannel encapsulates just a file
descriptor. On Windows it contains a file handle from _pipe() and a
few other things related to the implementation of gdk_input_add
and GIMP plug-in communication. Subject to change.
Removed duplicate declarations of the version variables.
For the Microsoft compiler, declare own implementation of
ftruncate and the <dirent.h> functions.
* gmem.c:
Define a symbolic name for the profiling table size.
* gmessages.c:
Conditionalized inclusion of unistd.h. On Windows, output using
stdio to stdout.
* gscanner.c:
Conditionalized inclusion of unistd.h. Added changes for
Microsoft C. Added CR to the skipped character set. Added small
workaround for MSC compiler bug in g_scanner_cur_value.
* gstrfuncs.c:
Added the function g_strescape, which escapes the backslash
character. Needed especially when printing Windows filenames.
* gtimer.c:
Conditionalized inclusion of unistd.h and sys/time.h. Added
implementations for Windows.
* gutils.c:
Conditionalized inclusion of platform-dependent headers. Use
the platform-independent file name syntax macros.
Conditionalize code on platform-dependent features. Added the
functions g_path_is_absolute g_path_skip_root and g_getenv.
Added the GIOChannel-related functions. Added
compiler-dependent Unix compatibility functions for Windows.
* makefile.lcc makefile.msc:
New files. Compiler-specific makefiles for LCC-Win32 and
Microsoft C. Only Microsoft C is actually supported currently.
* testglib.c:
Added pathname check cases for Windows. Added workaround for
bug in the Microsoft runtime library. Improved some tests a bit.
Tue Oct 27 04:00:11 1998 Tim Janik <timj@gtk.org>
* testgmodule.c (main): changed the #ifdef WIN32 test to NATIVE_WIN32,
this needs to be more constistent throughout the code, do we go for
NATIVE_WIN32 or WIN32?
* gmodule.c (LibMain): special cased the #ifdef __LCC__ case for
NATIVE_WIN32, since lcc maybe used on other platforms as well.
* libgplugin_a.c (LibMain):
* libgplugin_b.c (LibMain):
likewise. not sure i like this special requirement for lcc in here.
* gmodule-dl.c (_g_module_build_path):
feature empty "" directories and prepend the module name with "lib".
* gmodule-dld.c (_g_module_build_path):
* gmodule-win32.c (_g_module_build_path):
feature empty "" directories.
* we need some more magic in the _g_module_build_path variants
so we don't append/prepend lib and .so, .sl or .dll for those names
that already contain it.
* applied patch from Tor Lillqvist for g_module_build_path() and
windows support.
1998-10-20: Tor Lillqvist <tml@iki.fi>
* gmodule/gmodule-win32.c:
New file.
* gmodule/gmodule.c gmodule/gmodule.h:
Added the funcion g_module_build_path that builds the path to
a module file, decorating the name according to the system's
conventions. Added the Windows implementation.
* gmodule/libgplugin_a.c gmodule/libgplugin_b.c:
Added LibMain for LCC-Win32.
* gmodule/testgmodule.c:
Handle Windows dll names.
1998-10-27 04:11:34 +00:00
|
|
|
|
2005-03-20 11:35:48 +00:00
|
|
|
elapsed = timer->end - timer->start;
|
|
|
|
|
|
|
|
total = elapsed / 1e7;
|
removed dummy structure definitions for struct _GCache, _GTree, _GTimer,
Tue Oct 27 03:00:50 1998 Tim Janik <timj@gtk.org>
* glib.h: removed dummy structure definitions for struct _GCache,
_GTree, _GTimer, _GMemChunk, _GListAllocator and _GStringChunk.
* gutils.c: implement glib's inline functions _after_ all include
statements have been processed.
removed Tor's MAXPATHLEN check since there already was one supplied
further down in this file.
(LibMain): special cased the #ifdef __LCC__ case for NATIVE_WIN32,
since lcc maybe used on other platforms as well. why in hell is this
stuff required?
(g_get_any_init): for windows, if the user name is supplied, use it as
realname also.
in general, if there is no homedir specified, use the tmpdir that
we already figured.
* gtimer.c (g_timer_elapsed): changed a g_assert() statement to
g_return_if_fail().
* applied glib-tml-981020-0.patch for WIN32 portability, added some
comments and g_return_if_fail() statements, minor indentation fixes.
ChangeLog entry from Tor Lillqvist is appended.
* glib.h (struct dirent): use lower case structure members.
* glib.h:
* makefile.lcc:
* makefile.msc:
s/COMPILING_GLIB/GLIB_COMPILATION/
1998-10-20: Tor Lillqvist <tml@iki.fi>
* README.win32 glib.def gmodule.def
* glibconfig.h.win32 gmodule/gmoduleconf.h.win32:
New files for the Windows port. The .def files list exported
symbols for the Microsoft linker and compatibles.
* configure.in:
Added checks for some platform-dependent headers: pwd.h sys/param.h
sys/select.h sys/time.h sys/times.h unistd.h, and the function lstat.
* gerror.c:
Conditionalized inclusion of system-dependent headers. Changes
for Windows: no gdb to do a stack trace. Just call abort().
* glib.h:
Changes for Windows:
Added macros G_DIR_SEPARATOR, G_DIR_SEPARATOR_S for
platform-dependent file name syntax elements. Added macros
G_SEARCHPATH_SEPARATOR, G_SEARCHPATH_SEPARATOR_S for
platform-dependent search path syntax conventions.
Added pragmas for Microsoft C to make it more pedantic.
Marked GLib's global variables for export from DLL.
Added the function g_strescape that escapes backslashes.
Added functions g_path_is_absolute and g_path_skip_root to
handle platform-dependent file name syntax.
Added the function g_getenv that expands environment variables
that contain references to other environment variables, as is
typical on Windows NT.
Added the GIOChannel structure which is used to encapsulate the
IPC mechanism used by the GIMP's plug-ins, and possibly other
things later. On Unix a GIOChannel encapsulates just a file
descriptor. On Windows it contains a file handle from _pipe() and a
few other things related to the implementation of gdk_input_add
and GIMP plug-in communication. Subject to change.
Removed duplicate declarations of the version variables.
For the Microsoft compiler, declare own implementation of
ftruncate and the <dirent.h> functions.
* gmem.c:
Define a symbolic name for the profiling table size.
* gmessages.c:
Conditionalized inclusion of unistd.h. On Windows, output using
stdio to stdout.
* gscanner.c:
Conditionalized inclusion of unistd.h. Added changes for
Microsoft C. Added CR to the skipped character set. Added small
workaround for MSC compiler bug in g_scanner_cur_value.
* gstrfuncs.c:
Added the function g_strescape, which escapes the backslash
character. Needed especially when printing Windows filenames.
* gtimer.c:
Conditionalized inclusion of unistd.h and sys/time.h. Added
implementations for Windows.
* gutils.c:
Conditionalized inclusion of platform-dependent headers. Use
the platform-independent file name syntax macros.
Conditionalize code on platform-dependent features. Added the
functions g_path_is_absolute g_path_skip_root and g_getenv.
Added the GIOChannel-related functions. Added
compiler-dependent Unix compatibility functions for Windows.
* makefile.lcc makefile.msc:
New files. Compiler-specific makefiles for LCC-Win32 and
Microsoft C. Only Microsoft C is actually supported currently.
* testglib.c:
Added pathname check cases for Windows. Added workaround for
bug in the Microsoft runtime library. Improved some tests a bit.
Tue Oct 27 04:00:11 1998 Tim Janik <timj@gtk.org>
* testgmodule.c (main): changed the #ifdef WIN32 test to NATIVE_WIN32,
this needs to be more constistent throughout the code, do we go for
NATIVE_WIN32 or WIN32?
* gmodule.c (LibMain): special cased the #ifdef __LCC__ case for
NATIVE_WIN32, since lcc maybe used on other platforms as well.
* libgplugin_a.c (LibMain):
* libgplugin_b.c (LibMain):
likewise. not sure i like this special requirement for lcc in here.
* gmodule-dl.c (_g_module_build_path):
feature empty "" directories and prepend the module name with "lib".
* gmodule-dld.c (_g_module_build_path):
* gmodule-win32.c (_g_module_build_path):
feature empty "" directories.
* we need some more magic in the _g_module_build_path variants
so we don't append/prepend lib and .so, .sl or .dll for those names
that already contain it.
* applied patch from Tor Lillqvist for g_module_build_path() and
windows support.
1998-10-20: Tor Lillqvist <tml@iki.fi>
* gmodule/gmodule-win32.c:
New file.
* gmodule/gmodule.c gmodule/gmodule.h:
Added the funcion g_module_build_path that builds the path to
a module file, decorating the name according to the system's
conventions. Added the Windows implementation.
* gmodule/libgplugin_a.c gmodule/libgplugin_b.c:
Added LibMain for LCC-Win32.
* gmodule/testgmodule.c:
Handle Windows dll names.
1998-10-27 04:11:34 +00:00
|
|
|
|
|
|
|
if (microseconds)
|
2005-03-20 11:35:48 +00:00
|
|
|
*microseconds = (elapsed / 10) % 1000000;
|
1999-10-04 02:32:50 +00:00
|
|
|
#else /* !G_OS_WIN32 */
|
2001-09-19 18:08:19 +00:00
|
|
|
if (timer->active)
|
|
|
|
gettimeofday (&timer->end, NULL);
|
1998-06-10 23:21:14 +00:00
|
|
|
|
2001-09-19 18:08:19 +00:00
|
|
|
if (timer->start.tv_usec > timer->end.tv_usec)
|
1998-06-10 23:21:14 +00:00
|
|
|
{
|
2001-09-19 18:08:19 +00:00
|
|
|
timer->end.tv_usec += G_USEC_PER_SEC;
|
|
|
|
timer->end.tv_sec--;
|
1998-06-10 23:21:14 +00:00
|
|
|
}
|
|
|
|
|
2001-09-19 18:08:19 +00:00
|
|
|
elapsed.tv_usec = timer->end.tv_usec - timer->start.tv_usec;
|
|
|
|
elapsed.tv_sec = timer->end.tv_sec - timer->start.tv_sec;
|
1998-06-10 23:21:14 +00:00
|
|
|
|
|
|
|
total = elapsed.tv_sec + ((gdouble) elapsed.tv_usec / 1e6);
|
2000-03-01 09:44:10 +00:00
|
|
|
if (total < 0)
|
|
|
|
{
|
|
|
|
total = 0;
|
1998-06-10 23:21:14 +00:00
|
|
|
|
2000-03-01 09:44:10 +00:00
|
|
|
if (microseconds)
|
|
|
|
*microseconds = 0;
|
|
|
|
}
|
|
|
|
else if (microseconds)
|
1998-06-10 23:21:14 +00:00
|
|
|
*microseconds = elapsed.tv_usec;
|
2000-03-01 09:44:10 +00:00
|
|
|
|
1999-10-04 02:32:50 +00:00
|
|
|
#endif /* !G_OS_WIN32 */
|
1998-06-10 23:21:14 +00:00
|
|
|
|
|
|
|
return total;
|
|
|
|
}
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 15:39:31 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
g_usleep (gulong microseconds)
|
|
|
|
{
|
1999-10-04 02:32:50 +00:00
|
|
|
#ifdef G_OS_WIN32
|
1999-06-20 22:20:43 +00:00
|
|
|
Sleep (microseconds / 1000);
|
2001-06-07 13:46:14 +00:00
|
|
|
#else /* !G_OS_WIN32 */
|
|
|
|
# ifdef HAVE_NANOSLEEP
|
|
|
|
struct timespec request, remaining;
|
|
|
|
request.tv_sec = microseconds / G_USEC_PER_SEC;
|
|
|
|
request.tv_nsec = 1000 * (microseconds % G_USEC_PER_SEC);
|
2005-02-23 02:33:54 +00:00
|
|
|
while (nanosleep (&request, &remaining) == -1 && errno == EINTR)
|
|
|
|
request = remaining;
|
2001-06-07 13:46:14 +00:00
|
|
|
# else /* !HAVE_NANOSLEEP */
|
2000-03-23 16:23:50 +00:00
|
|
|
if (g_thread_supported ())
|
|
|
|
{
|
|
|
|
static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
|
|
|
|
static GCond* cond = NULL;
|
|
|
|
GTimeVal end_time;
|
|
|
|
|
|
|
|
g_get_current_time (&end_time);
|
2001-06-07 13:46:14 +00:00
|
|
|
if (microseconds > G_MAXLONG)
|
2000-03-23 16:23:50 +00:00
|
|
|
{
|
2001-06-07 13:46:14 +00:00
|
|
|
microseconds -= G_MAXLONG;
|
|
|
|
g_time_val_add (&end_time, G_MAXLONG);
|
2000-03-23 16:23:50 +00:00
|
|
|
}
|
2001-06-07 13:46:14 +00:00
|
|
|
g_time_val_add (&end_time, microseconds);
|
|
|
|
|
2000-03-23 16:23:50 +00:00
|
|
|
g_static_mutex_lock (&mutex);
|
|
|
|
|
|
|
|
if (!cond)
|
|
|
|
cond = g_cond_new ();
|
|
|
|
|
|
|
|
while (g_cond_timed_wait (cond, g_static_mutex_get_mutex (&mutex),
|
|
|
|
&end_time))
|
|
|
|
/* do nothing */;
|
|
|
|
|
|
|
|
g_static_mutex_unlock (&mutex);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct timeval tv;
|
2000-09-06 13:56:17 +00:00
|
|
|
tv.tv_sec = microseconds / G_USEC_PER_SEC;
|
|
|
|
tv.tv_usec = microseconds % G_USEC_PER_SEC;
|
2000-03-23 16:23:50 +00:00
|
|
|
select(0, NULL, NULL, NULL, &tv);
|
|
|
|
}
|
2001-06-07 13:46:14 +00:00
|
|
|
# endif /* !HAVE_NANOSLEEP */
|
|
|
|
#endif /* !G_OS_WIN32 */
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 15:39:31 +00:00
|
|
|
}
|
|
|
|
|
2001-06-07 13:46:14 +00:00
|
|
|
/**
|
|
|
|
* g_time_val_add:
|
2002-11-28 23:11:58 +00:00
|
|
|
* @time_: a #GTimeVal
|
2001-06-07 13:46:14 +00:00
|
|
|
* @microseconds: number of microseconds to add to @time
|
|
|
|
*
|
2002-11-28 23:11:58 +00:00
|
|
|
* Adds the given number of microseconds to @time_. @microseconds can
|
|
|
|
* also be negative to decrease the value of @time_.
|
2001-06-07 13:46:14 +00:00
|
|
|
**/
|
|
|
|
void
|
2002-11-28 23:11:58 +00:00
|
|
|
g_time_val_add (GTimeVal *time_, glong microseconds)
|
2001-06-07 13:46:14 +00:00
|
|
|
{
|
2002-11-28 23:11:58 +00:00
|
|
|
g_return_if_fail (time_->tv_usec >= 0 && time_->tv_usec < G_USEC_PER_SEC);
|
2001-06-07 13:46:14 +00:00
|
|
|
|
|
|
|
if (microseconds >= 0)
|
|
|
|
{
|
2002-11-28 23:11:58 +00:00
|
|
|
time_->tv_usec += microseconds % G_USEC_PER_SEC;
|
|
|
|
time_->tv_sec += microseconds / G_USEC_PER_SEC;
|
|
|
|
if (time_->tv_usec >= G_USEC_PER_SEC)
|
2001-06-07 13:46:14 +00:00
|
|
|
{
|
2002-11-28 23:11:58 +00:00
|
|
|
time_->tv_usec -= G_USEC_PER_SEC;
|
|
|
|
time_->tv_sec++;
|
2001-06-07 13:46:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
microseconds *= -1;
|
2002-11-28 23:11:58 +00:00
|
|
|
time_->tv_usec -= microseconds % G_USEC_PER_SEC;
|
|
|
|
time_->tv_sec -= microseconds / G_USEC_PER_SEC;
|
|
|
|
if (time_->tv_usec < 0)
|
2001-06-07 13:46:14 +00:00
|
|
|
{
|
2002-11-28 23:11:58 +00:00
|
|
|
time_->tv_usec += G_USEC_PER_SEC;
|
|
|
|
time_->tv_sec--;
|
2001-06-07 13:46:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-03-14 04:26:57 +00:00
|
|
|
|
2006-03-23 02:54:29 +00:00
|
|
|
/* converts a broken down date representation, relative to UTC, to
|
|
|
|
* a timestamp; it uses timegm() if it's available.
|
|
|
|
*/
|
|
|
|
static time_t
|
|
|
|
mktime_utc (struct tm *tm)
|
|
|
|
{
|
|
|
|
time_t retval;
|
|
|
|
|
|
|
|
#ifndef HAVE_TIMEGM
|
|
|
|
static const gint days_before[] =
|
|
|
|
{
|
|
|
|
0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_TIMEGM
|
|
|
|
if (tm->tm_mon < 0 || tm->tm_mon > 11)
|
|
|
|
return (time_t) -1;
|
|
|
|
|
|
|
|
retval = (tm->tm_year - 70) * 365;
|
|
|
|
retval += (tm->tm_year - 68) / 4;
|
|
|
|
retval += days_before[tm->tm_mon] + tm->tm_mday - 1;
|
|
|
|
|
|
|
|
if (tm->tm_year % 4 == 2 && tm->tm_mon < 2)
|
|
|
|
retval -= 1;
|
|
|
|
|
|
|
|
retval = ((((retval * 24) + tm->tm_hour) * 60) + tm->tm_min) * 60 + tm->tm_sec;
|
|
|
|
#else
|
|
|
|
retval = timegm (tm);
|
|
|
|
#endif /* !HAVE_TIMEGM */
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* g_time_val_from_iso8601:
|
|
|
|
* @iso_date: a ISO 8601 encoded date string
|
|
|
|
* @time_: a #GTimeVal
|
|
|
|
*
|
|
|
|
* Converts a string containing an ISO 8601 encoded date and time
|
|
|
|
* to a #GTimeVal and puts it into @time_.
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if the conversion was successful.
|
|
|
|
*
|
2006-03-23 13:38:17 +00:00
|
|
|
* Since: 2.12
|
2006-03-23 02:54:29 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
g_time_val_from_iso8601 (const gchar *iso_date,
|
|
|
|
GTimeVal *time_)
|
|
|
|
{
|
|
|
|
struct tm tm;
|
|
|
|
long val;
|
|
|
|
|
|
|
|
g_return_val_if_fail (iso_date != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (time_ != NULL, FALSE);
|
|
|
|
|
|
|
|
val = strtoul (iso_date, (char **)&iso_date, 10);
|
|
|
|
if (*iso_date == '-')
|
|
|
|
{
|
|
|
|
/* YYYY-MM-DD */
|
|
|
|
tm.tm_year = val - 1900;
|
|
|
|
iso_date++;
|
|
|
|
tm.tm_mon = strtoul (iso_date, (char **)&iso_date, 10) - 1;
|
|
|
|
|
|
|
|
if (*iso_date++ != '-')
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
tm.tm_mday = strtoul (iso_date, (char **)&iso_date, 10);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* YYYYMMDD */
|
|
|
|
tm.tm_mday = val % 100;
|
|
|
|
tm.tm_mon = (val % 10000) / 100 - 1;
|
|
|
|
tm.tm_year = val / 10000 - 1900;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*iso_date++ != 'T')
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
val = strtoul (iso_date, (char **)&iso_date, 10);
|
|
|
|
if (*iso_date == ':')
|
|
|
|
{
|
|
|
|
/* hh:mm:ss */
|
|
|
|
tm.tm_hour = val;
|
|
|
|
iso_date++;
|
|
|
|
tm.tm_min = strtoul (iso_date, (char **)&iso_date, 10);
|
|
|
|
|
|
|
|
if (*iso_date++ != ':')
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
tm.tm_sec = strtoul (iso_date, (char **)&iso_date, 10);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* hhmmss */
|
|
|
|
tm.tm_sec = val % 100;
|
|
|
|
tm.tm_min = (val % 10000) / 100;
|
|
|
|
tm.tm_hour = val / 10000;
|
|
|
|
}
|
|
|
|
|
|
|
|
time_->tv_sec = mktime_utc (&tm);
|
|
|
|
time_->tv_usec = 1;
|
|
|
|
|
|
|
|
if (*iso_date == '.')
|
|
|
|
time_->tv_usec = strtoul (iso_date + 1, (char **)&iso_date, 10);
|
|
|
|
|
|
|
|
if (*iso_date == '+' || *iso_date == '-')
|
|
|
|
{
|
|
|
|
gint sign = (*iso_date == '+') ? -1 : 1;
|
|
|
|
|
|
|
|
val = 60 * strtoul (iso_date + 1, (char **)&iso_date, 10);
|
|
|
|
|
|
|
|
if (*iso_date == ':')
|
|
|
|
val = 60 * val + strtoul (iso_date + 1, NULL, 10);
|
|
|
|
else
|
|
|
|
val = 60 * (val / 100) + (val % 100);
|
|
|
|
|
|
|
|
time_->tv_sec += (time_t) (val * sign);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* g_time_val_to_iso8601:
|
|
|
|
* @time_: a #GTimeVal
|
|
|
|
*
|
|
|
|
* Converts @time_ into a ISO 8601 encoded string, relative to the
|
|
|
|
* Coordinated Universal Time (UTC).
|
|
|
|
*
|
|
|
|
* Return value: a newly allocated string containing a ISO 8601 date
|
|
|
|
*
|
2006-03-23 13:38:17 +00:00
|
|
|
* Since: 2.12
|
2006-03-23 02:54:29 +00:00
|
|
|
*/
|
|
|
|
gchar *
|
|
|
|
g_time_val_to_iso8601 (GTimeVal *time_)
|
|
|
|
{
|
|
|
|
gchar *retval;
|
|
|
|
|
|
|
|
g_return_val_if_fail (time_->tv_usec >= 0 && time_->tv_usec < G_USEC_PER_SEC, NULL);
|
|
|
|
|
|
|
|
#define ISO_8601_LEN 21
|
|
|
|
#define ISO_8601_FORMAT "%Y-%m-%dT%H:%M:%SZ"
|
|
|
|
retval = g_new0 (gchar, ISO_8601_LEN + 1);
|
|
|
|
|
|
|
|
strftime (retval, ISO_8601_LEN,
|
|
|
|
ISO_8601_FORMAT,
|
|
|
|
gmtime (&(time_->tv_sec)));
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2005-03-14 04:26:57 +00:00
|
|
|
#define __G_TIMER_C__
|
|
|
|
#include "galiasdef.c"
|