2008-08-20 19:31:46 +02:00
|
|
|
|
/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
2000-08-16 00:23:59 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2000-08-16 00:23:59 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
1996-07-25 22:56:11 +00:00
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
|
* Lesser General Public License for more details.
|
2000-08-16 00:23:59 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2005-05-23 19:57:22 +00:00
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2003-04-05 19:15:35 +00:00
|
|
|
|
*/
|
1999-12-12 02:36:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2004-09-08 22:14:59 +00:00
|
|
|
|
/* _POSIX_C_SOURCE is not defined always, because it causes problems on some
|
|
|
|
|
|
systems, notably
|
|
|
|
|
|
|
|
|
|
|
|
- FreeBSD loses all BSD and XOPEN defines.
|
|
|
|
|
|
- glibc loses some things like CLK_TCK.
|
|
|
|
|
|
- On MINGW it conflicts with the pthread headers.
|
|
|
|
|
|
|
|
|
|
|
|
But on HP-UX _POSIX_C_SOURCE is needed, as noted, for gmtime_r.
|
|
|
|
|
|
|
|
|
|
|
|
Perhaps a configure test could figure out what _POSIX_C_SOURCE gives and
|
|
|
|
|
|
what it takes away, and decide from that whether to use it, instead of
|
|
|
|
|
|
hard coding __hpux. */
|
|
|
|
|
|
|
2007-08-23 21:10:57 +00:00
|
|
|
|
#ifndef _REENTRANT
|
|
|
|
|
|
# define _REENTRANT /* ask solaris for gmtime_r prototype */
|
|
|
|
|
|
#endif
|
2004-09-08 22:14:59 +00:00
|
|
|
|
#ifdef __hpux
|
2004-04-27 22:43:28 +00:00
|
|
|
|
#define _POSIX_C_SOURCE 199506L /* for gmtime_r prototype */
|
2004-09-03 19:45:37 +00:00
|
|
|
|
#endif
|
2004-03-13 23:32:16 +00:00
|
|
|
|
|
2008-09-13 15:35:27 +02:00
|
|
|
|
#ifdef HAVE_CONFIG_H
|
2003-03-26 00:00:18 +00:00
|
|
|
|
# include <config.h>
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
#include <stdio.h>
|
* _scm.h: Removed #include <errno.h>.
* error.c, net_db.c, putenv.c, stime.c: Removed declaration of
errno variable (can be a macro on some systems, for example when
using linux libc with threads).
* error.c, filesys.c, gc.c, ioext.c, iselect.c, net_db.c, ports.c,
posix.c, print.c, putenv.c, scmsigs.c, script.c, simpos.c, smob.c,
socket.c, srcprop.c, stime.c, strop.c, unif.c, vports.c: Added
#include <errno.h> in these 20 out of 100 files.
2001-03-10 16:56:09 +00:00
|
|
|
|
#include <errno.h>
|
2008-09-02 21:24:53 +02:00
|
|
|
|
#include <strftime.h>
|
* _scm.h: Removed #include <errno.h>.
* error.c, net_db.c, putenv.c, stime.c: Removed declaration of
errno variable (can be a macro on some systems, for example when
using linux libc with threads).
* error.c, filesys.c, gc.c, ioext.c, iselect.c, net_db.c, ports.c,
posix.c, print.c, putenv.c, scmsigs.c, script.c, simpos.c, smob.c,
socket.c, srcprop.c, stime.c, strop.c, unif.c, vports.c: Added
#include <errno.h> in these 20 out of 100 files.
2001-03-10 16:56:09 +00:00
|
|
|
|
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/_scm.h"
|
2005-03-07 21:42:02 +00:00
|
|
|
|
#include "libguile/async.h"
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/feature.h"
|
|
|
|
|
|
#include "libguile/strings.h"
|
|
|
|
|
|
#include "libguile/vectors.h"
|
* strings.h, strings.c: (scm_i_string_chars, scm_i_string_length,
scm_i_string_writable_chars, scm_i_string_stop_writing): New, to
replace SCM_I_STRING_CHARS and SCM_I_STRING_LENGTH. Updated all
uses.
(scm_i_make_string, scm_c_make_string): New, to replace
scm_allocate_string. Updated all uses.
(SCM_STRINGP, SCM_STRING_CHARS, SCM_STRING_UCHARS,
SCM_STRING_LENGTH): Deprecated.
(scm_allocate_string, scm_take_str, scm_take0str, scm_mem2string,
scm_str2string, scm_makfrom0str, scm_makfrom0str_opt):
Discouraged. Replaced all uses with scm_from_locale_string or
similar, as appropriate.
(scm_c_string_length, scm_c_string_ref, scm_c_string_set_x,
scm_c_substring, scm_c_substring_shared, scm_c_substring_copy,
scm_substring_shared, scm_substring_copy): New.
* symbols.c, symbols.h (SCM_SYMBOLP, SCM_SYMBOL_FUNC,
SCM_SET_SYMBOL_FUNC, SCM_SYMBOL_PROPS, SCM_SET_SYMBOL_PROPS,
SCM_SYMBOL_HASH, SCM_SYMBOL_INTERNED_P, scm_mem2symbol,
scm_str2symbol, scm_mem2uninterned_symbol): Discouraged.
(SCM_SYMBOL_LENGTH, SCM_SYMBOL_CHARS, scm_c_symbol2str):
Deprecated.
(SCM_MAKE_SYMBOL_TAG, SCM_SET_SYMBOL_LENGTH, SCM_SET_SYMBOL_CHARS,
SCM_PROP_SLOTS, SCM_SET_PROP_SLOTS): Removed.
(scm_is_symbol, scm_from_locale_symbol, scm_from_locale_symboln):
New, to replace scm_str2symbol and scm_mem2symbol, respectively.
Updated all uses.
(scm_gensym): Generate only the number suffix in the buffer, just
string-append the prefix.
2004-08-19 17:19:44 +00:00
|
|
|
|
#include "libguile/dynwind.h"
|
C files should #include only the header files they need, not
libguile.h (which #includes all the header files); the pointless
recompilation was wasting my time.
* Makefile.in (all .o dependency lists): Regenerated.
* libguile.h: Don't try to get a definition for size_t here...
* __scm.h: Do it here.
* _scm.h: Since this is the internal libguile header, put things
here that all (or a majority) of the libguile files will want.
Don't #include <libguile.h> here; that generates dependencies on
way too much. Instead, get "__scm.h", "error.h", "pairs.h",
"list.h", "gc.h", "gsubr.h", "procs.h", "numbers.h", "symbols.h",
"boolean.h", "strings.h", "vectors.h", "root.h", "ports.h", and
"async.h".
* alist.c: Get "eq.h", "list.h", "alist.h".
* append.c: Get "append.h", "list.h".
* arbiters.c: Get "arbiters.h", "smob.h".
* async.c: Get "async.h", "smob.h", "throw.h", "eval.h".
* boolean.c: Get "boolean.h".
* chars.c: Get "chars.h".
* continuations.c: Get "continuations.h", "dynwind.h", "debug.h",
"stackchk.h".
* debug.c: Get "debug.h", "feature.h", "read.h", "strports.h",
"continuations.h", "alist.h", "srcprop.h", "procprop.h", "smob.h",
"genio.h", "throw.h", "eval.h".
* dynwind.c: Get "dynwind.h", "alist.h", "eval.h".
* eq.c: Get "eq.h", "unif.h", "smob.h", "strorder.h",
"stackchk.h".
* error.c: Get "error.h", "throw.h", "genio.h", "pairs.h".
* eval.c: Get "eval.h", "stackchk.h", "srcprop.h", "debug.h",
"hashtab.h", "procprop.h", "markers.h", "smob.h", "throw.h",
"continuations.h", "eq.h", "sequences.h", "alist.h", "append.h",
"debug.h".
* fdsocket.c: Get "fdsocket.h", "unif.h", "filesys.h".
* feature.c: Get "feature.h".
* files.c: Get "files.h".
* filesys.c: Get "filesys.h", "smob.h", "genio.h".
* fports.c: Get "fports.h", "markers.h".
* gc.c: Get "async.h", "unif.h", "smob.h", "weaks.h",
"genio.h", "struct.h", "stackchk.h", "stime.h".
* gdbint.c: Get "gdbint.h", "chars.h", "eval.h", "print.h",
"read.h", "strports.h", "tag.h".
* genio.c: Get "genio.h", "chars.h".
* gsubr.c: Get "gsubr.h", "genio.h".
* hash.c: Get "hash.h", "chars.h".
* hashtab.c: Get "hashtab.h", "eval.h", "hash.h", "alist.h".
* init.c: Get everyone who has an scm_init_mumble function:
"weaks.h", "vports.h", "version.h", "vectors.h", "variable.h",
"unif.h", "throw.h", "tag.h", "symbols.h", "struct.h",
"strports.h", "strorder.h", "strop.h", "strings.h", "stime.h",
"stackchk.h", "srcprop.h", "socket.h", "simpos.h", "sequences.h",
"scmsigs.h", "read.h", "ramap.h", "procs.h", "procprop.h",
"print.h", "posix.h", "ports.h", "pairs.h", "options.h",
"objprop.h", "numbers.h", "mbstrings.h", "mallocs.h", "load.h",
"list.h", "kw.h", "ioext.h", "hashtab.h", "hash.h", "gsubr.h",
"gdbint.h", "gc.h", "fports.h", "filesys.h", "files.h",
"feature.h", "fdsocket.h", "eval.h", "error.h", "eq.h",
"dynwind.h", "debug.h", "continuations.h", "chars.h", "boolean.h",
"async.h", "arbiters.h", "append.h", "alist.h".
* ioext.c: Get "ioext.h", "fports.h".
* kw.c: Get "kw.h", "smob.h", "mbstrings.h", "genio.h".
* list.c: Get "list.h", "eq.h".
* load.c: Get "load.h", "eval.h", "read.h", "fports.h".
* mallocs.c: Get "smob.h", "genio.h".
* markers.c: Get "markers.h".
* mbstrings.c: Get "mbstrings.h", "read.h", "genio.h", "unif.h",
"chars.h".
* numbers.c: Get "unif.h", "genio.h".
* objprop.c: Get "objprop.h", "weaks.h", "alist.h", "hashtab.h".
* options.c: Get "options.h".
* ports.c: Get "ports.h", "vports.h", "strports.h", "fports.h",
"markers.h", "chars.h", "genio.h".
* posix.c: Get "posix.h", "sequences.h", "feature.h", "unif.h",
"read.h", "scmsigs.h", "genio.h", "fports.h".
* print.c: Get "print.h", "unif.h", "weaks.h", "read.h",
"procprop.h", "eval.h", "smob.h", "mbstrings.h", "genio.h",
"chars.h".
* procprop.c: Get "procprop.h", "eval.h", "alist.h".
* procs.c: Get "procs.h".
* ramap.c: Get "ramap.h", "feature.h", "eval.h", "eq.h",
"chars.h", "smob.h", "unif.h".
* read.c: Get "alist.h", "kw.h", "mbstrings.h", "unif.h",
"eval.h", "genio.h", "chars.h".
* root.c: Get "root.h", "stackchk.h".
* scmsigs.c: Get "scmsigs.h".
* sequences.c: Get "sequences.h".
* simpos.c: Get "simpos.h", "scmsigs.h".
* smob.c: Get "smob.h".
* socket.c: Get "socket.h", "feature.h".
* srcprop.c: Get "srcprop.h", "weaks.h", "hashtab.h", "debug.h",
"alist.h", "smob.h".
* stackchk.c: Get "stackchk.h", "genio.h".
* stime.c: Get "stime.h"."libguile/continuations.h".
* strings.c: Get "strings.h", "chars.h".
* strop.c: Get "strop.h", "chars.h".
* strorder.c: Get "strorder.h", "chars.h".
* strports.c: Get "strports.h", "print.h", "eval.h", "unif.h".
* struct.c: Get "struct.h", "chars.h".
* symbols.c: Get "symbols.h", "mbstrings.h", "alist.h",
"variable.h", "eval.h", "chars.h".
* tag.c: Get "tag.h", "struct.h", "chars.h".
* throw.c: Get "throw.h", "continuations.h", "debug.h",
"dynwind.h", "eval.h", "alist.h", "smob.h", "genio.h".
* unif.c: Get "unif.h", "feature.h", "strop.h", "sequences.h",
"smob.h", "genio.h", "eval.h", "chars.h".
* variable.c: Get "variable.h", "smob.h", "genio.h".
* vectors.c: Get "vectors.h", "eq.h".
* version.c: Get "version.h".
* vports.c: Get "vports.h", "fports.h", "chars.h", "eval.h".
* weaks.c: Get "weaks.h".
1996-09-10 02:26:07 +00:00
|
|
|
|
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/validate.h"
|
|
|
|
|
|
#include "libguile/stime.h"
|
C files should #include only the header files they need, not
libguile.h (which #includes all the header files); the pointless
recompilation was wasting my time.
* Makefile.in (all .o dependency lists): Regenerated.
* libguile.h: Don't try to get a definition for size_t here...
* __scm.h: Do it here.
* _scm.h: Since this is the internal libguile header, put things
here that all (or a majority) of the libguile files will want.
Don't #include <libguile.h> here; that generates dependencies on
way too much. Instead, get "__scm.h", "error.h", "pairs.h",
"list.h", "gc.h", "gsubr.h", "procs.h", "numbers.h", "symbols.h",
"boolean.h", "strings.h", "vectors.h", "root.h", "ports.h", and
"async.h".
* alist.c: Get "eq.h", "list.h", "alist.h".
* append.c: Get "append.h", "list.h".
* arbiters.c: Get "arbiters.h", "smob.h".
* async.c: Get "async.h", "smob.h", "throw.h", "eval.h".
* boolean.c: Get "boolean.h".
* chars.c: Get "chars.h".
* continuations.c: Get "continuations.h", "dynwind.h", "debug.h",
"stackchk.h".
* debug.c: Get "debug.h", "feature.h", "read.h", "strports.h",
"continuations.h", "alist.h", "srcprop.h", "procprop.h", "smob.h",
"genio.h", "throw.h", "eval.h".
* dynwind.c: Get "dynwind.h", "alist.h", "eval.h".
* eq.c: Get "eq.h", "unif.h", "smob.h", "strorder.h",
"stackchk.h".
* error.c: Get "error.h", "throw.h", "genio.h", "pairs.h".
* eval.c: Get "eval.h", "stackchk.h", "srcprop.h", "debug.h",
"hashtab.h", "procprop.h", "markers.h", "smob.h", "throw.h",
"continuations.h", "eq.h", "sequences.h", "alist.h", "append.h",
"debug.h".
* fdsocket.c: Get "fdsocket.h", "unif.h", "filesys.h".
* feature.c: Get "feature.h".
* files.c: Get "files.h".
* filesys.c: Get "filesys.h", "smob.h", "genio.h".
* fports.c: Get "fports.h", "markers.h".
* gc.c: Get "async.h", "unif.h", "smob.h", "weaks.h",
"genio.h", "struct.h", "stackchk.h", "stime.h".
* gdbint.c: Get "gdbint.h", "chars.h", "eval.h", "print.h",
"read.h", "strports.h", "tag.h".
* genio.c: Get "genio.h", "chars.h".
* gsubr.c: Get "gsubr.h", "genio.h".
* hash.c: Get "hash.h", "chars.h".
* hashtab.c: Get "hashtab.h", "eval.h", "hash.h", "alist.h".
* init.c: Get everyone who has an scm_init_mumble function:
"weaks.h", "vports.h", "version.h", "vectors.h", "variable.h",
"unif.h", "throw.h", "tag.h", "symbols.h", "struct.h",
"strports.h", "strorder.h", "strop.h", "strings.h", "stime.h",
"stackchk.h", "srcprop.h", "socket.h", "simpos.h", "sequences.h",
"scmsigs.h", "read.h", "ramap.h", "procs.h", "procprop.h",
"print.h", "posix.h", "ports.h", "pairs.h", "options.h",
"objprop.h", "numbers.h", "mbstrings.h", "mallocs.h", "load.h",
"list.h", "kw.h", "ioext.h", "hashtab.h", "hash.h", "gsubr.h",
"gdbint.h", "gc.h", "fports.h", "filesys.h", "files.h",
"feature.h", "fdsocket.h", "eval.h", "error.h", "eq.h",
"dynwind.h", "debug.h", "continuations.h", "chars.h", "boolean.h",
"async.h", "arbiters.h", "append.h", "alist.h".
* ioext.c: Get "ioext.h", "fports.h".
* kw.c: Get "kw.h", "smob.h", "mbstrings.h", "genio.h".
* list.c: Get "list.h", "eq.h".
* load.c: Get "load.h", "eval.h", "read.h", "fports.h".
* mallocs.c: Get "smob.h", "genio.h".
* markers.c: Get "markers.h".
* mbstrings.c: Get "mbstrings.h", "read.h", "genio.h", "unif.h",
"chars.h".
* numbers.c: Get "unif.h", "genio.h".
* objprop.c: Get "objprop.h", "weaks.h", "alist.h", "hashtab.h".
* options.c: Get "options.h".
* ports.c: Get "ports.h", "vports.h", "strports.h", "fports.h",
"markers.h", "chars.h", "genio.h".
* posix.c: Get "posix.h", "sequences.h", "feature.h", "unif.h",
"read.h", "scmsigs.h", "genio.h", "fports.h".
* print.c: Get "print.h", "unif.h", "weaks.h", "read.h",
"procprop.h", "eval.h", "smob.h", "mbstrings.h", "genio.h",
"chars.h".
* procprop.c: Get "procprop.h", "eval.h", "alist.h".
* procs.c: Get "procs.h".
* ramap.c: Get "ramap.h", "feature.h", "eval.h", "eq.h",
"chars.h", "smob.h", "unif.h".
* read.c: Get "alist.h", "kw.h", "mbstrings.h", "unif.h",
"eval.h", "genio.h", "chars.h".
* root.c: Get "root.h", "stackchk.h".
* scmsigs.c: Get "scmsigs.h".
* sequences.c: Get "sequences.h".
* simpos.c: Get "simpos.h", "scmsigs.h".
* smob.c: Get "smob.h".
* socket.c: Get "socket.h", "feature.h".
* srcprop.c: Get "srcprop.h", "weaks.h", "hashtab.h", "debug.h",
"alist.h", "smob.h".
* stackchk.c: Get "stackchk.h", "genio.h".
* stime.c: Get "stime.h"."libguile/continuations.h".
* strings.c: Get "strings.h", "chars.h".
* strop.c: Get "strop.h", "chars.h".
* strorder.c: Get "strorder.h", "chars.h".
* strports.c: Get "strports.h", "print.h", "eval.h", "unif.h".
* struct.c: Get "struct.h", "chars.h".
* symbols.c: Get "symbols.h", "mbstrings.h", "alist.h",
"variable.h", "eval.h", "chars.h".
* tag.c: Get "tag.h", "struct.h", "chars.h".
* throw.c: Get "throw.h", "continuations.h", "debug.h",
"dynwind.h", "eval.h", "alist.h", "smob.h", "genio.h".
* unif.c: Get "unif.h", "feature.h", "strop.h", "sequences.h",
"smob.h", "genio.h", "eval.h", "chars.h".
* variable.c: Get "variable.h", "smob.h", "genio.h".
* vectors.c: Get "vectors.h", "eq.h".
* version.c: Get "version.h".
* vports.c: Get "vports.h", "fports.h", "chars.h", "eval.h".
* weaks.c: Get "weaks.h".
1996-09-10 02:26:07 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ifdef HAVE_SYS_TYPES_H
|
|
|
|
|
|
# include <sys/types.h>
|
|
|
|
|
|
# endif
|
|
|
|
|
|
|
2000-07-23 23:12:39 +00:00
|
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
1997-04-21 08:14:48 +00:00
|
|
|
|
#ifdef HAVE_SYS_TIMES_H
|
|
|
|
|
|
# include <sys/times.h>
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_TIMEB_H
|
|
|
|
|
|
# include <sys/timeb.h>
|
|
|
|
|
|
#endif
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
1997-04-12 20:18:12 +00:00
|
|
|
|
#ifndef tzname /* For SGI. */
|
|
|
|
|
|
extern char *tzname[]; /* RS6000 and others reject char **tzname. */
|
|
|
|
|
|
#endif
|
2001-11-02 00:17:10 +00:00
|
|
|
|
#if defined (__MINGW32__)
|
|
|
|
|
|
# define tzname _tzname
|
|
|
|
|
|
#endif
|
1997-04-12 20:18:12 +00:00
|
|
|
|
|
2004-03-13 23:32:16 +00:00
|
|
|
|
#if ! HAVE_DECL_STRPTIME
|
1998-10-03 08:00:05 +00:00
|
|
|
|
extern char *strptime ();
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
#ifdef __STDC__
|
|
|
|
|
|
# define timet time_t
|
|
|
|
|
|
#else
|
|
|
|
|
|
# define timet long
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2004-02-18 00:20:08 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
#ifdef HAVE_TIMES
|
|
|
|
|
|
static
|
2000-08-16 00:23:59 +00:00
|
|
|
|
timet mytime()
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
|
|
|
|
|
struct tms time_buffer;
|
|
|
|
|
|
times(&time_buffer);
|
|
|
|
|
|
return time_buffer.tms_utime + time_buffer.tms_stime;
|
|
|
|
|
|
}
|
|
|
|
|
|
#else
|
|
|
|
|
|
# ifdef LACK_CLOCK
|
2003-01-23 16:04:37 +00:00
|
|
|
|
# define mytime() ((time((timet*)0) - scm_your_base) * SCM_TIME_UNITS_PER_SECOND)
|
1996-07-25 22:56:11 +00:00
|
|
|
|
# else
|
|
|
|
|
|
# define mytime clock
|
|
|
|
|
|
# endif
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_FTIME
|
|
|
|
|
|
struct timeb scm_your_base = {0};
|
* arbiters.c, eq.c, gc.c, guardians.c, list.c, ports.c, print.c,
regex-posix.c, scmsigs.c, stime.c, strings.c, variable.c, stime.c,
strings.c, variable.c: Added lots of documentation, cleaned up
some existing documentation. Occasionally changed formal params
to match docs. Also folded an #ifdef into the inners of a
primitive instead of having two copies of the primitive
(`get-internal-real-time', from stime.c)
2000-02-14 03:13:19 +00:00
|
|
|
|
#else
|
|
|
|
|
|
timet scm_your_base = 0;
|
|
|
|
|
|
#endif
|
1999-12-12 02:36:16 +00:00
|
|
|
|
|
2000-08-16 00:23:59 +00:00
|
|
|
|
SCM_DEFINE (scm_get_internal_real_time, "get-internal-real-time", 0, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(),
|
2001-04-03 13:19:05 +00:00
|
|
|
|
"Return the number of time units since the interpreter was\n"
|
|
|
|
|
|
"started.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_get_internal_real_time
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
* arbiters.c, eq.c, gc.c, guardians.c, list.c, ports.c, print.c,
regex-posix.c, scmsigs.c, stime.c, strings.c, variable.c, stime.c,
strings.c, variable.c: Added lots of documentation, cleaned up
some existing documentation. Occasionally changed formal params
to match docs. Also folded an #ifdef into the inners of a
primitive instead of having two copies of the primitive
(`get-internal-real-time', from stime.c)
2000-02-14 03:13:19 +00:00
|
|
|
|
#ifdef HAVE_FTIME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
struct timeb time_buffer;
|
1998-10-13 23:56:08 +00:00
|
|
|
|
|
|
|
|
|
|
SCM tmp;
|
|
|
|
|
|
ftime (&time_buffer);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
time_buffer.time -= scm_your_base.time;
|
* numbers.h, numbers.c, discouraged.h, discouraged.c (scm_short2num,
scm_ushort2num, scm_int2num, scm_uint2num, scm_long2num,
scm_ulong2num, scm_size2num, scm_ptrdiff2num, scm_num2short,
scm_num2ushort, scm_num2int, scm_num2uint, scm_num2long,
scm_num2ulong, scm_num2size, scm_num2ptrdiff, scm_long_long2num,
scm_ulong_long2num, scm_num2long_long, scm_num2ulong_long):
Discouraged by moving to discouraged.h and discouraged.c and
reimplementing in terms of scm_from_* and scm_to_*. Changed all uses
to the new scm_from_* and scm_to_* functions.
2004-08-02 16:14:04 +00:00
|
|
|
|
tmp = scm_from_long (time_buffer.millitm - scm_your_base.millitm);
|
1998-10-13 23:56:08 +00:00
|
|
|
|
tmp = scm_sum (tmp,
|
2004-07-23 15:43:02 +00:00
|
|
|
|
scm_product (scm_from_int (1000),
|
|
|
|
|
|
scm_from_int (time_buffer.time)));
|
* numbers.h, numbers.c, discouraged.h, discouraged.c (scm_short2num,
scm_ushort2num, scm_int2num, scm_uint2num, scm_long2num,
scm_ulong2num, scm_size2num, scm_ptrdiff2num, scm_num2short,
scm_num2ushort, scm_num2int, scm_num2uint, scm_num2long,
scm_num2ulong, scm_num2size, scm_num2ptrdiff, scm_long_long2num,
scm_ulong_long2num, scm_num2long_long, scm_num2ulong_long):
Discouraged by moving to discouraged.h and discouraged.c and
reimplementing in terms of scm_from_* and scm_to_*. Changed all uses
to the new scm_from_* and scm_to_* functions.
2004-08-02 16:14:04 +00:00
|
|
|
|
return scm_quotient (scm_product (tmp,
|
|
|
|
|
|
scm_from_int (SCM_TIME_UNITS_PER_SECOND)),
|
2004-07-23 15:43:02 +00:00
|
|
|
|
scm_from_int (1000));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
#else
|
* numbers.h, numbers.c, discouraged.h, discouraged.c (scm_short2num,
scm_ushort2num, scm_int2num, scm_uint2num, scm_long2num,
scm_ulong2num, scm_size2num, scm_ptrdiff2num, scm_num2short,
scm_num2ushort, scm_num2int, scm_num2uint, scm_num2long,
scm_num2ulong, scm_num2size, scm_num2ptrdiff, scm_long_long2num,
scm_ulong_long2num, scm_num2long_long, scm_num2ulong_long):
Discouraged by moving to discouraged.h and discouraged.c and
reimplementing in terms of scm_from_* and scm_to_*. Changed all uses
to the new scm_from_* and scm_to_* functions.
2004-08-02 16:14:04 +00:00
|
|
|
|
return scm_from_long ((time((timet*)0) - scm_your_base)
|
|
|
|
|
|
* (int)SCM_TIME_UNITS_PER_SECOND);
|
* arbiters.c, eq.c, gc.c, guardians.c, list.c, ports.c, print.c,
regex-posix.c, scmsigs.c, stime.c, strings.c, variable.c, stime.c,
strings.c, variable.c: Added lots of documentation, cleaned up
some existing documentation. Occasionally changed formal params
to match docs. Also folded an #ifdef into the inners of a
primitive instead of having two copies of the primitive
(`get-internal-real-time', from stime.c)
2000-02-14 03:13:19 +00:00
|
|
|
|
#endif /* HAVE_FTIME */
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
* eval.c: define scm_unbound_variable_key ('unbound-variable).
scm_lookupcar1: throw an error with key 'unbound-variable instead
of 'misc-error when an unbound variable is encountered.
* filesys.c (scm_mkdir, scm_rmdir, scm_getcwd, scm_select,
scm_symlink, scm_readlink, scm_lstat),
posix.c (scm_setpgid, scm_setsid, scm_ctermid, scm_tcgetpgrp,
scm_tcsetpgrp, scm_uname, scm_setlocale, scm_mknod, scm_nice,
scm_sync),
simpos.c (scm_system),
stime.c (scm_times, scm_strptime):
move the HAVE_XXX feature tests out of the procedure bodies.
don't use SCM_SYSMISSING.
scm_validate.h (SCM_SYSMISSING): removed.
error.h, error.c (scm_sysmissing): comment that this is deprecated.
see ChangeLog entry for 1999-12-28.
2000-01-09 13:41:53 +00:00
|
|
|
|
#ifdef HAVE_TIMES
|
2000-08-16 00:23:59 +00:00
|
|
|
|
SCM_DEFINE (scm_times, "times", 0, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(void),
|
2001-04-03 13:19:05 +00:00
|
|
|
|
"Return an object with information about real and processor\n"
|
|
|
|
|
|
"time. The following procedures accept such an object as an\n"
|
|
|
|
|
|
"argument and return a selected component:\n"
|
|
|
|
|
|
"\n"
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"@table @code\n"
|
|
|
|
|
|
"@item tms:clock\n"
|
|
|
|
|
|
"The current real time, expressed as time units relative to an\n"
|
|
|
|
|
|
"arbitrary base.\n"
|
|
|
|
|
|
"@item tms:utime\n"
|
|
|
|
|
|
"The CPU time units used by the calling process.\n"
|
|
|
|
|
|
"@item tms:stime\n"
|
2001-04-03 13:19:05 +00:00
|
|
|
|
"The CPU time units used by the system on behalf of the calling\n"
|
|
|
|
|
|
"process.\n"
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"@item tms:cutime\n"
|
2001-04-03 13:19:05 +00:00
|
|
|
|
"The CPU time units used by terminated child processes of the\n"
|
|
|
|
|
|
"calling process, whose status has been collected (e.g., using\n"
|
|
|
|
|
|
"@code{waitpid}).\n"
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"@item tms:cstime\n"
|
2001-04-03 13:19:05 +00:00
|
|
|
|
"Similarly, the CPU times units used by the system on behalf of\n"
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"terminated child processes.\n"
|
|
|
|
|
|
"@end table")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_times
|
* stime.h: prototype for scm_times.
* stime.c (scm_times): new procedure.
* ioext.c (scm_fseek): if the first argument is a file descriptor
call lseek.
(scm_ftell): if the first argument is a file descriptor call lseek
(sic).
* filesys.h: prototypes for scm_open_fdes, scm_fsync.
* filesys.c (scm_chmod): if the first argument is a file descriptor,
call fchmod.
(scm_chown): if the first argument is a port or file descriptor,
call fchown.
(scm_truncate_file): new procedure.
Add DEFER/ALLOW INTS to a few other procedures.
(scm_fsync): new procedure.
(scm_open_fdes): new procedure.
(scm_open): use scm_open_fdes. If mode isn't specified, 666 will
now be used.
(scm_fcntl): the first argument can now be a file descriptor. The
third argument is now optional.
* posix.c (scm_execl, scm_execlp): make the filename argument
compulsory, since omitting it causes SEGV.
(scm_sync): return unspecified instead of #f.
(scm_execle): new procedure.
(environ_list_to_c): new procedure.
(scm_environ): use environ_list_to_c. disable interrupts.
(scm_convert_exec_args): take pos and subr arguments and
improve error checking.
* boot-9.scm: define tms accessors: clock, utime, stime, cutime,
cstime.
1997-08-16 18:48:44 +00:00
|
|
|
|
{
|
|
|
|
|
|
struct tms t;
|
|
|
|
|
|
clock_t rv;
|
|
|
|
|
|
|
2001-02-02 04:56:25 +00:00
|
|
|
|
SCM result = scm_c_make_vector (5, SCM_UNDEFINED);
|
* stime.h: prototype for scm_times.
* stime.c (scm_times): new procedure.
* ioext.c (scm_fseek): if the first argument is a file descriptor
call lseek.
(scm_ftell): if the first argument is a file descriptor call lseek
(sic).
* filesys.h: prototypes for scm_open_fdes, scm_fsync.
* filesys.c (scm_chmod): if the first argument is a file descriptor,
call fchmod.
(scm_chown): if the first argument is a port or file descriptor,
call fchown.
(scm_truncate_file): new procedure.
Add DEFER/ALLOW INTS to a few other procedures.
(scm_fsync): new procedure.
(scm_open_fdes): new procedure.
(scm_open): use scm_open_fdes. If mode isn't specified, 666 will
now be used.
(scm_fcntl): the first argument can now be a file descriptor. The
third argument is now optional.
* posix.c (scm_execl, scm_execlp): make the filename argument
compulsory, since omitting it causes SEGV.
(scm_sync): return unspecified instead of #f.
(scm_execle): new procedure.
(environ_list_to_c): new procedure.
(scm_environ): use environ_list_to_c. disable interrupts.
(scm_convert_exec_args): take pos and subr arguments and
improve error checking.
* boot-9.scm: define tms accessors: clock, utime, stime, cutime,
cstime.
1997-08-16 18:48:44 +00:00
|
|
|
|
rv = times (&t);
|
|
|
|
|
|
if (rv == -1)
|
1999-12-12 02:36:16 +00:00
|
|
|
|
SCM_SYSERROR;
|
2005-01-02 20:49:04 +00:00
|
|
|
|
SCM_SIMPLE_VECTOR_SET (result, 0, scm_from_long (rv));
|
|
|
|
|
|
SCM_SIMPLE_VECTOR_SET (result, 1, scm_from_long (t.tms_utime));
|
|
|
|
|
|
SCM_SIMPLE_VECTOR_SET (result, 2, scm_from_long (t.tms_stime));
|
|
|
|
|
|
SCM_SIMPLE_VECTOR_SET (result ,3, scm_from_long (t.tms_cutime));
|
|
|
|
|
|
SCM_SIMPLE_VECTOR_SET (result, 4, scm_from_long (t.tms_cstime));
|
* stime.h: prototype for scm_times.
* stime.c (scm_times): new procedure.
* ioext.c (scm_fseek): if the first argument is a file descriptor
call lseek.
(scm_ftell): if the first argument is a file descriptor call lseek
(sic).
* filesys.h: prototypes for scm_open_fdes, scm_fsync.
* filesys.c (scm_chmod): if the first argument is a file descriptor,
call fchmod.
(scm_chown): if the first argument is a port or file descriptor,
call fchown.
(scm_truncate_file): new procedure.
Add DEFER/ALLOW INTS to a few other procedures.
(scm_fsync): new procedure.
(scm_open_fdes): new procedure.
(scm_open): use scm_open_fdes. If mode isn't specified, 666 will
now be used.
(scm_fcntl): the first argument can now be a file descriptor. The
third argument is now optional.
* posix.c (scm_execl, scm_execlp): make the filename argument
compulsory, since omitting it causes SEGV.
(scm_sync): return unspecified instead of #f.
(scm_execle): new procedure.
(environ_list_to_c): new procedure.
(scm_environ): use environ_list_to_c. disable interrupts.
(scm_convert_exec_args): take pos and subr arguments and
improve error checking.
* boot-9.scm: define tms accessors: clock, utime, stime, cutime,
cstime.
1997-08-16 18:48:44 +00:00
|
|
|
|
return result;
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
* eval.c: define scm_unbound_variable_key ('unbound-variable).
scm_lookupcar1: throw an error with key 'unbound-variable instead
of 'misc-error when an unbound variable is encountered.
* filesys.c (scm_mkdir, scm_rmdir, scm_getcwd, scm_select,
scm_symlink, scm_readlink, scm_lstat),
posix.c (scm_setpgid, scm_setsid, scm_ctermid, scm_tcgetpgrp,
scm_tcsetpgrp, scm_uname, scm_setlocale, scm_mknod, scm_nice,
scm_sync),
simpos.c (scm_system),
stime.c (scm_times, scm_strptime):
move the HAVE_XXX feature tests out of the procedure bodies.
don't use SCM_SYSMISSING.
scm_validate.h (SCM_SYSMISSING): removed.
error.h, error.c (scm_sysmissing): comment that this is deprecated.
see ChangeLog entry for 1999-12-28.
2000-01-09 13:41:53 +00:00
|
|
|
|
#endif /* HAVE_TIMES */
|
* stime.h: prototype for scm_times.
* stime.c (scm_times): new procedure.
* ioext.c (scm_fseek): if the first argument is a file descriptor
call lseek.
(scm_ftell): if the first argument is a file descriptor call lseek
(sic).
* filesys.h: prototypes for scm_open_fdes, scm_fsync.
* filesys.c (scm_chmod): if the first argument is a file descriptor,
call fchmod.
(scm_chown): if the first argument is a port or file descriptor,
call fchown.
(scm_truncate_file): new procedure.
Add DEFER/ALLOW INTS to a few other procedures.
(scm_fsync): new procedure.
(scm_open_fdes): new procedure.
(scm_open): use scm_open_fdes. If mode isn't specified, 666 will
now be used.
(scm_fcntl): the first argument can now be a file descriptor. The
third argument is now optional.
* posix.c (scm_execl, scm_execlp): make the filename argument
compulsory, since omitting it causes SEGV.
(scm_sync): return unspecified instead of #f.
(scm_execle): new procedure.
(environ_list_to_c): new procedure.
(scm_environ): use environ_list_to_c. disable interrupts.
(scm_convert_exec_args): take pos and subr arguments and
improve error checking.
* boot-9.scm: define tms accessors: clock, utime, stime, cutime,
cstime.
1997-08-16 18:48:44 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
static long scm_my_base = 0;
|
|
|
|
|
|
|
2000-08-16 00:23:59 +00:00
|
|
|
|
long
|
|
|
|
|
|
scm_c_get_internal_run_time ()
|
|
|
|
|
|
{
|
|
|
|
|
|
return mytime () - scm_my_base;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_get_internal_run_time, "get-internal-run-time", 0, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(void),
|
2001-04-03 13:19:05 +00:00
|
|
|
|
"Return the number of time units of processor time used by the\n"
|
|
|
|
|
|
"interpreter. Both @emph{system} and @emph{user} time are\n"
|
|
|
|
|
|
"included but subprocesses are not.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_get_internal_run_time
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
* numbers.h, numbers.c, discouraged.h, discouraged.c (scm_short2num,
scm_ushort2num, scm_int2num, scm_uint2num, scm_long2num,
scm_ulong2num, scm_size2num, scm_ptrdiff2num, scm_num2short,
scm_num2ushort, scm_num2int, scm_num2uint, scm_num2long,
scm_num2ulong, scm_num2size, scm_num2ptrdiff, scm_long_long2num,
scm_ulong_long2num, scm_num2long_long, scm_num2ulong_long):
Discouraged by moving to discouraged.h and discouraged.c and
reimplementing in terms of scm_from_* and scm_to_*. Changed all uses
to the new scm_from_* and scm_to_* functions.
2004-08-02 16:14:04 +00:00
|
|
|
|
return scm_from_long (scm_c_get_internal_run_time ());
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2004-01-03 22:25:24 +00:00
|
|
|
|
/* For reference, note that current-time and gettimeofday both should be
|
|
|
|
|
|
protected against setzone/restorezone changes in another thread, since on
|
|
|
|
|
|
DOS the system time is normally kept as local time, which means TZ
|
|
|
|
|
|
affects the return from current-time and gettimeofday. Not sure if DJGPP
|
|
|
|
|
|
etc actually has concurrent multi-threading, but it seems prudent not to
|
|
|
|
|
|
make assumptions about this. */
|
|
|
|
|
|
|
2000-08-16 00:23:59 +00:00
|
|
|
|
SCM_DEFINE (scm_current_time, "current-time", 0, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(void),
|
2001-04-03 13:19:05 +00:00
|
|
|
|
"Return the number of seconds since 1970-01-01 00:00:00 UTC,\n"
|
|
|
|
|
|
"excluding leap seconds.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_current_time
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
timet timv;
|
|
|
|
|
|
|
2005-03-02 20:42:01 +00:00
|
|
|
|
SCM_CRITICAL_SECTION_START;
|
2004-09-07 00:15:48 +00:00
|
|
|
|
timv = time (NULL);
|
2005-03-02 20:42:01 +00:00
|
|
|
|
SCM_CRITICAL_SECTION_END;
|
2004-09-07 00:15:48 +00:00
|
|
|
|
if (timv == -1)
|
|
|
|
|
|
SCM_MISC_ERROR ("current time not available", SCM_EOL);
|
* numbers.h, numbers.c, discouraged.h, discouraged.c (scm_short2num,
scm_ushort2num, scm_int2num, scm_uint2num, scm_long2num,
scm_ulong2num, scm_size2num, scm_ptrdiff2num, scm_num2short,
scm_num2ushort, scm_num2int, scm_num2uint, scm_num2long,
scm_num2ulong, scm_num2size, scm_num2ptrdiff, scm_long_long2num,
scm_ulong_long2num, scm_num2long_long, scm_num2ulong_long):
Discouraged by moving to discouraged.h and discouraged.c and
reimplementing in terms of scm_from_* and scm_to_*. Changed all uses
to the new scm_from_* and scm_to_* functions.
2004-08-02 16:14:04 +00:00
|
|
|
|
return scm_from_long (timv);
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
|
2000-08-16 00:23:59 +00:00
|
|
|
|
SCM_DEFINE (scm_gettimeofday, "gettimeofday", 0, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(void),
|
2001-04-03 13:19:05 +00:00
|
|
|
|
"Return a pair containing the number of seconds and microseconds\n"
|
|
|
|
|
|
"since 1970-01-01 00:00:00 UTC, excluding leap seconds. Note:\n"
|
|
|
|
|
|
"whether true microsecond resolution is available depends on the\n"
|
|
|
|
|
|
"operating system.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_gettimeofday
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
{
|
|
|
|
|
|
#ifdef HAVE_GETTIMEOFDAY
|
|
|
|
|
|
struct timeval time;
|
2004-09-07 00:15:48 +00:00
|
|
|
|
int ret, err;
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
|
2005-03-02 20:42:01 +00:00
|
|
|
|
SCM_CRITICAL_SECTION_START;
|
2004-09-07 00:15:48 +00:00
|
|
|
|
ret = gettimeofday (&time, NULL);
|
|
|
|
|
|
err = errno;
|
2005-03-02 20:42:01 +00:00
|
|
|
|
SCM_CRITICAL_SECTION_END;
|
2004-09-07 00:15:48 +00:00
|
|
|
|
if (ret == -1)
|
|
|
|
|
|
{
|
|
|
|
|
|
errno = err;
|
|
|
|
|
|
SCM_SYSERROR;
|
|
|
|
|
|
}
|
* numbers.h, numbers.c, discouraged.h, discouraged.c (scm_short2num,
scm_ushort2num, scm_int2num, scm_uint2num, scm_long2num,
scm_ulong2num, scm_size2num, scm_ptrdiff2num, scm_num2short,
scm_num2ushort, scm_num2int, scm_num2uint, scm_num2long,
scm_num2ulong, scm_num2size, scm_num2ptrdiff, scm_long_long2num,
scm_ulong_long2num, scm_num2long_long, scm_num2ulong_long):
Discouraged by moving to discouraged.h and discouraged.c and
reimplementing in terms of scm_from_* and scm_to_*. Changed all uses
to the new scm_from_* and scm_to_* functions.
2004-08-02 16:14:04 +00:00
|
|
|
|
return scm_cons (scm_from_long (time.tv_sec),
|
|
|
|
|
|
scm_from_long (time.tv_usec));
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
#else
|
|
|
|
|
|
# ifdef HAVE_FTIME
|
|
|
|
|
|
struct timeb time;
|
|
|
|
|
|
|
|
|
|
|
|
ftime(&time);
|
* numbers.h, numbers.c, discouraged.h, discouraged.c (scm_short2num,
scm_ushort2num, scm_int2num, scm_uint2num, scm_long2num,
scm_ulong2num, scm_size2num, scm_ptrdiff2num, scm_num2short,
scm_num2ushort, scm_num2int, scm_num2uint, scm_num2long,
scm_num2ulong, scm_num2size, scm_num2ptrdiff, scm_long_long2num,
scm_ulong_long2num, scm_num2long_long, scm_num2ulong_long):
Discouraged by moving to discouraged.h and discouraged.c and
reimplementing in terms of scm_from_* and scm_to_*. Changed all uses
to the new scm_from_* and scm_to_* functions.
2004-08-02 16:14:04 +00:00
|
|
|
|
return scm_cons (scm_from_long (time.time),
|
2004-07-23 15:43:02 +00:00
|
|
|
|
scm_from_int (time.millitm * 1000));
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
# else
|
|
|
|
|
|
timet timv;
|
2004-09-07 00:15:48 +00:00
|
|
|
|
int err;
|
2000-08-16 00:23:59 +00:00
|
|
|
|
|
2005-03-02 20:42:01 +00:00
|
|
|
|
SCM_CRITICAL_SECTION_START;
|
2004-09-07 00:15:48 +00:00
|
|
|
|
timv = time (NULL);
|
|
|
|
|
|
err = errno;
|
2005-03-02 20:42:01 +00:00
|
|
|
|
SCM_CRITICAL_SECTION_END;
|
2004-09-07 00:15:48 +00:00
|
|
|
|
if (timv == -1)
|
|
|
|
|
|
{
|
|
|
|
|
|
errno = err;
|
|
|
|
|
|
SCM_SYSERROR;
|
|
|
|
|
|
}
|
* numbers.h, numbers.c, discouraged.h, discouraged.c (scm_short2num,
scm_ushort2num, scm_int2num, scm_uint2num, scm_long2num,
scm_ulong2num, scm_size2num, scm_ptrdiff2num, scm_num2short,
scm_num2ushort, scm_num2int, scm_num2uint, scm_num2long,
scm_num2ulong, scm_num2size, scm_num2ptrdiff, scm_long_long2num,
scm_ulong_long2num, scm_num2long_long, scm_num2ulong_long):
Discouraged by moving to discouraged.h and discouraged.c and
reimplementing in terms of scm_from_* and scm_to_*. Changed all uses
to the new scm_from_* and scm_to_* functions.
2004-08-02 16:14:04 +00:00
|
|
|
|
return scm_cons (scm_from_long (timv), scm_from_int (0));
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
# endif
|
|
|
|
|
|
#endif
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
|
|
|
|
|
|
static SCM
|
2004-03-06 22:41:26 +00:00
|
|
|
|
filltime (struct tm *bd_time, int zoff, const char *zname)
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
{
|
2001-02-02 04:56:25 +00:00
|
|
|
|
SCM result = scm_c_make_vector (11, SCM_UNDEFINED);
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
|
2005-01-02 20:49:04 +00:00
|
|
|
|
SCM_SIMPLE_VECTOR_SET (result,0, scm_from_int (bd_time->tm_sec));
|
|
|
|
|
|
SCM_SIMPLE_VECTOR_SET (result,1, scm_from_int (bd_time->tm_min));
|
|
|
|
|
|
SCM_SIMPLE_VECTOR_SET (result,2, scm_from_int (bd_time->tm_hour));
|
|
|
|
|
|
SCM_SIMPLE_VECTOR_SET (result,3, scm_from_int (bd_time->tm_mday));
|
|
|
|
|
|
SCM_SIMPLE_VECTOR_SET (result,4, scm_from_int (bd_time->tm_mon));
|
|
|
|
|
|
SCM_SIMPLE_VECTOR_SET (result,5, scm_from_int (bd_time->tm_year));
|
|
|
|
|
|
SCM_SIMPLE_VECTOR_SET (result,6, scm_from_int (bd_time->tm_wday));
|
|
|
|
|
|
SCM_SIMPLE_VECTOR_SET (result,7, scm_from_int (bd_time->tm_yday));
|
|
|
|
|
|
SCM_SIMPLE_VECTOR_SET (result,8, scm_from_int (bd_time->tm_isdst));
|
|
|
|
|
|
SCM_SIMPLE_VECTOR_SET (result,9, scm_from_int (zoff));
|
|
|
|
|
|
SCM_SIMPLE_VECTOR_SET (result,10, (zname
|
|
|
|
|
|
? scm_from_locale_string (zname)
|
|
|
|
|
|
: SCM_BOOL_F));
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
1998-01-04 02:50:12 +00:00
|
|
|
|
static char tzvar[3] = "TZ";
|
|
|
|
|
|
|
2000-01-09 20:50:03 +00:00
|
|
|
|
/* if zone is set, create a temporary environment with only a TZ
|
|
|
|
|
|
string. other threads or interrupt handlers shouldn't be allowed
|
|
|
|
|
|
to run until the corresponding restorezone is called. hence the use
|
|
|
|
|
|
of a static variable for tmpenv is no big deal. */
|
1998-01-04 02:50:12 +00:00
|
|
|
|
static char **
|
* chars.c (scm_lowers, scm_uppers, scm_charnames, scm_charnums),
eval.c (s_expression, s_test, s_body, s_bindings, s_variable,
s_clauses, s_formals): Variables now const.
* eval.c (promsmob): Now const.
* macros.c (macrosmob): Now const.
* smob.c (scm_newsmob): Smobfuns argument now points to const.
(freecell, flob, bigob): Now const.
* dynl.c (scm_make_argv_from_stringlist, scm_coerce_rostring),
error.c (scm_error, scm_syserror, scm_syserror_msg,
scm_num_overflow, scm_out_of_range, scm_wrong_type_arg,
scm_memory_error, scm_misc_error, scm_wta), macros.c
(scm_make_synt), feature.c (scm_add_feature), filesys.c
(scm_input_waiting_p), gc.c (scm_gc_start, scm_igc,
scm_must_malloc, scm_must_realloc), gsubr.c (scm_make_gsubr),
numbers.c (scm_num2dbl, scm_two_doubles, scm_num2long,
scm_num2long_long, scm_num2ulong),
options.c (scm_options), posix.c (scm_convert_exec_args,
environ_list_to_c), procs.c (scm_make_subr_opt, scm_make_subr),
ramap.c (scm_ramapc), read.c (scm_flush_ws), socket.c
(scm_sock_fd_to_port, scm_fill_sockaddr, scm_addr_vector), stime.c
(setzone, restorezone, bdtime2c), strop.c (scm_i_index),
strports.c (scm_mkstrport), symbols.c (scm_intern_obarray_soft,
scm_intern_obarray, scm_intern, scm_intern0,
scm_sysintern0_no_module_lookup, scm_sysintern, scm_sysintern0,
scm_symbol_value0), unif.c (scm_aind, scm_shap2ra): Argument
indicating calling subr, error message text, reason for error,
symbol name or feature name are now pointer to const.
* snarf.h (SCM_PROC, SCM_PROC1): String variables are now const.
* procs.c (scm_init_iprocs): iproc argument now points to const.
* pairs.c (cxrs): Now const.
* chars.h, error.h, feature.h, filesys.h, gc.h, gsubr.h, macros.h,
numbers.h, options.h, procs.h, ramap.h, read.h, smob.h,
strports.h, symbols.h, unif.h: Update variable declarations and
function prototypes for above changes.
* dynl.c, dynl-dld.c, dynl-dl.c, dynl-shl.c (sysdep_dynl_link,
sysdep_dynl_unlink, sysdep_dynl_func): Arguments FNAME, SUBR, and
SYMB now point to const.
1999-02-06 12:31:04 +00:00
|
|
|
|
setzone (SCM zone, int pos, const char *subr)
|
1997-04-12 20:18:12 +00:00
|
|
|
|
{
|
1998-01-04 02:50:12 +00:00
|
|
|
|
char **oldenv = 0;
|
1997-04-12 20:18:12 +00:00
|
|
|
|
|
|
|
|
|
|
if (!SCM_UNBNDP (zone))
|
|
|
|
|
|
{
|
1998-01-04 02:50:12 +00:00
|
|
|
|
static char *tmpenv[2];
|
1997-04-12 20:18:12 +00:00
|
|
|
|
char *buf;
|
* stime.c, socket.c, simpos.c, procs.c, posix.c, ports.c,
net_db.c, fports.c, filesys.c, eval.c, deprecation.c, dynl.c:
Replaced uses of SCM_STRING_CHARS with proper uses of
scm_to_locale_string. Replaced SCM_STRINGP with scm_is_string.
Replaced scm_mem2string with scm_from_locale_string.
* simpos.c, posix.c (allocate_string_pointers, environ_list_to_c):
Removed, replaced all uses with scm_i_allocate_string_pointers.
2004-08-10 14:08:02 +00:00
|
|
|
|
size_t zone_len;
|
|
|
|
|
|
|
|
|
|
|
|
zone_len = scm_to_locale_stringbuf (zone, NULL, 0);
|
|
|
|
|
|
buf = scm_malloc (zone_len + sizeof (tzvar) + 1);
|
|
|
|
|
|
strcpy (buf, tzvar);
|
|
|
|
|
|
buf[sizeof(tzvar)-1] = '=';
|
|
|
|
|
|
scm_to_locale_stringbuf (zone, buf+sizeof(tzvar), zone_len);
|
|
|
|
|
|
buf[sizeof(tzvar)+zone_len] = '\0';
|
1998-01-04 02:50:12 +00:00
|
|
|
|
oldenv = environ;
|
|
|
|
|
|
tmpenv[0] = buf;
|
|
|
|
|
|
tmpenv[1] = 0;
|
|
|
|
|
|
environ = tmpenv;
|
1997-04-12 20:18:12 +00:00
|
|
|
|
}
|
1998-01-04 02:50:12 +00:00
|
|
|
|
return oldenv;
|
1997-04-12 20:18:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2001-06-07 21:12:19 +00:00
|
|
|
|
restorezone (SCM zone, char **oldenv, const char *subr SCM_UNUSED)
|
1997-04-12 20:18:12 +00:00
|
|
|
|
{
|
|
|
|
|
|
if (!SCM_UNBNDP (zone))
|
|
|
|
|
|
{
|
* gc.h, gc.c (scm_gc_sweep): Issue deprecation warning when
non-zero is returned from a port or smob free function.
(scm_malloc, scm_realloc, scm_strndup, scm_strdup,
scm_gc_register_collectable_memory,
scm_gc_unregister_collectable_memory, scm_gc_malloc,
scm_gc_realloc, scm_gc_free, scm_gc_strndup, scm_gc_strdup): New.
* backtrace.c, continuations.c, convert.i.c, coop-threads.c,
debug-malloc.c, dynl.c, environments.c, environments.h,
extensions.c, filesys.c, fports.c, gc.c, gc.h, gh_data.c, goops.c,
guardians.c, hooks.c, init.c, keywords.c, load.c, numbers.c,
ports.c, posix.c, procs.c, rdelim.c, regex-posix.c, root.c,
smob.c, stime.c, strings.c, struct.c, struct.h, symbols.c, unif.c,
vectors.c, weaks.c: Use scm_gc_malloc/scm_malloc and
scm_gc_free/free instead of scm_must_malloc and scm_must_free, as
appropriate. Return zero from smob and port free functions.
* debug-malloc.c (scm_malloc_reregister): Handle "old == NULL".
* fports.c (scm_setvbuf): Reset read buffer to saved values when
it is pointing to the putback buffer.
2002-02-11 18:06:50 +00:00
|
|
|
|
free (environ[0]);
|
1998-01-04 02:50:12 +00:00
|
|
|
|
environ = oldenv;
|
2000-01-09 20:50:03 +00:00
|
|
|
|
#ifdef HAVE_TZSET
|
|
|
|
|
|
/* for the possible benefit of user code linked with libguile. */
|
1997-04-12 20:18:12 +00:00
|
|
|
|
tzset();
|
2000-01-09 20:50:03 +00:00
|
|
|
|
#endif
|
1997-04-12 20:18:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2000-08-16 00:23:59 +00:00
|
|
|
|
SCM_DEFINE (scm_localtime, "localtime", 1, 1, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM time, SCM zone),
|
2001-04-03 13:19:05 +00:00
|
|
|
|
"Return an object representing the broken down components of\n"
|
|
|
|
|
|
"@var{time}, an integer like the one returned by\n"
|
|
|
|
|
|
"@code{current-time}. The time zone for the calculation is\n"
|
|
|
|
|
|
"optionally specified by @var{zone} (a string), otherwise the\n"
|
|
|
|
|
|
"@code{TZ} environment variable or the system default is used.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_localtime
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
{
|
|
|
|
|
|
timet itime;
|
1997-05-05 21:01:57 +00:00
|
|
|
|
struct tm *ltptr, lt, *utc;
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
SCM result;
|
|
|
|
|
|
int zoff;
|
|
|
|
|
|
char *zname = 0;
|
1998-01-04 02:50:12 +00:00
|
|
|
|
char **oldenv;
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
int err;
|
|
|
|
|
|
|
2001-04-10 07:57:05 +00:00
|
|
|
|
itime = SCM_NUM2LONG (1, time);
|
2000-01-09 20:50:03 +00:00
|
|
|
|
|
|
|
|
|
|
/* deferring interupts is essential since a) setzone may install a temporary
|
|
|
|
|
|
environment b) localtime uses a static buffer. */
|
2005-03-02 20:42:01 +00:00
|
|
|
|
SCM_CRITICAL_SECTION_START;
|
1999-12-12 02:36:16 +00:00
|
|
|
|
oldenv = setzone (zone, SCM_ARG2, FUNC_NAME);
|
2000-01-09 20:50:03 +00:00
|
|
|
|
#ifdef LOCALTIME_CACHE
|
|
|
|
|
|
tzset ();
|
|
|
|
|
|
#endif
|
2004-02-17 23:37:06 +00:00
|
|
|
|
/* POSIX says localtime sets errno, but C99 doesn't say that.
|
|
|
|
|
|
Give a sensible default value in case localtime doesn't set it. */
|
|
|
|
|
|
errno = EINVAL;
|
1997-05-05 21:01:57 +00:00
|
|
|
|
ltptr = localtime (&itime);
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
err = errno;
|
1997-05-05 21:01:57 +00:00
|
|
|
|
if (ltptr)
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
{
|
1998-10-03 08:00:05 +00:00
|
|
|
|
const char *ptr;
|
1998-01-04 02:50:12 +00:00
|
|
|
|
|
2000-02-08 22:16:15 +00:00
|
|
|
|
/* copy zone name before calling gmtime or restoring zone. */
|
|
|
|
|
|
#if defined (HAVE_TM_ZONE)
|
1998-01-04 02:50:12 +00:00
|
|
|
|
ptr = ltptr->tm_zone;
|
2000-02-08 22:16:15 +00:00
|
|
|
|
#elif defined (HAVE_TZNAME)
|
1998-01-04 02:50:12 +00:00
|
|
|
|
ptr = tzname[ (ltptr->tm_isdst == 1) ? 1 : 0 ];
|
2000-02-08 22:16:15 +00:00
|
|
|
|
#else
|
|
|
|
|
|
ptr = "";
|
1997-04-12 20:18:12 +00:00
|
|
|
|
#endif
|
* gc.h, gc.c (scm_gc_sweep): Issue deprecation warning when
non-zero is returned from a port or smob free function.
(scm_malloc, scm_realloc, scm_strndup, scm_strdup,
scm_gc_register_collectable_memory,
scm_gc_unregister_collectable_memory, scm_gc_malloc,
scm_gc_realloc, scm_gc_free, scm_gc_strndup, scm_gc_strdup): New.
* backtrace.c, continuations.c, convert.i.c, coop-threads.c,
debug-malloc.c, dynl.c, environments.c, environments.h,
extensions.c, filesys.c, fports.c, gc.c, gc.h, gh_data.c, goops.c,
guardians.c, hooks.c, init.c, keywords.c, load.c, numbers.c,
ports.c, posix.c, procs.c, rdelim.c, regex-posix.c, root.c,
smob.c, stime.c, strings.c, struct.c, struct.h, symbols.c, unif.c,
vectors.c, weaks.c: Use scm_gc_malloc/scm_malloc and
scm_gc_free/free instead of scm_must_malloc and scm_must_free, as
appropriate. Return zero from smob and port free functions.
* debug-malloc.c (scm_malloc_reregister): Handle "old == NULL".
* fports.c (scm_setvbuf): Reset read buffer to saved values when
it is pointing to the putback buffer.
2002-02-11 18:06:50 +00:00
|
|
|
|
zname = scm_malloc (strlen (ptr) + 1);
|
1998-01-04 02:50:12 +00:00
|
|
|
|
strcpy (zname, ptr);
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
}
|
1998-01-04 02:50:12 +00:00
|
|
|
|
/* the struct is copied in case localtime and gmtime share a buffer. */
|
|
|
|
|
|
if (ltptr)
|
|
|
|
|
|
lt = *ltptr;
|
2004-02-17 23:37:06 +00:00
|
|
|
|
/* POSIX says gmtime sets errno, but C99 doesn't say that.
|
|
|
|
|
|
Give a sensible default value in case gmtime doesn't set it. */
|
|
|
|
|
|
errno = EINVAL;
|
1998-01-04 02:50:12 +00:00
|
|
|
|
utc = gmtime (&itime);
|
|
|
|
|
|
if (utc == NULL)
|
|
|
|
|
|
err = errno;
|
1999-12-12 02:36:16 +00:00
|
|
|
|
restorezone (zone, oldenv, FUNC_NAME);
|
1997-04-12 20:18:12 +00:00
|
|
|
|
/* delayed until zone has been restored. */
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
errno = err;
|
1997-05-05 21:01:57 +00:00
|
|
|
|
if (utc == NULL || ltptr == NULL)
|
1999-12-12 02:36:16 +00:00
|
|
|
|
SCM_SYSERROR;
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
|
|
|
|
|
|
/* calculate timezone offset in seconds west of UTC. */
|
1997-05-05 21:01:57 +00:00
|
|
|
|
zoff = (utc->tm_hour - lt.tm_hour) * 3600 + (utc->tm_min - lt.tm_min) * 60
|
|
|
|
|
|
+ utc->tm_sec - lt.tm_sec;
|
|
|
|
|
|
if (utc->tm_year < lt.tm_year)
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
zoff -= 24 * 60 * 60;
|
1997-05-05 21:01:57 +00:00
|
|
|
|
else if (utc->tm_year > lt.tm_year)
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
zoff += 24 * 60 * 60;
|
1997-05-05 21:01:57 +00:00
|
|
|
|
else if (utc->tm_yday < lt.tm_yday)
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
zoff -= 24 * 60 * 60;
|
1997-05-05 21:01:57 +00:00
|
|
|
|
else if (utc->tm_yday > lt.tm_yday)
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
zoff += 24 * 60 * 60;
|
2000-08-16 00:23:59 +00:00
|
|
|
|
|
1997-05-05 21:01:57 +00:00
|
|
|
|
result = filltime (<, zoff, zname);
|
2005-03-02 20:42:01 +00:00
|
|
|
|
SCM_CRITICAL_SECTION_END;
|
* gc.h, gc.c (scm_gc_sweep): Issue deprecation warning when
non-zero is returned from a port or smob free function.
(scm_malloc, scm_realloc, scm_strndup, scm_strdup,
scm_gc_register_collectable_memory,
scm_gc_unregister_collectable_memory, scm_gc_malloc,
scm_gc_realloc, scm_gc_free, scm_gc_strndup, scm_gc_strdup): New.
* backtrace.c, continuations.c, convert.i.c, coop-threads.c,
debug-malloc.c, dynl.c, environments.c, environments.h,
extensions.c, filesys.c, fports.c, gc.c, gc.h, gh_data.c, goops.c,
guardians.c, hooks.c, init.c, keywords.c, load.c, numbers.c,
ports.c, posix.c, procs.c, rdelim.c, regex-posix.c, root.c,
smob.c, stime.c, strings.c, struct.c, struct.h, symbols.c, unif.c,
vectors.c, weaks.c: Use scm_gc_malloc/scm_malloc and
scm_gc_free/free instead of scm_must_malloc and scm_must_free, as
appropriate. Return zero from smob and port free functions.
* debug-malloc.c (scm_malloc_reregister): Handle "old == NULL".
* fports.c (scm_setvbuf): Reset read buffer to saved values when
it is pointing to the putback buffer.
2002-02-11 18:06:50 +00:00
|
|
|
|
if (zname)
|
|
|
|
|
|
free (zname);
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
return result;
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
|
2004-03-20 23:18:06 +00:00
|
|
|
|
/* tm_zone is normally a pointer, not an array within struct tm, so we might
|
|
|
|
|
|
have to worry about the lifespan of what it points to. The posix specs
|
|
|
|
|
|
don't seem to say anything about this, let's assume here that tm_zone
|
|
|
|
|
|
will be a constant and therefore no protection or anything is needed
|
|
|
|
|
|
until we copy it in filltime(). */
|
|
|
|
|
|
|
2000-08-16 00:23:59 +00:00
|
|
|
|
SCM_DEFINE (scm_gmtime, "gmtime", 1, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM time),
|
2001-04-03 13:19:05 +00:00
|
|
|
|
"Return an object representing the broken down components of\n"
|
|
|
|
|
|
"@var{time}, an integer like the one returned by\n"
|
|
|
|
|
|
"@code{current-time}. The values are calculated for UTC.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_gmtime
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
{
|
|
|
|
|
|
timet itime;
|
2004-03-20 23:18:06 +00:00
|
|
|
|
struct tm bd_buf, *bd_time;
|
2004-03-06 22:41:26 +00:00
|
|
|
|
const char *zname;
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
|
2001-04-10 07:57:05 +00:00
|
|
|
|
itime = SCM_NUM2LONG (1, time);
|
2004-03-20 23:18:06 +00:00
|
|
|
|
|
2004-02-17 23:37:06 +00:00
|
|
|
|
/* POSIX says gmtime sets errno, but C99 doesn't say that.
|
|
|
|
|
|
Give a sensible default value in case gmtime doesn't set it. */
|
|
|
|
|
|
errno = EINVAL;
|
2004-03-20 23:18:06 +00:00
|
|
|
|
|
|
|
|
|
|
#if HAVE_GMTIME_R
|
|
|
|
|
|
bd_time = gmtime_r (&itime, &bd_buf);
|
|
|
|
|
|
#else
|
2005-03-02 20:42:01 +00:00
|
|
|
|
SCM_CRITICAL_SECTION_START;
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
bd_time = gmtime (&itime);
|
2004-03-20 23:18:06 +00:00
|
|
|
|
if (bd_time != NULL)
|
|
|
|
|
|
bd_buf = *bd_time;
|
2005-03-02 20:42:01 +00:00
|
|
|
|
SCM_CRITICAL_SECTION_END;
|
2004-03-20 23:18:06 +00:00
|
|
|
|
#endif
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
if (bd_time == NULL)
|
1999-12-12 02:36:16 +00:00
|
|
|
|
SCM_SYSERROR;
|
2004-03-20 23:18:06 +00:00
|
|
|
|
|
2004-03-06 22:41:26 +00:00
|
|
|
|
#if HAVE_STRUCT_TM_TM_ZONE
|
2004-03-20 23:18:06 +00:00
|
|
|
|
zname = bd_buf.tm_zone;
|
2004-03-06 22:41:26 +00:00
|
|
|
|
#else
|
|
|
|
|
|
zname = "GMT";
|
|
|
|
|
|
#endif
|
2004-03-20 23:18:06 +00:00
|
|
|
|
return filltime (&bd_buf, 0, zname);
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
|
1997-04-12 20:18:12 +00:00
|
|
|
|
/* copy time components from a Scheme object to a struct tm. */
|
|
|
|
|
|
static void
|
* chars.c (scm_lowers, scm_uppers, scm_charnames, scm_charnums),
eval.c (s_expression, s_test, s_body, s_bindings, s_variable,
s_clauses, s_formals): Variables now const.
* eval.c (promsmob): Now const.
* macros.c (macrosmob): Now const.
* smob.c (scm_newsmob): Smobfuns argument now points to const.
(freecell, flob, bigob): Now const.
* dynl.c (scm_make_argv_from_stringlist, scm_coerce_rostring),
error.c (scm_error, scm_syserror, scm_syserror_msg,
scm_num_overflow, scm_out_of_range, scm_wrong_type_arg,
scm_memory_error, scm_misc_error, scm_wta), macros.c
(scm_make_synt), feature.c (scm_add_feature), filesys.c
(scm_input_waiting_p), gc.c (scm_gc_start, scm_igc,
scm_must_malloc, scm_must_realloc), gsubr.c (scm_make_gsubr),
numbers.c (scm_num2dbl, scm_two_doubles, scm_num2long,
scm_num2long_long, scm_num2ulong),
options.c (scm_options), posix.c (scm_convert_exec_args,
environ_list_to_c), procs.c (scm_make_subr_opt, scm_make_subr),
ramap.c (scm_ramapc), read.c (scm_flush_ws), socket.c
(scm_sock_fd_to_port, scm_fill_sockaddr, scm_addr_vector), stime.c
(setzone, restorezone, bdtime2c), strop.c (scm_i_index),
strports.c (scm_mkstrport), symbols.c (scm_intern_obarray_soft,
scm_intern_obarray, scm_intern, scm_intern0,
scm_sysintern0_no_module_lookup, scm_sysintern, scm_sysintern0,
scm_symbol_value0), unif.c (scm_aind, scm_shap2ra): Argument
indicating calling subr, error message text, reason for error,
symbol name or feature name are now pointer to const.
* snarf.h (SCM_PROC, SCM_PROC1): String variables are now const.
* procs.c (scm_init_iprocs): iproc argument now points to const.
* pairs.c (cxrs): Now const.
* chars.h, error.h, feature.h, filesys.h, gc.h, gsubr.h, macros.h,
numbers.h, options.h, procs.h, ramap.h, read.h, smob.h,
strports.h, symbols.h, unif.h: Update variable declarations and
function prototypes for above changes.
* dynl.c, dynl-dld.c, dynl-dl.c, dynl-shl.c (sysdep_dynl_link,
sysdep_dynl_unlink, sysdep_dynl_func): Arguments FNAME, SUBR, and
SYMB now point to const.
1999-02-06 12:31:04 +00:00
|
|
|
|
bdtime2c (SCM sbd_time, struct tm *lt, int pos, const char *subr)
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
{
|
2005-01-02 20:49:04 +00:00
|
|
|
|
SCM_ASSERT (scm_is_simple_vector (sbd_time)
|
|
|
|
|
|
&& SCM_SIMPLE_VECTOR_LENGTH (sbd_time) == 11,
|
1999-09-08 18:38:09 +00:00
|
|
|
|
sbd_time, pos, subr);
|
|
|
|
|
|
|
2005-01-02 20:49:04 +00:00
|
|
|
|
lt->tm_sec = scm_to_int (SCM_SIMPLE_VECTOR_REF (sbd_time, 0));
|
|
|
|
|
|
lt->tm_min = scm_to_int (SCM_SIMPLE_VECTOR_REF (sbd_time, 1));
|
|
|
|
|
|
lt->tm_hour = scm_to_int (SCM_SIMPLE_VECTOR_REF (sbd_time, 2));
|
|
|
|
|
|
lt->tm_mday = scm_to_int (SCM_SIMPLE_VECTOR_REF (sbd_time, 3));
|
|
|
|
|
|
lt->tm_mon = scm_to_int (SCM_SIMPLE_VECTOR_REF (sbd_time, 4));
|
|
|
|
|
|
lt->tm_year = scm_to_int (SCM_SIMPLE_VECTOR_REF (sbd_time, 5));
|
|
|
|
|
|
lt->tm_wday = scm_to_int (SCM_SIMPLE_VECTOR_REF (sbd_time, 6));
|
|
|
|
|
|
lt->tm_yday = scm_to_int (SCM_SIMPLE_VECTOR_REF (sbd_time, 7));
|
|
|
|
|
|
lt->tm_isdst = scm_to_int (SCM_SIMPLE_VECTOR_REF (sbd_time, 8));
|
2006-10-09 23:40:48 +00:00
|
|
|
|
#if HAVE_STRUCT_TM_TM_GMTOFF
|
|
|
|
|
|
lt->tm_gmtoff = - scm_to_int (SCM_SIMPLE_VECTOR_REF (sbd_time, 9));
|
|
|
|
|
|
#endif
|
1999-06-15 14:01:13 +00:00
|
|
|
|
#ifdef HAVE_TM_ZONE
|
2005-01-02 20:49:04 +00:00
|
|
|
|
if (scm_is_false (SCM_SIMPLE_VECTOR_REF (sbd_time, 10)))
|
1999-09-08 18:38:09 +00:00
|
|
|
|
lt->tm_zone = NULL;
|
|
|
|
|
|
else
|
2005-01-02 20:49:04 +00:00
|
|
|
|
lt->tm_zone = scm_to_locale_string (SCM_SIMPLE_VECTOR_REF (sbd_time, 10));
|
1999-06-15 14:01:13 +00:00
|
|
|
|
#endif
|
1997-04-12 20:18:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2000-08-16 00:23:59 +00:00
|
|
|
|
SCM_DEFINE (scm_mktime, "mktime", 1, 1, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM sbd_time, SCM zone),
|
2000-01-18 14:13:31 +00:00
|
|
|
|
"@var{bd-time} is an object representing broken down time and @code{zone}\n"
|
|
|
|
|
|
"is an optional time zone specifier (otherwise the TZ environment variable\n"
|
|
|
|
|
|
"or the system default is used).\n\n"
|
2001-02-17 11:28:30 +00:00
|
|
|
|
"Returns a pair: the car is a corresponding\n"
|
2000-01-18 14:13:31 +00:00
|
|
|
|
"integer time value like that returned\n"
|
2001-02-17 11:28:30 +00:00
|
|
|
|
"by @code{current-time}; the cdr is a broken down time object, similar to\n"
|
2000-01-18 14:13:31 +00:00
|
|
|
|
"as @var{bd-time} but with normalized values.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_mktime
|
1997-04-12 20:18:12 +00:00
|
|
|
|
{
|
|
|
|
|
|
timet itime;
|
|
|
|
|
|
struct tm lt, *utc;
|
|
|
|
|
|
SCM result;
|
|
|
|
|
|
int zoff;
|
|
|
|
|
|
char *zname = 0;
|
1998-01-04 02:50:12 +00:00
|
|
|
|
char **oldenv;
|
1997-04-12 20:18:12 +00:00
|
|
|
|
int err;
|
|
|
|
|
|
|
2006-01-29 00:23:28 +00:00
|
|
|
|
scm_dynwind_begin (0);
|
* strings.h, strings.c: (scm_i_string_chars, scm_i_string_length,
scm_i_string_writable_chars, scm_i_string_stop_writing): New, to
replace SCM_I_STRING_CHARS and SCM_I_STRING_LENGTH. Updated all
uses.
(scm_i_make_string, scm_c_make_string): New, to replace
scm_allocate_string. Updated all uses.
(SCM_STRINGP, SCM_STRING_CHARS, SCM_STRING_UCHARS,
SCM_STRING_LENGTH): Deprecated.
(scm_allocate_string, scm_take_str, scm_take0str, scm_mem2string,
scm_str2string, scm_makfrom0str, scm_makfrom0str_opt):
Discouraged. Replaced all uses with scm_from_locale_string or
similar, as appropriate.
(scm_c_string_length, scm_c_string_ref, scm_c_string_set_x,
scm_c_substring, scm_c_substring_shared, scm_c_substring_copy,
scm_substring_shared, scm_substring_copy): New.
* symbols.c, symbols.h (SCM_SYMBOLP, SCM_SYMBOL_FUNC,
SCM_SET_SYMBOL_FUNC, SCM_SYMBOL_PROPS, SCM_SET_SYMBOL_PROPS,
SCM_SYMBOL_HASH, SCM_SYMBOL_INTERNED_P, scm_mem2symbol,
scm_str2symbol, scm_mem2uninterned_symbol): Discouraged.
(SCM_SYMBOL_LENGTH, SCM_SYMBOL_CHARS, scm_c_symbol2str):
Deprecated.
(SCM_MAKE_SYMBOL_TAG, SCM_SET_SYMBOL_LENGTH, SCM_SET_SYMBOL_CHARS,
SCM_PROP_SLOTS, SCM_SET_PROP_SLOTS): Removed.
(scm_is_symbol, scm_from_locale_symbol, scm_from_locale_symboln):
New, to replace scm_str2symbol and scm_mem2symbol, respectively.
Updated all uses.
(scm_gensym): Generate only the number suffix in the buffer, just
string-append the prefix.
2004-08-19 17:19:44 +00:00
|
|
|
|
|
1999-12-12 02:36:16 +00:00
|
|
|
|
bdtime2c (sbd_time, <, SCM_ARG1, FUNC_NAME);
|
2004-09-03 19:45:37 +00:00
|
|
|
|
#if HAVE_STRUCT_TM_TM_ZONE
|
2006-01-29 00:23:28 +00:00
|
|
|
|
scm_dynwind_free ((char *)lt.tm_zone);
|
2004-09-03 19:45:37 +00:00
|
|
|
|
#endif
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
|
2006-01-29 00:23:28 +00:00
|
|
|
|
scm_dynwind_critical_section (SCM_BOOL_F);
|
2005-11-06 22:12:04 +00:00
|
|
|
|
|
1999-12-12 02:36:16 +00:00
|
|
|
|
oldenv = setzone (zone, SCM_ARG2, FUNC_NAME);
|
2000-01-09 20:50:03 +00:00
|
|
|
|
#ifdef LOCALTIME_CACHE
|
|
|
|
|
|
tzset ();
|
|
|
|
|
|
#endif
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
itime = mktime (<);
|
2004-02-17 23:37:06 +00:00
|
|
|
|
/* POSIX doesn't say mktime sets errno, and on glibc 2.3.2 for instance it
|
|
|
|
|
|
doesn't. Force a sensible value for our error message. */
|
|
|
|
|
|
err = EINVAL;
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
|
1997-04-12 20:18:12 +00:00
|
|
|
|
if (itime != -1)
|
|
|
|
|
|
{
|
1998-10-03 08:00:05 +00:00
|
|
|
|
const char *ptr;
|
1998-01-04 02:50:12 +00:00
|
|
|
|
|
2000-02-08 22:16:15 +00:00
|
|
|
|
/* copy zone name before calling gmtime or restoring the zone. */
|
|
|
|
|
|
#if defined (HAVE_TM_ZONE)
|
1998-01-04 02:50:12 +00:00
|
|
|
|
ptr = lt.tm_zone;
|
2000-02-08 22:16:15 +00:00
|
|
|
|
#elif defined (HAVE_TZNAME)
|
1998-01-04 02:50:12 +00:00
|
|
|
|
ptr = tzname[ (lt.tm_isdst == 1) ? 1 : 0 ];
|
2000-02-08 22:16:15 +00:00
|
|
|
|
#else
|
|
|
|
|
|
ptr = "";
|
1997-04-12 20:18:12 +00:00
|
|
|
|
#endif
|
* gc.h, gc.c (scm_gc_sweep): Issue deprecation warning when
non-zero is returned from a port or smob free function.
(scm_malloc, scm_realloc, scm_strndup, scm_strdup,
scm_gc_register_collectable_memory,
scm_gc_unregister_collectable_memory, scm_gc_malloc,
scm_gc_realloc, scm_gc_free, scm_gc_strndup, scm_gc_strdup): New.
* backtrace.c, continuations.c, convert.i.c, coop-threads.c,
debug-malloc.c, dynl.c, environments.c, environments.h,
extensions.c, filesys.c, fports.c, gc.c, gc.h, gh_data.c, goops.c,
guardians.c, hooks.c, init.c, keywords.c, load.c, numbers.c,
ports.c, posix.c, procs.c, rdelim.c, regex-posix.c, root.c,
smob.c, stime.c, strings.c, struct.c, struct.h, symbols.c, unif.c,
vectors.c, weaks.c: Use scm_gc_malloc/scm_malloc and
scm_gc_free/free instead of scm_must_malloc and scm_must_free, as
appropriate. Return zero from smob and port free functions.
* debug-malloc.c (scm_malloc_reregister): Handle "old == NULL".
* fports.c (scm_setvbuf): Reset read buffer to saved values when
it is pointing to the putback buffer.
2002-02-11 18:06:50 +00:00
|
|
|
|
zname = scm_malloc (strlen (ptr) + 1);
|
1998-01-04 02:50:12 +00:00
|
|
|
|
strcpy (zname, ptr);
|
1997-04-12 20:18:12 +00:00
|
|
|
|
}
|
1998-01-04 02:50:12 +00:00
|
|
|
|
|
|
|
|
|
|
/* get timezone offset in seconds west of UTC. */
|
2004-02-17 23:37:06 +00:00
|
|
|
|
/* POSIX says gmtime sets errno, but C99 doesn't say that.
|
|
|
|
|
|
Give a sensible default value in case gmtime doesn't set it. */
|
2005-01-10 00:11:25 +00:00
|
|
|
|
errno = EINVAL;
|
1998-01-04 02:50:12 +00:00
|
|
|
|
utc = gmtime (&itime);
|
|
|
|
|
|
if (utc == NULL)
|
|
|
|
|
|
err = errno;
|
|
|
|
|
|
|
1999-12-12 02:36:16 +00:00
|
|
|
|
restorezone (zone, oldenv, FUNC_NAME);
|
1997-04-12 20:18:12 +00:00
|
|
|
|
/* delayed until zone has been restored. */
|
|
|
|
|
|
errno = err;
|
|
|
|
|
|
if (utc == NULL || itime == -1)
|
1999-12-12 02:36:16 +00:00
|
|
|
|
SCM_SYSERROR;
|
1997-04-12 20:18:12 +00:00
|
|
|
|
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
zoff = (utc->tm_hour - lt.tm_hour) * 3600 + (utc->tm_min - lt.tm_min) * 60
|
|
|
|
|
|
+ utc->tm_sec - lt.tm_sec;
|
|
|
|
|
|
if (utc->tm_year < lt.tm_year)
|
|
|
|
|
|
zoff -= 24 * 60 * 60;
|
|
|
|
|
|
else if (utc->tm_year > lt.tm_year)
|
|
|
|
|
|
zoff += 24 * 60 * 60;
|
|
|
|
|
|
else if (utc->tm_yday < lt.tm_yday)
|
|
|
|
|
|
zoff -= 24 * 60 * 60;
|
|
|
|
|
|
else if (utc->tm_yday > lt.tm_yday)
|
|
|
|
|
|
zoff += 24 * 60 * 60;
|
|
|
|
|
|
|
* numbers.h, numbers.c, discouraged.h, discouraged.c (scm_short2num,
scm_ushort2num, scm_int2num, scm_uint2num, scm_long2num,
scm_ulong2num, scm_size2num, scm_ptrdiff2num, scm_num2short,
scm_num2ushort, scm_num2int, scm_num2uint, scm_num2long,
scm_num2ulong, scm_num2size, scm_num2ptrdiff, scm_long_long2num,
scm_ulong_long2num, scm_num2long_long, scm_num2ulong_long):
Discouraged by moving to discouraged.h and discouraged.c and
reimplementing in terms of scm_from_* and scm_to_*. Changed all uses
to the new scm_from_* and scm_to_* functions.
2004-08-02 16:14:04 +00:00
|
|
|
|
result = scm_cons (scm_from_long (itime),
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
filltime (<, zoff, zname));
|
* gc.h, gc.c (scm_gc_sweep): Issue deprecation warning when
non-zero is returned from a port or smob free function.
(scm_malloc, scm_realloc, scm_strndup, scm_strdup,
scm_gc_register_collectable_memory,
scm_gc_unregister_collectable_memory, scm_gc_malloc,
scm_gc_realloc, scm_gc_free, scm_gc_strndup, scm_gc_strdup): New.
* backtrace.c, continuations.c, convert.i.c, coop-threads.c,
debug-malloc.c, dynl.c, environments.c, environments.h,
extensions.c, filesys.c, fports.c, gc.c, gc.h, gh_data.c, goops.c,
guardians.c, hooks.c, init.c, keywords.c, load.c, numbers.c,
ports.c, posix.c, procs.c, rdelim.c, regex-posix.c, root.c,
smob.c, stime.c, strings.c, struct.c, struct.h, symbols.c, unif.c,
vectors.c, weaks.c: Use scm_gc_malloc/scm_malloc and
scm_gc_free/free instead of scm_must_malloc and scm_must_free, as
appropriate. Return zero from smob and port free functions.
* debug-malloc.c (scm_malloc_reregister): Handle "old == NULL".
* fports.c (scm_setvbuf): Reset read buffer to saved values when
it is pointing to the putback buffer.
2002-02-11 18:06:50 +00:00
|
|
|
|
if (zname)
|
|
|
|
|
|
free (zname);
|
* strings.h, strings.c: (scm_i_string_chars, scm_i_string_length,
scm_i_string_writable_chars, scm_i_string_stop_writing): New, to
replace SCM_I_STRING_CHARS and SCM_I_STRING_LENGTH. Updated all
uses.
(scm_i_make_string, scm_c_make_string): New, to replace
scm_allocate_string. Updated all uses.
(SCM_STRINGP, SCM_STRING_CHARS, SCM_STRING_UCHARS,
SCM_STRING_LENGTH): Deprecated.
(scm_allocate_string, scm_take_str, scm_take0str, scm_mem2string,
scm_str2string, scm_makfrom0str, scm_makfrom0str_opt):
Discouraged. Replaced all uses with scm_from_locale_string or
similar, as appropriate.
(scm_c_string_length, scm_c_string_ref, scm_c_string_set_x,
scm_c_substring, scm_c_substring_shared, scm_c_substring_copy,
scm_substring_shared, scm_substring_copy): New.
* symbols.c, symbols.h (SCM_SYMBOLP, SCM_SYMBOL_FUNC,
SCM_SET_SYMBOL_FUNC, SCM_SYMBOL_PROPS, SCM_SET_SYMBOL_PROPS,
SCM_SYMBOL_HASH, SCM_SYMBOL_INTERNED_P, scm_mem2symbol,
scm_str2symbol, scm_mem2uninterned_symbol): Discouraged.
(SCM_SYMBOL_LENGTH, SCM_SYMBOL_CHARS, scm_c_symbol2str):
Deprecated.
(SCM_MAKE_SYMBOL_TAG, SCM_SET_SYMBOL_LENGTH, SCM_SET_SYMBOL_CHARS,
SCM_PROP_SLOTS, SCM_SET_PROP_SLOTS): Removed.
(scm_is_symbol, scm_from_locale_symbol, scm_from_locale_symboln):
New, to replace scm_str2symbol and scm_mem2symbol, respectively.
Updated all uses.
(scm_gensym): Generate only the number suffix in the buffer, just
string-append the prefix.
2004-08-19 17:19:44 +00:00
|
|
|
|
|
2006-01-29 00:23:28 +00:00
|
|
|
|
scm_dynwind_end ();
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
return result;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-01-09 20:50:03 +00:00
|
|
|
|
#ifdef HAVE_TZSET
|
2000-08-16 00:23:59 +00:00
|
|
|
|
SCM_DEFINE (scm_tzset, "tzset", 0, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(void),
|
2000-01-18 14:13:31 +00:00
|
|
|
|
"Initialize the timezone from the TZ environment variable\n"
|
|
|
|
|
|
"or the system default. It's not usually necessary to call this procedure\n"
|
|
|
|
|
|
"since it's done automatically by other procedures that depend on the\n"
|
|
|
|
|
|
"timezone.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_tzset
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
* posix.c (scm_putenv): don't check HAVE_PUTENV.
* Makefile.am (EXTRA_libguile_la_SOURCES): add putenv.c.
* configure.in: move putenv from AC_CHECK_FUNCS to AC_REPLACE_FUNCS.
* putenv.c: new file, from sh-utils 1.12.
* posix.c (scm_environ): use malloc in place of scm_must_malloc
since allocation isn't for Scheme objects.
(scm_putenv): copy strings before placing in the environment.
* stime.c (scm_current_time): throw an error if time returns -1,
instead of returning #f.
(scm_get_internal_real_time, scm_get_internal_real_time): use
scm_long2num for return value instead of SCM_MAKINUM.
* stime.h: prototypes updated.
* stime.c (scm_time_in_msec): apparently unused, deleted.
* configure.in: check for gettimeofday.
* stime.c (scm_time_plus_ticks): new procedure, an scsh interface
which may be more usefully portable than a gettimeofday interface.
* stime.c (filltime): recovered static procedure.
(scm_localtime, scm_gmtime, scm_mktime, scm_tzset): recovered from
an earlier Guile.
* posix.h: add prototype for scm_close_pipe, remove prototypes for
scm_open_input_pipe, scm_open_output_pipe, change scm_mknod prototype.
* * posix.c (scm_mknod): split the mode argument into type and perms
arguments, like the extra fields returned by stat.
* fports.c (scm_pipob): set the close, free and print procedures.
(scm_close_pipe): new procedure.
* posix.c (scm_open_input_pipe, scm_open_output_pipe): deleted,
define them in boot-9.scm
1997-04-05 21:50:31 +00:00
|
|
|
|
tzset();
|
|
|
|
|
|
return SCM_UNSPECIFIED;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
2000-01-09 20:50:03 +00:00
|
|
|
|
#endif /* HAVE_TZSET */
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_strftime, "strftime", 2, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM format, SCM stime),
|
2005-10-23 22:29:25 +00:00
|
|
|
|
"Return a string which is broken-down time structure @var{stime}\n"
|
|
|
|
|
|
"formatted according to the given @var{format} string.\n"
|
|
|
|
|
|
"\n"
|
|
|
|
|
|
"@var{format} contains field specifications introduced by a\n"
|
|
|
|
|
|
"@samp{%} character. See @ref{Formatting Calendar Time,,, libc,\n"
|
|
|
|
|
|
"The GNU C Library Reference Manual}, or @samp{man 3 strftime},\n"
|
|
|
|
|
|
"for the available formatting.\n"
|
|
|
|
|
|
"\n"
|
|
|
|
|
|
"@lisp\n"
|
|
|
|
|
|
"(strftime \"%c\" (localtime (current-time)))\n"
|
|
|
|
|
|
"@result{} \"Mon Mar 11 20:17:43 2002\"\n"
|
|
|
|
|
|
"@end lisp\n"
|
|
|
|
|
|
"\n"
|
|
|
|
|
|
"If @code{setlocale} has been called (@pxref{Locales}), month\n"
|
|
|
|
|
|
"and day names are from the current locale and in the locale\n"
|
|
|
|
|
|
"character set.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_strftime
|
1997-04-12 20:18:12 +00:00
|
|
|
|
{
|
|
|
|
|
|
struct tm t;
|
|
|
|
|
|
|
|
|
|
|
|
char *tbuf;
|
|
|
|
|
|
int size = 50;
|
* strings.h, strings.c: (scm_i_string_chars, scm_i_string_length,
scm_i_string_writable_chars, scm_i_string_stop_writing): New, to
replace SCM_I_STRING_CHARS and SCM_I_STRING_LENGTH. Updated all
uses.
(scm_i_make_string, scm_c_make_string): New, to replace
scm_allocate_string. Updated all uses.
(SCM_STRINGP, SCM_STRING_CHARS, SCM_STRING_UCHARS,
SCM_STRING_LENGTH): Deprecated.
(scm_allocate_string, scm_take_str, scm_take0str, scm_mem2string,
scm_str2string, scm_makfrom0str, scm_makfrom0str_opt):
Discouraged. Replaced all uses with scm_from_locale_string or
similar, as appropriate.
(scm_c_string_length, scm_c_string_ref, scm_c_string_set_x,
scm_c_substring, scm_c_substring_shared, scm_c_substring_copy,
scm_substring_shared, scm_substring_copy): New.
* symbols.c, symbols.h (SCM_SYMBOLP, SCM_SYMBOL_FUNC,
SCM_SET_SYMBOL_FUNC, SCM_SYMBOL_PROPS, SCM_SET_SYMBOL_PROPS,
SCM_SYMBOL_HASH, SCM_SYMBOL_INTERNED_P, scm_mem2symbol,
scm_str2symbol, scm_mem2uninterned_symbol): Discouraged.
(SCM_SYMBOL_LENGTH, SCM_SYMBOL_CHARS, scm_c_symbol2str):
Deprecated.
(SCM_MAKE_SYMBOL_TAG, SCM_SET_SYMBOL_LENGTH, SCM_SET_SYMBOL_CHARS,
SCM_PROP_SLOTS, SCM_SET_PROP_SLOTS): Removed.
(scm_is_symbol, scm_from_locale_symbol, scm_from_locale_symboln):
New, to replace scm_str2symbol and scm_mem2symbol, respectively.
Updated all uses.
(scm_gensym): Generate only the number suffix in the buffer, just
string-append the prefix.
2004-08-19 17:19:44 +00:00
|
|
|
|
const char *fmt;
|
|
|
|
|
|
char *myfmt;
|
1997-04-12 20:18:12 +00:00
|
|
|
|
int len;
|
1998-01-04 02:50:12 +00:00
|
|
|
|
SCM result;
|
1997-04-12 20:18:12 +00:00
|
|
|
|
|
2000-10-30 11:42:26 +00:00
|
|
|
|
SCM_VALIDATE_STRING (1, format);
|
1999-12-12 02:36:16 +00:00
|
|
|
|
bdtime2c (stime, &t, SCM_ARG2, FUNC_NAME);
|
1997-04-12 20:18:12 +00:00
|
|
|
|
|
* strings.h, strings.c: (scm_i_string_chars, scm_i_string_length,
scm_i_string_writable_chars, scm_i_string_stop_writing): New, to
replace SCM_I_STRING_CHARS and SCM_I_STRING_LENGTH. Updated all
uses.
(scm_i_make_string, scm_c_make_string): New, to replace
scm_allocate_string. Updated all uses.
(SCM_STRINGP, SCM_STRING_CHARS, SCM_STRING_UCHARS,
SCM_STRING_LENGTH): Deprecated.
(scm_allocate_string, scm_take_str, scm_take0str, scm_mem2string,
scm_str2string, scm_makfrom0str, scm_makfrom0str_opt):
Discouraged. Replaced all uses with scm_from_locale_string or
similar, as appropriate.
(scm_c_string_length, scm_c_string_ref, scm_c_string_set_x,
scm_c_substring, scm_c_substring_shared, scm_c_substring_copy,
scm_substring_shared, scm_substring_copy): New.
* symbols.c, symbols.h (SCM_SYMBOLP, SCM_SYMBOL_FUNC,
SCM_SET_SYMBOL_FUNC, SCM_SYMBOL_PROPS, SCM_SET_SYMBOL_PROPS,
SCM_SYMBOL_HASH, SCM_SYMBOL_INTERNED_P, scm_mem2symbol,
scm_str2symbol, scm_mem2uninterned_symbol): Discouraged.
(SCM_SYMBOL_LENGTH, SCM_SYMBOL_CHARS, scm_c_symbol2str):
Deprecated.
(SCM_MAKE_SYMBOL_TAG, SCM_SET_SYMBOL_LENGTH, SCM_SET_SYMBOL_CHARS,
SCM_PROP_SLOTS, SCM_SET_PROP_SLOTS): Removed.
(scm_is_symbol, scm_from_locale_symbol, scm_from_locale_symboln):
New, to replace scm_str2symbol and scm_mem2symbol, respectively.
Updated all uses.
(scm_gensym): Generate only the number suffix in the buffer, just
string-append the prefix.
2004-08-19 17:19:44 +00:00
|
|
|
|
fmt = scm_i_string_chars (format);
|
|
|
|
|
|
len = scm_i_string_length (format);
|
1997-04-12 20:18:12 +00:00
|
|
|
|
|
2000-07-23 23:12:39 +00:00
|
|
|
|
/* Ugly hack: strftime can return 0 if its buffer is too small,
|
|
|
|
|
|
but some valid time strings (e.g. "%p") can sometimes produce
|
|
|
|
|
|
a zero-byte output string! Workaround is to prepend a junk
|
|
|
|
|
|
character to the format string, so that valid returns are always
|
|
|
|
|
|
nonzero. */
|
* gc.h, gc.c (scm_gc_sweep): Issue deprecation warning when
non-zero is returned from a port or smob free function.
(scm_malloc, scm_realloc, scm_strndup, scm_strdup,
scm_gc_register_collectable_memory,
scm_gc_unregister_collectable_memory, scm_gc_malloc,
scm_gc_realloc, scm_gc_free, scm_gc_strndup, scm_gc_strdup): New.
* backtrace.c, continuations.c, convert.i.c, coop-threads.c,
debug-malloc.c, dynl.c, environments.c, environments.h,
extensions.c, filesys.c, fports.c, gc.c, gc.h, gh_data.c, goops.c,
guardians.c, hooks.c, init.c, keywords.c, load.c, numbers.c,
ports.c, posix.c, procs.c, rdelim.c, regex-posix.c, root.c,
smob.c, stime.c, strings.c, struct.c, struct.h, symbols.c, unif.c,
vectors.c, weaks.c: Use scm_gc_malloc/scm_malloc and
scm_gc_free/free instead of scm_must_malloc and scm_must_free, as
appropriate. Return zero from smob and port free functions.
* debug-malloc.c (scm_malloc_reregister): Handle "old == NULL".
* fports.c (scm_setvbuf): Reset read buffer to saved values when
it is pointing to the putback buffer.
2002-02-11 18:06:50 +00:00
|
|
|
|
myfmt = scm_malloc (len+2);
|
2000-07-23 23:12:39 +00:00
|
|
|
|
*myfmt = 'x';
|
|
|
|
|
|
strncpy(myfmt+1, fmt, len);
|
|
|
|
|
|
myfmt[len+1] = 0;
|
|
|
|
|
|
|
* gc.h, gc.c (scm_gc_sweep): Issue deprecation warning when
non-zero is returned from a port or smob free function.
(scm_malloc, scm_realloc, scm_strndup, scm_strdup,
scm_gc_register_collectable_memory,
scm_gc_unregister_collectable_memory, scm_gc_malloc,
scm_gc_realloc, scm_gc_free, scm_gc_strndup, scm_gc_strdup): New.
* backtrace.c, continuations.c, convert.i.c, coop-threads.c,
debug-malloc.c, dynl.c, environments.c, environments.h,
extensions.c, filesys.c, fports.c, gc.c, gc.h, gh_data.c, goops.c,
guardians.c, hooks.c, init.c, keywords.c, load.c, numbers.c,
ports.c, posix.c, procs.c, rdelim.c, regex-posix.c, root.c,
smob.c, stime.c, strings.c, struct.c, struct.h, symbols.c, unif.c,
vectors.c, weaks.c: Use scm_gc_malloc/scm_malloc and
scm_gc_free/free instead of scm_must_malloc and scm_must_free, as
appropriate. Return zero from smob and port free functions.
* debug-malloc.c (scm_malloc_reregister): Handle "old == NULL".
* fports.c (scm_setvbuf): Reset read buffer to saved values when
it is pointing to the putback buffer.
2002-02-11 18:06:50 +00:00
|
|
|
|
tbuf = scm_malloc (size);
|
2000-05-14 22:15:59 +00:00
|
|
|
|
{
|
|
|
|
|
|
#if !defined (HAVE_TM_ZONE)
|
|
|
|
|
|
/* it seems the only way to tell non-GNU versions of strftime what
|
|
|
|
|
|
zone to use (for the %Z format) is to set TZ in the
|
|
|
|
|
|
environment. interrupts and thread switching must be deferred
|
|
|
|
|
|
until TZ is restored. */
|
|
|
|
|
|
char **oldenv = NULL;
|
2005-06-05 18:27:53 +00:00
|
|
|
|
SCM zone_spec = SCM_SIMPLE_VECTOR_REF (stime, 10);
|
2000-05-15 21:23:31 +00:00
|
|
|
|
int have_zone = 0;
|
2000-05-14 22:15:59 +00:00
|
|
|
|
|
2005-06-05 18:27:53 +00:00
|
|
|
|
if (scm_is_true (zone_spec) && scm_c_string_length (zone_spec) > 0)
|
2000-05-14 22:15:59 +00:00
|
|
|
|
{
|
|
|
|
|
|
/* it's not required that the TZ setting be correct, just that
|
2000-05-15 21:23:31 +00:00
|
|
|
|
it has the right name. so try something like TZ=EST0.
|
|
|
|
|
|
using only TZ=EST would be simpler but it doesn't work on
|
|
|
|
|
|
some OSs, e.g., Solaris. */
|
|
|
|
|
|
SCM zone =
|
2005-06-05 18:27:53 +00:00
|
|
|
|
scm_string_append (scm_list_2 (zone_spec,
|
|
|
|
|
|
scm_from_locale_string ("0")));
|
2000-08-16 00:23:59 +00:00
|
|
|
|
|
2000-05-15 21:23:31 +00:00
|
|
|
|
have_zone = 1;
|
2005-03-02 20:42:01 +00:00
|
|
|
|
SCM_CRITICAL_SECTION_START;
|
2000-05-15 21:23:31 +00:00
|
|
|
|
oldenv = setzone (zone, SCM_ARG2, FUNC_NAME);
|
2000-05-14 22:15:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2000-01-09 20:50:03 +00:00
|
|
|
|
#ifdef LOCALTIME_CACHE
|
2000-05-14 22:15:59 +00:00
|
|
|
|
tzset ();
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2008-09-02 21:24:53 +02:00
|
|
|
|
/* Use `nstrftime ()' from Gnulib, which supports all GNU extensions
|
|
|
|
|
|
supported by glibc. */
|
|
|
|
|
|
while ((len = nstrftime (tbuf, size, myfmt, &t, 0, 0)) == 0)
|
2000-05-14 22:15:59 +00:00
|
|
|
|
{
|
* gc.h, gc.c (scm_gc_sweep): Issue deprecation warning when
non-zero is returned from a port or smob free function.
(scm_malloc, scm_realloc, scm_strndup, scm_strdup,
scm_gc_register_collectable_memory,
scm_gc_unregister_collectable_memory, scm_gc_malloc,
scm_gc_realloc, scm_gc_free, scm_gc_strndup, scm_gc_strdup): New.
* backtrace.c, continuations.c, convert.i.c, coop-threads.c,
debug-malloc.c, dynl.c, environments.c, environments.h,
extensions.c, filesys.c, fports.c, gc.c, gc.h, gh_data.c, goops.c,
guardians.c, hooks.c, init.c, keywords.c, load.c, numbers.c,
ports.c, posix.c, procs.c, rdelim.c, regex-posix.c, root.c,
smob.c, stime.c, strings.c, struct.c, struct.h, symbols.c, unif.c,
vectors.c, weaks.c: Use scm_gc_malloc/scm_malloc and
scm_gc_free/free instead of scm_must_malloc and scm_must_free, as
appropriate. Return zero from smob and port free functions.
* debug-malloc.c (scm_malloc_reregister): Handle "old == NULL".
* fports.c (scm_setvbuf): Reset read buffer to saved values when
it is pointing to the putback buffer.
2002-02-11 18:06:50 +00:00
|
|
|
|
free (tbuf);
|
2000-05-14 22:15:59 +00:00
|
|
|
|
size *= 2;
|
* gc.h, gc.c (scm_gc_sweep): Issue deprecation warning when
non-zero is returned from a port or smob free function.
(scm_malloc, scm_realloc, scm_strndup, scm_strdup,
scm_gc_register_collectable_memory,
scm_gc_unregister_collectable_memory, scm_gc_malloc,
scm_gc_realloc, scm_gc_free, scm_gc_strndup, scm_gc_strdup): New.
* backtrace.c, continuations.c, convert.i.c, coop-threads.c,
debug-malloc.c, dynl.c, environments.c, environments.h,
extensions.c, filesys.c, fports.c, gc.c, gc.h, gh_data.c, goops.c,
guardians.c, hooks.c, init.c, keywords.c, load.c, numbers.c,
ports.c, posix.c, procs.c, rdelim.c, regex-posix.c, root.c,
smob.c, stime.c, strings.c, struct.c, struct.h, symbols.c, unif.c,
vectors.c, weaks.c: Use scm_gc_malloc/scm_malloc and
scm_gc_free/free instead of scm_must_malloc and scm_must_free, as
appropriate. Return zero from smob and port free functions.
* debug-malloc.c (scm_malloc_reregister): Handle "old == NULL".
* fports.c (scm_setvbuf): Reset read buffer to saved values when
it is pointing to the putback buffer.
2002-02-11 18:06:50 +00:00
|
|
|
|
tbuf = scm_malloc (size);
|
2000-05-14 22:15:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if !defined (HAVE_TM_ZONE)
|
2000-05-15 21:23:31 +00:00
|
|
|
|
if (have_zone)
|
2000-05-14 22:15:59 +00:00
|
|
|
|
{
|
2005-06-05 18:27:53 +00:00
|
|
|
|
restorezone (zone_spec, oldenv, FUNC_NAME);
|
2005-03-02 20:42:01 +00:00
|
|
|
|
SCM_CRITICAL_SECTION_END;
|
2000-05-14 22:15:59 +00:00
|
|
|
|
}
|
2000-01-09 20:50:03 +00:00
|
|
|
|
#endif
|
1997-04-12 20:18:12 +00:00
|
|
|
|
}
|
2000-05-14 22:15:59 +00:00
|
|
|
|
|
* strings.h, strings.c: (scm_i_string_chars, scm_i_string_length,
scm_i_string_writable_chars, scm_i_string_stop_writing): New, to
replace SCM_I_STRING_CHARS and SCM_I_STRING_LENGTH. Updated all
uses.
(scm_i_make_string, scm_c_make_string): New, to replace
scm_allocate_string. Updated all uses.
(SCM_STRINGP, SCM_STRING_CHARS, SCM_STRING_UCHARS,
SCM_STRING_LENGTH): Deprecated.
(scm_allocate_string, scm_take_str, scm_take0str, scm_mem2string,
scm_str2string, scm_makfrom0str, scm_makfrom0str_opt):
Discouraged. Replaced all uses with scm_from_locale_string or
similar, as appropriate.
(scm_c_string_length, scm_c_string_ref, scm_c_string_set_x,
scm_c_substring, scm_c_substring_shared, scm_c_substring_copy,
scm_substring_shared, scm_substring_copy): New.
* symbols.c, symbols.h (SCM_SYMBOLP, SCM_SYMBOL_FUNC,
SCM_SET_SYMBOL_FUNC, SCM_SYMBOL_PROPS, SCM_SET_SYMBOL_PROPS,
SCM_SYMBOL_HASH, SCM_SYMBOL_INTERNED_P, scm_mem2symbol,
scm_str2symbol, scm_mem2uninterned_symbol): Discouraged.
(SCM_SYMBOL_LENGTH, SCM_SYMBOL_CHARS, scm_c_symbol2str):
Deprecated.
(SCM_MAKE_SYMBOL_TAG, SCM_SET_SYMBOL_LENGTH, SCM_SET_SYMBOL_CHARS,
SCM_PROP_SLOTS, SCM_SET_PROP_SLOTS): Removed.
(scm_is_symbol, scm_from_locale_symbol, scm_from_locale_symboln):
New, to replace scm_str2symbol and scm_mem2symbol, respectively.
Updated all uses.
(scm_gensym): Generate only the number suffix in the buffer, just
string-append the prefix.
2004-08-19 17:19:44 +00:00
|
|
|
|
result = scm_from_locale_stringn (tbuf + 1, len - 1);
|
* gc.h, gc.c (scm_gc_sweep): Issue deprecation warning when
non-zero is returned from a port or smob free function.
(scm_malloc, scm_realloc, scm_strndup, scm_strdup,
scm_gc_register_collectable_memory,
scm_gc_unregister_collectable_memory, scm_gc_malloc,
scm_gc_realloc, scm_gc_free, scm_gc_strndup, scm_gc_strdup): New.
* backtrace.c, continuations.c, convert.i.c, coop-threads.c,
debug-malloc.c, dynl.c, environments.c, environments.h,
extensions.c, filesys.c, fports.c, gc.c, gc.h, gh_data.c, goops.c,
guardians.c, hooks.c, init.c, keywords.c, load.c, numbers.c,
ports.c, posix.c, procs.c, rdelim.c, regex-posix.c, root.c,
smob.c, stime.c, strings.c, struct.c, struct.h, symbols.c, unif.c,
vectors.c, weaks.c: Use scm_gc_malloc/scm_malloc and
scm_gc_free/free instead of scm_must_malloc and scm_must_free, as
appropriate. Return zero from smob and port free functions.
* debug-malloc.c (scm_malloc_reregister): Handle "old == NULL".
* fports.c (scm_setvbuf): Reset read buffer to saved values when
it is pointing to the putback buffer.
2002-02-11 18:06:50 +00:00
|
|
|
|
free (tbuf);
|
|
|
|
|
|
free (myfmt);
|
2005-01-04 00:35:48 +00:00
|
|
|
|
#if HAVE_STRUCT_TM_TM_ZONE
|
|
|
|
|
|
free ((char *) t.tm_zone);
|
|
|
|
|
|
#endif
|
1998-01-04 02:50:12 +00:00
|
|
|
|
return result;
|
1997-04-12 20:18:12 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1997-04-12 20:18:12 +00:00
|
|
|
|
|
* eval.c: define scm_unbound_variable_key ('unbound-variable).
scm_lookupcar1: throw an error with key 'unbound-variable instead
of 'misc-error when an unbound variable is encountered.
* filesys.c (scm_mkdir, scm_rmdir, scm_getcwd, scm_select,
scm_symlink, scm_readlink, scm_lstat),
posix.c (scm_setpgid, scm_setsid, scm_ctermid, scm_tcgetpgrp,
scm_tcsetpgrp, scm_uname, scm_setlocale, scm_mknod, scm_nice,
scm_sync),
simpos.c (scm_system),
stime.c (scm_times, scm_strptime):
move the HAVE_XXX feature tests out of the procedure bodies.
don't use SCM_SYSMISSING.
scm_validate.h (SCM_SYSMISSING): removed.
error.h, error.c (scm_sysmissing): comment that this is deprecated.
see ChangeLog entry for 1999-12-28.
2000-01-09 13:41:53 +00:00
|
|
|
|
#ifdef HAVE_STRPTIME
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_strptime, "strptime", 2, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM format, SCM string),
|
2001-02-17 11:28:30 +00:00
|
|
|
|
"Performs the reverse action to @code{strftime}, parsing\n"
|
|
|
|
|
|
"@var{string} according to the specification supplied in\n"
|
|
|
|
|
|
"@var{template}. The interpretation of month and day names is\n"
|
|
|
|
|
|
"dependent on the current locale. The value returned is a pair.\n"
|
|
|
|
|
|
"The car has an object with time components\n"
|
2000-01-18 14:13:31 +00:00
|
|
|
|
"in the form returned by @code{localtime} or @code{gmtime},\n"
|
|
|
|
|
|
"but the time zone components\n"
|
|
|
|
|
|
"are not usefully set.\n"
|
2001-02-17 11:28:30 +00:00
|
|
|
|
"The cdr reports the number of characters from @var{string}\n"
|
|
|
|
|
|
"which were used for the conversion.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_strptime
|
1997-04-12 20:18:12 +00:00
|
|
|
|
{
|
|
|
|
|
|
struct tm t;
|
* strings.h, strings.c: (scm_i_string_chars, scm_i_string_length,
scm_i_string_writable_chars, scm_i_string_stop_writing): New, to
replace SCM_I_STRING_CHARS and SCM_I_STRING_LENGTH. Updated all
uses.
(scm_i_make_string, scm_c_make_string): New, to replace
scm_allocate_string. Updated all uses.
(SCM_STRINGP, SCM_STRING_CHARS, SCM_STRING_UCHARS,
SCM_STRING_LENGTH): Deprecated.
(scm_allocate_string, scm_take_str, scm_take0str, scm_mem2string,
scm_str2string, scm_makfrom0str, scm_makfrom0str_opt):
Discouraged. Replaced all uses with scm_from_locale_string or
similar, as appropriate.
(scm_c_string_length, scm_c_string_ref, scm_c_string_set_x,
scm_c_substring, scm_c_substring_shared, scm_c_substring_copy,
scm_substring_shared, scm_substring_copy): New.
* symbols.c, symbols.h (SCM_SYMBOLP, SCM_SYMBOL_FUNC,
SCM_SET_SYMBOL_FUNC, SCM_SYMBOL_PROPS, SCM_SET_SYMBOL_PROPS,
SCM_SYMBOL_HASH, SCM_SYMBOL_INTERNED_P, scm_mem2symbol,
scm_str2symbol, scm_mem2uninterned_symbol): Discouraged.
(SCM_SYMBOL_LENGTH, SCM_SYMBOL_CHARS, scm_c_symbol2str):
Deprecated.
(SCM_MAKE_SYMBOL_TAG, SCM_SET_SYMBOL_LENGTH, SCM_SET_SYMBOL_CHARS,
SCM_PROP_SLOTS, SCM_SET_PROP_SLOTS): Removed.
(scm_is_symbol, scm_from_locale_symbol, scm_from_locale_symboln):
New, to replace scm_str2symbol and scm_mem2symbol, respectively.
Updated all uses.
(scm_gensym): Generate only the number suffix in the buffer, just
string-append the prefix.
2004-08-19 17:19:44 +00:00
|
|
|
|
const char *fmt, *str, *rest;
|
2006-10-09 23:40:48 +00:00
|
|
|
|
long zoff;
|
1997-04-12 20:18:12 +00:00
|
|
|
|
|
2000-10-30 11:42:26 +00:00
|
|
|
|
SCM_VALIDATE_STRING (1, format);
|
|
|
|
|
|
SCM_VALIDATE_STRING (2, string);
|
1997-04-12 20:18:12 +00:00
|
|
|
|
|
* strings.h, strings.c: (scm_i_string_chars, scm_i_string_length,
scm_i_string_writable_chars, scm_i_string_stop_writing): New, to
replace SCM_I_STRING_CHARS and SCM_I_STRING_LENGTH. Updated all
uses.
(scm_i_make_string, scm_c_make_string): New, to replace
scm_allocate_string. Updated all uses.
(SCM_STRINGP, SCM_STRING_CHARS, SCM_STRING_UCHARS,
SCM_STRING_LENGTH): Deprecated.
(scm_allocate_string, scm_take_str, scm_take0str, scm_mem2string,
scm_str2string, scm_makfrom0str, scm_makfrom0str_opt):
Discouraged. Replaced all uses with scm_from_locale_string or
similar, as appropriate.
(scm_c_string_length, scm_c_string_ref, scm_c_string_set_x,
scm_c_substring, scm_c_substring_shared, scm_c_substring_copy,
scm_substring_shared, scm_substring_copy): New.
* symbols.c, symbols.h (SCM_SYMBOLP, SCM_SYMBOL_FUNC,
SCM_SET_SYMBOL_FUNC, SCM_SYMBOL_PROPS, SCM_SET_SYMBOL_PROPS,
SCM_SYMBOL_HASH, SCM_SYMBOL_INTERNED_P, scm_mem2symbol,
scm_str2symbol, scm_mem2uninterned_symbol): Discouraged.
(SCM_SYMBOL_LENGTH, SCM_SYMBOL_CHARS, scm_c_symbol2str):
Deprecated.
(SCM_MAKE_SYMBOL_TAG, SCM_SET_SYMBOL_LENGTH, SCM_SET_SYMBOL_CHARS,
SCM_PROP_SLOTS, SCM_SET_PROP_SLOTS): Removed.
(scm_is_symbol, scm_from_locale_symbol, scm_from_locale_symboln):
New, to replace scm_str2symbol and scm_mem2symbol, respectively.
Updated all uses.
(scm_gensym): Generate only the number suffix in the buffer, just
string-append the prefix.
2004-08-19 17:19:44 +00:00
|
|
|
|
fmt = scm_i_string_chars (format);
|
|
|
|
|
|
str = scm_i_string_chars (string);
|
1997-04-12 20:18:12 +00:00
|
|
|
|
|
|
|
|
|
|
/* initialize the struct tm */
|
|
|
|
|
|
#define tm_init(field) t.field = 0
|
|
|
|
|
|
tm_init (tm_sec);
|
|
|
|
|
|
tm_init (tm_min);
|
|
|
|
|
|
tm_init (tm_hour);
|
|
|
|
|
|
tm_init (tm_mday);
|
|
|
|
|
|
tm_init (tm_mon);
|
|
|
|
|
|
tm_init (tm_year);
|
|
|
|
|
|
tm_init (tm_wday);
|
|
|
|
|
|
tm_init (tm_yday);
|
2006-10-09 23:40:48 +00:00
|
|
|
|
#if HAVE_STRUCT_TM_TM_GMTOFF
|
|
|
|
|
|
tm_init (tm_gmtoff);
|
|
|
|
|
|
#endif
|
1997-04-12 20:18:12 +00:00
|
|
|
|
#undef tm_init
|
|
|
|
|
|
|
2003-09-03 00:01:17 +00:00
|
|
|
|
/* GNU glibc strptime() "%s" is affected by the current timezone, since it
|
|
|
|
|
|
reads a UTC time_t value and converts with localtime_r() to set the tm
|
2005-03-02 20:42:01 +00:00
|
|
|
|
fields, hence the use of SCM_CRITICAL_SECTION_START. */
|
1997-04-12 20:18:12 +00:00
|
|
|
|
t.tm_isdst = -1;
|
2005-03-02 20:42:01 +00:00
|
|
|
|
SCM_CRITICAL_SECTION_START;
|
2004-09-07 00:15:48 +00:00
|
|
|
|
rest = strptime (str, fmt, &t);
|
2005-03-02 20:42:01 +00:00
|
|
|
|
SCM_CRITICAL_SECTION_END;
|
2004-09-07 00:15:48 +00:00
|
|
|
|
if (rest == NULL)
|
2004-02-17 23:37:06 +00:00
|
|
|
|
{
|
|
|
|
|
|
/* POSIX doesn't say strptime sets errno, and on glibc 2.3.2 for
|
|
|
|
|
|
instance it doesn't. Force a sensible value for our error
|
|
|
|
|
|
message. */
|
|
|
|
|
|
errno = EINVAL;
|
|
|
|
|
|
SCM_SYSERROR;
|
|
|
|
|
|
}
|
1997-04-12 20:18:12 +00:00
|
|
|
|
|
2006-10-09 23:40:48 +00:00
|
|
|
|
/* tm_gmtoff is set by GNU glibc strptime "%s", so capture it when
|
|
|
|
|
|
available */
|
|
|
|
|
|
#if HAVE_STRUCT_TM_TM_GMTOFF
|
|
|
|
|
|
zoff = - t.tm_gmtoff; /* seconds west, not east */
|
|
|
|
|
|
#else
|
|
|
|
|
|
zoff = 0;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
return scm_cons (filltime (&t, zoff, NULL),
|
2004-07-23 15:43:02 +00:00
|
|
|
|
scm_from_signed_integer (rest - str));
|
1997-04-12 20:18:12 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
* eval.c: define scm_unbound_variable_key ('unbound-variable).
scm_lookupcar1: throw an error with key 'unbound-variable instead
of 'misc-error when an unbound variable is encountered.
* filesys.c (scm_mkdir, scm_rmdir, scm_getcwd, scm_select,
scm_symlink, scm_readlink, scm_lstat),
posix.c (scm_setpgid, scm_setsid, scm_ctermid, scm_tcgetpgrp,
scm_tcsetpgrp, scm_uname, scm_setlocale, scm_mknod, scm_nice,
scm_sync),
simpos.c (scm_system),
stime.c (scm_times, scm_strptime):
move the HAVE_XXX feature tests out of the procedure bodies.
don't use SCM_SYSMISSING.
scm_validate.h (SCM_SYSMISSING): removed.
error.h, error.c (scm_sysmissing): comment that this is deprecated.
see ChangeLog entry for 1999-12-28.
2000-01-09 13:41:53 +00:00
|
|
|
|
#endif /* HAVE_STRPTIME */
|
1997-04-12 20:18:12 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
void
|
|
|
|
|
|
scm_init_stime()
|
|
|
|
|
|
{
|
2001-05-15 14:57:22 +00:00
|
|
|
|
scm_c_define ("internal-time-units-per-second",
|
* numbers.h, numbers.c, discouraged.h, discouraged.c (scm_short2num,
scm_ushort2num, scm_int2num, scm_uint2num, scm_long2num,
scm_ulong2num, scm_size2num, scm_ptrdiff2num, scm_num2short,
scm_num2ushort, scm_num2int, scm_num2uint, scm_num2long,
scm_num2ulong, scm_num2size, scm_num2ptrdiff, scm_long_long2num,
scm_ulong_long2num, scm_num2long_long, scm_num2ulong_long):
Discouraged by moving to discouraged.h and discouraged.c and
reimplementing in terms of scm_from_* and scm_to_*. Changed all uses
to the new scm_from_* and scm_to_* functions.
2004-08-02 16:14:04 +00:00
|
|
|
|
scm_from_long (SCM_TIME_UNITS_PER_SECOND));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_FTIME
|
|
|
|
|
|
if (!scm_your_base.time) ftime(&scm_your_base);
|
|
|
|
|
|
#else
|
|
|
|
|
|
if (!scm_your_base) time(&scm_your_base);
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
if (!scm_my_base) scm_my_base = mytime();
|
|
|
|
|
|
|
1997-03-02 15:40:23 +00:00
|
|
|
|
scm_add_feature ("current-time");
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/stime.x"
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2000-03-19 19:01:16 +00:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
Local Variables:
|
|
|
|
|
|
c-file-style: "gnu"
|
|
|
|
|
|
End:
|
|
|
|
|
|
*/
|