source: EcnlProtoTool/trunk/onigmo-6.1.3/src/st.h@ 331

Last change on this file since 331 was 331, checked in by coas-nagasima, 6 years ago

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 5.4 KB
Line 
1/* This is a public domain general purpose hash table package
2 originally written by Peter Moore @ UCB.
3
4 The hash table data strutures were redesigned and the package was
5 rewritten by Vladimir Makarov <vmakarov@redhat.com>. */
6
7#ifndef RUBY_ST_H
8#define RUBY_ST_H 1
9
10#if defined(__cplusplus)
11extern "C" {
12#if 0
13} /* satisfy cc-mode */
14#endif
15#endif
16
17#ifdef RUBY
18#include "ruby/defines.h"
19#else /* RUBY */
20#ifndef RUBY_SYMBOL_EXPORT_BEGIN
21#define RUBY_SYMBOL_EXPORT_BEGIN
22#define RUBY_SYMBOL_EXPORT_END
23#endif
24#endif /* RUBY */
25
26RUBY_SYMBOL_EXPORT_BEGIN
27
28#if SIZEOF_LONG == SIZEOF_VOIDP
29typedef unsigned long st_data_t;
30#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
31typedef unsigned LONG_LONG st_data_t;
32#else
33# error ---->> st.c requires sizeof(void*) == sizeof(long) or sizeof(LONG_LONG) to be compiled. <<----
34#endif
35#define ST_DATA_T_DEFINED
36
37#ifndef CHAR_BIT
38# ifdef HAVE_LIMITS_H
39# include <limits.h>
40# else
41# define CHAR_BIT 8
42# endif
43#endif
44#ifndef _
45# define _(args) args
46#endif
47#ifndef ANYARGS
48# ifdef __cplusplus
49# define ANYARGS ...
50# else
51# define ANYARGS
52# endif
53#endif
54
55typedef struct st_table st_table;
56
57typedef st_data_t st_index_t;
58
59/* Maximal value of unsigned integer type st_index_t. */
60#define MAX_ST_INDEX_VAL (~(st_index_t) 0)
61
62typedef int st_compare_func(st_data_t, st_data_t);
63typedef st_index_t st_hash_func(st_data_t);
64
65typedef char st_check_for_sizeof_st_index_t[SIZEOF_VOIDP == (int)sizeof(st_index_t) ? 1 : -1];
66#define SIZEOF_ST_INDEX_T SIZEOF_VOIDP
67
68struct st_hash_type {
69 int (*compare)(ANYARGS /*st_data_t, st_data_t*/); /* st_compare_func* */
70 st_index_t (*hash)(ANYARGS /*st_data_t*/); /* st_hash_func* */
71};
72
73#define ST_INDEX_BITS (SIZEOF_ST_INDEX_T * CHAR_BIT)
74
75#if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR) && defined(HAVE_BUILTIN___BUILTIN_TYPES_COMPATIBLE_P)
76# define ST_DATA_COMPATIBLE_P(type) \
77 __builtin_choose_expr(__builtin_types_compatible_p(type, st_data_t), 1, 0)
78#else
79# define ST_DATA_COMPATIBLE_P(type) 0
80#endif
81
82typedef struct st_table_entry st_table_entry;
83
84struct st_table_entry; /* defined in st.c */
85
86struct st_table {
87 /* Cached features of the table -- see st.c for more details. */
88 unsigned char entry_power, bin_power, size_ind;
89 /* How many times the table was rebuilt. */
90 unsigned int rebuilds_num;
91 const struct st_hash_type *type;
92 /* Number of entries currently in the table. */
93 st_index_t num_entries;
94 /* Array of bins used for access by keys. */
95 st_index_t *bins;
96 /* Start and bound index of entries in array entries.
97 entries_starts and entries_bound are in interval
98 [0,allocated_entries]. */
99 st_index_t entries_start, entries_bound;
100 /* Array of size 2^entry_power. */
101 st_table_entry *entries;
102};
103
104#define st_is_member(table,key) st_lookup((table),(key),(st_data_t *)0)
105
106enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE, ST_CHECK};
107
108st_table *st_init_table(const struct st_hash_type *);
109st_table *st_init_table_with_size(const struct st_hash_type *, st_index_t);
110st_table *st_init_numtable(void);
111st_table *st_init_numtable_with_size(st_index_t);
112st_table *st_init_strtable(void);
113st_table *st_init_strtable_with_size(st_index_t);
114st_table *st_init_strcasetable(void);
115st_table *st_init_strcasetable_with_size(st_index_t);
116int st_delete(st_table *, st_data_t *, st_data_t *); /* returns 0:notfound 1:deleted */
117int st_delete_safe(st_table *, st_data_t *, st_data_t *, st_data_t);
118int st_shift(st_table *, st_data_t *, st_data_t *); /* returns 0:notfound 1:deleted */
119int st_insert(st_table *, st_data_t, st_data_t);
120int st_insert2(st_table *, st_data_t, st_data_t, st_data_t (*)(st_data_t));
121int st_lookup(st_table *, st_data_t, st_data_t *);
122int st_get_key(st_table *, st_data_t, st_data_t *);
123typedef int st_update_callback_func(st_data_t *key, st_data_t *value, st_data_t arg, int existing);
124/* *key may be altered, but must equal to the old key, i.e., the
125 * results of hash() are same and compare() returns 0, otherwise the
126 * behavior is undefined */
127int st_update(st_table *table, st_data_t key, st_update_callback_func *func, st_data_t arg);
128int st_foreach(st_table *, int (*)(ANYARGS), st_data_t);
129int st_foreach_check(st_table *, int (*)(ANYARGS), st_data_t, st_data_t);
130st_index_t st_keys(st_table *table, st_data_t *keys, st_index_t size);
131st_index_t st_keys_check(st_table *table, st_data_t *keys, st_index_t size, st_data_t never);
132st_index_t st_values(st_table *table, st_data_t *values, st_index_t size);
133st_index_t st_values_check(st_table *table, st_data_t *values, st_index_t size, st_data_t never);
134void st_add_direct(st_table *, st_data_t, st_data_t);
135void st_free_table(st_table *);
136void st_cleanup_safe(st_table *, st_data_t);
137void st_clear(st_table *);
138st_table *st_copy(st_table *);
139int st_numcmp(st_data_t, st_data_t);
140st_index_t st_numhash(st_data_t);
141int st_locale_insensitive_strcasecmp(const char *s1, const char *s2);
142int st_locale_insensitive_strncasecmp(const char *s1, const char *s2, size_t n);
143#define st_strcasecmp st_locale_insensitive_strcasecmp
144#define st_strncasecmp st_locale_insensitive_strncasecmp
145size_t st_memsize(const st_table *);
146st_index_t st_hash(const void *ptr, size_t len, st_index_t h);
147st_index_t st_hash_uint32(st_index_t h, uint32_t i);
148st_index_t st_hash_uint(st_index_t h, st_index_t i);
149st_index_t st_hash_end(st_index_t h);
150st_index_t st_hash_start(st_index_t h);
151#define st_hash_start(h) ((st_index_t)(h))
152
153RUBY_SYMBOL_EXPORT_END
154
155#if defined(__cplusplus)
156#if 0
157{ /* satisfy cc-mode */
158#endif
159} /* extern "C" { */
160#endif
161
162#endif /* RUBY_ST_H */
Note: See TracBrowser for help on using the repository browser.