1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-11 00:00:49 +02:00
Commit graph

5570 commits

Author SHA1 Message Date
Ludovic Courtès
93f68a5ac4 Remove set-but-unused variables from libguile.
* libguile/filesys.c (scm_readdir): Remove set-but-unused `namlen' variable.
* libguile/fports.c (fport_flush): Same for `written'.
* libguile/gc-segment.c (scm_i_initialize_heap_segment_data): Same
  for `bvec_ptr'.
* libguile/posix.c (scm_nice): Same for `nice_value'.
* libguile/scmsigs.c (take_signal): Same for `count'.
* libguile/srfi-4.c (uvec_to_list): Same for `elts'.
* libguile/stacks.c (scm_stack_ref): Same for `c_index'.
* libguile/threads.c (scm_std_select): Same for `count'.
* libguile/throw.c (scm_ithrow): Same for `answer'.
* libguile/unif.c (scm_i_read_array): Same for `got_rank'.
2012-05-23 14:55:38 +02:00
Noah Lavine
e254747644 Remove unused variable
* libguile/async.c (scm_i_queue_async_cell): remove unused
  variable 'count'.
2012-05-01 23:27:58 -04:00
Noah Lavine
f5556ab3e6 Remove duplicate definitions
* libguile/c-tokenize.lex: remove duplicate definitions of yy*
  functions. Solution by Sergey Poznyakoff.
2012-05-01 23:27:32 -04:00
Ludovic Courtès
9718acde77 Don't rely on `HAVE_' macros in public header "tags.h".
* configure.ac: Check for `intptr_t' and `uintptr_t'.  Substitute
  `SCM_I_GSC_T_INTPTR' and `SCM_I_GSC_T_UINPTR'.

* libguile/__scm.h (SCM_T_UINTPTR_MAX, SCM_T_INTPTR_MIN,
  SCM_T_INTPTR_MAX): New macros.

* libguile/_scm.h (SIZEOF_SCM_T_BITS): New macro.

* libguile/gen-scmconfig.c (main): Produce typedefs for `scm_t_intptr'
  and `scm_t_uintptr'.

* libguile/gen-scmconfig.h.in (SCM_I_GSC_T_INTPTR, SCM_I_GSC_T_UINPTR):
  New macros.

* libguile/tags.h: Don't check for `HAVE_INTTYPES_H' and
  `HAVE_STDINT_H'; don't include <inttypes.h> nor <stdint.h>.
  (scm_t_signed_bits, scm_t_bits): Define unconditionally as aliases for
  `scm_t_intptr' and `scm_t_uintptr', respectively.
  (SCM_T_SIGNED_BITS_MAX, SCM_T_SIGNED_BITS_MIN, SCM_T_BITS_MAX):
  Likewise.
  (SIZEOF_SCM_T_BITS): Remove.
2011-11-06 18:15:51 +01:00
Cedric Cellier
c27411f180 Default to using poll(2) in `fport_input_waiting'.
* libguile/fports.c (fport_input_waiting): Use poll(2) instead of
  select(2) when possible.  Cosmetic changes by Ludovic Courtès.

* configure.in: Look for <poll.h> and `poll'.
2011-10-19 17:21:52 +02:00
Andy Wingo
99c6be814f fix write-beyond-end of an on-stack buffer while reading typed arrays
* libguile/unif.c (scm_i_read_array): Fix case in which we could write
  beyond the end of `tag'.  See
  http://article.gmane.org/gmane.lisp.guile.devel/12685.
2011-07-29 09:31:32 +02:00
Andy Wingo
4e30666a1a fix libguile compilation on newer solaris
* libguile/gc_os_dep.c: Update SUNOS5 stack and heap bounding heuristics
  from upstream libgc. Based on a patch by Marion Hakanson.
2010-08-29 12:20:05 -07:00
Andy Wingo
3de9a08715 fix vector-move-right! and vector-move-left!
* libguile/vectors.c (scm_vector_move_left_x, scm_vector_move_right_x):
  Fix some bugs reported by Michael Lucy -- both variants would happily
  write beyond the end, and vector-move-right! didn't increment the
  counter before copying in the reverse direction.

* test-suite/tests/vectors.test ("vector-move-left!"):
  ("vector-move-right!"): Add tests.
2010-08-05 10:54:37 +02:00
Andy Wingo
7e6f4be53e Fix the range of `random' on 64-bit platforms
For > 32 bit integers still in the fixnum range, scm_random() would
return random numbers with a lower range than specified.

* libguile/random.c (scm_i_mask32): New static inline function.
  (scm_c_random): Use `scm_i_mask32'.
  (scm_c_random64): New function, 64-bit variant of scm_c_random.
  (scm_random): Use `scm_c_random64' instead of forming the 64-bit random
  number in a bogus way.
* libguile/random.h: Added `scm_c_random64'.

Conflicts:

	libguile/random.c
	libguile/random.h
2010-08-04 20:13:04 +02:00
Andy Wingo
cfbccaf49c scm_random fix for 64-bit inums
* libguile/random.c (scm_random): Fix for 64-bit inums.
2010-07-27 11:43:22 +02:00
Andy Wingo
3bac8ddf92 though scm_c_random returns a ulong, it's only 32 random bits
* libguile/random.c (scm_c_random): Revert previous patch adapting to
  assume ulong-sized bits, as the RNGs really only give us 32 bits at a
  time.
  (scm_c_random_bignum): Adjust to expect random_bits giving us 32 bits
  at a time.

* libguile/random.h: Add comments.
2010-07-26 14:38:20 +02:00
Andy Wingo
db6e848d19 always having scm_t_uint64
* libguile/gen-scmconfig.c:
* libguile/random.c:
* libguile/srfi-4.c:
* libguile/srfi-4.h:
* libguile/__scm.h:
* libguile/numbers.c:
* libguile/numbers.h:
* test-suite/standalone/test-conversion.c: Since we always require
  scm_t_uint64 and friends, remove some conditional compiles.
2010-07-26 14:38:15 +02:00
Andreas Rottmann
33290f52ef Fix random number generator on 64-bit platforms
* libguile/random.c (scm_c_random): On platforms where `unsigned long' has 64
  bit, generate up to 64 bit of randomness. This is expected by
  scm_c_random_bignum(), and hence was a serious distortion of the random value
  distribution for values exceeding 2^32. This change also fixes a crash when
  the `m' argument is a value above 2^32.
2010-07-19 22:55:16 +02:00
Andy Wingo
2462fad237 avoid type-punning errors in guile_ieee_init on OSF
* libguile/numbers.c (guile_ieee_init): Avoid type-punning errors on
  OSF. Thanks to Jay Krell for the report.
2010-06-10 14:34:51 +02:00
Andy Wingo
899a17a783 fix build error with Compaq C V6.3-025
* libguile/hashtab.c: Re-arrange functions to avoid the need for
  pre-declaring character arrays with no length. Fixes compilation on
  Compaq C V6.3-025. Thanks to Jay Krell for the report.
2010-06-09 23:21:20 +02:00
Neil Jerram
23ff1cff61 Fix Interix build hang
Jay Krell writes:

"Later on I get to:
gawk -f ./guile-func-name-check /src/guile-1.8.6/libguile/regex-posix.c
(./guile-snarf-docs -DHAVE_CONFIG_H -I.. -I/src/guile-1.8.6 -I.. -g -O2 -Wall -
Wmissing-prototypes -Werror /src/guile-1.8.6/libguile/regex-posix.c | \
./guile_filter_doc_snarfage --filter-snarfage) > regex-posix.doc || { rm
regex-posix.doc; false; }
cat alist.doc arbiters.doc async.doc backtrace.doc boolean.doc chars.doc
continuations.doc debug.doc deprecation.doc deprecated.doc discouraged.doc dynl.doc
dynwind.doc environments.doc eq.doc error.doc eval.doc evalext.doc extensions.doc
feature.doc fluids.doc fports.doc futures.doc gc.doc goops.doc gsubr.doc
gc-mark.doc gc-segment.doc gc-malloc.doc gc-card.doc guardians.doc hash.doc hashtab.doc
hooks.doc i18n.doc init.doc ioext.doc keywords.doc lang.doc list.doc load.doc
macros.doc mallocs.doc modules.doc numbers.doc objects.doc objprop.doc
options.doc pairs.doc ports.doc print.doc procprop.doc procs.doc properties.doc random.doc
rdelim.doc read.doc root.doc rw.doc scmsigs.doc script.doc simpos.doc smob.doc
sort.doc srcprop.doc stackchk.doc stacks.doc stime.doc strings.doc srfi-4.doc
srfi-13.doc srfi-14.doc strorder.doc strports.doc struct.doc symbols.doc
threads.doc throw.doc values.doc variable.doc vectors.doc version.doc vports.doc
weaks.doc ramap.doc unif.doc dynl.doc filesys.doc posix.doc net_db.doc
socket.doc
regex-posix.doc | GUILE="/dev/fs/C/obj/guile/pre-inst-guile" /src/guile-1.8.6/scripts/
snarf-check-and-output-texi > guile-procedures.texi || { rm guile-procedures.texi; false; }
ERROR: In procedure fport_input_waiting:
ERROR: Invalid argument

and it hangs.

[...and then later...]

Here is a very strange but successul fix for the hang. Now guile 1.8.6 builds
all the way through for me."

* libguile/iselect.h: On Interix, restrict SELECT_SET_SIZE to 1024.
2010-03-26 01:05:52 +00:00
Neil Jerram
5be63eea82 Interix build warning fix
/bin/sh ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I.. -I/src/g
uile-1.8.6 -I.. -g -O2 -Wall -Wmissing-prototypes -Werror -MT filesys.lo -MD -
MP -MF .deps/filesys.Tpo -c -o filesys.lo /src/guile-1.8.6/libguile/filesys.c
libtool: compile: gcc -DHAVE_CONFIG_H -I.. -I/src/guile-1.8.6 -I.. -g -O2 -Wall
-Wmissing-prototypes -Werror -MT filesys.lo -MD -MP -MF .deps/filesys.Tpo -c /s
rc/guile-1.8.6/libguile/filesys.c -DPIC -o .libs/filesys.o
/src/guile-1.8.6/libguile/filesys.c: In function `scm_readdir':
/src/guile-1.8.6/libguile/filesys.c:918: warning: implicit declaration of
function `readdir_r'

Report and fix provided by Jay Krell.

* libguile/filesys.c: On Interix, define _REENTRANT in order to pick
  up readdir_r prototype.
2010-03-26 00:48:08 +00:00
Neil Jerram
84a54b292d Fix doc for inet-ntop: always produces a string
Thanks to Scott McPeak for reporting this.

* libguile/socket.c (scm_inet_ntop): In docstring, add quotes around
  IPv6 address (+ reflow a bit).

* doc/ref/posix.texi (Network Address Conversion): Corresponding
  change.

* doc/maint/guile.texi: Corresponding change.
2009-10-01 23:44:21 +01:00
Neil Jerram
451e15a06c Fix handling of IPv6 addresses
Thanks to Scott McPeak for reporting this and providing a patch.

* libguile/socket.c (scm_to_ipv6): When address is the wrong type,
  provide more information in the exception message.

  (scm_to_sockaddr): scm_to_ipv6 expects just an address, not the
  whole vector.

* test-suite/tests/socket.test ("AF_INET6/SOCK_STREAM"): New set of
  tests.
2009-10-01 23:43:54 +01:00
Andy Wingo
1bfae3ccf7 bugfix: don't dynamic link if we found a registered extension
* libguile/extensions.c (load_extension): Don't do dynamic linking if we
  actually did find an extension in the list.
2009-09-23 21:35:13 +01:00
Neil Jerram
e4d87bf9fd Avoid clash with system setjmp/longjmp on IA64
Problem was that if an application includes both libguile.h and the
system's setjmp.h, and is compiled on IA64, it gets compile errors
because of jmp_buf, setjmp and longjmp being multiply defined.

* libguile/__scm.h (__ia64__): Define scm_i_jmp_buf, SCM_I_SETJMP and
  SCM_I_LONGJMP instead of jmp_buf, setjmp and longjmp.

  (all other platforms): Map scm_i_jmp_buf, SCM_I_SETJMP and
  SCM_I_LONGJMP to jmp_buf, setjmp and longjmp.

* libguile/continuations.c (scm_make_continuation): Use `SCM_I_SETJMP'
  instead of `setjmp'.
  (copy_stack_and_call): Use `SCM_I_LONJMP' instead of `longjmp'.
  (scm_ia64_longjmp): Use type `scm_i_jmp_buf' instead of `jmp_buf'.

* libguile/continuations.h (scm_t_contregs): Use type `scm_i_jmp_buf'
  instead of `jmp_buf'.

* libguile/threads.c (suspend): Use `SCM_I_SETJMP' instead of
  `setjmp'.

* libguile/threads.h (scm_i_thread): Use type `scm_i_jmp_buf' instead
  of `jmp_buf'.

* libguile/throw.c (JBJMPBUF, make_jmpbuf, jmp_buf_and_retval): Use
  type `scm_i_jmp_buf' instead of `jmp_buf'.
  (scm_c_catch): Use `SCM_I_SETJMP' instead of `setjmp'.
  (scm_ithrow): Use `SCM_I_LONGJMP' instead of `longjmp'.
2009-08-21 22:15:56 +01:00
Andy Wingo
d8dd381fa7 fix buffer overrun reading partial numbers: 1.0f, 1.0/, and 1.0+
* libguile/numbers.c (mem2decimal_from_point, mem2ureal, mem2complex):
  Fix a number of cases where, for invalid numbers, we could read past
  the end of the buffer. This happened in e.g. "1.0+", "1/" and "1.0f".
  But I couldn't figure out how to test for these, given that the
  behavior depended on the contents of uninitialized memory in the
  reader buffer. We'll just have to be happy with this.

Thanks to Kjetil S. Matheussen for the report.
2009-08-04 20:32:51 +02:00
Ludovic Courtès
de8ab91a76 Work around the lack of a vsnprintf(3) declaration on AIX 5.3.
* configure.in: Check for the vsnprintf(3) declaration.

* libguile/deprecation.c [!HAVE_DECL_VSNPRINTF]: Provide vsnprintf(3)
  declaration.  This is needed on `powerpc-ibm-aix5.3.0.0'.
2009-07-05 21:13:02 +02:00
Neil Jerram
04f9bc774a Read complex numbers where both parts are inexact decimals
Thanks to Bill Schottstaedt for reporting this problem!

* libguile/numbers.c (mem2ureal): Don't be misled by *p_exactness
  being INEXACT on entry (as is possible when reading a complex
  number): use local exactness variable x which starts as EXACT.
  Call mem2decimal_from_point () with &x instead of p_exactness.

* test-suite/tests/numbers.test ("string->number"): Add complex number
  tests suggested by Bill.
2009-07-01 01:41:25 +01:00
Neil Jerram
9d9a58e184 For MinGW hide exported struct variables behind pointers
MinGW apparently can't export/import struct variables from/to a DLL,
so wrap the ones needed by inline.h in exported/imported pointer
variables.

All of the following changes apply to a MinGW build only.

* libguile/gc-freelist.c (scm_i_master_freelist_ptr,
  scm_i_master_freelist2_ptr): New API variables.

* libguile/gc.h (scm_i_freelist_ptr, scm_i_freelist2_ptr,
  scm_i_master_freelist_ptr, scm_i_master_freelist2_ptr): New global
  variable declarations.

* libguile/inline.h (scm_cell): Use scm_i_freelist_ptr and
  scm_i_master_freelist_ptr instead of scm_i_freelist and
  scm_i_master_freelist.
  (scm_double_cell): Use scm_i_freelist2_ptr and
  scm_i_master_freelist2_ptr instead of scm_i_freelist2 and
  scm_i_master_freelist2.

* libguile/threads.c (scm_i_freelist_ptr, scm_i_freelist2_ptr): New
  global variables.
2009-06-29 21:15:12 +01:00
Neil Jerram
8510e39278 Remove GDB_INTERFACE stuff from guile's main program
The main motivation for this is wanting a successful MinGW build,
which is currently failing with:

guile-guile.o: In function `inner_main':
/home/neil/SW/Guile/ovnight/libguile/guile.c:55: undefined reference to `__imp__gdb_result'
/home/neil/SW/Guile/ovnight/libguile/guile.c:55: undefined reference to `__imp__gdb_output'
/home/neil/SW/Guile/ovnight/libguile/guile.c:55: undefined reference to `__imp__gdb_output_length'

The detailed problem here is to do with how those variables are
declared as exported from the libguile DLL and imported by the guile.c
main program.  But in fact we don't need to solve that problem because
the GDB interface is an idea that never actually happened.  So here we
just remove the offending variable references from guile.c.

For the record, Guile contains two kinds of GDB support, one of which
is real (and works, last time I tried it), and the other mythical.

The first kind is that libguile includes the utility functions
gdb_print, gdb_eval, etc., and the variable gdb_output.  These have no
purpose except for developers to use from GDB when debugging
something.  For example, if you have a SCM x and want to know what it
is, you can do:

(gdb) call gdb_print(x)
(gdb) p gdb_output

The second kind is that those utility functions are somehow declared
to GDB, and then GDB itself uses/calls them in some useful way.  This
was an interesting idea, but (AFAICT) never actually happened.

I think it's worth leaving gdb_interface.h in the repository and the
distribution, in case this idea is properly resurrected in the future.

* libguile/guile.c (top level): Remove GDB_INTERFACE declaration.
  (inner_main): Remove GDB_INTERFACE_INIT call.
2009-06-25 21:40:32 +01:00
Neil Jerram
0367cb9d56 Fix MinGW build warning caused by tzname redeclaration
The warning is:
stime.c:85: warning: `tzname' redeclared without dllimport attribute: previous dllimport ignored

The second half of this section of #ifdefery implies that the MinGW
build isn't going to reference a function called `tzname' anyway
(because it's going to use `_tzname' instead).  So why should a MinGW
build want any declaration of `tzname' at all?

As far as a declaration of `_tzname' is concerned, there are no
more #includes after this, so we must have already got a declaration
of `_tzname' from one of the preceding includes.

* libguile/stime.c (tzname): Remove declaration in __MINGW32__ build.
  It isn't needed and causes a build warning.
2009-06-21 17:46:07 +01:00
Neil Jerram
5e9dc714ca Remove AC_SYS_RESTARTABLE_SYSCALLS and related code
As the Autoconf documentation says, "These days portable programs
[...] should not rely on `HAVE_RESTARTABLE_SYSCALLS', since nowadays
whether a system call is restartable is a dynamic issue, not a
configuration-time issue."

In other words, if we ever rely on HAVE_RESTARTABLE_SYSCALLS, we are
at the mercy of any code that Guile happens to be linked with, because
that code could install a signal handler without the SA_RESTART flag,
and then a Guile system call could unexpectedly return EINTR.

The readline part of this goes back to this problem report:
excellent example of the above paragraph.  It was noted during the
discussion that undefining HAVE_RESTARTABLE_SYSCALLS would fix the
problem, but that solution wasn't adopted - I guess because Guile was
still using cooperative threads then (not pthreads) and so there was a
significant concern (whether founded or not) that not using
restartable syscalls (where available) could lead to a loss of
performance.

Now Guile's default mode of operation is with pthreads, where we
already don't assume that HAVE_RESTARTABLE_SYSCALLS is reliable, so
there is no possible further performance loss.  And in any case we
really have no choice, if we want correct operation.

* configure.in (AC_SYS_RESTARTABLE_SYSCALLS): Removed.

* doc/ref/posix.texi (Signals): Remove statement that Guile always
  sets SA_RESTART flag.

* guile-readline/configure.in (GUILE_SIGWINCH_SA_RESTART_CLEARED):
  Remove this setting, together with its test code.
  (HAVE_RL_PRE_INPUT_HOOK): Remove this setting and its code, as no
  longer needed.

* guile-readline/readline.c (sigwinch_enable_restart): Removed.
  (scm_init_readline): Remove setting of rl_pre_input_hook.

* libguile/_scm.h (SCM_SYSCALL): Remove the definition that relies on
  HAVE_RESTARTABLE_SYSCALLS.

* libguile/scmsigs.c (scm_sigaction_for_thread): Don't always set the
  SA_RESTART flag if available.  Update docstring accordingly.
  (scm_init_scmsigs): Remove code that sets SA_RESTART flag for all
  signals.
2009-06-18 20:35:45 +01:00
Neil Jerram
66f3b6c1b0 Remove possible deadlock in scm_join_thread
* libguile/threads.c (scm_join_thread): Always recheck t->exited
  before calling block_self again, in case thread t has now exited.

* test-suite/tests/threads.test (joining): New test.
2009-05-20 21:56:17 +01:00
Neil Jerram
0310b348a1 Fix explicitely' typos, should be explicitly' 2009-05-20 18:54:23 +01:00
Michael Gran
93c0c75658 Symbols longer than 128 chars can cause an exception. Also, the terminating colon of long postfix keywords are not handled correctly.
* test-suite/tests/reader.test ("read-options"): Add test
	for long postfix keywords.

	* libguile/read.c (scm_read_mixed_case_symbol): Fix
	exception on symbols are greater than 128 chars.  Also,
	colons are not stripped from long postfix keywords.
2009-05-12 00:07:51 +02:00
Ludovic Courtès
5d8f339fd8 Work around lack of flock(2) declaration on Tru64 5.1b.
* configure.in: Check for the declaration of flock(2).

* libguile/posix.c [!__MINGW32__][!HAVE_DECL_FLOCK]: Provide an flock(2)
  declaration, needed on Tru64 5.1b.
2009-05-11 22:54:45 +02:00
Ludovic Courtès
cabfe198fd Ask for IEEE floating point behavior on Alpha and SH.
* configure.in (CPPFLAGS): Add `-mieee' or `-ieee' on Alpha and SH.

* libguile/numbers.c (guile_ieee_init): Make sure `-mieee' was passed
  when using GCC on Alpha.

* NEWS: Update.
2009-05-11 22:11:25 +02:00
Ludovic Courtès
fbcc27cfef Work around lack of cuserid(3) declaration on Tru64 5.1b.
* configure.in: Check for a cuserid(3) declaration.

* libguile/posix.c [HAVE_CUSERID][!HAVE_DECL_CUSERID]: Provide a
  declaration.
2009-04-23 22:24:32 +02:00
Ludovic Courtès
d2469ca702 Work around the lack of hstrerror(3) declaration on Tru64.
* configure.in: Look for the declaration of hstrerror(3).

* libguile/net_db.c: Add hstrerror(3) declaration if
  `HAVE_DECL_HSTRERROR' is undefined.
2009-04-23 22:04:05 +02:00
Ludovic Courtès
df2870d385 Fix use of unsetenv(3) on Tru64.
* configure.in: Check for the declaration of unsetenv(3), which Tru64
  5.1b doesn't have.

* libguile/posix.c: Include <stdlib.h> since that's where POSIX says
  unsetenv(3) should reside.
  (scm_putenv): Don't attempt to use unsetenv(3) if its declaration
  isn't available since that wouldn't work well on Tru64.
2009-04-23 22:00:44 +02:00
Ludovic Courtès
ceb6da3f8b Fix compilation of `numbers.c' on Tru64.
* libguile/numbers.c (scm_c_make_polar): Don't use sincos(3) on non-GNU
  platforms.  Reported by Didier Godefroy <ldg@ulysium.net>.
2009-04-21 22:37:45 +02:00
Ludovic Courtès
ecea820468 Fix compilation of `gcc_os_dep.c' on Tru64.
* libguile/gc_os_dep.c [OSF1](_end): Specify the type.
  (scm_get_stack_base): Suitably cast RESULT.  Reported by Didier
  Godefroy <ldg@ulysium.net>.
2009-04-21 22:34:54 +02:00
daniel
5e5b073faa Make `--disable-deprecated' work.
* configure.in (enable_deprecated): Set SCM_WARN_DEPRECATED_DEFAULT
  even when --disable-deprecated is passed.
* libguile/deprecation.h: Declare deprecation-issuing methods even
  if SCM_ENABLE_DEPRECATED is not set.
* libguile/deprecation.c: Ditto.
  (scm_init_deprecation): Include full body even for unset
  SCM_ENABLE_DEPRECATED.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2009-04-21 22:11:48 +02:00
Neil Jerram
3009b5d557 Fix spurious `throw from within critical section' errors
The crux of this problem was that the thread doing a throw, and so
checking scm_i_critical_section_level, was different from the thread
that was in a critical section.

* libguile/async.h (scm_i_critical_section_level): Removed, replaced
  by per-thread critical_section_level.
  (SCM_CRITICAL_SECTION_START, SCM_CRITICAL_SECTION_END): Use
  per-thread critical_section_level.

* libguile/continuations.c (scm_dynthrow): Check per-thread
  critical_section_level.

* libguile/threads.c (guilify_self_1): Init per-thread
  critical_section_level.
  (scm_i_critical_section_level): Removed.

* libguile/threads.h (scm_i_thread): New critical_section_level field.

* libguile/throw.c (scm_ithrow): Check per-thread critical_section_level.
2009-03-25 18:54:34 +00:00
Neil Jerram
499c43b032 Avoid throw from critical section, given invalid sigaction call
* libguile/scmsigs.c (scm_sigaction_for_thread): Exit critical section
  before raising out-of-range error.

* test-suite/Makefile.am (SCM_TESTS): Add signals.test.

* test-suite/tests/signals.test: New file.
2009-03-25 18:53:12 +00:00
Ludovic Courtès
8760f4694d Have `scm_take_locale_symbol ()' return an interned symbol (fixes bug #25865).
* libguile/symbols.c (intern_symbol): New function, with code formerly
  duplicated in `scm_i_c_mem2symbol ()' and `scm_i_mem2symbol ()'.
  (scm_i_c_mem2symbol, scm_i_mem2symbol): Use it.
  (scm_take_locale_symboln): Use `intern_symbol ()'.  This fixes
  bug #25865.

* test-suite/standalone/Makefile.am
  (test_scm_take_locale_symbol_SOURCES,
  test_scm_take_locale_symbol_CFLAGS,
  test_scm_take_locale_symbol_LDADD): New variables.
  (check_PROGRAMS, TESTS): Add `test-scm-take-locale-symbol'.
2009-03-19 22:19:04 +01:00
Neil Jerram
2bfcaf2605 Lock ordering: don't allocate when in critical section (scm_sigaction_for_thread)
This fixes the following helgrind report.

Thread #1: lock order "0x4114748 before 0x4331084" violated
   at 0x40234F7: pthread_mutex_lock (hg_intercepts.c:408)
   by 0x407A55F: deval (eval.c:4077)
   by 0x407A071: scm_dapply (eval.c:5012)
   by 0x407888A: scm_apply (eval.c:4811)
   by 0x407E20C: scm_call_0 (eval.c:4666)
   by 0x406BDF7: scm_dynamic_wind (dynwind.c:111)
   by 0x407620C: ceval (eval.c:4571)
   by 0x407E8D9: scm_primitive_eval_x (eval.c:5921)
   by 0x407E934: scm_eval_x (eval.c:5956)
   by 0x40B9140: scm_shell (script.c:737)
   by 0x4095AC5: invoke_main_func (init.c:367)
   by 0x4065A81: c_body (continuations.c:349)
  Required order was established by acquisition of lock at 0x4114748
   at 0x40234F7: pthread_mutex_lock (hg_intercepts.c:408)
   by 0x40B7BE1: scm_sigaction_for_thread (scmsigs.c:339)
   by 0x40911DE: scm_gsubr_apply (gsubr.c:223)
   by 0x4079E36: scm_dapply (eval.c:4930)
   by 0x407AB68: deval (eval.c:4378)
   by 0x407A071: scm_dapply (eval.c:5012)
   by 0x407888A: scm_apply (eval.c:4811)
   by 0x407E1D0: scm_call_1 (eval.c:4672)
   by 0x407FEEE: scm_map (eval.c:5489)
   by 0x407BDCC: deval (eval.c:4367)
   by 0x407D197: deval (eval.c:3698)
   by 0x407A071: scm_dapply (eval.c:5012)
  followed by a later acquisition of lock at 0x4331084
   at 0x40234F7: pthread_mutex_lock (hg_intercepts.c:408)
   by 0x40DC397: scm_enter_guile (threads.c:377)
   by 0x40DC8F4: scm_pthread_mutex_lock (threads.c:1485)
   by 0x4083FAA: scm_gc_for_newcell (gc.c:484)
   by 0x40A9781: scm_cons (inline.h:115)
   by 0x4079867: scm_dapply (eval.c:4850)
   by 0x407888A: scm_apply (eval.c:4811)
   by 0x40796D6: scm_call_3 (eval.c:4684)
   by 0x409A7C2: module_variable (modules.c:302)
   by 0x409A7EE: module_variable (modules.c:312)
   by 0x409A962: scm_sym2var (modules.c:466)
   by 0x40738F4: scm_lookupcar1 (eval.c:2874)

* libguile/scmsigs.c (close_1): Renamed `handler_to_async'; also
  handle #f case and wrapping the async in a cons, if necessary.

  (install_handler): Pass in async instead of constructing it; combine
  two branches into one.

  (scm_sigaction_for_thread): Allocate async upfront instead of inside
  the critical section, and pass it to install_handler calls.  Leave
  critical section before signaling out-of-range error.
2009-03-05 19:48:41 +00:00
Neil Jerram
58bef38c0a Don't leave Guile mode to lock async_mutex
This fixes lots of helgrind-reported problems, such as:

Thread #1: lock order "0x4325084 before 0x4108928" violated
   at 0x40234F7: pthread_mutex_lock (hg_intercepts.c:408)
   by 0x40CFD37: scm_enter_guile (threads.c:377)
   by 0x40D0284: scm_pthread_mutex_lock (threads.c:1485)
   by 0x405A736: scm_async_click (async.c:155)
   by 0x406F9EE: deval (eval.c:4080)
   by 0x40761D9: scm_primitive_eval_x (eval.c:5921)
   by 0x40AD20E: install_handler (scmsigs.c:113)
   by 0x40AD402: scm_sigaction_for_thread (scmsigs.c:394)
   by 0x4087D1F: scm_gsubr_apply (gsubr.c:223)
   by 0x406DF55: scm_dapply (eval.c:4930)
   by 0x407147C: deval (eval.c:4378)
   by 0x406E1BD: scm_dapply (eval.c:5012)
  Required order was established by acquisition of lock at 0x4325084
   at 0x40234F7: pthread_mutex_lock (hg_intercepts.c:408)
   by 0x40CFD37: scm_enter_guile (threads.c:377)
   by 0x408C58B: scm_i_init_guile (init.c:421)
   by 0x40D1873: scm_i_init_thread_for_guile (threads.c:589)
   by 0x40D18B4: scm_i_with_guile_and_parent (threads.c:731)
   by 0x40D19BD: scm_with_guile (threads.c:720)
   by 0x408C42E: scm_boot_guile (init.c:350)
   by 0x8048710: main (guile.c:69)
  followed by a later acquisition of lock at 0x4108928
   at 0x40234F7: pthread_mutex_lock (hg_intercepts.c:408)
   by 0x40AFD61: scm_make_smob_type (smob.c:294)
   by 0x40AFF19: scm_smob_prehistory (smob.c:512)
   by 0x408C595: scm_i_init_guile (init.c:423)
   by 0x40D1873: scm_i_init_thread_for_guile (threads.c:589)
   by 0x40D18B4: scm_i_with_guile_and_parent (threads.c:731)
   by 0x40D19BD: scm_with_guile (threads.c:720)
   by 0x408C42E: scm_boot_guile (init.c:350)
   by 0x8048710: main (guile.c:69)

* libguile/async.c (scm_async_click): Don't leave Guile mode when
  locking async_mutex.  We don't need to, because none of the code
  that has async_mutex locked can block, and doing so may lead to lock
  ordering problems between async_mutex and a thread's heap_mutex.
2009-03-04 22:20:53 +00:00
Neil Jerram
acb9cffee0 Lock ordering: don't lock heap_mutex and then thread_admin_mutex
This fixes the following helgrind report.

Thread #1: lock order "0x4325084 before 0x4105328" violated
   at 0x40234F7: pthread_mutex_lock (hg_intercepts.c:408)
   by 0x40D01EA: scm_i_thread_put_to_sleep (threads.c:1622)
   by 0x4078958: scm_make_fluid (fluids.c:114)
   by 0x40778D6: scm_init_feature (feature.c:101)
   by 0x408C62E: scm_i_init_guile (init.c:464)
   by 0x40D1873: scm_i_init_thread_for_guile (threads.c:583)
   by 0x40D18B4: scm_i_with_guile_and_parent (threads.c:725)
   by 0x40D19BD: scm_with_guile (threads.c:714)
   by 0x408C42E: scm_boot_guile (init.c:350)
   by 0x8048710: main (guile.c:69)
  Required order was established by acquisition of lock at 0x4325084
   at 0x40234F7: pthread_mutex_lock (hg_intercepts.c:408)
   by 0x40CFFA4: guilify_self_1 (threads.c:468)
   by 0x408C58B: scm_i_init_guile (init.c:421)
   by 0x40D1873: scm_i_init_thread_for_guile (threads.c:583)
   by 0x40D18B4: scm_i_with_guile_and_parent (threads.c:725)
   by 0x40D19BD: scm_with_guile (threads.c:714)
   by 0x408C42E: scm_boot_guile (init.c:350)
   by 0x8048710: main (guile.c:69)
  followed by a later acquisition of lock at 0x4105328
   at 0x40234F7: pthread_mutex_lock (hg_intercepts.c:408)
   by 0x40CFFAC: guilify_self_1 (threads.c:470)
   by 0x408C58B: scm_i_init_guile (init.c:421)
   by 0x40D1873: scm_i_init_thread_for_guile (threads.c:583)
   by 0x40D18B4: scm_i_with_guile_and_parent (threads.c:725)
   by 0x40D19BD: scm_with_guile (threads.c:714)
   by 0x408C42E: scm_boot_guile (init.c:350)
   by 0x8048710: main (guile.c:69)

* threads.c (guilify_self_1): Add self to global thread list _before_
  entering Guile mode.
2009-03-04 22:20:52 +00:00
Neil Jerram
a24f4637ea Fix build when compiled with -Wundef -Werror
(Reported by David Fang)

* libguile/inline.h: Check if __APPLE_CC__ is defined before testing
  its value.
2009-02-05 22:13:17 +00:00
Neil Jerram
94922b177b Fix build when scm_t_timespec is different from struct timespec
Reported by Roland Haeder.  The declaration and definition of
scm_pthread_cond_timedwait were using possibly different types for the
third arg.

* THANKS: Added Roland Haeder.

* libguile/threads.h (scm_pthread_cond_timedwait): Use scm_t_timespec
  for third arg rather than struct timespec, for consistency with the
  function implementation.
2009-01-23 01:27:20 +00:00
Neil Jerram
d681856755 Fix MinGW HAVE_STRUCT_TIMESPEC build problem
Reported by Carlo Bramini.  See the comment in _scm.h.

* THANKS: Add Carlo Bramini.

* libguile/_scm.h: Undefine HAVE_STRUCT_TIMESPEC.
2009-01-23 01:02:46 +00:00
Neil Jerram
53a79cd060 Fix implementation of %fast-slot-ref and %fast-slot-set!
* libguile/goops.c (scm_sys_fast_slot_ref, scm_sys_fast_slot_set_x):
  Correct incantation for getting the number of slots of the specified
  instance.

* libguile/goops.h (SCM_NUMBER_OF_SLOTS): Removed (because wrong).

* test-suite/standalone/test-fast-slot-ref.in: New standalone test.

* configure.in: Generate test-suite/standalone/test-fast-slot-ref.

* test-suite/standalone/Makefile.am (check_SCRIPTS): Add
  test-fast-slot-ref.
2009-01-04 22:41:51 +00:00
Ludovic Courtès
a97cd69632 Don't use deprecated functions in `debug-malloc.c'.
* libguile/debug-malloc.c (scm_malloc_stats): Use
  `scm_from_locale_string ()'.  Patch by Linas Vepstas
  <linasvepstas@gmail.com>.
2008-12-18 22:48:45 +01:00