Ruby
4.1.0dev (2026-04-04 revision 3b6245536cf55da9e8bfcdb03c845fe9ef931d7f)
parser_st.c (3b6245536cf55da9e8bfcdb03c845fe9ef931d7f)
1
#include "parser_st.h"
2
#include "parser_bits.h"
3
4
#ifndef TRUE
5
# define TRUE 1
6
#endif
7
8
#ifndef FALSE
9
# define FALSE 0
10
#endif
11
12
#undef NOT_RUBY
13
#undef RUBY
14
#undef RUBY_EXPORT
15
16
#undef MEMCPY
17
#define MEMCPY(p1,p2,type,n) nonempty_memcpy((p1), (p2), (sizeof(type) * (n)))
18
/* The multiplication should not overflow since this macro is used
19
* only with the already allocated size. */
20
static
inline
void
*
21
nonempty_memcpy(
void
*dest,
const
void
*src,
size_t
n)
22
{
23
if
(n) {
24
return
memcpy(dest, src, n);
25
}
26
else
{
27
return
dest;
28
}
29
}
30
31
#include <stdio.h>
32
#ifdef HAVE_STDLIB_H
33
#include <stdlib.h>
34
#endif
35
#include <string.h>
36
#include <
assert.h
>
37
38
#ifdef __GNUC__
39
#define PREFETCH(addr, write_p) __builtin_prefetch(addr, write_p)
40
#define EXPECT(expr, val) __builtin_expect(expr, val)
41
#define ATTRIBUTE_UNUSED __attribute__((unused))
42
#else
43
#define PREFETCH(addr, write_p)
44
#define EXPECT(expr, val) (expr)
45
#define ATTRIBUTE_UNUSED
46
#endif
47
48
49
#define st_index_t parser_st_index_t
50
#define st_hash_t parser_st_hash_t
51
#define st_data_t parser_st_data_t
52
#define st_hash_type parser_st_hash_type
53
#define st_table parser_st_table
54
#define st_table_entry parser_st_table_entry
55
#define st_update_callback_func parser_st_update_callback_func
56
#define st_foreach_check_callback_func parser_st_foreach_check_callback_func
57
#define st_foreach_callback_func parser_st_foreach_callback_func
58
#define st_retval parser_st_retval
59
60
#define ST_CONTINUE ST2_CONTINUE
61
#define ST_STOP ST2_STOP
62
#define ST_DELETE ST2_DELETE
63
#define ST_CHECK ST2_CHECK
64
#define ST_REPLACE ST2_REPLACE
65
66
#undef st_numcmp
67
#define st_numcmp rb_parser_st_numcmp
68
#undef st_numhash
69
#define st_numhash rb_parser_st_numhash
70
#undef st_free_table
71
#define st_free_table rb_parser_st_free_table
72
#define rb_st_hash_start rb_parser_st_hash_start
73
#undef st_delete
74
#define st_delete rb_parser_st_delete
75
#undef st_foreach
76
#define st_foreach rb_parser_st_foreach
77
#undef st_init_numtable
78
#define st_init_numtable rb_parser_st_init_numtable
79
#undef st_init_table_with_size
80
#define st_init_table_with_size rb_parser_st_init_table_with_size
81
#undef st_init_existing_table_with_size
82
#define st_init_existing_table_with_size rb_parser_st_init_existing_table_with_size
83
#undef st_init_existing_strtable_with_size
84
#define st_init_existing_strtable_with_size rb_parser_st_init_existing_strtable_with_size
85
#undef st_init_existing_numtable_with_size
86
#define st_init_existing_numtable_with_size rb_parser_st_init_existing_numtable_with_size
87
#undef st_free_embedded_table
88
#define st_free_embedded_table rb_parser_st_free_embedded_table
89
#undef st_insert
90
#define st_insert rb_parser_st_insert
91
#undef st_lookup
92
#define st_lookup rb_parser_st_lookup
93
94
#undef st_table_size
95
#define st_table_size rb_parser_st_table_size
96
#undef st_clear
97
#define st_clear rb_parser_st_clear
98
#undef st_init_strtable
99
#define st_init_strtable rb_parser_st_init_strtable
100
#undef st_init_table
101
#define st_init_table rb_parser_st_init_table
102
#undef st_init_strcasetable
103
#define st_init_strcasetable rb_parser_st_init_strcasetable
104
#undef st_init_strtable_with_size
105
#define st_init_strtable_with_size rb_parser_st_init_strtable_with_size
106
#undef st_init_numtable_with_size
107
#define st_init_numtable_with_size rb_parser_st_init_numtable_with_size
108
#undef st_init_strcasetable_with_size
109
#define st_init_strcasetable_with_size rb_parser_st_init_strcasetable_with_size
110
#undef st_memsize
111
#define st_memsize rb_parser_st_memsize
112
#undef st_get_key
113
#define st_get_key rb_parser_st_get_key
114
#undef st_add_direct
115
#define st_add_direct rb_parser_st_add_direct
116
#define rb_st_add_direct_with_hash rb_parser_st_add_direct_with_hash
117
#undef st_insert2
118
#define st_insert2 rb_parser_st_insert2
119
#undef st_replace
120
#define st_replace rb_parser_st_replace
121
#undef st_copy
122
#define st_copy rb_parser_st_copy
123
#undef st_delete_safe
124
#define st_delete_safe rb_parser_st_delete_safe
125
#undef st_shift
126
#define st_shift rb_parser_st_shift
127
#undef st_cleanup_safe
128
#define st_cleanup_safe rb_parser_st_cleanup_safe
129
#undef st_update
130
#define st_update rb_parser_st_update
131
#undef st_foreach_with_replace
132
#define st_foreach_with_replace rb_parser_st_foreach_with_replace
133
#undef st_foreach_check
134
#define st_foreach_check rb_parser_st_foreach_check
135
#undef st_keys
136
#define st_keys rb_parser_st_keys
137
#undef st_keys_check
138
#define st_keys_check rb_parser_st_keys_check
139
#undef st_values
140
#define st_values rb_parser_st_values
141
#undef st_values_check
142
#define st_values_check rb_parser_st_values_check
143
#undef st_hash
144
#define st_hash rb_parser_st_hash
145
#undef st_hash_uint32
146
#define st_hash_uint32 rb_parser_st_hash_uint32
147
#undef st_hash_uint
148
#define st_hash_uint rb_parser_st_hash_uint
149
#undef st_hash_end
150
#define st_hash_end rb_parser_st_hash_end
151
#undef st_locale_insensitive_strcasecmp
152
#define st_locale_insensitive_strcasecmp rb_parser_st_locale_insensitive_strcasecmp
153
#undef st_locale_insensitive_strncasecmp
154
#define st_locale_insensitive_strncasecmp rb_parser_st_locale_insensitive_strncasecmp
155
156
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
157
/* GCC warns about unknown sanitizer, which is annoying. */
158
# undef NO_SANITIZE
159
# define NO_SANITIZE(x, y) \
160
_Pragma("GCC diagnostic push") \
161
_Pragma("GCC diagnostic ignored \"-Wattributes\"") \
162
__attribute__((__no_sanitize__(x))) y; \
163
_Pragma("GCC diagnostic pop") \
164
y
165
#endif
166
167
#ifndef NO_SANITIZE
168
# define NO_SANITIZE(x, y) y
169
#endif
170
171
#include "st.c"
assert.h
Generated by
1.9.8