2003-06-14 Stefan Jahn <stefan@lkcc.org>
* configure.in: Checking for __int64 as possible candidate for
the SCM_I_GSC_T_INT64 define.
2003-06-14 Stefan Jahn <stefan@lkcc.org>
* threads.h: Redefined scm_getspecific() and scm_setspecific()
to be functions instead of macros.
* threads.c: Conditionalized inclusion of <sys/time.h> and
<unistd.h>.
(scm_getspecific, scm_setspecific): Made these two function
real part of the API.
* posix.c (s_scm_putenv): Added some code to make a
(putenv "FOO="), i.e. setting an empty string, work also on
Win32 systems. Thanks to Kevin Ryde for the proposal.
This commit is contained in:
parent
cf4e2dabf4
commit
fcc5d734fc
8 changed files with 97 additions and 12 deletions
|
|
@ -1,3 +1,8 @@
|
||||||
|
2003-06-14 Stefan Jahn <stefan@lkcc.org>
|
||||||
|
|
||||||
|
* configure.in: Checking for __int64 as possible candidate for
|
||||||
|
the SCM_I_GSC_T_INT64 define.
|
||||||
|
|
||||||
2003-05-30 Stefan Jahn <stefan@lkcc.org>
|
2003-05-30 Stefan Jahn <stefan@lkcc.org>
|
||||||
|
|
||||||
* configure.in: Checking for unsetenv().
|
* configure.in: Checking for unsetenv().
|
||||||
|
|
|
||||||
10
configure.in
10
configure.in
|
|
@ -242,6 +242,8 @@ AC_CHECK_SIZEOF(unsigned long)
|
||||||
AC_CHECK_SIZEOF(size_t)
|
AC_CHECK_SIZEOF(size_t)
|
||||||
AC_CHECK_SIZEOF(long long)
|
AC_CHECK_SIZEOF(long long)
|
||||||
AC_CHECK_SIZEOF(unsigned long long)
|
AC_CHECK_SIZEOF(unsigned long long)
|
||||||
|
AC_CHECK_SIZEOF(__int64)
|
||||||
|
AC_CHECK_SIZEOF(unsigned __int64)
|
||||||
AC_CHECK_SIZEOF(void *)
|
AC_CHECK_SIZEOF(void *)
|
||||||
AC_CHECK_SIZEOF(intptr_t)
|
AC_CHECK_SIZEOF(intptr_t)
|
||||||
AC_CHECK_SIZEOF(uintptr_t)
|
AC_CHECK_SIZEOF(uintptr_t)
|
||||||
|
|
@ -419,7 +421,7 @@ fi
|
||||||
AC_SUBST([SCM_I_GSC_T_UINT32])
|
AC_SUBST([SCM_I_GSC_T_UINT32])
|
||||||
|
|
||||||
### Optional type scm_t_int64 (ANSI C says int, short, or long might work)
|
### Optional type scm_t_int64 (ANSI C says int, short, or long might work)
|
||||||
### Also try long long if we have it.
|
### Also try 'long long' and '__int64' if we have it.
|
||||||
SCM_I_GSC_T_INT64=0
|
SCM_I_GSC_T_INT64=0
|
||||||
if test "$ac_cv_sizeof_int" -eq 8; then
|
if test "$ac_cv_sizeof_int" -eq 8; then
|
||||||
SCM_I_GSC_T_INT64='"int"'
|
SCM_I_GSC_T_INT64='"int"'
|
||||||
|
|
@ -429,6 +431,8 @@ elif test "$ac_cv_sizeof_short" -eq 8; then
|
||||||
SCM_I_GSC_T_INT64='"short"'
|
SCM_I_GSC_T_INT64='"short"'
|
||||||
elif test "$ac_cv_sizeof_long_long" -eq 8; then
|
elif test "$ac_cv_sizeof_long_long" -eq 8; then
|
||||||
SCM_I_GSC_T_INT64='"long long"'
|
SCM_I_GSC_T_INT64='"long long"'
|
||||||
|
elif test "$ac_cv_sizeof___int64" -eq 8; then
|
||||||
|
SCM_I_GSC_T_INT64='"__int64"'
|
||||||
elif test "$scm_stdint_has_int64"; then
|
elif test "$scm_stdint_has_int64"; then
|
||||||
SCM_I_GSC_T_INT64='"int64_t"'
|
SCM_I_GSC_T_INT64='"int64_t"'
|
||||||
SCM_I_GSC_NEEDS_STDINT_H=1
|
SCM_I_GSC_NEEDS_STDINT_H=1
|
||||||
|
|
@ -441,7 +445,7 @@ fi
|
||||||
AC_SUBST([SCM_I_GSC_T_INT64])
|
AC_SUBST([SCM_I_GSC_T_INT64])
|
||||||
|
|
||||||
### Optional type scm_t_uint64 (ANSI C says int, short, or long might work)
|
### Optional type scm_t_uint64 (ANSI C says int, short, or long might work)
|
||||||
### Also try long long if we have it.
|
### Also try 'long long' and '__int64' if we have it.
|
||||||
SCM_I_GSC_T_UINT64=0
|
SCM_I_GSC_T_UINT64=0
|
||||||
if test "$ac_cv_sizeof_unsigned_int" -eq 8; then
|
if test "$ac_cv_sizeof_unsigned_int" -eq 8; then
|
||||||
SCM_I_GSC_T_UINT64='"unsigned int"'
|
SCM_I_GSC_T_UINT64='"unsigned int"'
|
||||||
|
|
@ -451,6 +455,8 @@ elif test "$ac_cv_sizeof_unsigned_short" -eq 8; then
|
||||||
SCM_I_GSC_T_UINT64='"unsigned short"'
|
SCM_I_GSC_T_UINT64='"unsigned short"'
|
||||||
elif test "$ac_cv_sizeof_unsigned_long_long" -eq 8; then
|
elif test "$ac_cv_sizeof_unsigned_long_long" -eq 8; then
|
||||||
SCM_I_GSC_T_UINT64='"unsigned long long"'
|
SCM_I_GSC_T_UINT64='"unsigned long long"'
|
||||||
|
elif test "$ac_cv_sizeof_unsigned___int64" -eq 8; then
|
||||||
|
SCM_I_GSC_T_UINT64='"unsigned __int64"'
|
||||||
elif test "$scm_stdint_has_uint64"; then
|
elif test "$scm_stdint_has_uint64"; then
|
||||||
SCM_I_GSC_T_UINT64='"uint64_t"'
|
SCM_I_GSC_T_UINT64='"uint64_t"'
|
||||||
SCM_I_GSC_NEEDS_STDINT_H=1
|
SCM_I_GSC_NEEDS_STDINT_H=1
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,17 @@
|
||||||
|
2003-06-14 Stefan Jahn <stefan@lkcc.org>
|
||||||
|
|
||||||
|
* threads.h: Redefined scm_getspecific() and scm_setspecific()
|
||||||
|
to be functions instead of macros.
|
||||||
|
|
||||||
|
* threads.c: Conditionalized inclusion of <sys/time.h> and
|
||||||
|
<unistd.h>.
|
||||||
|
(scm_getspecific, scm_setspecific): Made these two function
|
||||||
|
real part of the API.
|
||||||
|
|
||||||
|
* posix.c (s_scm_putenv): Added some code to make a
|
||||||
|
(putenv "FOO="), i.e. setting an empty string, work also on
|
||||||
|
Win32 systems. Thanks to Kevin Ryde for the proposal.
|
||||||
|
|
||||||
2003-06-12 Kevin Ryde <user42@zip.com.au>
|
2003-06-12 Kevin Ryde <user42@zip.com.au>
|
||||||
|
|
||||||
* posix.c (scm_putenv): Free temporary ptr in mingw unset. Add
|
* posix.c (scm_putenv): Free temporary ptr in mingw unset. Add
|
||||||
|
|
|
||||||
|
|
@ -68,8 +68,13 @@ SCM_API const char scm_s_formals[];
|
||||||
#define scm_substring_move_left_x scm_substring_move_x
|
#define scm_substring_move_left_x scm_substring_move_x
|
||||||
#define scm_substring_move_right_x scm_substring_move_x
|
#define scm_substring_move_right_x scm_substring_move_x
|
||||||
|
|
||||||
|
#if SCM_SIZEOF_LONG_LONG != 0
|
||||||
typedef long long long_long;
|
typedef long long long_long;
|
||||||
typedef unsigned long long ulong_long;
|
typedef unsigned long long ulong_long;
|
||||||
|
#elif SCM_SIZEOF___INT64 != 0
|
||||||
|
typedef __int64 long_long;
|
||||||
|
typedef unsigned __int64 ulong_long;
|
||||||
|
#endif
|
||||||
|
|
||||||
#define scm_sizet size_t
|
#define scm_sizet size_t
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -276,6 +276,8 @@ main (int argc, char *argv[])
|
||||||
" be more likely to be what you want */\n");
|
" be more likely to be what you want */\n");
|
||||||
pf ("#define SCM_SIZEOF_LONG_LONG %d\n", SIZEOF_LONG_LONG);
|
pf ("#define SCM_SIZEOF_LONG_LONG %d\n", SIZEOF_LONG_LONG);
|
||||||
pf ("#define SCM_SIZEOF_UNSIGNED_LONG_LONG %d\n", SIZEOF_UNSIGNED_LONG_LONG);
|
pf ("#define SCM_SIZEOF_UNSIGNED_LONG_LONG %d\n", SIZEOF_UNSIGNED_LONG_LONG);
|
||||||
|
pf ("#define SCM_SIZEOF___INT64 %d\n", SIZEOF___INT64);
|
||||||
|
pf ("#define SCM_SIZEOF_UNSIGNED___INT64 %d\n", SIZEOF_UNSIGNED___INT64);
|
||||||
|
|
||||||
pf ("\n");
|
pf ("\n");
|
||||||
pf ("/* These are always defined. */\n");
|
pf ("/* These are always defined. */\n");
|
||||||
|
|
|
||||||
|
|
@ -1175,6 +1175,8 @@ SCM_DEFINE (scm_putenv, "putenv", 1, 0, 0,
|
||||||
environment variable 'name'. */
|
environment variable 'name'. */
|
||||||
int e;
|
int e;
|
||||||
ptr = scm_malloc (SCM_STRING_LENGTH (str) + 2);
|
ptr = scm_malloc (SCM_STRING_LENGTH (str) + 2);
|
||||||
|
if (ptr == NULL)
|
||||||
|
SCM_MEMORY_ERROR;
|
||||||
strncpy (ptr, SCM_STRING_CHARS (str), SCM_STRING_LENGTH (str));
|
strncpy (ptr, SCM_STRING_CHARS (str), SCM_STRING_LENGTH (str));
|
||||||
ptr[SCM_STRING_LENGTH (str)] = '=';
|
ptr[SCM_STRING_LENGTH (str)] = '=';
|
||||||
ptr[SCM_STRING_LENGTH (str) + 1] = 0;
|
ptr[SCM_STRING_LENGTH (str) + 1] = 0;
|
||||||
|
|
@ -1182,7 +1184,7 @@ SCM_DEFINE (scm_putenv, "putenv", 1, 0, 0,
|
||||||
e = errno; free (ptr); errno = e;
|
e = errno; free (ptr); errno = e;
|
||||||
if (rv < 0)
|
if (rv < 0)
|
||||||
SCM_SYSERROR;
|
SCM_SYSERROR;
|
||||||
#endif
|
#endif /* !HAVE_UNSETENV */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -1191,6 +1193,41 @@ SCM_DEFINE (scm_putenv, "putenv", 1, 0, 0,
|
||||||
if (ptr == NULL)
|
if (ptr == NULL)
|
||||||
SCM_MEMORY_ERROR;
|
SCM_MEMORY_ERROR;
|
||||||
strncpy (ptr, SCM_STRING_CHARS (str), SCM_STRING_LENGTH (str));
|
strncpy (ptr, SCM_STRING_CHARS (str), SCM_STRING_LENGTH (str));
|
||||||
|
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
/* If str is "FOO=", ie. attempting to set an empty string, then
|
||||||
|
we need to see if it's been successful. On MINGW, "FOO="
|
||||||
|
means remove FOO from the environment. As a workaround, we
|
||||||
|
set "FOO= ", ie. a space, and then modify the string returned
|
||||||
|
by getenv. It's not enough just to modify the string we set,
|
||||||
|
because MINGW putenv copies it. */
|
||||||
|
if (ptr[SCM_STRING_LENGTH (str) - 1] == '=')
|
||||||
|
{
|
||||||
|
char *alt;
|
||||||
|
SCM name = scm_substring (str, SCM_MAKINUM (0),
|
||||||
|
SCM_MAKINUM (SCM_STRING_LENGTH (str) - 1));
|
||||||
|
if (getenv (SCM_STRING_CHARS (name)) == NULL)
|
||||||
|
{
|
||||||
|
alt = scm_malloc (SCM_STRING_LENGTH (str) + 2);
|
||||||
|
if (alt == NULL)
|
||||||
|
{
|
||||||
|
free (ptr);
|
||||||
|
SCM_MEMORY_ERROR;
|
||||||
|
}
|
||||||
|
memcpy (alt, SCM_STRING_CHARS (str), SCM_STRING_LENGTH (str));
|
||||||
|
alt[SCM_STRING_LENGTH (str)] = ' ';
|
||||||
|
alt[SCM_STRING_LENGTH (str) + 1] = '\0';
|
||||||
|
rv = putenv (alt);
|
||||||
|
if (rv < 0)
|
||||||
|
SCM_SYSERROR;
|
||||||
|
free (ptr); /* don't need the old string we gave to putenv */
|
||||||
|
}
|
||||||
|
alt = getenv (SCM_STRING_CHARS (name));
|
||||||
|
alt[0] = '\0';
|
||||||
|
return SCM_UNSPECIFIED;
|
||||||
|
}
|
||||||
|
#endif /* __MINGW32__ */
|
||||||
|
|
||||||
ptr[SCM_STRING_LENGTH (str)] = 0;
|
ptr[SCM_STRING_LENGTH (str)] = 0;
|
||||||
rv = putenv (ptr);
|
rv = putenv (ptr);
|
||||||
if (rv < 0)
|
if (rv < 0)
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,14 @@
|
||||||
|
|
||||||
#include "libguile/_scm.h"
|
#include "libguile/_scm.h"
|
||||||
|
|
||||||
|
#if HAVE_UNISTD_H
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#if HAVE_SYS_TIME_H
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "libguile/validate.h"
|
#include "libguile/validate.h"
|
||||||
#include "libguile/root.h"
|
#include "libguile/root.h"
|
||||||
|
|
@ -1088,6 +1092,18 @@ scm_cond_timedwait (scm_t_cond *c, scm_t_mutex *m, const scm_t_timespec *wt)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
scm_getspecific (scm_t_key k)
|
||||||
|
{
|
||||||
|
return scm_i_plugin_getspecific (k);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
scm_setspecific (scm_t_key k, void *s)
|
||||||
|
{
|
||||||
|
return scm_i_plugin_setspecific (k, s);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
scm_enter_guile ()
|
scm_enter_guile ()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,12 @@ SCM_API void scm_threads_mark_stacks (void);
|
||||||
SCM_API void scm_init_threads (SCM_STACKITEM *);
|
SCM_API void scm_init_threads (SCM_STACKITEM *);
|
||||||
SCM_API void scm_init_thread_procs (void);
|
SCM_API void scm_init_thread_procs (void);
|
||||||
|
|
||||||
|
#if SCM_USE_PTHREAD_THREADS
|
||||||
|
# include "libguile/pthread-threads.h"
|
||||||
|
#else
|
||||||
|
# include "libguile/null-threads.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
/* Low-level C API */
|
/* Low-level C API */
|
||||||
|
|
||||||
|
|
@ -130,8 +136,8 @@ SCM_API int scm_cond_timedwait (scm_t_cond *c,
|
||||||
|
|
||||||
#define scm_key_create scm_i_plugin_key_create
|
#define scm_key_create scm_i_plugin_key_create
|
||||||
#define scm_key_delete scm_i_plugin_key_delete
|
#define scm_key_delete scm_i_plugin_key_delete
|
||||||
#define scm_setspecific scm_i_plugin_setspecific
|
SCM_API int scm_setspecific (scm_t_key k, void *s);
|
||||||
#define scm_getspecific scm_i_plugin_getspecific
|
SCM_API void *scm_getspecific (scm_t_key k);
|
||||||
|
|
||||||
#define scm_thread_select scm_internal_select
|
#define scm_thread_select scm_internal_select
|
||||||
|
|
||||||
|
|
@ -224,19 +230,13 @@ SCM_API SCM scm_thread_exited_p (SCM thread);
|
||||||
|
|
||||||
SCM_API scm_root_state *scm_i_thread_root (SCM thread);
|
SCM_API scm_root_state *scm_i_thread_root (SCM thread);
|
||||||
|
|
||||||
#if SCM_USE_PTHREAD_THREADS
|
|
||||||
# include "libguile/pthread-threads.h"
|
|
||||||
#else
|
|
||||||
# include "libguile/null-threads.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SCM_CURRENT_THREAD \
|
#define SCM_CURRENT_THREAD \
|
||||||
((scm_thread *) scm_i_plugin_getspecific (scm_i_thread_key))
|
((scm_thread *) scm_i_plugin_getspecific (scm_i_thread_key))
|
||||||
extern scm_t_key scm_i_thread_key;
|
extern scm_t_key scm_i_thread_key;
|
||||||
|
|
||||||
/* These macros have confusing names.
|
/* These macros have confusing names.
|
||||||
They really refer to the root state of the running thread. */
|
They really refer to the root state of the running thread. */
|
||||||
#define SCM_THREAD_LOCAL_DATA (scm_i_plugin_getspecific (scm_i_root_state_key))
|
#define SCM_THREAD_LOCAL_DATA (scm_getspecific (scm_i_root_state_key))
|
||||||
#define SCM_SET_THREAD_LOCAL_DATA(x) scm_i_set_thread_data(x)
|
#define SCM_SET_THREAD_LOCAL_DATA(x) scm_i_set_thread_data(x)
|
||||||
SCM_API scm_t_key scm_i_root_state_key;
|
SCM_API scm_t_key scm_i_root_state_key;
|
||||||
SCM_API void scm_i_set_thread_data (void *);
|
SCM_API void scm_i_set_thread_data (void *);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue