diff options
author | Han-Wen Nienhuys <hanwen@lilypond.org> | 2004-03-28 13:55:03 +0000 |
---|---|---|
committer | Han-Wen Nienhuys <hanwen@lilypond.org> | 2004-03-28 13:55:03 +0000 |
commit | 702551e6cc41e90745ca5f8626956ecab46c41c9 (patch) | |
tree | 235ad8bc5db51683904a1dd730ea3857c0ffaa95 | |
parent | 88a7ae1f6818b68bc72a4bb8763b3299c69c4988 (diff) | |
download | guile-702551e6cc41e90745ca5f8626956ecab46c41c9.tar.gz |
* gc.h (SCM_GC_CELL_TYPE): SCM_GC_CELL_TYPE uses SCM_GC_CELL_OBJECT.
* goops.h (SCM_NUMBER_OF_SLOTS): don't SCM_UNPACK the result.
* backtrace.c ("display_backtrace_body"): SCM_PACK before SCM_EQ_P
(display_frame): idem.
(display_backtrace_file_and_line): idem.
* tags.h (SCM_UNPACK): stricter typechecking on SCM_UNPACK
arguments.
-rw-r--r-- | libguile/ChangeLog | 13 | ||||
-rw-r--r-- | libguile/backtrace.c | 6 | ||||
-rw-r--r-- | libguile/debug.c | 2 | ||||
-rw-r--r-- | libguile/gc-mark.c | 2 | ||||
-rw-r--r-- | libguile/gc.h | 2 | ||||
-rw-r--r-- | libguile/goops.h | 3 | ||||
-rw-r--r-- | libguile/tags.h | 17 |
7 files changed, 35 insertions, 10 deletions
diff --git a/libguile/ChangeLog b/libguile/ChangeLog index a74b38472..747f0de98 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,16 @@ +2004-03-28 Han-Wen Nienhuys <hanwen@xs4all.nl> + + * gc.h (SCM_GC_CELL_TYPE): SCM_GC_CELL_TYPE uses SCM_GC_CELL_OBJECT. + + * goops.h (SCM_NUMBER_OF_SLOTS): don't SCM_UNPACK the result. + + * backtrace.c ("display_backtrace_body"): SCM_PACK before SCM_EQ_P + (display_frame): idem. + (display_backtrace_file_and_line): idem. + + * tags.h (SCM_UNPACK): stricter typechecking on SCM_UNPACK + arguments. + 2004-03-26 Kevin Ryde <user42@zip.com.au> * filesys.c (scm_getcwd, scm_readlink): Avoid memory leak on errors. diff --git a/libguile/backtrace.c b/libguile/backtrace.c index f73c80dcc..860197805 100644 --- a/libguile/backtrace.c +++ b/libguile/backtrace.c @@ -521,7 +521,7 @@ display_backtrace_file_and_line (SCM frame, SCM port, scm_print_state *pstate) display_backtrace_get_file_line (frame, &file, &line); - if (SCM_EQ_P (SCM_SHOW_FILE_NAME, sym_base)) + if (SCM_EQ_P (SCM_PACK (SCM_SHOW_FILE_NAME), sym_base)) { if (SCM_FALSEP (file)) { @@ -572,7 +572,7 @@ display_frame (SCM frame, int nfield, int indentation, SCM sport, SCM port, scm_ } /* display file name and line number */ - if (!SCM_FALSEP (SCM_SHOW_FILE_NAME)) + if (!SCM_FALSEP (SCM_PACK (SCM_SHOW_FILE_NAME))) display_backtrace_file_and_line (frame, port, pstate); /* Check size of frame number. */ @@ -722,7 +722,7 @@ display_backtrace_body (struct display_backtrace_args *a) last_file = SCM_UNDEFINED; for (i = 0; i < n; ++i) { - if (!SCM_EQ_P (SCM_SHOW_FILE_NAME, sym_base)) + if (!SCM_EQ_P (SCM_PACK (SCM_SHOW_FILE_NAME), sym_base)) display_backtrace_file (frame, &last_file, a->port, pstate); display_frame (frame, nfield, indentation, sport, a->port, pstate); diff --git a/libguile/debug.c b/libguile/debug.c index 2ec0a0c8c..01bf656eb 100644 --- a/libguile/debug.c +++ b/libguile/debug.c @@ -87,7 +87,7 @@ with_traps_after (void *data) static SCM with_traps_inner (void *data) { - SCM thunk = SCM_PACK (data); + SCM thunk = SCM_PACK ((scm_t_bits) data); return scm_call_0 (thunk); } diff --git a/libguile/gc-mark.c b/libguile/gc-mark.c index 10f1522e0..456cb37b0 100644 --- a/libguile/gc-mark.c +++ b/libguile/gc-mark.c @@ -166,7 +166,7 @@ scm_gc_mark_dependencies (SCM p) { register long i; register SCM ptr; - scm_t_bits cell_type; + SCM cell_type; ptr = p; scm_mark_dependencies_again: diff --git a/libguile/gc.h b/libguile/gc.h index aab4bb648..545b0b350 100644 --- a/libguile/gc.h +++ b/libguile/gc.h @@ -151,7 +151,7 @@ typedef unsigned long scm_t_c_bvec_long; (((scm_t_bits *) SCM2PTR (x)) [n] = (scm_t_bits) (v)) #define SCM_GC_SET_CELL_OBJECT(x, n, v) \ (((scm_t_bits *) SCM2PTR (x)) [n] = SCM_UNPACK (v)) -#define SCM_GC_CELL_TYPE(x) SCM_GC_CELL_WORD (x, 0) +#define SCM_GC_CELL_TYPE(x) SCM_GC_CELL_OBJECT (x, 0) /* ugh - only used once. */ /* Except for the garbage collector, no part of guile should ever run over a diff --git a/libguile/goops.h b/libguile/goops.h index 599d6944f..710abb941 100644 --- a/libguile/goops.h +++ b/libguile/goops.h @@ -99,8 +99,7 @@ typedef struct scm_t_method { #define SCM_CLASS_OF(x) SCM_STRUCT_VTABLE (x) #define SCM_ACCESSORS_OF(x) (SCM_PACK (SCM_STRUCT_VTABLE_DATA (x)[scm_si_getters_n_setters])) #define SCM_NUMBER_OF_SLOTS(x) \ - (SCM_UNPACK (SCM_STRUCT_DATA (x)[scm_struct_i_n_words]) \ - - scm_struct_n_extra_words) + ((SCM_STRUCT_DATA (x)[scm_struct_i_n_words]) - scm_struct_n_extra_words) #define SCM_CLASSP(x) \ (SCM_STRUCTP (x) && SCM_STRUCT_VTABLE_FLAGS (x) & SCM_CLASSF_METACLASS) diff --git a/libguile/tags.h b/libguile/tags.h index f58bf5853..10a66c747 100644 --- a/libguile/tags.h +++ b/libguile/tags.h @@ -106,8 +106,21 @@ typedef unsigned long scm_t_bits; * type checking while still resulting in very efficient code. */ typedef struct scm_unused_struct * SCM; -# define SCM_UNPACK(x) ((scm_t_bits) (x)) + +/* + The 0?: constructions makes sure that the code is never executed, + and that there is no performance hit. However, the alternative is + compiled, and does generate a warning when used with the wrong + pointer type. + */ +# define SCM_UNPACK(x) ((scm_t_bits) (0? (*(SCM*)0=(x)): x)) + +/* + There is no typechecking on SCM_PACK, since all kinds of types + (unsigned long, void*) go in SCM_PACK + */ # define SCM_PACK(x) ((SCM) (x)) + #else /* This should be used as a fall back solution for machines on which casting * to a pointer may lead to loss of bit information, e. g. in the three least @@ -115,7 +128,7 @@ typedef unsigned long scm_t_bits; */ typedef scm_t_bits SCM; # define SCM_UNPACK(x) (x) -# define SCM_PACK(x) ((scm_t_bits) (x)) +# define SCM_PACK(x) ((SCM) (x)) #endif |