[uim-commit] r2931 - in branches/r5rs/sigscheme: . src

yamaken at freedesktop.org yamaken at freedesktop.org
Tue Jan 17 09:36:34 PST 2006


Author: yamaken
Date: 2006-01-17 09:36:29 -0800 (Tue, 17 Jan 2006)
New Revision: 2931

Modified:
   branches/r5rs/sigscheme/TODO
   branches/r5rs/sigscheme/configure.in
   branches/r5rs/sigscheme/src/alloc.c
   branches/r5rs/sigscheme/src/basecport.c
   branches/r5rs/sigscheme/src/baseport.h
   branches/r5rs/sigscheme/src/encoding.c
   branches/r5rs/sigscheme/src/encoding.h
   branches/r5rs/sigscheme/src/env.c
   branches/r5rs/sigscheme/src/eval.c
   branches/r5rs/sigscheme/src/fileport.c
   branches/r5rs/sigscheme/src/io.c
   branches/r5rs/sigscheme/src/mbcport.c
   branches/r5rs/sigscheme/src/mbcport.h
   branches/r5rs/sigscheme/src/nullport.c
   branches/r5rs/sigscheme/src/operations-nonstd.c
   branches/r5rs/sigscheme/src/operations-siod.c
   branches/r5rs/sigscheme/src/operations-srfi1.c
   branches/r5rs/sigscheme/src/operations-srfi6.c
   branches/r5rs/sigscheme/src/operations-srfi60.c
   branches/r5rs/sigscheme/src/operations-srfi8.c
   branches/r5rs/sigscheme/src/operations.c
   branches/r5rs/sigscheme/src/read.c
   branches/r5rs/sigscheme/src/sbcport.c
   branches/r5rs/sigscheme/src/sigscheme.h
   branches/r5rs/sigscheme/src/sigschemeinternal.h
   branches/r5rs/sigscheme/src/storage-compact.h
   branches/r5rs/sigscheme/src/storage-fatty.h
   branches/r5rs/sigscheme/src/storage-gc.c
   branches/r5rs/sigscheme/src/storage-symbol.c
   branches/r5rs/sigscheme/src/storage.c
   branches/r5rs/sigscheme/src/strport.c
   branches/r5rs/sigscheme/src/syntax.c
   branches/r5rs/sigscheme/src/write.c
Log:
* This commit make SigScheme 64bit-ready with storage-fatty. But no
  tests on actual 64-bit environment is performed, and storage-compact
  is not supported yet.

* sigscheme/configure.in
  - Add some AC_C_* macros
  - Comment out currently unused macros
* sigscheme/src/sigscheme.h
  - Add description about 64-bit support
  - (SCM_LISTLEN_CIRCULARP, struct ScmStorageConf_,
    scm_port_put_char): Support 64bit models
  - (scm_bool, scm_false, scm_true): Prevent redefinition by
    SCM_BOOL_DEFINED
  - (SCM_BOOL_DEFINED, SCM_INT_T_MAX, SCM_INT_T_MIN, SCM_UINT_T_MAX,
    SCM_INT_T_MAX, SCM_INT_T_MIN, SCM_UINT_T_MAX, SCM_INT_T_MAX,
    SCM_INT_T_MIN, SCM_UINT_T_MAX, SCM_INT_T_MAX, SCM_INT_T_MIN,
    SCM_UINT_T_MAX, SCM_INT_T_FMT, SCM_ICHAR_T_DEFINED,
    SCM_ICHAR_T_MAX, SCM_ICHAR_T_MIN, SCM_BYTE_T_DEFINED,
    SCM_BYTE_T_MAX, SCM_BYTE_T_MIN, SCM_SIZE_T_FMT): New macro
* sigscheme/src/sigschemeinternal.h
  - (struct ScmSpecialCharInfo_): Replace int with scm_ichar_t
  - (SCM_LISTLEN_ENCODE_CIRCULAR, ScmLBuf,
    scm_valid_environment_extension_lengthp, scm_validate_formals,
    scm_validate_actuals, scm_finite_length, scm_length): Support
    64bit models
* sigscheme/src/storage-fatty.h
  - Add description about storage-fatty
  - (struct ScmCell_):
    * Add members attr, attr.strut, obj.strut to align against 64bit
      primitives
    * Move member 'type' into 'attr'
    * Move member 'gctype' into 'attr' and change the type to scm_bool
    * Change the type 'int' of 'obj.integer', 'obj.character',
      'obj.string', 'obj.vector' and 'obj.continuation' to support
      64bit models
    * Reorder members in 'obj.function' and 'obj.port' for performance
  - (SCM_SAL_TYPE, SCM_ENTYPE, SCM_SAL_IS_MARKED, SCM_SAL_DO_MARK,
    SCM_SAL_DO_UNMARK): Follow the change of struct ScmCell_
  - (SCM_SAL_CHAR_BITS, SCM_SAL_CHAR_MAX, SCM_SAL_INT_BITS,
    SCM_SAL_INT_MAX, SCM_SAL_INT_MIN, scm_make_int, scm_make_char,
    scm_make_immutable_string, scm_make_immutable_string_copying,
    scm_make_string, scm_make_string_copying, scm_make_vector,
    SCM_INT_MSB, SCM_SAL_STRING_LEN, SCM_SAL_STRING_SET_LEN,
    SCM_SAL_STRING_SET_MUTABLE, SCM_SAL_STRING_SET_IMMUTABLE): Support
    64bit models
* sigscheme/src/storage-compact.h
  - Add FIXME comment about 64bit support
  - (scm_make_int, scm_make_char, scm_make_immutable_string,
    scm_make_immutable_string_copying, scm_make_string,
    scm_make_string_copying, scm_make_vector): Support 64bit models
* sigscheme/src/alloc.c
  - (ALIGN_CELL): New macro
  - (scm_malloc_aligned):
    * Support 64bit models by replacing fixed-size alignment with
      sizeof(ScmCell)
    * Simplify
    * Add alignment assertion for scm_malloc()
* sigscheme/src/storage.c
  - (scm_make_int, scm_make_char, scm_make_string_internal,
    scm_make_immutable_string, scm_make_immutable_string_copying,
    scm_make_string, scm_make_string_copying, scm_make_vector,
    scm_type): Support 64bit models
* sigscheme/src/storage-symbol.c
  - (scm_intern): Support 64bit models
  - (symbol_name_hash):
    * Ditto
    * Fix broken hash value calculation for non-ASCII byte
* sigscheme/src/storage-gc.c
  - (N_REGS_IN_JMP_BUF, SCMOBJ_ALIGNEDP): New macro
  - (n_heaps, n_heaps_max): Change to size_t to support 64bit models
  - (scm_gc_protect_stack_internal, initialize_heap, finalize_heap,
    mark_obj, mark_obj, within_heapp, gc_mark_locations_n,
    gc_mark_definite_locations_n, gc_mark_locations, gc_sweep):
    Support 64bit models
  - (gc_mark):
    * Ditto
    * Make efficient
* sigscheme/src/env.c
  - (scm_valid_environment_extensionp,
    scm_valid_environment_extension_lengthp, scm_validate_formals,
    scm_validate_actuals): Support 64bit models
* sigscheme/src/eval.c
  - (call_closure, call, map_eval): Support 64bit models
* sigscheme/src/syntax.c
  - (struct _vector_translator, vectran, qquote_internal): Support
    64bit models
* sigscheme/src/operations.c
  - (list_tail, scm_p_equalp, scm_p_add, scm_p_multiply,
    scm_p_subtract, scm_p_divide, scm_p_abs, scm_p_quotient,
    scm_p_modulo, scm_p_remainder, scm_p_number2string,
    scm_p_string2number, scm_finite_length, scm_length, scm_p_length,
    scm_p_char_alphabeticp, scm_p_char_numericp,
    scm_p_char_whitespacep, scm_p_char_upper_casep,
    scm_p_char_lower_casep, scm_p_integer2char, scm_p_char_upcase,
    scm_p_char_downcase, scm_p_make_string, scm_p_string_length,
    scm_p_string_ref, scm_p_string_setd, scm_p_substring,
    scm_p_string_append, scm_p_string2list, scm_p_list2string,
    scm_p_string_filld, scm_p_make_vector, scm_p_vector_ref,
    scm_p_vector_setd, scm_p_vector2list, scm_p_list2vector,
    scm_p_vector_filld): Support 64bit models
* sigscheme/src/operations-nonstd.c
  - (scm_p_lengthstar): Support 64bit models
* sigscheme/src/operations-siod.c
  - (scm_set_verbose_level): Support 64bit models
* sigscheme/src/operations-srfi1.c
  - (scm_p_srfi1_make_list, scm_p_srfi1_list_tabulate,
    scm_p_srfi1_iota, scm_p_srfi1_null_listp, scm_p_srfi1_take,
    scm_p_srfi1_drop, scm_p_srfi1_take_right, scm_p_srfi1_drop_right,
    scm_p_srfi1_taked, scm_p_srfi1_drop_rightd,
    scm_p_srfi1_lengthplus): Support 64bit models
* sigscheme/src/operations-srfi6.c
  - (scm_p_srfi6_get_output_string): Support 64bit models
* sigscheme/src/operations-srfi8.c
  - (scm_s_srfi8_receive): Support 64bit models
* sigscheme/src/operations-srfi60.c
  - (BITWISE_OPERATION_BODY, scm_p_srfi60_bitwise_if): Support 64bit models
* sigscheme/src/io.c
  - (scm_port_put_char, scm_p_close_input_port,
    scm_p_close_output_port, scm_p_read_char, scm_p_peek_char,
    find_path): Support 64bit models
* sigscheme/src/read.c
  - (TOKEN_BUF_EXCEEDED): Fix possible mis-association of the minus
    operator
  - (INT_LITERAL_LEN_MAX): Simplify with SCM_INT_BITS
  - (skip_comment_and_space, read_list, parse_unicode_sequence,
    read_unicode_sequence, read_sequence, read_token,
    read_sexpression, read_char, read_string, read_number_or_symbol,
    parse_number): Support 64bit models
* sigscheme/src/write.c
  - (write_obj, write_char, write_string, write_list, write_vector):
    Support 64bit models
* sigscheme/src/encoding.h
  - (scm_bool, scm_false, scm_true): Prevent redefinition by
    SCM_BOOL_DEFINED
  - (scm_ichar_t, scm_byte_t): New type
  - (SCM_BOOL_DEFINED, SIZEOF_SCM_ICHAR_T, SCM_ICHAR_T_MAX,
    SCM_ICHAR_T_MIN, SCM_ICHAR_T_DEFINED, SIZEOF_SCM_BYTE_T): New
    macro
  - (ScmMultibyteCharInfo, ScmMultibyteString): Support 64bit models
  - (ScmCharCodecMethod_char_len, ScmCharCodecMethod_str2int,
    ScmCharCodecMethod_int2str, scm_mb_strlen, scm_mb_bare_c_strlen,
    scm_mb_substring, scm_charcodec_read_char): Support 64bit models
* sigscheme/src/encoding.c
  - (uint): Removed
  - (scm_mb_strlen, scm_mb_bare_c_strlen, scm_mb_substring,
    scm_charcodec_read_char, IS_ASCII, IS_1BYTE, IS_2BYTES, IS_3BYTES,
    eucjp_char_len, eucjp_scan_char, eucjp_str2int, eucjp_int2str,
    dbc_str2int, euc_char_len, euc_int2str, euccn_scan_char,
    euckr_scan_char, IN_OCT_BMP, IN_BMP, IN_SMP, utf8_char_len,
    utf8_scan_char, utf8_str2int, utf8_int2str, sjis_char_len,
    sjis_scan_char, sjis_int2str, unibyte_char_len, unibyte_str2int,
    unibyte_int2str): Support 64bit models
* sigscheme/src/baseport.h
  - (scm_bool, scm_false, scm_true): Prevent redefinition by
    SCM_BOOL_DEFINED
  - (scm_ichar_t, scm_byte_t): New type
  - (SCM_BOOL_DEFINED, SIZEOF_SCM_ICHAR_T, SCM_ICHAR_T_MAX,
    SCM_ICHAR_T_MIN, SCM_ICHAR_T_DEFINED, SIZEOF_SCM_BYTE_T): New
    macro
  - (ScmCharPortMethod_get_char, ScmCharPortMethod_peek_char,
    ScmCharPortMethod_put_char, ScmBytePortMethod_get_byte,
    ScmBytePortMethod_peek_byte): Replace int with scm_ichar_t to make
    64bit execution efficient
* sigscheme/src/nullport.c
  - (nullport_get_byte, nullport_peek_byte): Replace int with
    scm_ichar_t to make 64bit execution efficient
* sigscheme/src/fileport.c
  - (fileport_get_byte, fileport_peek_byte): Replace int with
    scm_ichar_t to make 64bit execution efficient
* sigscheme/src/strport.c
  - (istrport_get_byte, istrport_peek_byte, ostrport_get_byte,
    ostrport_peek_byte): Replace int with scm_ichar_t to make 64bit
    execution efficient
* sigscheme/src/basecport.c
  - (basecport_get_char, basecport_peek_char, basecport_put_char):
    Replace int with scm_ichar_t to make 64bit execution efficient
* sigscheme/src/sbcport.c
  - (sbcport_put_char): Replace int with scm_ichar_t to make 64bit
    execution efficient
* sigscheme/src/mbcport.h
  - (SCM_MB_MAX_LEN): Removed to use the one defined in encoding.h
* sigscheme/src/mbcport.c
  - (uchar): Removed
  - (struct ScmMultiByteCharPort_): Replace uchar with scm_byte_t
  - (mbcport_get_char, mbcport_peek_char, mbcport_put_char): Replace
    int with scm_ichar_t to make 64bit execution efficient
  - (mbcport_fill_rbuf): Follow the changes
* sigscheme/TODO
  - Update


Modified: branches/r5rs/sigscheme/TODO
===================================================================
--- branches/r5rs/sigscheme/TODO	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/TODO	2006-01-17 17:36:29 UTC (rev 2931)
@@ -23,7 +23,12 @@
 * Review and refactor some functions in syntax.c(listran, vectran,
   qquote_internal, scm_s_quasiquote) (other files had already been done)
 
-* Make 64bit-safe (after compaction and stdint.h)
+* Make 64bit-safe
+  - Write tests
+  - Make the tests passed on actual 64bit environment with fatty representation
+  - Modify storage-compact.h
+  - Make the tests passed on actual 64bit environment with compact
+    representation
 
 * Confirm R5RS and SRFI conformance for each function implementation
 
@@ -94,6 +99,7 @@
 
 * Object representation compaction ([Anthy-dev 2353], [Anthy-dev 2360])
   - Make all tests passed without error or SEGV
+  - Support 64bit models
   - Create immediate objects directly without calling scm_make_*()
   - Refine logical structure and namings
 

Modified: branches/r5rs/sigscheme/configure.in
===================================================================
--- branches/r5rs/sigscheme/configure.in	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/configure.in	2006-01-17 17:36:29 UTC (rev 2931)
@@ -22,29 +22,37 @@
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
+AC_C_VOLATILE
+#AC_C_LONG_LONG
+#AC_C_LONG_DOUBLE
+AC_C_CHAR_UNSIGNED
+AC_C_BIGENDIAN
+AC_C_STRINGIZE
 AC_TYPE_SIZE_T
-AC_C_VOLATILE
 
 AC_CHECK_SIZEOF(short)
 AC_CHECK_SIZEOF(int)
 AC_CHECK_SIZEOF(long)
-AC_CHECK_SIZEOF(float)
-AC_CHECK_SIZEOF(double)
-AC_CHECK_SIZEOF(long double)
+AC_CHECK_SIZEOF(long long)
+#AC_CHECK_SIZEOF(float)
+#AC_CHECK_SIZEOF(double)
+#AC_CHECK_SIZEOF(long double)
 AC_CHECK_SIZEOF(void *)
 
-# Do not assume (sizeof(int32_t) == 4) and so on
+AC_CHECK_SIZEOF(size_t)
+
+# Do not assume (sizeof(int32_t) == 4) and so on (i.e. do not (CHAR_BIT == 8)).
 AC_CHECK_SIZEOF(int16_t)
 AC_CHECK_SIZEOF(int32_t)
 AC_CHECK_SIZEOF(int64_t)
-AC_CHECK_SIZEOF(int_least8_t)
-AC_CHECK_SIZEOF(int_least16_t)
-AC_CHECK_SIZEOF(int_least32_t)
-AC_CHECK_SIZEOF(int_least64_t)
-AC_CHECK_SIZEOF(int_fast8_t)
-AC_CHECK_SIZEOF(int_fast16_t)
-AC_CHECK_SIZEOF(int_fast32_t)
-AC_CHECK_SIZEOF(int_fast64_t)
+#AC_CHECK_SIZEOF(int_least8_t)
+#AC_CHECK_SIZEOF(int_least16_t)
+#AC_CHECK_SIZEOF(int_least32_t)
+#AC_CHECK_SIZEOF(int_least64_t)
+#AC_CHECK_SIZEOF(int_fast8_t)
+#AC_CHECK_SIZEOF(int_fast16_t)
+#AC_CHECK_SIZEOF(int_fast32_t)
+#AC_CHECK_SIZEOF(int_fast64_t)
 AC_CHECK_SIZEOF(intmax_t)
 AC_CHECK_SIZEOF(intptr_t)
 

Modified: branches/r5rs/sigscheme/src/alloc.c
===================================================================
--- branches/r5rs/sigscheme/src/alloc.c	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/alloc.c	2006-01-17 17:36:29 UTC (rev 2931)
@@ -50,6 +50,7 @@
 /*=======================================
   File Local Macro Definitions
 =======================================*/
+#define ALIGN_CELL (sizeof(ScmCell))
 
 /*=======================================
   File Local Type Definitions
@@ -82,18 +83,13 @@
      *     SUSv3.  The function memalign() appears in SunOS 4.1.3 but not in
      *     BSD 4.4.  The function posix_memalign() comes from POSIX 1003.1d.
      */
-    /* FIXME: replace the '16' with sizeof(ScmCell) if not required */
-    posix_memalign(&p, 16, size);
-    SCM_ENSURE_ALLOCATED(p);
-#if SCM_DEBUG
-    /* check for buggy allocator */
-    assert(!((uintptr_t)p % 16));
-#endif
+    posix_memalign(&p, ALIGN_CELL, size);
 #else
     p = scm_malloc(size);
-    /* heaps must be aligned to sizeof(ScmCell) */
-    assert(!((uintptr_t)p % sizeof(ScmCell)));
 #endif
+    SCM_ENSURE_ALLOCATED(p);
+    /* heaps must be aligned to sizeof(ScmCell) */
+    SCM_ASSERT(!((uintptr_t)p % ALIGN_CELL));
 
     return p;
 }

Modified: branches/r5rs/sigscheme/src/basecport.c
===================================================================
--- branches/r5rs/sigscheme/src/basecport.c	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/basecport.c	2006-01-17 17:36:29 UTC (rev 2931)
@@ -71,13 +71,13 @@
 static int basecport_close(ScmBaseCharPort *port);
 static ScmCharCodec *basecport_codec(ScmBaseCharPort *port);
 static char *basecport_inspect(ScmBaseCharPort *port);
-static int basecport_get_char(ScmBaseCharPort *port);
-static int basecport_peek_char(ScmBaseCharPort *port);
+static scm_ichar_t basecport_get_char(ScmBaseCharPort *port);
+static scm_ichar_t basecport_peek_char(ScmBaseCharPort *port);
 static scm_bool basecport_char_readyp(ScmBaseCharPort *port);
 static int basecport_vprintf(ScmBaseCharPort *port, const char *str,
                              va_list args);
 static int basecport_puts(ScmBaseCharPort *port, const char *str);
-static int basecport_put_char(ScmBaseCharPort *port, int ch);
+static int basecport_put_char(ScmBaseCharPort *port, scm_ichar_t ch);
 static int basecport_flush(ScmBaseCharPort *port);
 
 /*=======================================
@@ -168,10 +168,10 @@
     return ScmBaseCharPort_inspect(port, "unknown");
 }
 
-static int
+static scm_ichar_t
 basecport_get_char(ScmBaseCharPort *port)
 {
-    int ch;
+    scm_ichar_t ch;
 
     ch = SCM_BYTEPORT_GET_BYTE(port->bport);
 #if SCM_DEBUG
@@ -182,7 +182,7 @@
     return ch;
 }
 
-static int
+static scm_ichar_t
 basecport_peek_char(ScmBaseCharPort *port)
 {
     return SCM_BYTEPORT_PEEK_BYTE(port->bport);
@@ -207,7 +207,7 @@
 }
 
 static int
-basecport_put_char(ScmBaseCharPort *port, int ch)
+basecport_put_char(ScmBaseCharPort *port, scm_ichar_t ch)
 {
     SCM_PORT_ERROR_INVALID_OPERATION(CHAR, port, ScmBaseCharPort);
     /* NOTREACHED */

Modified: branches/r5rs/sigscheme/src/baseport.h
===================================================================
--- branches/r5rs/sigscheme/src/baseport.h	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/baseport.h	2006-01-17 17:36:29 UTC (rev 2931)
@@ -47,7 +47,9 @@
 /*=======================================
   System Include
 =======================================*/
+#include <stdint.h> /* FIXME: make C99-independent */
 #include <stdlib.h>
+#include <stdio.h>  /* for EOF */
 #include <stdarg.h>
 
 /*=======================================
@@ -140,12 +142,30 @@
 /*=======================================
   Type Definitions
 =======================================*/
-#if (!defined(scm_true) && !defined(scm_false))
+#ifndef SCM_BOOL_DEFINED
 typedef int scm_bool;
 #define scm_false 0
 #define scm_true  (!scm_false)
+#define SCM_BOOL_DEFINED
+#endif /* SCM_BOOL_DEFINED */
+
+#ifndef SCM_ICHAR_T_DEFINED
+typedef int32_t            scm_ichar_t;
+#define SIZEOF_SCM_ICHAR_T SIZEOF_INT32_T
+#define SCM_ICHAR_T_MAX    INT32_MAX
+#define SCM_ICHAR_T_MIN    INT32_MIN
+#if (EOF < SCM_ICHAR_T_MIN || SCM_ICHAR_T_MAX < EOF)
+#error "scm_ichar_t cannot represent EOF on this platform"
 #endif
+#define SCM_ICHAR_T_DEFINED
+#endif /* SCM_ICHAR_T_DEFINED */
 
+#ifndef SCM_BYTE_T_DEFINED
+#define SCM_BYTE_T_DEFINED
+typedef unsigned char      scm_byte_t;
+#define SIZEOF_SCM_BYTE_T  1
+#endif /* SCM_BYTE_T_DEFINED */
+
 typedef struct ScmCharPortVTbl_ ScmCharPortVTbl;
 typedef struct ScmCharPort_     ScmCharPort;
 typedef struct ScmBaseCharPort_ ScmBaseCharPort;
@@ -162,15 +182,15 @@
 typedef char *(*ScmCharPortMethod_inspect)(ScmCharPort *cport);
 
 /* input */
-typedef int (*ScmCharPortMethod_get_char)(ScmCharPort *cport);
-typedef int (*ScmCharPortMethod_peek_char)(ScmCharPort *cport);
+typedef scm_ichar_t (*ScmCharPortMethod_get_char)(ScmCharPort *cport);
+typedef scm_ichar_t (*ScmCharPortMethod_peek_char)(ScmCharPort *cport);
 typedef scm_bool (*ScmCharPortMethod_char_readyp)(ScmCharPort *cport);
 
 /* output */
 typedef int (*ScmCharPortMethod_vprintf)(ScmCharPort *cport,
                                          const char *str, va_list args);
 typedef int (*ScmCharPortMethod_puts)(ScmCharPort *cport, const char *str);
-typedef int (*ScmCharPortMethod_put_char)(ScmCharPort *cport, int ch);
+typedef int (*ScmCharPortMethod_put_char)(ScmCharPort *cport, scm_ichar_t ch);
 typedef int (*ScmCharPortMethod_flush)(ScmCharPort *cport);
 
 struct ScmCharPortVTbl_ {
@@ -207,8 +227,8 @@
 typedef char *(*ScmBytePortMethod_inspect)(ScmBytePort *bport);
 
 /* input */
-typedef int (*ScmBytePortMethod_get_byte)(ScmBytePort *bport);
-typedef int (*ScmBytePortMethod_peek_byte)(ScmBytePort *bport);
+typedef scm_ichar_t (*ScmBytePortMethod_get_byte)(ScmBytePort *bport);
+typedef scm_ichar_t (*ScmBytePortMethod_peek_byte)(ScmBytePort *bport);
 typedef scm_bool (*ScmBytePortMethod_byte_readyp)(ScmBytePort *bport);
 
 /* output */

Modified: branches/r5rs/sigscheme/src/encoding.c
===================================================================
--- branches/r5rs/sigscheme/src/encoding.c	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/encoding.c	2006-01-17 17:36:29 UTC (rev 2931)
@@ -67,7 +67,6 @@
   File Local Type Definitions
 =======================================*/
 typedef unsigned char uchar;
-typedef unsigned int  uint;
 
 /*=======================================
   File Local Functions
@@ -78,11 +77,12 @@
 #if SCM_USE_EUCJP
 static const char *eucjp_encoding(void);
 static enum ScmCodedCharSet eucjp_ccs(void);
-static int eucjp_char_len(int ch);
+static int eucjp_char_len(scm_ichar_t ch);
 static ScmMultibyteCharInfo eucjp_scan_char(ScmMultibyteString mbs);
-static int eucjp_str2int(const uchar *src, size_t len,
-                         ScmMultibyteState state);
-static uchar *eucjp_int2str(uchar *dst, int ch, ScmMultibyteState state);
+static scm_ichar_t eucjp_str2int(const uchar *src, size_t len,
+                                 ScmMultibyteState state);
+static uchar *eucjp_int2str(uchar *dst, scm_ichar_t ch,
+                            ScmMultibyteState state);
 #endif
 
 #if SCM_USE_ISO2022KR
@@ -98,20 +98,22 @@
 #if SCM_USE_SJIS
 static const char *sjis_encoding(void);
 static enum ScmCodedCharSet sjis_ccs(void);
-static int sjis_char_len(int ch);
+static int sjis_char_len(scm_ichar_t ch);
 static ScmMultibyteCharInfo sjis_scan_char(ScmMultibyteString mbs);
-static uchar *sjis_int2str(uchar *dst, int ch, ScmMultibyteState state);
+static uchar *sjis_int2str(uchar *dst, scm_ichar_t ch,
+                           ScmMultibyteState state);
 #endif
 
 #if (SCM_USE_EUCCN || SCM_USE_EUCKR || SCM_USE_SJIS)
 /* generic double-byte char */
-static int dbc_str2int(const uchar *src, size_t len, ScmMultibyteState state);
+static scm_ichar_t dbc_str2int(const uchar *src, size_t len,
+                               ScmMultibyteState state);
 #endif
 
 #if (SCM_USE_EUCCN || SCM_USE_EUCKR)
 /* shared by EUCCN and EUCKR */
-static int euc_char_len(int ch);
-static uchar *euc_int2str(uchar *dst, int ch, ScmMultibyteState state);
+static int euc_char_len(scm_ichar_t ch);
+static uchar *euc_int2str(uchar *dst, scm_ichar_t ch, ScmMultibyteState state);
 #endif
 
 #if SCM_USE_EUCCN
@@ -129,19 +131,22 @@
 #if SCM_USE_UTF8
 static const char *utf8_encoding(void);
 static enum ScmCodedCharSet utf8_ccs(void);
-static int utf8_char_len(int ch);
+static int utf8_char_len(scm_ichar_t ch);
 static ScmMultibyteCharInfo utf8_scan_char(ScmMultibyteString mbs);
-static int utf8_str2int(const uchar *src, size_t len, ScmMultibyteState state);
-static uchar *utf8_int2str(uchar *dst, int ch, ScmMultibyteState state);
+static scm_ichar_t utf8_str2int(const uchar *src, size_t len,
+                                ScmMultibyteState state);
+static uchar *utf8_int2str(uchar *dst, scm_ichar_t ch,
+                           ScmMultibyteState state);
 #endif
 
 static const char *unibyte_encoding(void);
 static enum ScmCodedCharSet unibyte_ccs(void);
-static int unibyte_char_len(int ch);
+static int unibyte_char_len(scm_ichar_t ch);
 static ScmMultibyteCharInfo unibyte_scan_char(ScmMultibyteString mbs);
-static int unibyte_str2int(const uchar *src, size_t len,
-                           ScmMultibyteState state);
-static uchar *unibyte_int2str(uchar *dst, int ch, ScmMultibyteState state);
+static scm_ichar_t unibyte_str2int(const uchar *src, size_t len,
+                                   ScmMultibyteState state);
+static uchar *unibyte_int2str(uchar *dst, scm_ichar_t ch,
+                              ScmMultibyteState state);
 
 /*=======================================
   Local Variables
@@ -265,27 +270,28 @@
   Public API
 =======================================*/
 
-int
+size_t
 scm_mb_strlen(ScmCharCodec *codec, ScmMultibyteString mbs)
 {
-    int len;
+    size_t len;
     ScmMultibyteCharInfo c;
 
-    CDBG((SCM_DBG_ENCODING, "mb_strlen: size = %d; str = %s;",
+    CDBG((SCM_DBG_ENCODING, "mb_strlen: size = " SCM_SIZE_T_FMT "; str = %s;",
           SCM_MBS_GET_SIZE(mbs), SCM_MBS_GET_STR(mbs)));
 
     for (len = 0; SCM_MBS_GET_SIZE(mbs); len++) {
         c = SCM_CHARCODEC_SCAN_CHAR(codec, mbs);
-        CDBG((SCM_DBG_ENCODING, "%d, %d;", SCM_MBCINFO_GET_SIZE(c), c.flag));
+        CDBG((SCM_DBG_ENCODING, SCM_SIZE_T_FMT ", %d;",
+              SCM_MBCINFO_GET_SIZE(c), c.flag));
         SCM_MBS_SKIP_CHAR(mbs, c);
     }
 
-    CDBG((SCM_DBG_ENCODING, "len=%d\n", len));
+    CDBG((SCM_DBG_ENCODING, "len=" SCM_SIZE_T_FMT "\n", len));
     return len;
 }
 
 /* FIXME: pick a better name. */
-int
+size_t
 scm_mb_bare_c_strlen(ScmCharCodec *codec, const char *s)
 {
     ScmMultibyteString mbs;
@@ -295,7 +301,7 @@
 }
 
 ScmMultibyteString
-scm_mb_substring(ScmCharCodec *codec, ScmMultibyteString mbs, int i, int len)
+scm_mb_substring(ScmCharCodec *codec, ScmMultibyteString mbs, size_t i, size_t len)
 {
     ScmMultibyteString ret, end;
     ScmMultibyteCharInfo c;
@@ -332,13 +338,13 @@
     return NULL;
 }
 
-int
+scm_ichar_t
 scm_charcodec_read_char(ScmCharCodec *codec, ScmMultibyteString *mbs,
                         const char *caller)
 {
     ScmMultibyteCharInfo mbc;
     ScmMultibyteState state;
-    int ch;
+    scm_ichar_t ch;
     DECLARE_INTERNAL_FUNCTION("scm_charcodec_read_char");
 
     SCM_ASSERT(SCM_MBS_GET_SIZE(*mbs));
@@ -418,14 +424,14 @@
 #define IN_GR94(c) (0xA1 <= (uchar)(c) && (uchar)(c) <= 0xFE)
 #define IN_GR96(c) (0xA0 <= (uchar)(c) /* && (uchar)(c) <= 0xFF */)
 
-#define IS_ASCII(c) ((uint)(c) <= 0x7F)
+#define IS_ASCII(c) ((scm_ichar_t)(c) <= 0x7F)
 #define IS_GR_SPC_OR_DEL(c)  ((uchar)(c) == 0xA0 || (uchar)(c) == 0xFF)
 
 #define CHAR_BITS    8
 #define BYTE_MASK    0xFF
-#define IS_1BYTE(e)  ((uint)(e) <= 0x7F)
-#define IS_2BYTES(e) ((uint)(e) <= 0xFFFF)
-#define IS_3BYTES(e) ((uint)(e) <= ((SS3 << CHAR_BITS * 2) | 0xFFFF))
+#define IS_1BYTE(e)  ((scm_ichar_t)(e) <= 0x7F)
+#define IS_2BYTES(e) ((scm_ichar_t)(e) <= 0xFFFF)
+#define IS_3BYTES(e) ((scm_ichar_t)(e) <= ((SS3 << CHAR_BITS * 2) | 0xFFFF))
 
 #define ESC 0x1B
 #define SO  0x0E
@@ -448,7 +454,7 @@
 
 /* FIXME: Optimize */
 int
-eucjp_char_len(int ch)
+eucjp_char_len(scm_ichar_t ch)
 {
     uchar *end, buf[SCM_MB_MAX_LEN + sizeof("")];
 
@@ -469,8 +475,8 @@
 static ScmMultibyteCharInfo
 eucjp_scan_char(ScmMultibyteString mbs)
 {
-    const char *str = SCM_MBS_GET_STR(mbs);
-    const int size  = SCM_MBS_GET_SIZE(mbs);
+    const uchar *str = (const uchar *)SCM_MBS_GET_STR(mbs);
+    const size_t size = SCM_MBS_GET_SIZE(mbs);
     ENTER;
 
     if (!size)
@@ -505,10 +511,10 @@
     RETURN_ERROR();
 }
 
-static int
+static scm_ichar_t
 eucjp_str2int(const uchar *src, size_t len, ScmMultibyteState state)
 {
-    int ch;
+    scm_ichar_t ch;
 
     switch (len) {
     case 1:
@@ -537,7 +543,7 @@
    absolute character set identifier instead of raw encoding-dependent
    shifts */
 static uchar *
-eucjp_int2str(uchar *dst, int ch, ScmMultibyteState state)
+eucjp_int2str(uchar *dst, scm_ichar_t ch, ScmMultibyteState state)
 {
 #if SCM_STRICT_ENCODING_CHECK
     uchar seq[3];
@@ -577,10 +583,10 @@
 
 #if (SCM_USE_EUCCN || SCM_USE_EUCKR || SCM_USE_SJIS)
 /* generic double-byte char */
-static int
+static scm_ichar_t
 dbc_str2int(const uchar *src, size_t len, ScmMultibyteState state)
 {
-    int ch;
+    scm_ichar_t ch;
 
     switch (len) {
     case 1:
@@ -603,7 +609,7 @@
 #if (SCM_USE_EUCCN || SCM_USE_EUCKR)
 /* FIXME: Optimize */
 int
-euc_char_len(int ch)
+euc_char_len(scm_ichar_t ch)
 {
     uchar *end, buf[SCM_MB_MAX_LEN + sizeof("")];
 
@@ -613,7 +619,7 @@
 }
 
 static uchar *
-euc_int2str(uchar *dst, int ch, ScmMultibyteState state)
+euc_int2str(uchar *dst, scm_ichar_t ch, ScmMultibyteState state)
 {
 #if SCM_STRICT_ENCODING_CHECK
     uchar seq[2];
@@ -663,8 +669,8 @@
 euccn_scan_char(ScmMultibyteString mbs)
 {
     /* TODO: maybe we can make this an alias of eucjp_scan_char()? */
-    const char *str = SCM_MBS_GET_STR(mbs);
-    const int size  = SCM_MBS_GET_SIZE(mbs);
+    const uchar *str = (const uchar *)SCM_MBS_GET_STR(mbs);
+    const size_t size = SCM_MBS_GET_SIZE(mbs);
     ENTER;
 
     if (!size)
@@ -710,8 +716,8 @@
 static ScmMultibyteCharInfo
 euckr_scan_char(ScmMultibyteString mbs)
 {
-    const char *str = SCM_MBS_GET_STR(mbs);
-    const int size  = SCM_MBS_GET_SIZE(mbs);
+    const uchar *str = (const uchar *)SCM_MBS_GET_STR(mbs);
+    const size_t size = SCM_MBS_GET_SIZE(mbs);
     ENTER;
 
     if (!size)
@@ -733,9 +739,9 @@
 #endif /* SCM_USE_EUCKR */
 
 /*==== Encodings for Unicode ====*/
-#define IN_OCT_BMP(u)  ((uint)(u) <= 0x7ff)
-#define IN_BMP(u)      ((uint)(u) <= 0xffff)
-#define IN_SMP(u)      ((uint)(u) <= 0x10ffff && !IN_BMP(u))
+#define IN_OCT_BMP(u)  ((scm_ichar_t)(u) <= 0x7ff)
+#define IN_BMP(u)      ((scm_ichar_t)(u) <= 0xffff)
+#define IN_SMP(u)      ((scm_ichar_t)(u) <= 0x10ffff && !IN_BMP(u))
 
 #if SCM_USE_UTF8
 /* RFC 3629 */
@@ -765,7 +771,7 @@
 
 /* FIXME: Optimize */
 int
-utf8_char_len(int ch)
+utf8_char_len(scm_ichar_t ch)
 {
     uchar *end, buf[SCM_MB_MAX_LEN + sizeof("")];
 
@@ -777,9 +783,9 @@
 static ScmMultibyteCharInfo
 utf8_scan_char(ScmMultibyteString mbs)
 {
-    const char *str = SCM_MBS_GET_STR(mbs);
-    const int size  = SCM_MBS_GET_SIZE(mbs);
-    int len;
+    const uchar *str = (const uchar *)SCM_MBS_GET_STR(mbs);
+    const size_t size = SCM_MBS_GET_SIZE(mbs);
+    size_t len;
     ENTER;
 
     if (!size)
@@ -794,7 +800,7 @@
 
 #if SCM_STRICT_ENCODING_CHECK
     {
-        int i;
+        size_t i;
         for (i = 1; i < len; i++) {
             if (size <= i)
                 RETURN_INCOMPLETE(size);
@@ -811,10 +817,10 @@
 
 }
 
-static int
+static scm_ichar_t
 utf8_str2int(const uchar *src, size_t len, ScmMultibyteState state)
 {
-    int ch;
+    scm_ichar_t ch;
 
     switch (len) {
     case 1:
@@ -847,7 +853,7 @@
 }
 
 static uchar *
-utf8_int2str(uchar *dst, int ch, ScmMultibyteState state)
+utf8_int2str(uchar *dst, scm_ichar_t ch, ScmMultibyteState state)
 {
     if (IS_ASCII(ch)) {
         *dst++ = ch;
@@ -922,7 +928,7 @@
 
 /* FIXME: Optimize */
 int
-sjis_char_len(int ch)
+sjis_char_len(scm_ichar_t ch)
 {
     uchar *end, buf[SCM_MB_MAX_LEN + sizeof("")];
 
@@ -934,8 +940,8 @@
 static ScmMultibyteCharInfo
 sjis_scan_char(ScmMultibyteString mbs)
 {
-    const char *str = SCM_MBS_GET_STR(mbs);
-    const int  size = SCM_MBS_GET_SIZE(mbs);
+    const uchar *str = (const uchar *)SCM_MBS_GET_STR(mbs);
+    const size_t size = SCM_MBS_GET_SIZE(mbs);
     ENTER;
 
     if (!size)
@@ -954,7 +960,7 @@
 }
 
 static uchar *
-sjis_int2str(uchar *dst, int ch, ScmMultibyteState state)
+sjis_int2str(uchar *dst, scm_ichar_t ch, ScmMultibyteState state)
 {
     uchar high, low;
 
@@ -1005,7 +1011,7 @@
 }
 
 int
-unibyte_char_len(int ch)
+unibyte_char_len(scm_ichar_t ch)
 {
     return (0 < ch && ch <= 0xff) ? 1 : 0;
 }
@@ -1020,7 +1026,7 @@
     RETURN(0);
 }
 
-static int
+static scm_ichar_t
 unibyte_str2int(const uchar *src, size_t len, ScmMultibyteState state)
 {
 #if SCM_STRICT_ENCODING_CHECK
@@ -1031,7 +1037,7 @@
 }
 
 static uchar *
-unibyte_int2str(uchar *dst, int ch, ScmMultibyteState state)
+unibyte_int2str(uchar *dst, scm_ichar_t ch, ScmMultibyteState state)
 {
 #if SCM_STRICT_ENCODING_CHECK
     if (ch & ~BYTE_MASK)

Modified: branches/r5rs/sigscheme/src/encoding.h
===================================================================
--- branches/r5rs/sigscheme/src/encoding.h	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/encoding.h	2006-01-17 17:36:29 UTC (rev 2931)
@@ -45,6 +45,7 @@
   System Include
 =======================================*/
 #include <stddef.h>
+#include <stdint.h> /* FIXME: make C99-independent */
 
 /*=======================================
   Local Include
@@ -133,12 +134,30 @@
 /*=======================================
   Type Definitions
 =======================================*/
-#if (!defined(scm_true) && !defined(scm_false))
+#ifndef SCM_BOOL_DEFINED
 typedef int scm_bool;
 #define scm_false 0
 #define scm_true  (!scm_false)
+#define SCM_BOOL_DEFINED
+#endif /* SCM_BOOL_DEFINED */
+
+#ifndef SCM_ICHAR_T_DEFINED
+typedef int32_t            scm_ichar_t;
+#define SIZEOF_SCM_ICHAR_T SIZEOF_INT32_T
+#define SCM_ICHAR_T_MAX    INT32_MAX
+#define SCM_ICHAR_T_MIN    INT32_MIN
+#if (EOF < SCM_ICHAR_T_MIN || SCM_ICHAR_T_MAX < EOF)
+#error "scm_ichar_t cannot represent EOF on this platform"
 #endif
+#define SCM_ICHAR_T_DEFINED
+#endif /* SCM_ICHAR_T_DEFINED */
 
+#ifndef SCM_BYTE_T_DEFINED
+#define SCM_BYTE_T_DEFINED
+typedef unsigned char      scm_byte_t;
+#define SIZEOF_SCM_BYTE_T  1
+#endif /* SCM_BYTE_T_DEFINED */
+
 enum ScmCodedCharSet {
     SCM_CCS_UNKNOWN   = 0,
     SCM_CCS_UCS2      = 1,
@@ -155,9 +174,14 @@
 /* Metadata of a multibyte character.  These are usually allocated on
    stack or register, so we'll make liberal use of space. */
 typedef struct {
+#if 0
+    /* will be changed to this */
+    const scm_byte_t *start;
+#else
     const char *start;
+#endif
+    size_t size;
     int flag;
-    int size;
 
 #if SCM_USE_STATEFUL_ENCODING
     /* Shift state at the *end* of the described character. */
@@ -166,12 +190,17 @@
 } ScmMultibyteCharInfo;
 
 typedef struct {
+#if 0
+    /* will be changed to this */
+    const scm_byte_t *str;
+#else
     const char *str;
+#endif
 
     /* Only the size is stored because ScmObj caches the length, and
      * we'll have to traverse from the beginning all the time
      * anyway. */
-    int size;
+    size_t size;
 #if SCM_USE_STATEFUL_ENCODING
     ScmMultibyteState state;
 #endif
@@ -183,11 +212,11 @@
 typedef scm_bool (*ScmCharCodecMethod_statefulp)(void);
 typedef const char *(*ScmCharCodecMethod_encoding)(void);
 typedef enum ScmCodedCharSet (*ScmCharCodecMethod_ccs)(void);
-typedef int (*ScmCharCodecMethod_char_len)(int ch);
+typedef int (*ScmCharCodecMethod_char_len)(scm_ichar_t ch);
 typedef ScmMultibyteCharInfo (*ScmCharCodecMethod_scan_char)(ScmMultibyteString mbs);
-typedef int (*ScmCharCodecMethod_str2int)(const char *src, size_t len,
-                                          ScmMultibyteState state);
-typedef char *(*ScmCharCodecMethod_int2str)(char *dst, int ch,
+typedef scm_ichar_t (*ScmCharCodecMethod_str2int)(const char *src, size_t len,
+                                                  ScmMultibyteState state);
+typedef char *(*ScmCharCodecMethod_int2str)(char *dst, scm_ichar_t ch,
                                             ScmMultibyteState state);
 
 struct ScmCharCodecVTbl_ {
@@ -208,14 +237,16 @@
 /*=======================================
    Function Declarations
 =======================================*/
-int scm_mb_strlen(ScmCharCodec *codec, ScmMultibyteString mbs);
-int scm_mb_bare_c_strlen(ScmCharCodec *codec, const char *str);
+size_t scm_mb_strlen(ScmCharCodec *codec, ScmMultibyteString mbs);
+size_t scm_mb_bare_c_strlen(ScmCharCodec *codec, const char *str);
 ScmMultibyteString scm_mb_substring(ScmCharCodec *codec,
-                                    ScmMultibyteString str, int i, int len);
+                                    ScmMultibyteString str,
+                                    size_t i, size_t len);
 #define scm_mb_strref(codec, str, i) (scm_mb_substring((codec), (str), (i), 1))
 ScmCharCodec *scm_mb_find_codec(const char *encoding);
-int scm_charcodec_read_char(ScmCharCodec *codec, ScmMultibyteString *mbs,
-                            const char *caller);
+scm_ichar_t scm_charcodec_read_char(ScmCharCodec *codec,
+                                    ScmMultibyteString *mbs,
+                                    const char *caller);
 
 #ifdef __cplusplus
 }

Modified: branches/r5rs/sigscheme/src/env.c
===================================================================
--- branches/r5rs/sigscheme/src/env.c	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/env.c	2006-01-17 17:36:29 UTC (rev 2931)
@@ -299,7 +299,7 @@
 scm_bool
 scm_valid_environment_extensionp(ScmObj formals, ScmObj actuals)
 {
-    int formals_len, actuals_len;
+    scm_int_t formals_len, actuals_len;
 
     formals_len = scm_validate_formals(formals);
     actuals_len = scm_validate_actuals(actuals);
@@ -308,7 +308,8 @@
 
 /* formals_len must be validated by scm_validate_formals() prior to here */
 scm_bool
-scm_valid_environment_extension_lengthp(int formals_len, int actuals_len)
+scm_valid_environment_extension_lengthp(scm_int_t formals_len,
+                                        scm_int_t actuals_len)
 {
     if (SCM_LISTLEN_ERRORP(formals_len) || !SCM_LISTLEN_PROPERP(actuals_len))
         return scm_false;
@@ -319,11 +320,11 @@
     return (formals_len == actuals_len);
 }
 
-int
+scm_int_t
 scm_validate_formals(ScmObj formals)
 {
 #if SCM_STRICT_ARGCHECK
-    int len;
+    scm_int_t len;
     DECLARE_INTERNAL_FUNCTION("scm_validate_formals");
 
     /* This loop goes infinite if the formals is circular. SigSchme expects
@@ -347,10 +348,10 @@
 #endif
 }
 
-int
+scm_int_t
 scm_validate_actuals(ScmObj actuals)
 {
-    int len;
+    scm_int_t len;
 
 #if SCM_STRICT_ARGCHECK
     len = scm_length(actuals);

Modified: branches/r5rs/sigscheme/src/eval.c
===================================================================
--- branches/r5rs/sigscheme/src/eval.c	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/eval.c	2006-01-17 17:36:29 UTC (rev 2931)
@@ -68,7 +68,7 @@
                            enum ScmValueType need_eval);
 static ScmObj call(ScmObj proc, ScmObj args, ScmEvalState *eval_state,
                    enum ScmValueType need_eval);
-static ScmObj map_eval(ScmObj args, int *args_len, ScmObj env);
+static ScmObj map_eval(ScmObj args, scm_int_t *args_len, ScmObj env);
 
 /*=======================================
   Function Implementations
@@ -193,7 +193,7 @@
              enum ScmValueType need_eval)
 {
     ScmObj formals, body, proc_env;
-    int formals_len, args_len;
+    scm_int_t formals_len, args_len;
     DECLARE_INTERNAL_FUNCTION("call_closure");
 
     /*
@@ -273,7 +273,8 @@
     ScmObj (*func)();
     enum ScmFuncTypeCode type;
     scm_bool syntaxp;
-    int mand_count, i, variadic_len;
+    int mand_count, i;
+    scm_int_t variadic_len;
     /* The +2 is for rest and env/eval_state. */
     void *argbuf[SCM_FUNCTYPE_MAND_MAX + 2];
     DECLARE_INTERNAL_FUNCTION("(function call)");
@@ -457,11 +458,11 @@
 }
 
 static ScmObj
-map_eval(ScmObj args, int *args_len, ScmObj env)
+map_eval(ScmObj args, scm_int_t *args_len, ScmObj env)
 {
     ScmQueue q;
     ScmObj res, elm, rest;
-    int len;
+    scm_int_t len;
     DECLARE_INTERNAL_FUNCTION("(function call)");
 
     if (NULLP(args)) {

Modified: branches/r5rs/sigscheme/src/fileport.c
===================================================================
--- branches/r5rs/sigscheme/src/fileport.c	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/fileport.c	2006-01-17 17:36:29 UTC (rev 2931)
@@ -85,8 +85,8 @@
                                       const ScmBytePortVTbl *dest_vptr);
 static int fileport_close(ScmFilePort *bport);
 static char *fileport_inspect(ScmFilePort *port);
-static int fileport_get_byte(ScmFilePort *bport);
-static int fileport_peek_byte(ScmFilePort *bport);
+static scm_ichar_t fileport_get_byte(ScmFilePort *bport);
+static scm_ichar_t fileport_peek_byte(ScmFilePort *bport);
 static scm_bool fileport_byte_readyp(ScmFilePort *bport);
 static int fileport_vprintf(ScmFilePort *bport, const char *str, va_list args);
 static int fileport_puts(ScmFilePort *bport, const char *str);
@@ -203,16 +203,16 @@
     }
 }
 
-static int
+static scm_ichar_t
 fileport_get_byte(ScmFilePort *port)
 {
     return getc(port->file);
 }
 
-static int
+static scm_ichar_t
 fileport_peek_byte(ScmFilePort *port)
 {
-    int ch;
+    scm_ichar_t ch;
 
     ch = getc(port->file);
     return ungetc(ch, port->file);

Modified: branches/r5rs/sigscheme/src/io.c
===================================================================
--- branches/r5rs/sigscheme/src/io.c	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/io.c	2006-01-17 17:36:29 UTC (rev 2931)
@@ -34,6 +34,7 @@
 /*=======================================
   System Include
 =======================================*/
+#include <stddef.h>
 #include <stdio.h>
 #include <string.h>
 
@@ -246,7 +247,7 @@
 }
 
 int
-scm_port_put_char(ScmObj port, int ch)
+scm_port_put_char(ScmObj port, scm_ichar_t ch)
 {
     SCM_ENSURE_LIVE_PORT(port);
     return SCM_CHARPORT_PUT_CHAR(SCM_PORT_IMPL(port), ch);
@@ -414,7 +415,7 @@
 ScmObj
 scm_p_close_input_port(ScmObj port)
 {
-    int flag;
+    scm_int_t flag;
     DECLARE_FUNCTION("close-input-port", procedure_fixed_1);
 
     ENSURE_PORT(port);
@@ -430,7 +431,7 @@
 ScmObj
 scm_p_close_output_port(ScmObj port)
 {
-    int flag;
+    scm_int_t flag;
     DECLARE_FUNCTION("close-output-port", procedure_fixed_1);
 
     ENSURE_PORT(port);
@@ -460,7 +461,7 @@
 scm_p_read_char(ScmObj args)
 {
     ScmObj port;
-    int ch;
+    scm_ichar_t ch;
     DECLARE_FUNCTION("read-char", procedure_variadic_0);
 
     port = scm_prepare_port(args, scm_in);
@@ -476,7 +477,7 @@
 scm_p_peek_char(ScmObj args)
 {
     ScmObj port;
-    int ch;
+    scm_ichar_t ch;
     DECLARE_FUNCTION("peek-char", procedure_variadic_0);
 
     port = scm_prepare_port(args, scm_in);
@@ -616,7 +617,7 @@
 find_path(const char *filename)
 {
     char *path;
-    int lib_path_len, filename_len, path_len;
+    size_t lib_path_len, filename_len, path_len;
 
     SCM_ASSERT(filename);
 

Modified: branches/r5rs/sigscheme/src/mbcport.c
===================================================================
--- branches/r5rs/sigscheme/src/mbcport.c	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/mbcport.c	2006-01-17 17:36:29 UTC (rev 2931)
@@ -52,8 +52,8 @@
  * on SigScheme-specific things */
 #include "sigscheme.h"
 
-#include "baseport.h"
 #include "encoding.h"
+#include "baseport.h"
 #include "mbcport.h"
 
 /*=======================================
@@ -70,8 +70,6 @@
 /*=======================================
   File Local Type Definitions
 =======================================*/
-typedef unsigned char uchar;
-
 struct ScmMultiByteCharPort_ {  /* inherits ScmBaseCharPort */
     const ScmCharPortVTbl *vptr;
 
@@ -80,7 +78,7 @@
 
     ScmCharCodec *codec;
     ScmMultibyteState state;
-    uchar rbuf[SCM_MB_MAX_LEN + sizeof("")];
+    scm_byte_t rbuf[SCM_MB_MAX_LEN + sizeof("")];
 };
 
 /*=======================================
@@ -90,10 +88,10 @@
                                      const ScmCharPortVTbl *dst_vptr);
 static ScmCharCodec *mbcport_codec(ScmMultiByteCharPort *port);
 static char *mbcport_inspect(ScmMultiByteCharPort *port);
-static int mbcport_get_char(ScmMultiByteCharPort *port);
-static int mbcport_peek_char(ScmMultiByteCharPort *port);
+static scm_ichar_t mbcport_get_char(ScmMultiByteCharPort *port);
+static scm_ichar_t mbcport_peek_char(ScmMultiByteCharPort *port);
 static scm_bool mbcport_char_readyp(ScmMultiByteCharPort *port);
-static int mbcport_put_char(ScmMultiByteCharPort *port, int ch);
+static int mbcport_put_char(ScmMultiByteCharPort *port, scm_ichar_t ch);
 
 static ScmMultibyteCharInfo mbcport_fill_rbuf(ScmMultiByteCharPort *port,
                                               scm_bool blockp);
@@ -180,10 +178,10 @@
     return ScmBaseCharPort_inspect((ScmBaseCharPort *)port, "mb");
 }
 
-static int
+static scm_ichar_t
 mbcport_get_char(ScmMultiByteCharPort *port)
 {
-    int ch;
+    scm_ichar_t ch;
 #if SCM_USE_STATEFUL_ENCODING
     ScmMultibyteCharInfo mbc;
     ScmMultibyteState next_state;
@@ -205,11 +203,12 @@
     return ch;
 }
 
-static int
+static scm_ichar_t
 mbcport_peek_char(ScmMultiByteCharPort *port)
 {
     ScmMultibyteCharInfo mbc;
-    int size, ch;
+    size_t size;
+    scm_ichar_t ch;
 
     mbc = mbcport_fill_rbuf(port, scm_true);
     size = SCM_MBCINFO_GET_SIZE(mbc);
@@ -232,7 +231,7 @@
 }
 
 static int
-mbcport_put_char(ScmMultiByteCharPort *port, int ch)
+mbcport_put_char(ScmMultiByteCharPort *port, scm_ichar_t ch)
 {
     char *end, wbuf[SCM_MB_MAX_LEN + sizeof("")];
 
@@ -246,12 +245,12 @@
 static ScmMultibyteCharInfo
 mbcport_fill_rbuf(ScmMultiByteCharPort *port, scm_bool blockp)
 {
-    uchar *end;
-    int byte;
+    scm_byte_t *end;
+    scm_ichar_t byte;
     ScmMultibyteString mbs;
     ScmMultibyteCharInfo mbc;
 
-    end = (uchar *)strchr((char *)port->rbuf, '\0');
+    end = (scm_byte_t *)strchr((char *)port->rbuf, '\0');
     SCM_MBS_SET_STATE(mbs, port->state);
     do {
         SCM_MBS_SET_STR(mbs, (char *)port->rbuf);

Modified: branches/r5rs/sigscheme/src/mbcport.h
===================================================================
--- branches/r5rs/sigscheme/src/mbcport.h	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/mbcport.h	2006-01-17 17:36:29 UTC (rev 2931)
@@ -51,17 +51,13 @@
 /*=======================================
   Local Include
 =======================================*/
-#include "baseport.h"
 #include "encoding.h"
+#include "baseport.h"
 
 /*=======================================
   Macro Definitions
 =======================================*/
-#ifndef SCM_MB_MAX_LEN
-#define SCM_MB_MAX_LEN 4
-#endif
 
-
 /*=======================================
   Type Definitions
 =======================================*/

Modified: branches/r5rs/sigscheme/src/nullport.c
===================================================================
--- branches/r5rs/sigscheme/src/nullport.c	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/nullport.c	2006-01-17 17:36:29 UTC (rev 2931)
@@ -73,8 +73,8 @@
                                       const ScmBytePortVTbl *dest_vptr);
 static int nullport_close(ScmNullPort *bport);
 static char *nullport_inspect(ScmNullPort *port);
-static int nullport_get_byte(ScmNullPort *bport);
-static int nullport_peek_byte(ScmNullPort *bport);
+static scm_ichar_t nullport_get_byte(ScmNullPort *bport);
+static scm_ichar_t nullport_peek_byte(ScmNullPort *bport);
 static scm_bool nullport_byte_readyp(ScmNullPort *bport);
 static int nullport_vprintf(ScmNullPort *bport, const char *str, va_list args);
 static int nullport_puts(ScmNullPort *bport, const char *str);
@@ -142,13 +142,13 @@
     return scm_strdup("null");
 }
 
-static int
+static scm_ichar_t
 nullport_get_byte(ScmNullPort *port)
 {
     return EOF;
 }
 
-static int
+static scm_ichar_t
 nullport_peek_byte(ScmNullPort *port)
 {
     return EOF;

Modified: branches/r5rs/sigscheme/src/operations-nonstd.c
===================================================================
--- branches/r5rs/sigscheme/src/operations-nonstd.c	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/operations-nonstd.c	2006-01-17 17:36:29 UTC (rev 2931)
@@ -249,7 +249,7 @@
 ScmObj
 scm_p_lengthstar(ScmObj lst)
 {
-    int len;
+    scm_int_t len;
     DECLARE_FUNCTION("length*", procedure_fixed_1);
 
     len = scm_length(lst);

Modified: branches/r5rs/sigscheme/src/operations-siod.c
===================================================================
--- branches/r5rs/sigscheme/src/operations-siod.c	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/operations-siod.c	2006-01-17 17:36:29 UTC (rev 2931)
@@ -249,7 +249,7 @@
 {
     if (level < 0)
         ERR("scm_set_verbose_level: positive value required but got: %d",
-            level);
+            (int)level);
 
     if (sscm_verbose_level == level)
         return;

Modified: branches/r5rs/sigscheme/src/operations-srfi1.c
===================================================================
--- branches/r5rs/sigscheme/src/operations-srfi1.c	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/operations-srfi1.c	2006-01-17 17:36:29 UTC (rev 2931)
@@ -106,8 +106,8 @@
 {
     ScmObj filler;
     ScmObj head = SCM_NULL;
-    int len = 0;
-    int i   = 0;
+    scm_int_t len = 0;
+    scm_int_t i   = 0;
     DECLARE_FUNCTION("make-list", procedure_variadic_1);
 
     ENSURE_INT(length);
@@ -134,8 +134,8 @@
     ScmObj proc  = SCM_FALSE;
     ScmObj head  = SCM_NULL;
     ScmObj num   = SCM_FALSE;
-    int n = 0;
-    int i = 0;
+    scm_int_t n = 0;
+    scm_int_t i = 0;
     DECLARE_FUNCTION("list-tabulate", procedure_variadic_1);
 
     ENSURE_INT(scm_n);
@@ -207,10 +207,10 @@
     ScmObj scm_start = SCM_FALSE;
     ScmObj scm_step  = SCM_FALSE;
     ScmObj head      = SCM_NULL;
-    int count = 0;
-    int start = 0;
-    int step  = 0;
-    int i = 0;
+    scm_int_t count = 0;
+    scm_int_t start = 0;
+    scm_int_t step  = 0;
+    scm_int_t i = 0;
     DECLARE_FUNCTION("iota", procedure_variadic_1);
 
     /* get params */
@@ -277,7 +277,7 @@
 ScmObj
 scm_p_srfi1_null_listp(ScmObj lst)
 {
-    int len;
+    scm_int_t len;
     DECLARE_FUNCTION("null-list?", procedure_fixed_1);
 
     len = scm_length(lst);
@@ -420,8 +420,8 @@
     ScmObj tmp      = lst;
     ScmObj ret      = SCM_FALSE;
     ScmObj ret_tail = SCM_FALSE;
-    int idx = 0;
-    int i;
+    scm_int_t idx = 0;
+    scm_int_t i;
     DECLARE_FUNCTION("take", procedure_fixed_2);
 
     ENSURE_INT(scm_idx);
@@ -449,8 +449,8 @@
 scm_p_srfi1_drop(ScmObj lst, ScmObj scm_idx)
 {
     ScmObj ret = lst;
-    int idx = 0;
-    int i;
+    scm_int_t idx = 0;
+    scm_int_t i;
     DECLARE_FUNCTION("drop", procedure_fixed_2);
 
     ENSURE_INT(scm_idx);
@@ -470,7 +470,7 @@
 scm_p_srfi1_take_right(ScmObj lst, ScmObj scm_elem)
 {
     ScmObj tmp = lst;
-    int len = 0;
+    scm_int_t len = 0;
     DECLARE_FUNCTION("take-right", procedure_fixed_2);
 
     ENSURE_INT(scm_elem);
@@ -487,7 +487,7 @@
 scm_p_srfi1_drop_right(ScmObj lst, ScmObj scm_elem)
 {
     ScmObj tmp = lst;
-    int len = 0;
+    scm_int_t len = 0;
     DECLARE_FUNCTION("drop-right", procedure_fixed_2);
 
     ENSURE_INT(scm_elem);
@@ -504,8 +504,8 @@
 scm_p_srfi1_taked(ScmObj lst, ScmObj scm_idx)
 {
     ScmObj tmp = lst;
-    int idx = 0;
-    int i;
+    scm_int_t idx = 0;
+    scm_int_t i;
     DECLARE_FUNCTION("take!", procedure_fixed_2);
 
     ENSURE_INT(scm_idx);
@@ -525,8 +525,8 @@
 scm_p_srfi1_drop_rightd(ScmObj lst, ScmObj scm_idx)
 {
     ScmObj tmp = lst;
-    int len = 0;
-    int i;
+    scm_int_t len = 0;
+    scm_int_t i;
     DECLARE_FUNCTION("drop-right!", procedure_fixed_2);
 
     ENSURE_INT(scm_idx);
@@ -598,7 +598,7 @@
 ScmObj
 scm_p_srfi1_lengthplus(ScmObj lst)
 {
-    int len;
+    scm_int_t len;
     DECLARE_FUNCTION("length+", procedure_fixed_1);
 
     len = scm_length(lst);

Modified: branches/r5rs/sigscheme/src/operations-srfi6.c
===================================================================
--- branches/r5rs/sigscheme/src/operations-srfi6.c	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/operations-srfi6.c	2006-01-17 17:36:29 UTC (rev 2931)
@@ -114,7 +114,7 @@
     ScmBaseCharPort *cport;
     const char *str;
     char *new_str;
-    int mb_len;
+    scm_int_t mb_len;
 #if SCM_USE_NULL_CAPABLE_STRING
     size_t size;
 #endif

Modified: branches/r5rs/sigscheme/src/operations-srfi60.c
===================================================================
--- branches/r5rs/sigscheme/src/operations-srfi60.c	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/operations-srfi60.c	2006-01-17 17:36:29 UTC (rev 2931)
@@ -50,7 +50,7 @@
 =======================================*/
 #define BITWISE_OPERATION_BODY(op, left, right)                              \
     do {                                                                     \
-        int result;                                                          \
+        scm_int_t result;                                                    \
                                                                              \
         result = 0;                                                          \
         switch (*state) {                                                    \
@@ -133,7 +133,7 @@
 ScmObj
 scm_p_srfi60_bitwise_if(ScmObj mask, ScmObj n0, ScmObj n1)
 {
-    int result, c_mask;
+    scm_int_t result, c_mask;
     DECLARE_FUNCTION("bitwise-if", procedure_fixed_3);
 
     ENSURE_INT(mask);

Modified: branches/r5rs/sigscheme/src/operations-srfi8.c
===================================================================
--- branches/r5rs/sigscheme/src/operations-srfi8.c	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/operations-srfi8.c	2006-01-17 17:36:29 UTC (rev 2931)
@@ -70,7 +70,7 @@
 scm_s_srfi8_receive(ScmObj formals, ScmObj expr, ScmObj body,
                     ScmEvalState *eval_state)
 {
-    int formals_len, actuals_len;
+    scm_int_t formals_len, actuals_len;
     ScmObj env, actuals;
     DECLARE_FUNCTION("receive", syntax_variadic_tailrec_2);
 

Modified: branches/r5rs/sigscheme/src/operations.c
===================================================================
--- branches/r5rs/sigscheme/src/operations.c	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/operations.c	2006-01-17 17:36:29 UTC (rev 2931)
@@ -67,7 +67,7 @@
   File Local Function Declarations
 =======================================*/
 static int prepare_radix(const char *funcname, ScmObj args);
-static ScmObj list_tail(ScmObj lst, int k);
+static ScmObj list_tail(ScmObj lst, scm_int_t k);
 static ScmObj map_single_arg(ScmObj proc, ScmObj args);
 static ScmObj map_multiple_args(ScmObj proc, ScmObj args);
 
@@ -128,7 +128,7 @@
 {
     enum ScmObjType type;
     ScmObj elm1, elm2, *v1, *v2;
-    int i, len;
+    scm_int_t i, len;
     DECLARE_FUNCTION("equal?", procedure_fixed_2);
 
     if (EQ(obj1, obj2))
@@ -213,7 +213,7 @@
 ScmObj
 scm_p_add(ScmObj left, ScmObj right, enum ScmReductionState *state)
 {
-    int result;
+    scm_int_t result;
     DECLARE_FUNCTION("+", reduction_operator);
 
     result = 0;
@@ -239,7 +239,7 @@
 ScmObj
 scm_p_multiply(ScmObj left, ScmObj right, enum ScmReductionState *state)
 {
-    int result;
+    scm_int_t result;
     DECLARE_FUNCTION("*", reduction_operator);
 
     result = 1;
@@ -265,7 +265,7 @@
 ScmObj
 scm_p_subtract(ScmObj left, ScmObj right, enum ScmReductionState *state)
 {
-    int result;
+    scm_int_t result;
     DECLARE_FUNCTION("-", reduction_operator);
 
     result = 0;
@@ -291,7 +291,7 @@
 ScmObj
 scm_p_divide(ScmObj left, ScmObj right, enum ScmReductionState *state)
 {
-    int result;
+    scm_int_t result;
     DECLARE_FUNCTION("/", reduction_operator);
 
     result = 1;
@@ -463,7 +463,7 @@
 ScmObj
 scm_p_abs(ScmObj scm_n)
 {
-    int n;
+    scm_int_t n;
     DECLARE_FUNCTION("abs", procedure_fixed_1);
 
     ENSURE_INT(scm_n);
@@ -476,7 +476,7 @@
 ScmObj
 scm_p_quotient(ScmObj scm_n1, ScmObj scm_n2)
 {
-    int n1, n2;
+    scm_int_t n1, n2;
     DECLARE_FUNCTION("quotient", procedure_fixed_2);
 
     ENSURE_INT(scm_n1);
@@ -494,7 +494,7 @@
 ScmObj
 scm_p_modulo(ScmObj scm_n1, ScmObj scm_n2)
 {
-    int n1, n2, rem;
+    scm_int_t n1, n2, rem;
     DECLARE_FUNCTION("modulo", procedure_fixed_2);
 
     ENSURE_INT(scm_n1);
@@ -519,7 +519,7 @@
 ScmObj
 scm_p_remainder(ScmObj scm_n1, ScmObj scm_n2)
 {
-    int n1, n2;
+    scm_int_t n1, n2;
     DECLARE_FUNCTION("remainder", procedure_fixed_2);
 
     ENSURE_INT(scm_n1);
@@ -570,7 +570,8 @@
   char buf[sizeof(int) * CHAR_BIT + sizeof("")];
   char *p;
   const char *end;
-  int n, r, digit;
+  scm_int_t n, digit;
+  int r;
   scm_bool neg;
   DECLARE_FUNCTION("number->string", procedure_variadic_1);
 
@@ -597,7 +598,8 @@
 ScmObj
 scm_p_string2number(ScmObj str, ScmObj args)
 {
-    int n, r;
+    scm_int_t n;
+    int r;
     char *end;
     const char *c_str;
     scm_bool empty_strp;
@@ -630,7 +632,7 @@
 
     c_str = SCM_STRING_STR(str);
     r = prepare_radix(SCM_MANGLE(name), args);
-    n = (int)strtol(c_str, &end, r);
+    n = (scm_int_t)strtol(c_str, &end, r);
 
     empty_strp = (end == c_str);  /* apply the first rule above */
     return (empty_strp || *end) ? SCM_FALSE : MAKE_INT(n);
@@ -818,10 +820,10 @@
 #define TERMINATOR_LEN 1
 
 /* scm_length() for non-circular list */
-int
+scm_int_t
 scm_finite_length(ScmObj lst)
 {
-    int len;
+    scm_int_t len;
 
     for (len = 0; CONSP(lst); lst = CDR(lst))
         len++;
@@ -845,11 +847,11 @@
  *
  */
 /* Returns -1 as one length improper list for non-list obj. */
-int
+scm_int_t
 scm_length(ScmObj lst)
 {
     ScmObj slow;
-    int proper_len;
+    scm_int_t proper_len;
 
     for (proper_len = 0, slow = lst;;) {
         if (NULLP(lst)) break;
@@ -879,7 +881,7 @@
 ScmObj
 scm_p_length(ScmObj obj)
 {
-    int len;
+    scm_int_t len;
     DECLARE_FUNCTION("length", procedure_fixed_1);
 
     len = scm_length(obj);
@@ -927,7 +929,7 @@
 }
 
 static ScmObj
-list_tail(ScmObj lst, int k)
+list_tail(ScmObj lst, scm_int_t k)
 {
     while (k--) {
         if (!CONSP(lst))
@@ -1111,7 +1113,7 @@
 ScmObj
 scm_p_char_alphabeticp(ScmObj ch)
 {
-    int val;
+    scm_ichar_t val;
     DECLARE_FUNCTION("char-alphabetic?", procedure_fixed_1);
 
     ENSURE_CHAR(ch);
@@ -1124,7 +1126,7 @@
 ScmObj
 scm_p_char_numericp(ScmObj ch)
 {
-    int val;
+    scm_ichar_t val;
     DECLARE_FUNCTION("char-numeric?", procedure_fixed_1);
 
     ENSURE_CHAR(ch);
@@ -1137,7 +1139,7 @@
 ScmObj
 scm_p_char_whitespacep(ScmObj ch)
 {
-    int val;
+    scm_ichar_t val;
     DECLARE_FUNCTION("char-whitespace?", procedure_fixed_1);
 
     ENSURE_CHAR(ch);
@@ -1150,7 +1152,7 @@
 ScmObj
 scm_p_char_upper_casep(ScmObj ch)
 {
-    int val;
+    scm_ichar_t val;
     DECLARE_FUNCTION("char-upper-case?", procedure_fixed_1);
 
     ENSURE_CHAR(ch);
@@ -1163,7 +1165,7 @@
 ScmObj
 scm_p_char_lower_casep(ScmObj ch)
 {
-    int val;
+    scm_ichar_t val;
     DECLARE_FUNCTION("char-lower-case?", procedure_fixed_1);
 
     ENSURE_CHAR(ch);
@@ -1186,7 +1188,7 @@
 ScmObj
 scm_p_integer2char(ScmObj n)
 {
-    int val;
+    scm_int_t val;
     DECLARE_FUNCTION("integer->char", procedure_fixed_1);
 
     ENSURE_INT(n);
@@ -1205,7 +1207,7 @@
 ScmObj
 scm_p_char_upcase(ScmObj ch)
 {
-    int val;
+    scm_ichar_t val;
     DECLARE_FUNCTION("char-upcase", procedure_fixed_1);
 
     ENSURE_CHAR(ch);
@@ -1220,7 +1222,7 @@
 ScmObj
 scm_p_char_downcase(ScmObj ch)
 {
-    int val;
+    scm_ichar_t val;
     DECLARE_FUNCTION("char-downcase", procedure_fixed_1);
 
     ENSURE_CHAR(ch);
@@ -1247,7 +1249,9 @@
 scm_p_make_string(ScmObj length, ScmObj args)
 {
     ScmObj filler;
-    int filler_val, len, ch_len;
+    scm_ichar_t filler_val;
+    size_t len;
+    int ch_len;
     char *str, *dst;
 #if SCM_USE_MULTIBYTE_CHAR
     const char *next;
@@ -1286,7 +1290,7 @@
                                  SCM_MB_STATELESS);
     if (!next)
         ERR("make-string: invalid char 0x%x for encoding %s",
-            filler_val, SCM_CHARCODEC_ENCODING(scm_current_char_codec));
+            (int)filler_val, SCM_CHARCODEC_ENCODING(scm_current_char_codec));
 
     str = scm_malloc(ch_len * len + sizeof(""));
     for (dst = str; dst < &str[ch_len * len]; dst += ch_len)
@@ -1313,7 +1317,7 @@
 ScmObj
 scm_p_string_length(ScmObj str)
 {
-    int len;
+    scm_int_t len;
     DECLARE_FUNCTION("string-length", procedure_fixed_1);
 
     ENSURE_STRING(str);
@@ -1330,7 +1334,8 @@
 ScmObj
 scm_p_string_ref(ScmObj str, ScmObj k)
 {
-    int idx, ch;
+    scm_int_t idx;
+    scm_ichar_t ch;
 #if SCM_USE_MULTIBYTE_CHAR
     ScmMultibyteString mbs;
 #endif
@@ -1361,7 +1366,8 @@
 ScmObj
 scm_p_string_setd(ScmObj str, ScmObj k, ScmObj ch)
 {
-    int idx, ch_val;
+    scm_int_t idx;
+    scm_ichar_t ch_val;
     char *c_str;
 #if SCM_USE_MULTIBYTE_CHAR
     int ch_len, orig_ch_len;
@@ -1397,7 +1403,7 @@
                                    SCM_MB_STATELESS);
     if (!ch_end)
         ERR("string-set!: invalid char 0x%x for encoding %s",
-            ch_val, SCM_CHARCODEC_ENCODING(scm_current_char_codec));
+            (int)ch_val, SCM_CHARCODEC_ENCODING(scm_current_char_codec));
     ch_len = ch_end - ch_buf;
 
     /* prepare the space for new char */
@@ -1443,7 +1449,7 @@
 ScmObj
 scm_p_substring(ScmObj str, ScmObj start, ScmObj end)
 {
-    int c_start, c_end, len, sub_len;
+    scm_int_t c_start, c_end, len, sub_len;
     const char *c_str;
     char *new_str;
 #if SCM_USE_MULTIBYTE_CHAR
@@ -1497,7 +1503,8 @@
 scm_p_string_append(ScmObj args)
 {
     ScmObj rest, str;
-    size_t byte_len, mb_len;
+    size_t byte_len;
+    scm_int_t mb_len;
     char  *new_str, *dst;
     const char *src;
     DECLARE_FUNCTION("string-append", procedure_variadic_0);
@@ -1544,7 +1551,8 @@
     ScmQueue q;
 #endif
     ScmObj res;
-    int ch, mb_len;
+    scm_ichar_t ch;
+    scm_int_t mb_len;
     const char *c_str;
     DECLARE_FUNCTION("string->list", procedure_fixed_1);
 
@@ -1588,10 +1596,10 @@
 {
     ScmObj rest, ch;
     size_t str_size;
-    int len;
+    scm_int_t len;
     char *str, *dst;
 #if SCM_USE_MULTIBYTE_CHAR
-    int ch_val;
+    scm_ichar_t ch_val;
 #endif
     DECLARE_FUNCTION("list->string", procedure_fixed_1);
 
@@ -1654,7 +1662,7 @@
 ScmObj
 scm_p_string_filld(ScmObj str, ScmObj ch)
 {
-    int str_len;
+    size_t str_len;
     char *dst;
 #if SCM_USE_MULTIBYTE_CHAR
     int ch_len;
@@ -1662,7 +1670,7 @@
     char ch_str[SCM_MB_MAX_LEN + sizeof("")];
     const char *next;
 #else
-    int ch_val;
+    scm_ichar_t ch_val;
     char *c_str;
 #endif
     DECLARE_FUNCTION("string-fill!", procedure_fixed_2);
@@ -1681,7 +1689,7 @@
                                  SCM_CHAR_VALUE(ch), SCM_MB_STATELESS);
     if (!next)
         ERR("string-fill!: invalid char 0x%x for encoding %s",
-            SCM_CHAR_VALUE(ch),
+            (int)SCM_CHAR_VALUE(ch),
             SCM_CHARCODEC_ENCODING(scm_current_char_codec));
 
     /* create new str */
@@ -1718,7 +1726,7 @@
 scm_p_make_vector(ScmObj scm_len, ScmObj args)
 {
     ScmObj *vec, filler;
-    int len, i;
+    scm_int_t len, i;
     DECLARE_FUNCTION("make-vector", procedure_variadic_1);
 
     ENSURE_INT(scm_len);
@@ -1761,7 +1769,7 @@
 ScmObj
 scm_p_vector_ref(ScmObj vec, ScmObj scm_k)
 {
-    int k;
+    scm_int_t k;
     DECLARE_FUNCTION("vector-ref", procedure_fixed_2);
 
     ENSURE_VECTOR(vec);
@@ -1778,7 +1786,7 @@
 ScmObj
 scm_p_vector_setd(ScmObj vec, ScmObj scm_k, ScmObj obj)
 {
-    int k;
+    scm_int_t k;
     DECLARE_FUNCTION("vector-set!", procedure_fixed_3);
 
     ENSURE_VECTOR(vec);
@@ -1799,7 +1807,7 @@
 {
     ScmQueue q;
     ScmObj res, *v;
-    int len, i;
+    scm_int_t len, i;
     DECLARE_FUNCTION("vector->list", procedure_fixed_1);
 
     ENSURE_VECTOR(vec);
@@ -1819,7 +1827,7 @@
 scm_p_list2vector(ScmObj lst)
 {
     ScmObj *vec;
-    int len, i;
+    scm_int_t len, i;
     DECLARE_FUNCTION("list->vector", procedure_fixed_1);
 
     len = scm_length(lst);
@@ -1837,7 +1845,7 @@
 scm_p_vector_filld(ScmObj vec, ScmObj fill)
 {
     ScmObj *v;
-    int len, i;
+    scm_int_t len, i;
     DECLARE_FUNCTION("vector-fill!", procedure_fixed_2);
 
     ENSURE_VECTOR(vec);

Modified: branches/r5rs/sigscheme/src/read.c
===================================================================
--- branches/r5rs/sigscheme/src/read.c	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/read.c	2006-01-17 17:36:29 UTC (rev 2931)
@@ -59,7 +59,7 @@
   File Local Macro Declarations
 =======================================*/
 #define OK 0
-#define TOKEN_BUF_EXCEEDED -1
+#define TOKEN_BUF_EXCEEDED (-1)
 
 #define MB_MAX_SIZE (SCM_MB_MAX_LEN + sizeof(""))
 
@@ -67,7 +67,7 @@
 #define CHAR_LITERAL_LEN_MAX (sizeof("backspace") - sizeof(""))
 
 /* #b-010101... */
-#define INT_LITERAL_LEN_MAX  (sizeof("-") + sizeof(int) * CHAR_BIT - sizeof(""))
+#define INT_LITERAL_LEN_MAX SCM_INT_BITS
 
 #define WHITESPACE_CHARS " \t\n\r\v\f"
 #define DELIMITER_CHARS  "()\";" WHITESPACE_CHARS
@@ -110,16 +110,16 @@
 /*=======================================
   File Local Function Declarations
 =======================================*/
-static int    skip_comment_and_space(ScmObj port);
+static scm_ichar_t skip_comment_and_space(ScmObj port);
 static void   read_sequence(ScmObj port, char *buf, int len);
 static size_t read_token(ScmObj port, int *err,
                          char *buf, size_t buf_size, const char *delim);
 
 static ScmObj read_sexpression(ScmObj port);
-static ScmObj read_list(ScmObj port, int closeParen);
+static ScmObj read_list(ScmObj port, scm_ichar_t closeParen);
 #if SCM_USE_SRFI75
-static int    parse_unicode_sequence(const char *seq, int len);
-static int    read_unicode_sequence(ScmObj port, char prefix);
+static scm_ichar_t parse_unicode_sequence(const char *seq, int len);
+static scm_ichar_t read_unicode_sequence(ScmObj port, char prefix);
 #endif
 static ScmObj read_char(ScmObj port);
 static ScmObj read_string(ScmObj port);
@@ -169,7 +169,8 @@
 static int
 skip_comment_and_space(ScmObj port)
 {
-    int c, state;
+    scm_ichar_t c;
+    int state;
 
     for (state = LEX_ST_NORMAL;;) {
         c = scm_port_peek_char(port);
@@ -195,7 +196,7 @@
 static void
 read_sequence(ScmObj port, char *buf, int len)
 {
-    int c;
+    scm_ichar_t c;
     char *p;
 
     for (p = buf; p < &buf[len]; p++) {
@@ -214,13 +215,13 @@
            int *err, char *buf, size_t buf_size, const char *delim)
 {
     ScmCharCodec *codec;
-    int c;
+    scm_ichar_t c;
     size_t len;
     char *p;
 
     for (p = buf;;) {
         c = scm_port_peek_char(port);
-        CDBG((SCM_DBG_PARSER, "c = %c", c));
+        CDBG((SCM_DBG_PARSER, "c = %c", (int)c));
 
         if (p == buf) {
             if (c == EOF)
@@ -246,12 +247,13 @@
             }
             codec = scm_port_codec(port);
             if (SCM_CHARCODEC_CCS(codec) != SCM_CCS_UCS4)
-                ERR("non-ASCII char in token on a non-Unicode port: 0x%x", c);
+                ERR("non-ASCII char in token on a non-Unicode port: 0x%x",
+                    (int)c);
             /* canonicalize internal Unicode encoding */
             p = SCM_CHARCODEC_INT2STR(scm_identifier_codec, p, c,
                                       SCM_MB_STATELESS);
 #else
-            ERR("non-ASCII char in token: 0x%x", c);
+            ERR("non-ASCII char in token: 0x%x", (int)c);
 #endif
         }
         DISCARD_LOOKAHEAD(port);
@@ -265,14 +267,14 @@
 static ScmObj
 read_sexpression(ScmObj port)
 {
-    int c;
+    scm_ichar_t c;
 
     CDBG((SCM_DBG_PARSER, "read_sexpression"));
 
     for (;;) {
         c = skip_comment_and_space(port);
 
-        CDBG((SCM_DBG_PARSER, "read_sexpression c = %c", c));
+        CDBG((SCM_DBG_PARSER, "read_sexpression c = %c", (int)c));
 
         /* case labels are ordered by appearance rate and penalty cost */
         switch (c) {
@@ -305,7 +307,7 @@
             case EOF:
                 ERR("EOF in #");
             default:
-                ERR("Unsupported # notation: %c", c);
+                ERR("Unsupported # notation: %c", (int)c);
             }
             break;
 
@@ -349,13 +351,13 @@
 }
 
 static ScmObj
-read_list(ScmObj port, int closeParen)
+read_list(ScmObj port, scm_ichar_t closeParen)
 {
     ScmObj lst, elm, cdr;
     ScmQueue q;
     ScmBaseCharPort *basecport;
-    int start_line, cur_line;
-    int c, err;
+    scm_ichar_t c;
+    int err, start_line, cur_line;
     char dot_buf[sizeof("...")];
 
     CDBG((SCM_DBG_PARSER, "read_list"));
@@ -366,7 +368,7 @@
     for (lst = SCM_NULL, SCM_QUEUE_POINT_TO(q, lst);; SCM_QUEUE_ADD(q, elm)) {
         c = skip_comment_and_space(port);
 
-        CDBG((SCM_DBG_PARSER, "read_list c = [%c]", c));
+        CDBG((SCM_DBG_PARSER, "read_list c = [%c]", (int)c));
 
         if (c == EOF) {
             if (basecport) {
@@ -422,10 +424,10 @@
 }
 
 #if SCM_USE_SRFI75
-static int
+static scm_ichar_t
 parse_unicode_sequence(const char *seq, int len)
 {
-    int c;
+    scm_ichar_t c;
     char *end;
 
     /* reject ordinary char literal and invalid signed hexadecimal */
@@ -465,7 +467,7 @@
     return c;
 }
 
-static int
+static scm_ichar_t
 read_unicode_sequence(ScmObj port, char prefix)
 {
     int len;
@@ -487,13 +489,14 @@
 static ScmObj
 read_char(ScmObj port)
 {
-    int c, next, err;
-#if SCM_USE_SRFI75
-    int unicode;
-#endif
     const ScmSpecialCharInfo *info;
     ScmCharCodec *codec;
     size_t len;
+    scm_ichar_t c, next;
+#if SCM_USE_SRFI75
+    scm_ichar_t unicode;
+#endif
+    int err;
     char buf[CHAR_LITERAL_LEN_MAX + sizeof("")];
     DECLARE_INTERNAL_FUNCTION("read_char");
 
@@ -537,9 +540,10 @@
     ScmObj obj;
     const ScmSpecialCharInfo *info;
     ScmCharCodec *codec;
-    int c, len;
+    scm_int_t len;
+    scm_ichar_t c;
+    char *p;
     size_t offset;
-    char *p;
     ScmLBuf(char) lbuf;
     char init_buf[SCM_INITIAL_STRING_BUF_SIZE];
     DECLARE_INTERNAL_FUNCTION("read_string");
@@ -555,7 +559,7 @@
     {
         c = scm_port_get_char(port);
 
-        CDBG((SCM_DBG_PARSER, "read_string c = %c", c));
+        CDBG((SCM_DBG_PARSER, "read_string c = %c", (int)c));
 
         switch (c) {
         case EOF:
@@ -582,7 +586,7 @@
                 p = &LBUF_BUF(lbuf)[offset];
                 p = SCM_CHARCODEC_INT2STR(codec, p, c, SCM_MB_STATELESS);
                 if (!p)
-                    ERR("invalid Unicode sequence in string: 0x%x", c);
+                    ERR("invalid Unicode sequence in string: 0x%x", (int)c);
                 goto found;
             } else
 #endif
@@ -597,7 +601,7 @@
                     }
                 }
             }
-            ERR("invalid escape sequence in string: \\%c", c);
+            ERR("invalid escape sequence in string: \\%c", (int)c);
         found:
             break;
 
@@ -607,7 +611,7 @@
             /* FIXME: support stateful encoding */
             p = SCM_CHARCODEC_INT2STR(codec, p, c, SCM_MB_STATELESS);
             if (!p)
-                ERR("invalid char in string: 0x%x", c);
+                ERR("invalid char in string: 0x%x", (int)c);
             break;
         }
 #if !SCM_USE_NULL_CAPABLE_STRING
@@ -653,7 +657,8 @@
 static ScmObj
 read_number_or_symbol(ScmObj port)
 {
-    int c, err;
+    scm_ichar_t c;
+    int err;
     size_t len;
     char buf[INT_LITERAL_LEN_MAX + sizeof("")];
 
@@ -703,7 +708,8 @@
 static ScmObj
 parse_number(ScmObj port, char *buf, size_t buf_size, char prefix)
 {
-    int radix, number;
+    scm_int_t number;
+    int radix;
     char *end;
 
     switch (prefix) {
@@ -722,7 +728,7 @@
     return MAKE_INT(number);
 
  err:
-    ERR("ill-formatted number: #%c%s", prefix, buf);
+    ERR("ill-formatted number: #%c%s", (int)prefix, buf);
 }
 
 static ScmObj

Modified: branches/r5rs/sigscheme/src/sbcport.c
===================================================================
--- branches/r5rs/sigscheme/src/sbcport.c	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/sbcport.c	2006-01-17 17:36:29 UTC (rev 2931)
@@ -74,7 +74,7 @@
                                      const ScmCharPortVTbl *dst_vptr);
 static ScmCharCodec *sbcport_codec(ScmSingleByteCharPort *port);
 static char *sbcport_inspect(ScmSingleByteCharPort *port);
-static int sbcport_put_char(ScmSingleByteCharPort *port, int ch);
+static int sbcport_put_char(ScmSingleByteCharPort *port, scm_ichar_t ch);
 
 /*=======================================
   Variable Declarations
@@ -142,7 +142,7 @@
 }
 
 static int
-sbcport_put_char(ScmSingleByteCharPort *port, int ch)
+sbcport_put_char(ScmSingleByteCharPort *port, scm_ichar_t ch)
 {
     char buf[1];
 

Modified: branches/r5rs/sigscheme/src/sigscheme.h
===================================================================
--- branches/r5rs/sigscheme/src/sigscheme.h	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/sigscheme.h	2006-01-17 17:36:29 UTC (rev 2931)
@@ -166,7 +166,7 @@
 
 /* result decoders for scm_length() */
 #define SCM_LISTLEN_PROPERP(len)    (0 <= (len))
-#define SCM_LISTLEN_CIRCULARP(len)  ((len) == INT_MIN)
+#define SCM_LISTLEN_CIRCULARP(len)  ((len) == SCM_INT_T_MIN)
 #define SCM_LISTLEN_ERRORP          SCM_LISTLEN_CIRCULARP
 #define SCM_LISTLEN_DOTTEDP(len)    ((len) < 0                               \
                                      && !SCM_LISTLEN_CIRCULARP(len))
@@ -247,13 +247,28 @@
  * VALUE FOR TRUE. Use (val) or (val != scm_false) instead.
  *
  */
-#if (!defined(scm_true) && !defined(scm_false))
+#ifndef SCM_BOOL_DEFINED
 typedef int scm_bool;
 #define scm_false 0
 #define scm_true  (!scm_false)
-#endif
+#define SCM_BOOL_DEFINED
+#endif /* SCM_BOOL_DEFINED */
 
 /*
+ * 64-bit support of SigScheme
+ *
+ * SigScheme supports all data models of ILP32, ILP32 with 64-bit long long,
+ * LLP64, LP64 and ILP64. Default settings can automatically configure both ABI
+ * and the underlying storage implementation appropriately, if the storage
+ * implementation is storage-fatty or storage-compact. On the case, the integer
+ * size Scheme can handle is determined by sizeof(long), and heap capacity and
+ * addressable space are determined by the pointer size.
+ *
+ * Other storage implementations (currently not exist) may need some manual
+ * settings to fit to the specified data model.
+ */
+
+/*
  * Fixed bit width numbers
  *
  * This types define internal representation corresponding to each number
@@ -261,26 +276,35 @@
  *
  * The configuration alters both ABI and storage implementation of
  * libsscm. Although it specifies the bit width, actual width varies for each
- * substantial storage implementation. Refer SCM_INT_BITS, SCM_INT_MAX and so
+ * underlying storage implementation. Refer SCM_INT_BITS, SCM_INT_MAX and so
  * on to know such values.
  *
- * The integer type defaults to 64bit on LP64 platforms.
+ * The integer type defaults to 64-bit on LP64 platforms.
  */
 #if SCM_USE_64BIT_FIXNUM
 typedef int64_t           scm_int_t;
 typedef uint64_t          scm_uint_t;
 #define SIZEOF_SCM_INT_T  SIZEOF_INT64_T
 #define SIZEOF_SCM_UINT_T SIZEOF_INT64_T
+#define SCM_INT_T_MAX     INT64_MAX
+#define SCM_INT_T_MIN     INT64_MIN
+#define SCM_UINT_T_MAX    UINT64_MAX
 #elif SCM_USE_32BIT_FIXNUM
 typedef int32_t           scm_int_t;
 typedef uint32_t          scm_uint_t;
 #define SIZEOF_SCM_INT_T  SIZEOF_INT32_T
 #define SIZEOF_SCM_UINT_T SIZEOF_INT32_T
+#define SCM_INT_T_MAX     INT32_MAX
+#define SCM_INT_T_MIN     INT32_MIN
+#define SCM_UINT_T_MAX    UINT32_MAX
 #elif SCM_USE_INT_FIXNUM
 typedef int               scm_int_t;
 typedef unsigned int      scm_uint_t;
 #define SIZEOF_SCM_INT_T  SIZEOF_INT
 #define SIZEOF_SCM_UINT_T SIZEOF_INT
+#define SCM_INT_T_MAX     INT_MAX
+#define SCM_INT_T_MIN     INT_MIN
+#define SCM_UINT_T_MAX    UINT_MAX
 #else
 #undef  SCM_USE_LONG_FIXNUM
 #define SCM_USE_LONG_FIXNUM
@@ -288,8 +312,33 @@
 typedef unsigned long     scm_uint_t;
 #define SIZEOF_SCM_INT_T  SIZEOF_LONG
 #define SIZEOF_SCM_UINT_T SIZEOF_LONG
+#define SCM_INT_T_MAX     LONG_MAX
+#define SCM_INT_T_MIN     LONG_MIN
+#define SCM_UINT_T_MAX    ULONG_MAX
 #endif
 
+#if   (SIZEOF_SCM_INT_T == SIZEOF_INT)
+#define SCM_INT_T_FMT "%d"
+#elif (SIZEOF_SCM_INT_T == SIZEOF_LONG)
+    /* FIXME: check by autoconf */
+#define SCM_INT_T_FMT "%ld"
+#elif (SIZEOF_SCM_INT_T == SIZEOF_INT64_T && SIZEOF_INT64_T)
+    /* FIXME: check by autoconf */
+#if 1
+#define SCM_INT_T_FMT "%lld"
+#else
+#define SCM_INT_T_FMT "%qd"
+#endif
+#elif (SIZEOF_SCM_INT_T == SIZEOF_SHORT)
+    /* FIXME: check by autoconf */
+#define SCM_INT_T_FMT "%hd"
+#elif (SIZEOF_SCM_INT_T == 1)
+    /* FIXME: check by autoconf */
+#define SCM_INT_T_FMT "%hhd"
+#else
+#error "unsupported integer size for printf(3)"
+#endif
+
 /*
  * Integer representation of abstract reference to ScmObj
  *
@@ -299,10 +348,10 @@
  * A ScmRef is abstract reference to a ScmObj. It is usually a pointer, but do
  * not assume it since another representation may be used. For instance, a pair
  * of heap index and object index in the heap can be a ScmRef. In such case,
- * scm_uintref_t can address any object in a heap scattered in full 64bit
- * address space even if the bit width of the reference is smaller than a 64bit
- * pointer. So any size assumption between pointer and the reference must not
- * be coded.
+ * scm_uintref_t can address any object in a heap scattered in full 64-bit
+ * address space even if the bit width of the reference is smaller than a
+ * 64-bit pointer. So any size assumption between pointer and the reference
+ * must not be coded.
  *
  * The integer representation is intended for low-level bitwise processing. Use
  * ScmRef instead for higher-level code.
@@ -312,7 +361,7 @@
  * of reference objects. Deal with particular storage implementation if fine
  * tuning is required. Otherwise simply keep untouched.
  *
- * The type defaults to direct pointer represenation, so *LP64 gets 64bit.
+ * The type defaults to direct pointer represenation, so *LP64 gets 64-bit.
  */
 #if SCM_USE_64BIT_SCMREF
 typedef int64_t              scm_intref_t;
@@ -374,8 +423,16 @@
  * Actual bit width varies for each storage implementation. Refer
  * SCM_CHAR_BITS, SCM_CHAR_MAX and SCM_CHAR_MIN if needed.
  */
+#ifndef SCM_ICHAR_T_DEFINED
 typedef int32_t            scm_ichar_t;
 #define SIZEOF_SCM_ICHAR_T SIZEOF_INT32_T
+#define SCM_ICHAR_T_MAX    INT32_MAX
+#define SCM_ICHAR_T_MIN    INT32_MIN
+#if (EOF < SCM_ICHAR_T_MIN || SCM_ICHAR_T_MAX < EOF)
+#error "scm_ichar_t cannot represent EOF on this platform"
+#endif
+#define SCM_ICHAR_T_DEFINED
+#endif /* SCM_ICHAR_T_DEFINED */
 
 /*
  * Definitive byte type
@@ -384,8 +441,13 @@
  * (for example, ARM compilers treat 'char' as 'unsigned char'), use this type
  * for raw strings and so on.
  */
-typedef unsigned char     scm_byte_t;
-#define SIZEOF_SCM_BYTE_T 1
+#ifndef SCM_BYTE_T_DEFINED
+#define SCM_BYTE_T_DEFINED
+typedef unsigned char      scm_byte_t;
+#define SIZEOF_SCM_BYTE_T  1
+#define SCM_BYTE_T_MAX     UCHAR_MAX
+#define SCM_BYTE_T_MIN     0
+#endif /* SCM_BYTE_T_DEFINED */
 
 /*
  * Constant-width character for strings (not used yet)
@@ -414,6 +476,25 @@
 #error "size constraints of primitive types are broken"
 #endif
 
+#if   0
+    /* FIXME: check by autoconf */
+#define SCM_SIZE_T_FMT "%zu"
+#elif (SIZEOF_SIZE_T == SIZEOF_INT)
+#define SCM_SIZE_T_FMT "%u"
+#elif (SIZEOF_SCM_INT_T == SIZEOF_LONG)
+    /* FIXME: check by autoconf */
+#define SCM_SIZE_T_FMT "%lu"
+#elif (SIZEOF_SCM_INT_T == SIZEOF_INT64_T && SIZEOF_INT64_T)
+    /* FIXME: check by autoconf */
+#if 1
+#define SCM_SIZE_T_FMT "%llu"
+#else
+#define SCM_SIZE_T_FMT "%qu"
+#endif
+#else
+#error "unsupported size_t size for printf(3)"
+#endif
+
 /*=======================================
    Enums
 =======================================*/
@@ -547,8 +628,8 @@
     /* heap */
     size_t heap_size;             /* number of ScmCell in a heap */
     size_t heap_alloc_threshold;  /* minimum number of freecells after a GC */
-    int n_heaps_max;              /* max number of heaps */
-    int n_heaps_init;             /* initial number of heaps */
+    size_t n_heaps_max;           /* max number of heaps */
+    size_t n_heaps_init;          /* initial number of heaps */
 
     /* symbol table */
     size_t symbol_hash_size;      /* hash size of symbol table */
@@ -618,7 +699,7 @@
 /* SCM_MAKE_FUNC(enum ScmFuncTypeCode type, ScmFuncType func) */
 #define SCM_MAKE_FUNC(type, func)         SCM_SAL_MAKE_FUNC((type), (func))
 #define SCM_MAKE_CLOSURE(exp, env)        SCM_SAL_MAKE_CLOSURE((exp), (env))
-/* SCM_MAKE_VECTOR(ScmObj *vec, int len) */
+/* SCM_MAKE_VECTOR(ScmObj *vec, scm_int_t len) */
 #define SCM_MAKE_VECTOR(vec, len)         SCM_SAL_MAKE_VECTOR((vec), (len))
 #define SCM_MAKE_PORT(cport, flag)        SCM_SAL_MAKE_PORT((cport), (flag))
 #define SCM_MAKE_CONTINUATION()           SCM_SAL_MAKE_CONTINUATION()
@@ -1211,7 +1292,7 @@
 int scm_port_peek_char(ScmObj port);
 scm_bool scm_port_char_readyp(ScmObj port);
 int scm_port_puts(ScmObj port, const char *str);
-int scm_port_put_char(ScmObj port, int ch);
+int scm_port_put_char(ScmObj port, scm_ichar_t ch);
 int scm_port_printf(ScmObj port, const char *fmt, ...);
 int scm_port_vprintf(ScmObj port, const char *fmt, va_list args);
 int scm_port_newline(ScmObj port);

Modified: branches/r5rs/sigscheme/src/sigschemeinternal.h
===================================================================
--- branches/r5rs/sigscheme/src/sigschemeinternal.h	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/sigschemeinternal.h	2006-01-17 17:36:29 UTC (rev 2931)
@@ -53,7 +53,7 @@
 =======================================*/
 typedef struct ScmSpecialCharInfo_ ScmSpecialCharInfo;
 struct ScmSpecialCharInfo_ {
-    int code;             /* character code as ASCII/Unicode */
+    scm_ichar_t code;     /* character code as ASCII/Unicode */
     const char *esc_seq;  /* escape sequence as string */
     const char *lex_rep;  /* lexical representation as character object */
 };
@@ -370,7 +370,7 @@
 
 /* result encoders for scm_length() */
 #define SCM_LISTLEN_ENCODE_DOTTED(len)   (-(len))
-#define SCM_LISTLEN_ENCODE_CIRCULAR(len) (INT_MIN)
+#define SCM_LISTLEN_ENCODE_CIRCULAR(len) (SCM_INT_T_MIN)
 #define SCM_LISTLEN_ENCODE_ERROR         SCM_LISTLEN_ENCODE_CIRCULAR
 
 /*=======================================
@@ -401,7 +401,7 @@
         size_t size;                                                         \
         T *init_buf;                                                         \
         size_t init_size;                                                    \
-        int extended_cnt;                                                    \
+        size_t extended_cnt;                                                 \
     }
 
 ScmLBuf(void);
@@ -483,10 +483,10 @@
 
 scm_bool scm_valid_environmentp(ScmObj env);
 scm_bool scm_valid_environment_extensionp(ScmObj formals, ScmObj actuals);
-scm_bool scm_valid_environment_extension_lengthp(int formals_len,
-                                                 int actuals_len);
-int scm_validate_formals(ScmObj formals);
-int scm_validate_actuals(ScmObj actuals);
+scm_bool scm_valid_environment_extension_lengthp(scm_int_t formals_len,
+                                                 scm_int_t actuals_len);
+scm_int_t scm_validate_formals(ScmObj formals);
+scm_int_t scm_validate_actuals(ScmObj actuals);
 
 /* eval.c */
 ScmObj scm_symbol_value(ScmObj var, ScmObj env);
@@ -503,8 +503,8 @@
 void scm_init_error(void);
 
 /* operations.c */
-int scm_finite_length(ScmObj lst);
-int scm_length(ScmObj lst);
+scm_int_t scm_finite_length(ScmObj lst);
+scm_int_t scm_length(ScmObj lst);
 
 /* io.c */
 void scm_init_io(void);

Modified: branches/r5rs/sigscheme/src/storage-compact.h
===================================================================
--- branches/r5rs/sigscheme/src/storage-compact.h	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/storage-compact.h	2006-01-17 17:36:29 UTC (rev 2931)
@@ -35,6 +35,28 @@
 #define __STORAGE_COMPACT_H
 
 /*
+ * FIXME: Support 64-bit data models
+ *
+ * - fill all lacking SCM_SAL_*_{BITS,MAX,MIN}
+ * - replace casts for Scheme-level integers with scm_int_t or scm_uint_t
+ * - replace casts for internal integer chars with 'scm_ichar_t'
+ * - replace 'unsigned long' cast for pointers with 'uintptr_t'
+ * - eliminate all other 'int' to support LP64 properly
+ * - above modifications enables LLP64, LP64 and ILP64
+ * - (low priority) change ScmObj definition to the union below to support
+ *   ILP32 with 64-bit long long
+ */
+#if 0
+/* FIXME: adapt to this to support ILP32 with 64-bit long long */
+/* To allow scm_int_t broader than pointer width, ScmCell * is enclosed into
+ * the union. */
+union ScmObj_ {
+    ScmCell *cell;
+    scm_uintobj_t word;
+};
+#endif
+
+/*
  * Internal representation defined in this file MUST NOT directly touched by
  * libsscm users. Use abstract public APIs defined in sigscheme.h.
  */
@@ -696,17 +718,17 @@
 ScmObj scm_make_cons(ScmObj kar, ScmObj kdr);
 #if 1
 /* FIXME: directly create by SCM_SAL_MAKE_*() */
-ScmObj scm_make_int(int val);
-ScmObj scm_make_char(int val);
+ScmObj scm_make_int(scm_int_t val);
+ScmObj scm_make_char(scm_ichar_t val);
 #endif
 ScmObj scm_make_symbol(char *name, ScmObj val);
-ScmObj scm_make_immutable_string(char *str, int len);
-ScmObj scm_make_immutable_string_copying(const char *str, int len);
-ScmObj scm_make_string(char *str, int len);
-ScmObj scm_make_string_copying(const char *str, int len);
+ScmObj scm_make_immutable_string(char *str, scm_int_t len);
+ScmObj scm_make_immutable_string_copying(const char *str, scm_int_t len);
+ScmObj scm_make_string(char *str, scm_int_t len);
+ScmObj scm_make_string_copying(const char *str, scm_int_t len);
 ScmObj scm_make_func(enum ScmFuncTypeCode type, ScmFuncType func);
 ScmObj scm_make_closure(ScmObj exp, ScmObj env);
-ScmObj scm_make_vector(ScmObj *vec, int len);
+ScmObj scm_make_vector(ScmObj *vec, scm_int_t len);
 ScmObj scm_make_port(ScmCharPort *cport, enum ScmPortFlag flag);
 ScmObj scm_make_continuation(void);
 #if !SCM_USE_VALUECONS

Modified: branches/r5rs/sigscheme/src/storage-fatty.h
===================================================================
--- branches/r5rs/sigscheme/src/storage-fatty.h	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/storage-fatty.h	2006-01-17 17:36:29 UTC (rev 2931)
@@ -39,6 +39,21 @@
  * libsscm users. Use abstract public APIs defined in sigscheme.h.
  */
 
+/*
+ * storage-fatty.h: An storage implementation with fatty represenation
+ *
+ * This is the most simple storage implementation for SigScheme. The features
+ * are below.
+ *
+ * - Supports all data models of ILP32, ILP32 with 64-bit long long, LLP64,
+ *   LP64 and ILP64
+ * - Consumes larger memory space (twice of storage-compact)
+ * - Can hold full-width integer
+ * - Easy to read and recognize
+ * - Easy to debug upper layer of SigScheme and its clients
+ * - Easy to extend and test experimental features
+ */
+
 /*=======================================
    System Include
 =======================================*/
@@ -50,24 +65,41 @@
 =======================================*/
 
 /*=======================================
-   Type Declarations
+   Type Definitions
 =======================================*/
+/* Since this storage implementation does not have any immediate values,
+ * (sizeof(ScmObj) == sizeof(ScmCell *)) is ensured even if sizeof(scm_int_t)
+ * is larger than sizeof(ScmObj). */
 typedef struct ScmCell_ ScmCell;
 typedef ScmCell *ScmObj;
 typedef ScmObj *ScmRef;
 
 typedef ScmObj (*ScmFuncType)();
 
-/*=======================================
-   Struct Declarations
-=======================================*/
 struct ScmCell_ {
-    enum ScmObjType type;
-    int gcmark;
+    union {
+        struct {
+            enum ScmObjType type;
+            scm_bool gcmark;
+        } v;
 
+        /* to align against 64-bit primitives */
+        struct {
+            scm_uintobj_t slot0;
+            scm_uintobj_t slot1;
+        } strut;
+    } attr;
+
+    /*
+     * Pointer members should be placed first for efficient alignment when
+     * strict alignment is not forced by the compiler/processor. (e.g. A 64-bit
+     * pointer placed on a 32-bit aligned address on amd64 with gcc -Os. The
+     * arch does not cause error even if a data is not aligned although it
+     * affects performence)
+     */
     union {
         struct {
-            int value;
+            scm_int_t value;
         } integer;
 
         struct {
@@ -81,17 +113,17 @@
         } symbol;
 
         struct {
-            int value;
+            scm_ichar_t value;
         } character;
 
         struct {
             char *str;
-            int len;  /* number of (multibyte) chars */
+            scm_int_t len;  /* number of (multibyte) chars */
         } string;
 
         struct {
+            ScmFuncType ptr;
             enum ScmFuncTypeCode type;
-            ScmFuncType ptr;
         } function;
 
         struct {
@@ -101,17 +133,17 @@
 
         struct {
             ScmObj *vec;
-            int len;
+            scm_int_t len;
         } vector;
 
         struct {
+            ScmCharPort *impl;
             enum ScmPortFlag flag;
-            ScmCharPort *impl;
         } port;
 
         struct {
             void *opaque;
-            int tag;
+            scm_int_t tag;
         } continuation;
 
 #if !SCM_USE_VALUECONS
@@ -127,6 +159,12 @@
         struct {
             ScmCFunc value;
         } c_func_pointer;
+
+        /* to align against 64-bit primitives */
+        struct {
+            scm_uintobj_t slot2;
+            scm_uintobj_t slot3;
+        } strut;
     } obj;
 };
 
@@ -150,12 +188,12 @@
 
 #define SCM_SAL_PTR_BITS    (sizeof(void *) * CHAR_BIT)
 
-#define SCM_SAL_CHAR_BITS   SCM_INT_BITS
-#define SCM_SAL_CHAR_MAX    SCM_INT_MAX
+#define SCM_SAL_CHAR_BITS   (sizeof(scm_ichar_t) * CHAR_BIT)
+#define SCM_SAL_CHAR_MAX    SCM_ICHAR_T_MAX
 
-#define SCM_SAL_INT_BITS    (sizeof(int) * CHAR_BIT)
-#define SCM_SAL_INT_MAX     INT_MAX
-#define SCM_SAL_INT_MIN     INT_MIN
+#define SCM_SAL_INT_BITS    (sizeof(scm_int_t) * CHAR_BIT)
+#define SCM_SAL_INT_MAX     SCM_INT_T_MAX
+#define SCM_SAL_INT_MIN     SCM_INT_T_MIN
 
 /* string length */
 #define SCM_SAL_STRLEN_BITS SCM_INT_BITS
@@ -195,16 +233,16 @@
 /* Don't use these functions directly. Use SCM_MAKE_*() or MAKE_*() instead to
  * allow flexible object allocation. */
 ScmObj scm_make_cons(ScmObj kar, ScmObj kdr);
-ScmObj scm_make_int(int val);
+ScmObj scm_make_int(scm_int_t val);
 ScmObj scm_make_symbol(char *name, ScmObj val);
-ScmObj scm_make_char(int val);
-ScmObj scm_make_immutable_string(char *str, int len);
-ScmObj scm_make_immutable_string_copying(const char *str, int len);
-ScmObj scm_make_string(char *str, int len);
-ScmObj scm_make_string_copying(const char *str, int len);
+ScmObj scm_make_char(scm_ichar_t val);
+ScmObj scm_make_immutable_string(char *str, scm_int_t len);
+ScmObj scm_make_immutable_string_copying(const char *str, scm_int_t len);
+ScmObj scm_make_string(char *str, scm_int_t len);
+ScmObj scm_make_string_copying(const char *str, scm_int_t len);
 ScmObj scm_make_func(enum ScmFuncTypeCode type, ScmFuncType func);
 ScmObj scm_make_closure(ScmObj exp, ScmObj env);
-ScmObj scm_make_vector(ScmObj *vec, int len);
+ScmObj scm_make_vector(ScmObj *vec, scm_int_t len);
 ScmObj scm_make_port(ScmCharPort *cport, enum ScmPortFlag flag);
 ScmObj scm_make_continuation(void);
 #if !SCM_USE_VALUECONS
@@ -219,8 +257,8 @@
    Accessors For Scheme Objects
 =======================================*/
 /* ScmObj Global Attribute */
-#define SCM_SAL_TYPE(o)        ((o)->type)
-#define SCM_ENTYPE(o, objtype) ((o)->type = (objtype))
+#define SCM_SAL_TYPE(o)        ((o)->attr.v.type)
+#define SCM_ENTYPE(o, objtype) ((o)->attr.v.type = (objtype))
 
 /* Real Accessors */
 #define SCM_SAL_NUMBERP(o)             SCM_SAL_INTP(o)
@@ -268,7 +306,7 @@
  * - tagged pointer approach prevents leak detection
  * - tagged pointer approach brings alignment restriction
  */
-#define SCM_INT_MSB                    (~((unsigned)-1 >> 1))
+#define SCM_INT_MSB                    (~((scm_uint_t)-1 >> 1))
 #define SCM_STRING_MUTABILITY_MASK     SCM_INT_MSB
 #define SCM_STRING_MUTABLE             SCM_INT_MSB
 #define SCM_SAL_STRINGP(o)             (SCM_TYPE(o) == ScmString)
@@ -277,19 +315,21 @@
 #define SCM_SAL_STRING_SET_STR(o, val)                                       \
     (SCM_AS_STRING(o)->obj.string.str = (val))
 #define SCM_SAL_STRING_LEN(o)                                                \
-    ((int)(SCM_AS_STRING(o)->obj.string.len & ~SCM_STRING_MUTABILITY_MASK))
+    ((scm_int_t)(SCM_AS_STRING(o)->obj.string.len                            \
+                 & ~SCM_STRING_MUTABILITY_MASK))
 #define SCM_SAL_STRING_SET_LEN(o, _len)                                      \
     (SCM_AS_STRING(o)->obj.string.len                                        \
-     = (_len) | (int)(SCM_AS_STRING(o)->obj.string.len                       \
-                      & SCM_STRING_MUTABILITY_MASK))
+     = (_len) | (scm_int_t)(SCM_AS_STRING(o)->obj.string.len                 \
+                            & SCM_STRING_MUTABILITY_MASK))
 #define SCM_SAL_STRING_MUTABLEP(o)                                           \
     (SCM_AS_STRING(o)->obj.string.len < 0)
 #define SCM_SAL_STRING_SET_MUTABLE(o)                                        \
     (SCM_AS_STRING(o)->obj.string.len                                        \
-     = (int)(SCM_AS_STRING(o)->obj.string.len | SCM_STRING_MUTABLE))
+     = (scm_int_t)(SCM_AS_STRING(o)->obj.string.len | SCM_STRING_MUTABLE))
 #define SCM_SAL_STRING_SET_IMMUTABLE(o)                                      \
     (SCM_AS_STRING(o)->obj.string.len                                        \
-     = (int)(SCM_AS_STRING(o)->obj.string.len & ~SCM_STRING_MUTABILITY_MASK))
+     = (scm_int_t)(SCM_AS_STRING(o)->obj.string.len                          \
+                   & ~SCM_STRING_MUTABILITY_MASK))
 
 #define SCM_SAL_FUNCP(o)                   (SCM_TYPE(o) == ScmFunc)
 #define SCM_SAL_ENTYPE_FUNC(o)             (SCM_ENTYPE((o), ScmFunc))
@@ -391,10 +431,10 @@
         SCM_FREECELL_CLEAR_FREESLOT(cell);                                   \
     } while (/* CONSTCOND */ 0)
 
-#define SCM_SAL_IS_MARKED(o)   ((o)->gcmark)
+#define SCM_SAL_IS_MARKED(o)   ((o)->attr.v.gcmark)
 #define SCM_SAL_IS_UNMARKED(o) (!SCM_IS_MARKED(o))
-#define SCM_SAL_DO_MARK(o)     ((o)->gcmark = 1)
-#define SCM_SAL_DO_UNMARK(o)   ((o)->gcmark = 0)
+#define SCM_SAL_DO_MARK(o)     ((o)->attr.v.gcmark = scm_true)
+#define SCM_SAL_DO_UNMARK(o)   ((o)->attr.v.gcmark = scm_false)
 
 /*============================================================================
   Environment Specifiers

Modified: branches/r5rs/sigscheme/src/storage-gc.c
===================================================================
--- branches/r5rs/sigscheme/src/storage-gc.c	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/storage-gc.c	2006-01-17 17:36:29 UTC (rev 2931)
@@ -56,6 +56,7 @@
 /*=======================================
   System Include
 =======================================*/
+#include <stddef.h>
 #include <stdint.h> /* FIXME: make C99-independent */
 #include <string.h>
 #include <stdlib.h>
@@ -75,12 +76,14 @@
 /*=======================================
   File Local Macro Declarations
 =======================================*/
+#define N_REGS_IN_JMP_BUF    (sizeof(jmp_buf) / sizeof(void *))
+#define SCMOBJ_ALIGNEDP(ptr) (!((uintptr_t)(ptr) % sizeof(ScmObj)))
 
 /*=======================================
   Variable Declarations
 =======================================*/
 static size_t heap_size, heap_alloc_threshold;
-static int n_heaps, n_heaps_max;
+static size_t n_heaps, n_heaps_max;
 static ScmObjHeap *heaps;
 static ScmCell *heaps_lowest, *heaps_highest;
 static ScmObj freelist;
@@ -242,6 +245,8 @@
     if (!stack_start_pointer)
         stack_start_pointer = designated_stack_start;
 
+    SCM_ASSERT(SCMOBJ_ALIGNEDP(stack_start_pointer));
+
     /* may intentionally be an invalidated local address */
     return designated_stack_start;
 }
@@ -269,7 +274,7 @@
 static void
 initialize_heap(const ScmStorageConf *conf)
 {
-    int i;
+    size_t i;
 
     heap_size            = conf->heap_size;
     heap_alloc_threshold = conf->heap_alloc_threshold;
@@ -313,7 +318,7 @@
 static void
 finalize_heap(void)
 {
-    int i;
+    size_t i;
     ScmCell *cell;
     ScmObjHeap heap;
 
@@ -346,8 +351,8 @@
 static void
 mark_obj(ScmObj obj)
 {
-    int i = 0;
-    unsigned int tag;
+    scm_int_t i;
+    scm_uintobj_t tag;
 
 mark_loop:
     /* no need to mark immediates */
@@ -396,7 +401,7 @@
 static void
 mark_obj(ScmObj obj)
 {
-    int i = 0;
+    scm_int_t i;
 
 mark_loop:
     /* no need to mark constants */
@@ -459,7 +464,7 @@
 within_heapp(ScmObj obj)
 {
     ScmCell *heap, *ptr;
-    int i;
+    size_t i;
 
 #if SCM_OBJ_COMPACT
     if (!SCM_CANBE_MARKED(obj))
@@ -516,6 +521,8 @@
 {
     ScmObj *objp;
 
+    SCM_ASSERT(SCMOBJ_ALIGNEDP(start));
+
     for (objp = start; objp < &start[n]; objp++) {
         if (within_heapp(*objp))
             mark_obj(*objp);
@@ -527,6 +534,8 @@
 {
     ScmObj *objp;
 
+    SCM_ASSERT(SCMOBJ_ALIGNEDP(start));
+
     for (objp = start; objp < &start[n]; objp++)
         mark_obj(*objp);
 }
@@ -534,9 +543,11 @@
 static void
 gc_mark_locations(ScmObj *start, ScmObj *end)
 {
-    int size;
+    ptrdiff_t size;
     ScmObj *tmp;
 
+    SCM_ASSERT(SCMOBJ_ALIGNEDP(end));
+
     /* swap end and start if (end < start) */
     if (end < start) {
         tmp = end;
@@ -546,7 +557,8 @@
 
     size = end - start;
 
-    CDBG((SCM_DBG_GC, "gc_mark_locations: size = %d", size));
+    CDBG((SCM_DBG_GC, "gc_mark_locations: size = " SCM_SIZE_T_FMT,
+          (size_t)size));
 
     gc_mark_locations_n(start, size);
 }
@@ -559,10 +571,9 @@
 gc_mark(void)
 {
     ScmObj stack_end;
-    void *save_regs_buf_end = (char *)save_regs_buf + sizeof(save_regs_buf);
 
     setjmp(save_regs_buf);
-    gc_mark_locations((ScmObj *)save_regs_buf, (ScmObj *)save_regs_buf_end);
+    gc_mark_locations_n((ScmObj *)save_regs_buf, N_REGS_IN_JMP_BUF);
     gc_mark_locations(stack_start_pointer, &stack_end);
 
     /* performed after above two because of cache pollution */
@@ -651,8 +662,7 @@
 static size_t
 gc_sweep(void)
 {
-    int i;
-    size_t sum_collected, n_collected;
+    size_t i, sum_collected, n_collected;
     ScmObjHeap heap;
     ScmCell *cell;
     ScmObj obj, new_freelist;
@@ -679,7 +689,8 @@
         }
 
         sum_collected += n_collected;
-        CDBG((SCM_DBG_GC, "heap[%d] swept = %d", i, n_collected));
+        CDBG((SCM_DBG_GC, "heap[" SCM_SIZE_T_FMT "] swept = " SCM_SIZE_T_FMT,
+              i, n_collected));
     }
     freelist = new_freelist;
 

Modified: branches/r5rs/sigscheme/src/storage-symbol.c
===================================================================
--- branches/r5rs/sigscheme/src/storage-symbol.c	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/storage-symbol.c	2006-01-17 17:36:29 UTC (rev 2931)
@@ -34,6 +34,7 @@
 /*=======================================
   System Include
 =======================================*/
+#include <stdint.h> /* FIXME: make C99-independent */
 #include <string.h>
 #include <stdlib.h>
 
@@ -62,7 +63,7 @@
 =======================================*/
 static void initialize_symbol_hash(const ScmStorageConf *conf);
 static void finalize_symbol_hash(void);
-static int  symbol_name_hash(const char *name);
+static uint32_t symbol_name_hash(const char *name);
 
 /*=======================================
   Function Implementations
@@ -71,7 +72,7 @@
 scm_intern(const char *name)
 {
     ScmObj sym, lst, rest;
-    int hash;
+    uint32_t hash;
     DECLARE_INTERNAL_FUNCTION("scm_intern");
 
 #if (SCM_USE_SRFI75 && SCM_STRICT_ARGCHECK)
@@ -151,12 +152,12 @@
     free(scm_symbol_hash);
 }
 
-static int
+static uint32_t
 symbol_name_hash(const char *name)
 {
-    int hash, c;
+    uint32_t hash, c;
 
-    for (hash = 0; (c = *name); name++)
+    for (hash = 0; (c = *(const scm_byte_t *)name); name++)
         hash = ((hash * 17) ^ c) % scm_symbol_hash_size;
 
     return hash;

Modified: branches/r5rs/sigscheme/src/storage.c
===================================================================
--- branches/r5rs/sigscheme/src/storage.c	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/storage.c	2006-01-17 17:36:29 UTC (rev 2931)
@@ -91,7 +91,7 @@
   File Local Function Declarations
 =======================================*/
 static void initialize_special_constants(void);
-static ScmObj scm_make_string_internal(char *str, int len,
+static ScmObj scm_make_string_internal(char *str, scm_int_t len,
                                        scm_bool is_immutable);
 
 /*=======================================
@@ -170,7 +170,7 @@
 }
 
 ScmObj
-scm_make_int(int val)
+scm_make_int(scm_int_t val)
 {
     ScmObj obj;
 
@@ -197,7 +197,7 @@
 }
 
 ScmObj
-scm_make_char(int val)
+scm_make_char(scm_ichar_t val)
 {
     ScmObj obj;
 
@@ -211,7 +211,7 @@
 }
 
 static ScmObj
-scm_make_string_internal(char *str, int len, scm_bool is_immutable)
+scm_make_string_internal(char *str, scm_int_t len, scm_bool is_immutable)
 {
     ScmObj obj;
 
@@ -234,25 +234,25 @@
 }
 
 ScmObj
-scm_make_immutable_string(char *str, int len)
+scm_make_immutable_string(char *str, scm_int_t len)
 {
     return scm_make_string_internal(str, len, scm_true);
 }
 
 ScmObj
-scm_make_immutable_string_copying(const char *str, int len)
+scm_make_immutable_string_copying(const char *str, scm_int_t len)
 {
     return scm_make_string_internal(scm_strdup(str), len, scm_true);
 }
 
 ScmObj
-scm_make_string(char *str, int len)
+scm_make_string(char *str, scm_int_t len)
 {
     return scm_make_string_internal(str, len, scm_false);
 }
 
 ScmObj
-scm_make_string_copying(const char *str, int len)
+scm_make_string_copying(const char *str, scm_int_t len)
 {
     return scm_make_string_internal(scm_strdup(str), len, scm_false);
 }
@@ -284,7 +284,7 @@
 }
 
 ScmObj
-scm_make_vector(ScmObj *vec, int len)
+scm_make_vector(ScmObj *vec, scm_int_t len)
 {
     ScmObj obj;
 
@@ -372,7 +372,7 @@
 enum ScmObjType
 scm_type(ScmObj obj)
 {
-    unsigned int tag = SCM_TAG(obj);
+    scm_uintobj_t tag = SCM_TAG(obj);
     switch (tag) {
     case SCM_TAG_CONS:
         return ScmCons;

Modified: branches/r5rs/sigscheme/src/strport.c
===================================================================
--- branches/r5rs/sigscheme/src/strport.c	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/strport.c	2006-01-17 17:36:29 UTC (rev 2931)
@@ -97,8 +97,8 @@
                                       const ScmBytePortVTbl *dest_vptr);
 static int istrport_close(ScmInputStrPort *port);
 static char *istrport_inspect(ScmInputStrPort *port);
-static int istrport_get_byte(ScmInputStrPort *port);
-static int istrport_peek_byte(ScmInputStrPort *port);
+static scm_ichar_t istrport_get_byte(ScmInputStrPort *port);
+static scm_ichar_t istrport_peek_byte(ScmInputStrPort *port);
 static scm_bool istrport_byte_readyp(ScmInputStrPort *port);
 static int istrport_vprintf(ScmInputStrPort *port,
                             const char *str, va_list args);
@@ -111,8 +111,8 @@
                                       const ScmBytePortVTbl *dest_vptr);
 static int ostrport_close(ScmOutputStrPort *port);
 static char *ostrport_inspect(ScmOutputStrPort *port);
-static int ostrport_get_byte(ScmOutputStrPort *port);
-static int ostrport_peek_byte(ScmOutputStrPort *port);
+static scm_ichar_t ostrport_get_byte(ScmOutputStrPort *port);
+static scm_ichar_t ostrport_peek_byte(ScmOutputStrPort *port);
 static scm_bool ostrport_byte_readyp(ScmOutputStrPort *port);
 static int ostrport_vprintf(ScmOutputStrPort *port,
                             const char *str, va_list args);
@@ -241,13 +241,13 @@
     return scm_strdup("string");
 }
 
-static int
+static scm_ichar_t
 istrport_get_byte(ScmInputStrPort *port)
 {
     return (*port->cur) ? *port->cur++ : EOF;
 }
 
-static int
+static scm_ichar_t
 istrport_peek_byte(ScmInputStrPort *port)
 {
     return (*port->cur) ? *port->cur : EOF;
@@ -361,14 +361,14 @@
     return scm_strdup("string");
 }
 
-static int
+static scm_ichar_t
 ostrport_get_byte(ScmOutputStrPort *port)
 {
     SCM_PORT_ERROR_INVALID_OPERATION(BYTE, port, ScmOutputStrPort);
     /* NOTREACHED */
 }
 
-static int
+static scm_ichar_t
 ostrport_peek_byte(ScmOutputStrPort *port)
 {
     SCM_PORT_ERROR_INVALID_OPERATION(BYTE, port, ScmOutputStrPort);

Modified: branches/r5rs/sigscheme/src/syntax.c
===================================================================
--- branches/r5rs/sigscheme/src/syntax.c	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/syntax.c	2006-01-17 17:36:29 UTC (rev 2931)
@@ -70,7 +70,7 @@
 
 /* Quasiquotation. */
 typedef struct _qquote_result qquote_result;
-static qquote_result qquote_internal(ScmObj input, ScmObj env, int nest);
+static qquote_result qquote_internal(ScmObj input, ScmObj env, scm_int_t nest);
 
 /*=======================================
   Function Implementations
@@ -178,8 +178,8 @@
     ScmObj src;
     ScmObj diff;
     ScmQueue q;                 /* Points to diff. */
-    int index;                  /* Current position. */
-    int growth;
+    scm_int_t index;            /* Current position. */
+    scm_int_t growth;
 };
 
 struct _sequence_translator {
@@ -289,8 +289,8 @@
 static ScmObj
 vectran(sequence_translator *t, tr_msg msg, ScmObj obj)
 {
-    int splice_len;
-    int change_index;
+    scm_int_t splice_len;
+    scm_int_t change_index;
     DECLARE_INTERNAL_FUNCTION("vectran");
 
     switch (msg) {
@@ -329,7 +329,7 @@
             ScmObj *src_buf;
             ScmObj tmp;
             ScmObj diff;
-            int src_len, i, cpi;
+            scm_int_t src_len, i, cpi;
 
             src_len = SCM_VECTOR_LEN(t->u.vec.src);
             src_buf = SCM_VECTOR_VEC(t->u.vec.src);
@@ -1102,7 +1102,7 @@
  * @see qquote_vector()
  */
 static qquote_result
-qquote_internal(ScmObj input, ScmObj env, int nest)
+qquote_internal(ScmObj input, ScmObj env, scm_int_t nest)
 {
     ScmObj obj;
     sequence_translator tr;

Modified: branches/r5rs/sigscheme/src/write.c
===================================================================
--- branches/r5rs/sigscheme/src/write.c	2006-01-15 15:54:39 UTC (rev 2930)
+++ branches/r5rs/sigscheme/src/write.c	2006-01-17 17:36:29 UTC (rev 2931)
@@ -48,7 +48,7 @@
   File Local Struct Declarations
 =======================================*/
 enum OutputType {
-    AS_WRITE,   /* string is enclosed by ", char is written using #\ notation. */
+    AS_WRITE,   /* string is enclosed by ", char is written using #\ notation */
     AS_DISPLAY, /* string and char is written as-is */
     UNKNOWN
 };
@@ -184,7 +184,7 @@
 #endif
     switch (SCM_TYPE(obj)) {
     case ScmInt:
-        scm_port_printf(port, "%d", SCM_INT_VALUE(obj));
+        scm_port_printf(port, SCM_INT_T_FMT, SCM_INT_VALUE(obj));
         break;
     case ScmCons:
         if (ERROBJP(obj))
@@ -244,7 +244,7 @@
         break;
     case ScmCFuncPointer:
         scm_port_printf(port, "#<c_func_pointer %p>",
-                          (void *)(uintptr_t)SCM_C_FUNCPOINTER_VALUE(obj));
+                        (void *)(uintptr_t)SCM_C_FUNCPOINTER_VALUE(obj));
         break;
     default:
         SCM_ASSERT(scm_false);
@@ -255,7 +255,7 @@
 write_char(ScmObj port, ScmObj obj, enum OutputType otype)
 {
     const ScmSpecialCharInfo *info;
-    int c;
+    scm_ichar_t c;
 
     c = SCM_CHAR_VALUE(obj);
     switch (otype) {
@@ -271,7 +271,7 @@
 
         /* other control chars are printed in hexadecimal form */
         if (isascii(c) && iscntrl(c)) {
-            scm_port_printf(port, "x%02x", c);
+            scm_port_printf(port, "x%02x", (int)c);
             return;
         }
         /* FALLTHROUGH */
@@ -292,7 +292,8 @@
     ScmMultibyteString mbs;
     const ScmSpecialCharInfo *info;
     const char *str;
-    int len, c;
+    size_t len;
+    scm_ichar_t c;
     DECLARE_INTERNAL_FUNCTION("write_string");
 
     str = SCM_STRING_STR(obj);
@@ -341,7 +342,8 @@
 {
     ScmObj car;
 #if SCM_USE_SRFI38
-    int index, necessary_close_parens;
+    size_t necessary_close_parens;
+    int index;
 
     necessary_close_parens = 1;
   cheap_recursion:
@@ -399,7 +401,7 @@
 write_vector(ScmObj port, ScmObj vec, enum OutputType otype)
 {
     ScmObj *v;
-    int len, i;
+    scm_int_t len, i;
 
     scm_port_puts(port, "#(");
 



More information about the uim-commit mailing list