1998-06-11 01:21:14 +02:00
|
|
|
|
/* GLIB - Library of useful routines for C programming
|
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
|
*
|
2022-05-18 10:15:38 +02:00
|
|
|
|
* SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
|
*
|
1998-06-11 01:21:14 +02:00
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 13:02:02 +02:00
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1998-06-11 01:21:14 +02:00
|
|
|
|
* License as published by the Free Software Foundation; either
|
2017-01-05 12:47:07 +01:00
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
1998-06-11 01:21:14 +02:00
|
|
|
|
*
|
|
|
|
|
* 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 13:02:02 +02:00
|
|
|
|
* Lesser General Public License for more details.
|
1998-06-11 01:21:14 +02:00
|
|
|
|
*
|
2000-07-26 13:02:02 +02:00
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2014-01-23 12:58:29 +01:00
|
|
|
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
1998-06-11 01:21:14 +02:00
|
|
|
|
*/
|
1998-11-01 05:19:54 +01:00
|
|
|
|
|
1999-02-24 07:14:27 +01:00
|
|
|
|
/*
|
2000-07-26 13:02:02 +02:00
|
|
|
|
* Modified by the GLib Team and others 1997-2000. See the AUTHORS
|
1999-02-24 07:14:27 +01: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
|
2010-09-04 05:03:14 +02:00
|
|
|
|
* GLib at ftp://ftp.gtk.org/pub/gtk/.
|
1999-02-24 07:14:27 +01:00
|
|
|
|
*/
|
|
|
|
|
|
2010-09-04 05:03:14 +02:00
|
|
|
|
/*
|
1998-12-15 06:28:02 +01:00
|
|
|
|
* MT safe
|
|
|
|
|
*/
|
|
|
|
|
|
2002-12-04 02:27:44 +01:00
|
|
|
|
#include "config.h"
|
2002-12-05 21:33:26 +01:00
|
|
|
|
#include "glibconfig.h"
|
1998-11-01 05:19:54 +01:00
|
|
|
|
|
2006-03-23 03:54:29 +01:00
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
Replace #ifdef HAVE_UNISTD_H checks with #ifdef G_OS_UNIX
In Windows development environments that have it, <unistd.h> is mostly
just a wrapper around several other native headers (in particular,
<io.h>, which contains read(), close(), etc, and <process.h>, which
contains getpid()). But given that some Windows dev environments don't
have <unistd.h>, everything that uses those functions on Windows
already needed to include the correct Windows header as well, and so
there is never any point to including <unistd.h> on Windows.
Also, remove some <unistd.h> includes (and a few others) that were
unnecessary even on unix.
https://bugzilla.gnome.org/show_bug.cgi?id=710519
2013-10-19 19:04:00 +02:00
|
|
|
|
#ifdef G_OS_UNIX
|
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 05:11:34 +01:00
|
|
|
|
#include <unistd.h>
|
Replace #ifdef HAVE_UNISTD_H checks with #ifdef G_OS_UNIX
In Windows development environments that have it, <unistd.h> is mostly
just a wrapper around several other native headers (in particular,
<io.h>, which contains read(), close(), etc, and <process.h>, which
contains getpid()). But given that some Windows dev environments don't
have <unistd.h>, everything that uses those functions on Windows
already needed to include the correct Windows header as well, and so
there is never any point to including <unistd.h> on Windows.
Also, remove some <unistd.h> includes (and a few others) that were
unnecessary even on unix.
https://bugzilla.gnome.org/show_bug.cgi?id=710519
2013-10-19 19:04:00 +02:00
|
|
|
|
#endif /* G_OS_UNIX */
|
2002-12-05 21:33:26 +01:00
|
|
|
|
|
2010-11-09 02:53:12 +01:00
|
|
|
|
#ifdef HAVE_SYS_TIME_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 05:11:34 +01:00
|
|
|
|
#include <sys/time.h>
|
2010-11-09 02:53:12 +01:00
|
|
|
|
#endif
|
2001-06-07 15:46:14 +02:00
|
|
|
|
#include <time.h>
|
2010-09-06 14:56:16 +02:00
|
|
|
|
#ifndef G_OS_WIN32
|
2001-06-07 15:46:14 +02:00
|
|
|
|
#include <errno.h>
|
1999-10-04 04:32:50 +02:00
|
|
|
|
#endif /* G_OS_WIN32 */
|
1998-06-11 01:21:14 +02:00
|
|
|
|
|
1999-10-04 04:32:50 +02: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 05:11:34 +01:00
|
|
|
|
#include <windows.h>
|
1999-10-04 04:32:50 +02:00
|
|
|
|
#endif /* G_OS_WIN32 */
|
1998-06-11 01:21:14 +02:00
|
|
|
|
|
2010-09-04 05:03:14 +02:00
|
|
|
|
#include "gtimer.h"
|
|
|
|
|
|
|
|
|
|
#include "gmem.h"
|
|
|
|
|
#include "gstrfuncs.h"
|
|
|
|
|
#include "gtestutils.h"
|
2010-11-09 13:32:39 +01:00
|
|
|
|
#include "gmain.h"
|
2002-12-04 02:27:44 +01:00
|
|
|
|
|
2010-01-31 04:12:22 +01:00
|
|
|
|
/**
|
|
|
|
|
* GTimer:
|
|
|
|
|
*
|
2023-09-25 14:42:49 +02:00
|
|
|
|
* `GTimer` records a start time, and counts microseconds elapsed since
|
|
|
|
|
* that time.
|
|
|
|
|
*
|
|
|
|
|
* This is done somewhat differently on different platforms, and can be
|
|
|
|
|
* tricky to get exactly right, so `GTimer` provides a portable/convenient interface.
|
|
|
|
|
*/
|
2001-09-19 20:08:19 +02:00
|
|
|
|
struct _GTimer
|
1998-06-11 01:21:14 +02:00
|
|
|
|
{
|
2005-03-20 12:35:48 +01:00
|
|
|
|
guint64 start;
|
|
|
|
|
guint64 end;
|
1998-06-11 01:21:14 +02: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 05:11:34 +01:00
|
|
|
|
guint active : 1;
|
|
|
|
|
};
|
1998-06-11 01:21:14 +02:00
|
|
|
|
|
2010-01-31 04:12:22 +01:00
|
|
|
|
/**
|
2023-09-11 11:55:45 +02:00
|
|
|
|
* g_timer_new: (constructor)
|
2010-01-31 04:12:22 +01:00
|
|
|
|
*
|
|
|
|
|
* Creates a new timer, and starts timing (i.e. g_timer_start() is
|
|
|
|
|
* implicitly called for you).
|
2012-10-31 02:56:00 +01:00
|
|
|
|
*
|
2023-09-11 11:55:45 +02:00
|
|
|
|
* Returns: (transfer full): a new #GTimer.
|
2010-01-31 04:12:22 +01:00
|
|
|
|
**/
|
1998-06-11 01:21:14 +02:00
|
|
|
|
GTimer*
|
|
|
|
|
g_timer_new (void)
|
|
|
|
|
{
|
2001-09-19 20:08:19 +02:00
|
|
|
|
GTimer *timer;
|
1998-06-11 01:21:14 +02:00
|
|
|
|
|
2001-09-19 20:08:19 +02:00
|
|
|
|
timer = g_new (GTimer, 1);
|
1998-06-11 01:21:14 +02:00
|
|
|
|
timer->active = TRUE;
|
|
|
|
|
|
2010-11-09 13:32:39 +01:00
|
|
|
|
timer->start = g_get_monotonic_time ();
|
1998-06-11 01:21:14 +02:00
|
|
|
|
|
2001-09-19 20:08:19 +02:00
|
|
|
|
return timer;
|
1998-06-11 01:21:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-01-31 04:12:22 +01:00
|
|
|
|
/**
|
|
|
|
|
* g_timer_destroy:
|
|
|
|
|
* @timer: a #GTimer to destroy.
|
|
|
|
|
*
|
|
|
|
|
* Destroys a timer, freeing associated resources.
|
|
|
|
|
**/
|
1998-06-11 01:21:14 +02:00
|
|
|
|
void
|
|
|
|
|
g_timer_destroy (GTimer *timer)
|
|
|
|
|
{
|
1999-03-17 02:05:49 +01:00
|
|
|
|
g_return_if_fail (timer != NULL);
|
1998-06-11 01:21:14 +02:00
|
|
|
|
|
|
|
|
|
g_free (timer);
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-31 04:12:22 +01:00
|
|
|
|
/**
|
|
|
|
|
* g_timer_start:
|
|
|
|
|
* @timer: a #GTimer.
|
|
|
|
|
*
|
|
|
|
|
* Marks a start time, so that future calls to g_timer_elapsed() will
|
|
|
|
|
* report the time since g_timer_start() was called. g_timer_new()
|
|
|
|
|
* automatically marks the start time, so no need to call
|
|
|
|
|
* g_timer_start() immediately after creating the timer.
|
|
|
|
|
**/
|
1998-06-11 01:21:14 +02:00
|
|
|
|
void
|
|
|
|
|
g_timer_start (GTimer *timer)
|
|
|
|
|
{
|
1999-03-17 02:05:49 +01:00
|
|
|
|
g_return_if_fail (timer != NULL);
|
1998-06-11 01:21:14 +02:00
|
|
|
|
|
2001-09-19 20:08:19 +02: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 05:11:34 +01:00
|
|
|
|
|
2010-11-09 13:32:39 +01:00
|
|
|
|
timer->start = g_get_monotonic_time ();
|
1998-06-11 01:21:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-01-31 04:12:22 +01:00
|
|
|
|
/**
|
|
|
|
|
* g_timer_stop:
|
|
|
|
|
* @timer: a #GTimer.
|
|
|
|
|
*
|
|
|
|
|
* Marks an end time, so calls to g_timer_elapsed() will return the
|
|
|
|
|
* difference between this end time and the start time.
|
|
|
|
|
**/
|
1998-06-11 01:21:14 +02:00
|
|
|
|
void
|
|
|
|
|
g_timer_stop (GTimer *timer)
|
|
|
|
|
{
|
1999-03-17 02:05:49 +01:00
|
|
|
|
g_return_if_fail (timer != NULL);
|
1998-06-11 01:21:14 +02:00
|
|
|
|
|
2001-09-19 20:08:19 +02: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 05:11:34 +01:00
|
|
|
|
|
2010-11-09 13:32:39 +01:00
|
|
|
|
timer->end = g_get_monotonic_time ();
|
1998-06-11 01:21:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-01-31 04:12:22 +01:00
|
|
|
|
/**
|
|
|
|
|
* g_timer_reset:
|
|
|
|
|
* @timer: a #GTimer.
|
|
|
|
|
*
|
|
|
|
|
* This function is useless; it's fine to call g_timer_start() on an
|
|
|
|
|
* already-started timer to reset the start time, so g_timer_reset()
|
|
|
|
|
* serves no purpose.
|
|
|
|
|
**/
|
1998-06-11 01:21:14 +02:00
|
|
|
|
void
|
|
|
|
|
g_timer_reset (GTimer *timer)
|
|
|
|
|
{
|
1999-03-17 02:05:49 +01:00
|
|
|
|
g_return_if_fail (timer != NULL);
|
1998-06-11 01:21:14 +02:00
|
|
|
|
|
2010-11-09 13:32:39 +01:00
|
|
|
|
timer->start = g_get_monotonic_time ();
|
1998-06-11 01:21:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-01-31 04:12:22 +01:00
|
|
|
|
/**
|
|
|
|
|
* g_timer_continue:
|
|
|
|
|
* @timer: a #GTimer.
|
|
|
|
|
*
|
|
|
|
|
* Resumes a timer that has previously been stopped with
|
|
|
|
|
* g_timer_stop(). g_timer_stop() must be called before using this
|
|
|
|
|
* function.
|
2010-01-31 04:58:43 +01:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.4
|
2010-01-31 04:12:22 +01:00
|
|
|
|
**/
|
2004-01-22 20:56:28 +01:00
|
|
|
|
void
|
|
|
|
|
g_timer_continue (GTimer *timer)
|
|
|
|
|
{
|
2005-03-20 12:35:48 +01:00
|
|
|
|
guint64 elapsed;
|
2004-01-22 20:56:28 +01:00
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
elapsed = timer->end - timer->start;
|
|
|
|
|
|
2010-11-09 13:32:39 +01:00
|
|
|
|
timer->start = g_get_monotonic_time ();
|
2004-01-22 20:56:28 +01:00
|
|
|
|
|
|
|
|
|
timer->start -= elapsed;
|
|
|
|
|
|
|
|
|
|
timer->active = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-31 04:12:22 +01:00
|
|
|
|
/**
|
|
|
|
|
* g_timer_elapsed:
|
|
|
|
|
* @timer: a #GTimer.
|
|
|
|
|
* @microseconds: return location for the fractional part of seconds
|
|
|
|
|
* elapsed, in microseconds (that is, the total number
|
|
|
|
|
* of microseconds elapsed, modulo 1000000), or %NULL
|
|
|
|
|
*
|
|
|
|
|
* If @timer has been started but not stopped, obtains the time since
|
|
|
|
|
* the timer was started. If @timer has been stopped, obtains the
|
|
|
|
|
* elapsed time between the time it was started and the time it was
|
|
|
|
|
* stopped. The return value is the number of seconds elapsed,
|
|
|
|
|
* including any fractional part. The @microseconds out parameter is
|
|
|
|
|
* essentially useless.
|
2012-10-31 02:56:00 +01:00
|
|
|
|
*
|
|
|
|
|
* Returns: seconds elapsed as a floating point value, including any
|
|
|
|
|
* fractional part.
|
2010-01-31 04:12:22 +01:00
|
|
|
|
**/
|
1998-06-11 01:21:14 +02:00
|
|
|
|
gdouble
|
|
|
|
|
g_timer_elapsed (GTimer *timer,
|
2010-11-09 02:53:12 +01:00
|
|
|
|
gulong *microseconds)
|
1998-06-11 01:21:14 +02:00
|
|
|
|
{
|
|
|
|
|
gdouble total;
|
2005-03-20 12:35:48 +01:00
|
|
|
|
gint64 elapsed;
|
1998-06-11 01:21:14 +02: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 05:11:34 +01:00
|
|
|
|
g_return_val_if_fail (timer != NULL, 0);
|
1998-06-11 01:21:14 +02:00
|
|
|
|
|
2001-09-19 20:08:19 +02:00
|
|
|
|
if (timer->active)
|
2010-11-09 13:32:39 +01:00
|
|
|
|
timer->end = g_get_monotonic_time ();
|
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 05:11:34 +01:00
|
|
|
|
|
2005-03-20 12:35:48 +01:00
|
|
|
|
elapsed = timer->end - timer->start;
|
|
|
|
|
|
2010-11-22 03:59:57 +01:00
|
|
|
|
total = elapsed / 1e6;
|
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 05:11:34 +01:00
|
|
|
|
|
|
|
|
|
if (microseconds)
|
2010-11-22 03:59:57 +01:00
|
|
|
|
*microseconds = elapsed % 1000000;
|
1998-06-11 01:21:14 +02: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 17:39:31 +02:00
|
|
|
|
|
2019-06-21 12:22:41 +02:00
|
|
|
|
/**
|
|
|
|
|
* g_timer_is_active:
|
|
|
|
|
* @timer: a #GTimer.
|
|
|
|
|
*
|
|
|
|
|
* Exposes whether the timer is currently active.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the timer is running, %FALSE otherwise
|
|
|
|
|
* Since: 2.62
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
g_timer_is_active (GTimer *timer)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (timer != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
return timer->active;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-14 13:44:52 +01:00
|
|
|
|
/**
|
|
|
|
|
* g_usleep:
|
|
|
|
|
* @microseconds: number of microseconds to pause
|
|
|
|
|
*
|
|
|
|
|
* Pauses the current thread for the given number of microseconds.
|
|
|
|
|
*
|
|
|
|
|
* There are 1 million microseconds per second (represented by the
|
2022-03-04 17:21:55 +01:00
|
|
|
|
* %G_USEC_PER_SEC macro). g_usleep() may have limited precision,
|
2011-11-14 13:44:52 +01:00
|
|
|
|
* depending on hardware and operating system; don't rely on the exact
|
|
|
|
|
* length of the sleep.
|
|
|
|
|
*/
|
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 17:39:31 +02:00
|
|
|
|
void
|
|
|
|
|
g_usleep (gulong microseconds)
|
|
|
|
|
{
|
2023-04-14 20:06:26 +02:00
|
|
|
|
if G_UNLIKELY (microseconds == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
1999-10-04 04:32:50 +02:00
|
|
|
|
#ifdef G_OS_WIN32
|
2018-05-10 20:30:49 +02:00
|
|
|
|
/* Round up to the next millisecond */
|
|
|
|
|
Sleep (microseconds ? (1 + (microseconds - 1) / 1000) : 0);
|
2010-11-09 13:32:39 +01:00
|
|
|
|
#else
|
2001-06-07 15:46:14 +02:00
|
|
|
|
struct timespec request, remaining;
|
|
|
|
|
request.tv_sec = microseconds / G_USEC_PER_SEC;
|
|
|
|
|
request.tv_nsec = 1000 * (microseconds % G_USEC_PER_SEC);
|
2005-02-23 03:33:54 +01:00
|
|
|
|
while (nanosleep (&request, &remaining) == -1 && errno == EINTR)
|
|
|
|
|
request = remaining;
|
2010-11-09 13:32:39 +01:00
|
|
|
|
#endif
|
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 17:39:31 +02:00
|
|
|
|
}
|
|
|
|
|
|
2001-06-07 15:46:14 +02:00
|
|
|
|
/**
|
|
|
|
|
* g_time_val_add:
|
2002-11-29 00:11:58 +01:00
|
|
|
|
* @time_: a #GTimeVal
|
2001-06-07 15:46:14 +02:00
|
|
|
|
* @microseconds: number of microseconds to add to @time
|
|
|
|
|
*
|
2002-11-29 00:11:58 +01:00
|
|
|
|
* Adds the given number of microseconds to @time_. @microseconds can
|
|
|
|
|
* also be negative to decrease the value of @time_.
|
2019-06-18 13:35:09 +02:00
|
|
|
|
*
|
|
|
|
|
* Deprecated: 2.62: #GTimeVal is not year-2038-safe. Use `guint64` for
|
|
|
|
|
* representing microseconds since the epoch, or use #GDateTime.
|
2001-06-07 15:46:14 +02:00
|
|
|
|
**/
|
2019-06-18 13:35:09 +02:00
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
2001-06-07 15:46:14 +02:00
|
|
|
|
void
|
2002-11-29 00:11:58 +01:00
|
|
|
|
g_time_val_add (GTimeVal *time_, glong microseconds)
|
2001-06-07 15:46:14 +02:00
|
|
|
|
{
|
2022-02-22 23:34:09 +01:00
|
|
|
|
g_return_if_fail (time_ != NULL &&
|
|
|
|
|
time_->tv_usec >= 0 &&
|
|
|
|
|
time_->tv_usec < G_USEC_PER_SEC);
|
2001-06-07 15:46:14 +02:00
|
|
|
|
|
|
|
|
|
if (microseconds >= 0)
|
|
|
|
|
{
|
2002-11-29 00:11:58 +01: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 15:46:14 +02:00
|
|
|
|
{
|
2002-11-29 00:11:58 +01:00
|
|
|
|
time_->tv_usec -= G_USEC_PER_SEC;
|
|
|
|
|
time_->tv_sec++;
|
2001-06-07 15:46:14 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
microseconds *= -1;
|
2002-11-29 00:11:58 +01: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 15:46:14 +02:00
|
|
|
|
{
|
2002-11-29 00:11:58 +01:00
|
|
|
|
time_->tv_usec += G_USEC_PER_SEC;
|
|
|
|
|
time_->tv_sec--;
|
2001-06-07 15:46:14 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-06-18 13:35:09 +02:00
|
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS
|
2005-03-14 05:26:57 +01:00
|
|
|
|
|
2013-12-29 19:43:28 +01:00
|
|
|
|
/* converts a broken down date representation, relative to UTC,
|
|
|
|
|
* to a timestamp; it uses timegm() if it's available.
|
2006-03-23 03:54:29 +01:00
|
|
|
|
*/
|
|
|
|
|
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;
|
|
|
|
|
|
2006-06-20 18:37:43 +02:00
|
|
|
|
if (tm->tm_year % 4 == 0 && tm->tm_mon < 2)
|
2006-03-23 03:54:29 +01:00
|
|
|
|
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:
|
2008-06-19 06:14:25 +02:00
|
|
|
|
* @iso_date: an ISO 8601 encoded date string
|
2011-09-10 06:35:09 +02:00
|
|
|
|
* @time_: (out): a #GTimeVal
|
2006-03-23 03:54:29 +01:00
|
|
|
|
*
|
|
|
|
|
* Converts a string containing an ISO 8601 encoded date and time
|
|
|
|
|
* to a #GTimeVal and puts it into @time_.
|
|
|
|
|
*
|
2011-10-12 01:28:59 +02:00
|
|
|
|
* @iso_date must include year, month, day, hours, minutes, and
|
|
|
|
|
* seconds. It can optionally include fractions of a second and a time
|
|
|
|
|
* zone indicator. (In the absence of any time zone indication, the
|
|
|
|
|
* timestamp is assumed to be in local time.)
|
|
|
|
|
*
|
2018-08-03 15:19:21 +02:00
|
|
|
|
* Any leading or trailing space in @iso_date is ignored.
|
|
|
|
|
*
|
2019-06-18 13:35:09 +02:00
|
|
|
|
* This function was deprecated, along with #GTimeVal itself, in GLib 2.62.
|
|
|
|
|
* Equivalent functionality is available using code like:
|
|
|
|
|
* |[
|
|
|
|
|
* GDateTime *dt = g_date_time_new_from_iso8601 (iso8601_string, NULL);
|
|
|
|
|
* gint64 time_val = g_date_time_to_unix (dt);
|
|
|
|
|
* g_date_time_unref (dt);
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
2014-02-20 01:35:23 +01:00
|
|
|
|
* Returns: %TRUE if the conversion was successful.
|
2006-03-23 03:54:29 +01:00
|
|
|
|
*
|
2006-03-23 14:38:17 +01:00
|
|
|
|
* Since: 2.12
|
2019-06-18 13:35:09 +02:00
|
|
|
|
* Deprecated: 2.62: #GTimeVal is not year-2038-safe. Use
|
|
|
|
|
* g_date_time_new_from_iso8601() instead.
|
2006-03-23 03:54:29 +01:00
|
|
|
|
*/
|
2019-06-18 13:35:09 +02:00
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
2006-03-23 03:54:29 +01:00
|
|
|
|
gboolean
|
|
|
|
|
g_time_val_from_iso8601 (const gchar *iso_date,
|
|
|
|
|
GTimeVal *time_)
|
|
|
|
|
{
|
2009-12-02 01:48:30 +01:00
|
|
|
|
struct tm tm = {0};
|
2006-03-23 03:54:29 +01:00
|
|
|
|
long val;
|
2018-08-03 15:20:29 +02:00
|
|
|
|
long mday, mon, year;
|
|
|
|
|
long hour, min, sec;
|
2006-03-23 03:54:29 +01:00
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (iso_date != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (time_ != NULL, FALSE);
|
|
|
|
|
|
2013-12-29 19:43:28 +01:00
|
|
|
|
/* Ensure that the first character is a digit, the first digit
|
|
|
|
|
* of the date, otherwise we don't have an ISO 8601 date
|
|
|
|
|
*/
|
2007-12-13 15:44:37 +01:00
|
|
|
|
while (g_ascii_isspace (*iso_date))
|
|
|
|
|
iso_date++;
|
2007-12-19 18:28:38 +01:00
|
|
|
|
|
2007-12-13 15:44:37 +01:00
|
|
|
|
if (*iso_date == '\0')
|
|
|
|
|
return FALSE;
|
2007-12-19 18:28:38 +01:00
|
|
|
|
|
2018-08-06 14:58:06 +02:00
|
|
|
|
if (!g_ascii_isdigit (*iso_date) && *iso_date != '+')
|
2007-12-13 15:44:37 +01:00
|
|
|
|
return FALSE;
|
|
|
|
|
|
2006-03-23 03:54:29 +01:00
|
|
|
|
val = strtoul (iso_date, (char **)&iso_date, 10);
|
|
|
|
|
if (*iso_date == '-')
|
|
|
|
|
{
|
|
|
|
|
/* YYYY-MM-DD */
|
2018-08-03 15:20:29 +02:00
|
|
|
|
year = val;
|
2006-03-23 03:54:29 +01:00
|
|
|
|
iso_date++;
|
2018-08-03 15:20:29 +02:00
|
|
|
|
|
|
|
|
|
mon = strtoul (iso_date, (char **)&iso_date, 10);
|
2006-03-23 03:54:29 +01:00
|
|
|
|
if (*iso_date++ != '-')
|
2009-12-02 01:48:30 +01:00
|
|
|
|
return FALSE;
|
2006-03-23 03:54:29 +01:00
|
|
|
|
|
2018-08-03 15:20:29 +02:00
|
|
|
|
mday = strtoul (iso_date, (char **)&iso_date, 10);
|
2006-03-23 03:54:29 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* YYYYMMDD */
|
2018-08-03 15:20:29 +02:00
|
|
|
|
mday = val % 100;
|
|
|
|
|
mon = (val % 10000) / 100;
|
|
|
|
|
year = val / 10000;
|
2006-03-23 03:54:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-03 15:20:29 +02:00
|
|
|
|
/* Validation. */
|
|
|
|
|
if (year < 1900 || year > G_MAXINT)
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (mon < 1 || mon > 12)
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (mday < 1 || mday > 31)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
tm.tm_mday = mday;
|
|
|
|
|
tm.tm_mon = mon - 1;
|
|
|
|
|
tm.tm_year = year - 1900;
|
|
|
|
|
|
2010-08-24 23:18:23 +02:00
|
|
|
|
if (*iso_date != 'T')
|
2013-12-29 19:43:28 +01:00
|
|
|
|
return FALSE;
|
2010-08-24 23:18:23 +02:00
|
|
|
|
|
2010-09-04 19:03:33 +02:00
|
|
|
|
iso_date++;
|
2010-08-24 23:18:23 +02:00
|
|
|
|
|
|
|
|
|
/* If there is a 'T' then there has to be a time */
|
|
|
|
|
if (!g_ascii_isdigit (*iso_date))
|
2006-03-23 03:54:29 +01:00
|
|
|
|
return FALSE;
|
2010-08-24 23:18:23 +02:00
|
|
|
|
|
2006-03-23 03:54:29 +01:00
|
|
|
|
val = strtoul (iso_date, (char **)&iso_date, 10);
|
|
|
|
|
if (*iso_date == ':')
|
|
|
|
|
{
|
|
|
|
|
/* hh:mm:ss */
|
2018-08-03 15:20:29 +02:00
|
|
|
|
hour = val;
|
2006-03-23 03:54:29 +01:00
|
|
|
|
iso_date++;
|
2018-08-03 15:20:29 +02:00
|
|
|
|
min = strtoul (iso_date, (char **)&iso_date, 10);
|
2006-03-23 03:54:29 +01:00
|
|
|
|
|
|
|
|
|
if (*iso_date++ != ':')
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2018-08-03 15:20:29 +02:00
|
|
|
|
sec = strtoul (iso_date, (char **)&iso_date, 10);
|
2006-03-23 03:54:29 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* hhmmss */
|
2018-08-03 15:20:29 +02:00
|
|
|
|
sec = val % 100;
|
|
|
|
|
min = (val % 10000) / 100;
|
|
|
|
|
hour = val / 10000;
|
2006-03-23 03:54:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-03 15:20:29 +02:00
|
|
|
|
/* Validation. Allow up to 2 leap seconds when validating @sec. */
|
|
|
|
|
if (hour > 23)
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (min > 59)
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (sec > 61)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
tm.tm_hour = hour;
|
|
|
|
|
tm.tm_min = min;
|
|
|
|
|
tm.tm_sec = sec;
|
|
|
|
|
|
2008-06-19 06:14:25 +02:00
|
|
|
|
time_->tv_usec = 0;
|
2006-03-23 03:54:29 +01:00
|
|
|
|
|
2009-04-08 16:26:11 +02:00
|
|
|
|
if (*iso_date == ',' || *iso_date == '.')
|
2008-06-19 06:14:25 +02:00
|
|
|
|
{
|
|
|
|
|
glong mul = 100000;
|
|
|
|
|
|
2018-08-03 15:20:29 +02:00
|
|
|
|
while (mul >= 1 && g_ascii_isdigit (*++iso_date))
|
2008-06-19 06:14:25 +02:00
|
|
|
|
{
|
|
|
|
|
time_->tv_usec += (*iso_date - '0') * mul;
|
|
|
|
|
mul /= 10;
|
|
|
|
|
}
|
2018-08-03 15:20:29 +02:00
|
|
|
|
|
|
|
|
|
/* Skip any remaining digits after we’ve reached our limit of precision. */
|
|
|
|
|
while (g_ascii_isdigit (*iso_date))
|
|
|
|
|
iso_date++;
|
2008-06-19 06:14:25 +02:00
|
|
|
|
}
|
2006-03-23 03:54:29 +01:00
|
|
|
|
|
2009-09-01 15:37:48 +02:00
|
|
|
|
/* Now parse the offset and convert tm to a time_t */
|
|
|
|
|
if (*iso_date == 'Z')
|
|
|
|
|
{
|
|
|
|
|
iso_date++;
|
|
|
|
|
time_->tv_sec = mktime_utc (&tm);
|
|
|
|
|
}
|
|
|
|
|
else if (*iso_date == '+' || *iso_date == '-')
|
2006-03-23 03:54:29 +01:00
|
|
|
|
{
|
|
|
|
|
gint sign = (*iso_date == '+') ? -1 : 1;
|
|
|
|
|
|
2009-04-08 16:26:11 +02:00
|
|
|
|
val = strtoul (iso_date + 1, (char **)&iso_date, 10);
|
2006-03-23 03:54:29 +01:00
|
|
|
|
|
|
|
|
|
if (*iso_date == ':')
|
2018-08-03 15:20:29 +02:00
|
|
|
|
{
|
|
|
|
|
/* hh:mm */
|
|
|
|
|
hour = val;
|
|
|
|
|
min = strtoul (iso_date + 1, (char **)&iso_date, 10);
|
|
|
|
|
}
|
2006-03-23 03:54:29 +01:00
|
|
|
|
else
|
2018-08-03 15:20:29 +02:00
|
|
|
|
{
|
|
|
|
|
/* hhmm */
|
|
|
|
|
hour = val / 100;
|
|
|
|
|
min = val % 100;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (hour > 99)
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (min > 59)
|
|
|
|
|
return FALSE;
|
2006-03-23 03:54:29 +01:00
|
|
|
|
|
2018-08-10 11:43:37 +02:00
|
|
|
|
time_->tv_sec = mktime_utc (&tm) + (time_t) (60 * (gint64) (60 * hour + min) * sign);
|
2009-09-01 15:37:48 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* No "Z" or offset, so local time */
|
2009-12-02 01:48:30 +01:00
|
|
|
|
tm.tm_isdst = -1; /* locale selects DST */
|
2009-09-01 15:37:48 +02:00
|
|
|
|
time_->tv_sec = mktime (&tm);
|
2006-03-23 03:54:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
2008-06-19 06:14:25 +02:00
|
|
|
|
while (g_ascii_isspace (*iso_date))
|
|
|
|
|
iso_date++;
|
|
|
|
|
|
|
|
|
|
return *iso_date == '\0';
|
2006-03-23 03:54:29 +01:00
|
|
|
|
}
|
2019-06-18 13:35:09 +02:00
|
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS
|
2006-03-23 03:54:29 +01:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* g_time_val_to_iso8601:
|
|
|
|
|
* @time_: a #GTimeVal
|
|
|
|
|
*
|
2011-10-18 12:14:20 +02:00
|
|
|
|
* Converts @time_ into an RFC 3339 encoded string, relative to the
|
|
|
|
|
* Coordinated Universal Time (UTC). This is one of the many formats
|
|
|
|
|
* allowed by ISO 8601.
|
|
|
|
|
*
|
|
|
|
|
* ISO 8601 allows a large number of date/time formats, with or without
|
|
|
|
|
* punctuation and optional elements. The format returned by this function
|
|
|
|
|
* is a complete date and time, with optional punctuation included, the
|
|
|
|
|
* UTC time zone represented as "Z", and the @tv_usec part included if
|
|
|
|
|
* and only if it is nonzero, i.e. either
|
|
|
|
|
* "YYYY-MM-DDTHH:MM:SSZ" or "YYYY-MM-DDTHH:MM:SS.fffffZ".
|
|
|
|
|
*
|
|
|
|
|
* This corresponds to the Internet date/time format defined by
|
2014-02-06 03:23:28 +01:00
|
|
|
|
* [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt),
|
|
|
|
|
* and to either of the two most-precise formats defined by
|
|
|
|
|
* the W3C Note
|
|
|
|
|
* [Date and Time Formats](http://www.w3.org/TR/NOTE-datetime-19980827).
|
|
|
|
|
* Both of these documents are profiles of ISO 8601.
|
2011-10-18 12:14:20 +02:00
|
|
|
|
*
|
|
|
|
|
* Use g_date_time_format() or g_strdup_printf() if a different
|
|
|
|
|
* variation of ISO 8601 format is required.
|
2006-03-23 03:54:29 +01:00
|
|
|
|
*
|
2017-05-02 16:53:13 +02:00
|
|
|
|
* If @time_ represents a date which is too large to fit into a `struct tm`,
|
2018-09-04 12:15:25 +02:00
|
|
|
|
* %NULL will be returned. This is platform dependent. Note also that since
|
|
|
|
|
* `GTimeVal` stores the number of seconds as a `glong`, on 32-bit systems it
|
2019-06-18 13:35:09 +02:00
|
|
|
|
* is subject to the year 2038 problem. Accordingly, since GLib 2.62, this
|
|
|
|
|
* function has been deprecated. Equivalent functionality is available using:
|
|
|
|
|
* |[
|
|
|
|
|
* GDateTime *dt = g_date_time_new_from_unix_utc (time_val);
|
|
|
|
|
* iso8601_string = g_date_time_format_iso8601 (dt);
|
|
|
|
|
* g_date_time_unref (dt);
|
|
|
|
|
* ]|
|
2018-09-04 12:15:25 +02:00
|
|
|
|
*
|
|
|
|
|
* The return value of g_time_val_to_iso8601() has been nullable since GLib
|
|
|
|
|
* 2.54; before then, GLib would crash under the same conditions.
|
2017-05-02 16:53:13 +02:00
|
|
|
|
*
|
|
|
|
|
* Returns: (nullable): a newly allocated string containing an ISO 8601 date,
|
|
|
|
|
* or %NULL if @time_ was too large
|
2006-03-23 03:54:29 +01:00
|
|
|
|
*
|
2006-03-23 14:38:17 +01:00
|
|
|
|
* Since: 2.12
|
2019-06-18 13:35:09 +02:00
|
|
|
|
* Deprecated: 2.62: #GTimeVal is not year-2038-safe. Use
|
|
|
|
|
* g_date_time_format_iso8601(dt) instead.
|
2006-03-23 03:54:29 +01:00
|
|
|
|
*/
|
2019-06-18 13:35:09 +02:00
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
2006-03-23 03:54:29 +01:00
|
|
|
|
gchar *
|
|
|
|
|
g_time_val_to_iso8601 (GTimeVal *time_)
|
|
|
|
|
{
|
|
|
|
|
gchar *retval;
|
2008-06-19 06:14:25 +02:00
|
|
|
|
struct tm *tm;
|
2008-01-28 07:27:28 +01:00
|
|
|
|
#ifdef HAVE_GMTIME_R
|
|
|
|
|
struct tm tm_;
|
|
|
|
|
#endif
|
2009-01-31 20:19:21 +01:00
|
|
|
|
time_t secs;
|
2017-05-02 16:59:59 +02:00
|
|
|
|
|
2022-02-22 23:34:09 +01:00
|
|
|
|
g_return_val_if_fail (time_ != NULL &&
|
|
|
|
|
time_->tv_usec >= 0 &&
|
|
|
|
|
time_->tv_usec < G_USEC_PER_SEC, NULL);
|
2006-03-23 03:54:29 +01:00
|
|
|
|
|
2017-05-02 16:59:59 +02:00
|
|
|
|
secs = time_->tv_sec;
|
2008-09-16 00:52:12 +02:00
|
|
|
|
#ifdef _WIN32
|
2017-05-02 16:59:59 +02:00
|
|
|
|
tm = gmtime (&secs);
|
Fix problems on 64-bit Windows. Avoid warnings, some of which indicated
2008-07-28 Tor Lillqvist <tml@novell.com>
Fix problems on 64-bit Windows. Avoid warnings, some of which
indicated actual problems, some which were just annoyances.
Where casts to an integer type are needed for pointers, use
gssize. Technically intptr_t would be the more proper type, but we
still want to be compilable with MSVS6 and 7 which don't have
intptr_t. MSVS8 and 9 do have intptr_t, but in <crtdefs.h>, not
<stdint.h>.
Use %p to print out handles. Use gssize casts when assigning
GPollFD::fd fields.
Use G_GSIZE_FORMAT when printing size_t values.
* configure.in: Define automake conditional G_OS_WIN32_X64 which
is true on Win64.
* glib/giochannel.h: Use slightly different prototype for
g_io_channel_win32_new_messages() on Win64 with gsize instead of
guint.
* glib/giowin32.c
* glib/gmain.c
* glib/gspawn-win32.c
* tests/testglib.c: Generic changes as described above.
* glib/gmain.h: Don't bother mentioning GIMP in comment.
* glib/grel.c (tuple_hash_2): Use all bits of pointer.
* glib/gspawn-win32.c
* glib/gspawn-win32-helper.c: Use gssize types in the
communication between parent and helper process, so that we can
pass process handles, which are pointers, also on Win64.
* glib/gtimer.c (g_time_val_to_iso8601): time_t is 64 bits on
Win64 so we can't pass the address of a GTimeVal::tv_sec which is
a long directly to gmtime(). On the other hand, changing
GTimeVal::tv_sec to be a gint64 on Win64 is not really feasible
either, as that would then require changes in much code that uses
GTimeVals.
* glib/gspawn-win32.c
* glib/Makefile.am: Call the helper programs
gspawn-win64-helper.exe and gspawn-win64-helper-console.exe on
Win64, to avoid potential risk of running a 32-bit version of the
helper.
svn path=/trunk/; revision=7260
2008-07-28 02:24:14 +02:00
|
|
|
|
#else
|
2008-01-28 07:27:28 +01:00
|
|
|
|
#ifdef HAVE_GMTIME_R
|
2009-01-31 20:19:21 +01:00
|
|
|
|
tm = gmtime_r (&secs, &tm_);
|
2008-01-28 07:27:28 +01:00
|
|
|
|
#else
|
2009-01-31 20:19:21 +01:00
|
|
|
|
tm = gmtime (&secs);
|
Fix problems on 64-bit Windows. Avoid warnings, some of which indicated
2008-07-28 Tor Lillqvist <tml@novell.com>
Fix problems on 64-bit Windows. Avoid warnings, some of which
indicated actual problems, some which were just annoyances.
Where casts to an integer type are needed for pointers, use
gssize. Technically intptr_t would be the more proper type, but we
still want to be compilable with MSVS6 and 7 which don't have
intptr_t. MSVS8 and 9 do have intptr_t, but in <crtdefs.h>, not
<stdint.h>.
Use %p to print out handles. Use gssize casts when assigning
GPollFD::fd fields.
Use G_GSIZE_FORMAT when printing size_t values.
* configure.in: Define automake conditional G_OS_WIN32_X64 which
is true on Win64.
* glib/giochannel.h: Use slightly different prototype for
g_io_channel_win32_new_messages() on Win64 with gsize instead of
guint.
* glib/giowin32.c
* glib/gmain.c
* glib/gspawn-win32.c
* tests/testglib.c: Generic changes as described above.
* glib/gmain.h: Don't bother mentioning GIMP in comment.
* glib/grel.c (tuple_hash_2): Use all bits of pointer.
* glib/gspawn-win32.c
* glib/gspawn-win32-helper.c: Use gssize types in the
communication between parent and helper process, so that we can
pass process handles, which are pointers, also on Win64.
* glib/gtimer.c (g_time_val_to_iso8601): time_t is 64 bits on
Win64 so we can't pass the address of a GTimeVal::tv_sec which is
a long directly to gmtime(). On the other hand, changing
GTimeVal::tv_sec to be a gint64 on Win64 is not really feasible
either, as that would then require changes in much code that uses
GTimeVals.
* glib/gspawn-win32.c
* glib/Makefile.am: Call the helper programs
gspawn-win64-helper.exe and gspawn-win64-helper-console.exe on
Win64, to avoid potential risk of running a 32-bit version of the
helper.
svn path=/trunk/; revision=7260
2008-07-28 02:24:14 +02:00
|
|
|
|
#endif
|
2008-01-28 07:27:28 +01:00
|
|
|
|
#endif
|
2008-06-19 06:14:25 +02:00
|
|
|
|
|
2017-05-02 16:53:13 +02:00
|
|
|
|
/* If the gmtime() call has failed, time_->tv_sec is too big. */
|
|
|
|
|
if (tm == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2008-06-19 06:14:25 +02:00
|
|
|
|
if (time_->tv_usec != 0)
|
|
|
|
|
{
|
2008-07-21 15:05:24 +02:00
|
|
|
|
/* ISO 8601 date and time format, with fractionary seconds:
|
|
|
|
|
* YYYY-MM-DDTHH:MM:SS.MMMMMMZ
|
|
|
|
|
*/
|
2008-07-21 18:30:16 +02:00
|
|
|
|
retval = g_strdup_printf ("%4d-%02d-%02dT%02d:%02d:%02d.%06ldZ",
|
2008-07-21 15:05:24 +02:00
|
|
|
|
tm->tm_year + 1900,
|
|
|
|
|
tm->tm_mon + 1,
|
|
|
|
|
tm->tm_mday,
|
|
|
|
|
tm->tm_hour,
|
|
|
|
|
tm->tm_min,
|
|
|
|
|
tm->tm_sec,
|
|
|
|
|
time_->tv_usec);
|
2008-06-19 06:14:25 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2008-07-21 15:05:24 +02:00
|
|
|
|
/* ISO 8601 date and time format:
|
|
|
|
|
* YYYY-MM-DDTHH:MM:SSZ
|
|
|
|
|
*/
|
2008-07-21 18:30:16 +02:00
|
|
|
|
retval = g_strdup_printf ("%4d-%02d-%02dT%02d:%02d:%02dZ",
|
2008-07-21 15:05:24 +02:00
|
|
|
|
tm->tm_year + 1900,
|
|
|
|
|
tm->tm_mon + 1,
|
|
|
|
|
tm->tm_mday,
|
|
|
|
|
tm->tm_hour,
|
|
|
|
|
tm->tm_min,
|
|
|
|
|
tm->tm_sec);
|
2008-06-19 06:14:25 +02:00
|
|
|
|
}
|
2006-03-23 03:54:29 +01:00
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
2019-06-18 13:35:09 +02:00
|
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS
|