mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* st.c (st_numcmp, st_numhash): use st_data_t instead of long, because
the former may be larger than the latter. * include/ruby/st.h (CHAR_BIT): get rid of magic number. * include/ruby/st.h (struct st_table): num_entries never exceed num_bins. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b39e00d39d
commit
d4cbf95002
4 changed files with 54 additions and 31 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
Sat Sep 1 11:14:38 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* st.c (st_numcmp, st_numhash): use st_data_t instead of long, because
|
||||
the former may be larger than the latter.
|
||||
|
||||
* include/ruby/st.h (CHAR_BIT): get rid of magic number.
|
||||
|
||||
* include/ruby/st.h (struct st_table): num_entries never exceed
|
||||
num_bins.
|
||||
|
||||
Fri Aug 31 07:12:24 2007 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* numeric.c (SQRT_LONG_MAX): use SIZEOF_LONG instead of SIZEOF_VALUE
|
||||
|
|
|
@ -17,31 +17,17 @@ typedef unsigned long st_data_t;
|
|||
#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
|
||||
typedef unsigned LONG_LONG st_data_t;
|
||||
#else
|
||||
# error ---->> st.c requires sizeof(void*) == sizeof(long) to be compiled. <<---
|
||||
-
|
||||
# error ---->> st.c requires sizeof(void*) == sizeof(long) to be compiled. <<----
|
||||
#endif
|
||||
#define ST_DATA_T_DEFINED
|
||||
|
||||
typedef struct st_table st_table;
|
||||
|
||||
struct st_hash_type {
|
||||
int (*compare)();
|
||||
int (*hash)();
|
||||
};
|
||||
|
||||
struct st_table {
|
||||
const struct st_hash_type *type;
|
||||
unsigned int entries_packed : 1;
|
||||
int num_bins : sizeof(int) * 8 - 1;
|
||||
int num_entries;
|
||||
struct st_table_entry **bins;
|
||||
struct st_table_entry *head;
|
||||
};
|
||||
|
||||
#define st_is_member(table,key) st_lookup(table,key,(st_data_t *)0)
|
||||
|
||||
enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE, ST_CHECK};
|
||||
|
||||
#ifndef CHAR_BIT
|
||||
# ifdef HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
# else
|
||||
# define CHAR_BIT 8
|
||||
# endif
|
||||
#endif
|
||||
#ifndef _
|
||||
# define _(args) args
|
||||
#endif
|
||||
|
@ -53,6 +39,33 @@ enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE, ST_CHECK};
|
|||
# endif
|
||||
#endif
|
||||
|
||||
typedef struct st_table st_table;
|
||||
|
||||
typedef int st_compare_func(st_data_t, st_data_t);
|
||||
typedef int st_hash_func(st_data_t);
|
||||
|
||||
struct st_hash_type {
|
||||
int (*compare)(ANYARGS /*st_data_t, st_data_t*/); /* st_compare_func* */
|
||||
int (*hash)(ANYARGS /*st_data_t*/); /* st_hash_func* */
|
||||
};
|
||||
|
||||
typedef unsigned int st_index_t;
|
||||
#define ST_INDEX_BITS (sizeof(st_index_t) * CHAR_BIT - 1)
|
||||
|
||||
struct st_table {
|
||||
const struct st_hash_type *type;
|
||||
unsigned int entries_packed : 1;
|
||||
st_index_t num_bins : ST_INDEX_BITS;
|
||||
unsigned int st_dummy_bit : 1;
|
||||
st_index_t num_entries : ST_INDEX_BITS;
|
||||
struct st_table_entry **bins;
|
||||
struct st_table_entry *head;
|
||||
};
|
||||
|
||||
#define st_is_member(table,key) st_lookup(table,key,(st_data_t *)0)
|
||||
|
||||
enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE, ST_CHECK};
|
||||
|
||||
st_table *st_init_table(const struct st_hash_type *);
|
||||
st_table *st_init_table_with_size(const struct st_hash_type *, int);
|
||||
st_table *st_init_numtable(void);
|
||||
|
@ -70,8 +83,8 @@ void st_free_table(st_table *);
|
|||
void st_cleanup_safe(st_table *, st_data_t);
|
||||
void st_clear(st_table *);
|
||||
st_table *st_copy(st_table *);
|
||||
int st_numcmp(long, long);
|
||||
int st_numhash(long);
|
||||
int st_numcmp(st_data_t, st_data_t);
|
||||
int st_numhash(st_data_t);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#if 0
|
||||
|
|
6
st.c
6
st.c
|
@ -815,13 +815,13 @@ strhash(register const char *string)
|
|||
}
|
||||
|
||||
int
|
||||
st_numcmp(long x, long y)
|
||||
st_numcmp(st_data_t x, st_data_t y)
|
||||
{
|
||||
return x != y;
|
||||
}
|
||||
|
||||
int
|
||||
st_numhash(long n)
|
||||
st_numhash(st_data_t n)
|
||||
{
|
||||
return n;
|
||||
return (int)n;
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
#define RUBY_VERSION "1.9.0"
|
||||
#define RUBY_RELEASE_DATE "2007-08-31"
|
||||
#define RUBY_RELEASE_DATE "2007-09-01"
|
||||
#define RUBY_VERSION_CODE 190
|
||||
#define RUBY_RELEASE_CODE 20070831
|
||||
#define RUBY_RELEASE_CODE 20070901
|
||||
#define RUBY_PATCHLEVEL 0
|
||||
|
||||
#define RUBY_VERSION_MAJOR 1
|
||||
#define RUBY_VERSION_MINOR 9
|
||||
#define RUBY_VERSION_TEENY 0
|
||||
#define RUBY_RELEASE_YEAR 2007
|
||||
#define RUBY_RELEASE_MONTH 8
|
||||
#define RUBY_RELEASE_DAY 31
|
||||
#define RUBY_RELEASE_MONTH 9
|
||||
#define RUBY_RELEASE_DAY 1
|
||||
|
||||
#ifdef RUBY_EXTERN
|
||||
RUBY_EXTERN const char ruby_version[];
|
||||
|
|
Loading…
Reference in a new issue