21
21
#include "murmur/PMurHash128.h"
22
22
23
23
24
- const php_hash_ops php_hash_murmur3a_ops = {/*{{{*/
24
+ const php_hash_ops php_hash_murmur3a_ops = {
25
25
"murmur3a" ,
26
26
(php_hash_init_func_t ) PHP_MURMUR3AInit ,
27
27
(php_hash_update_func_t ) PHP_MURMUR3AUpdate ,
@@ -34,40 +34,40 @@ const php_hash_ops php_hash_murmur3a_ops = {/*{{{*/
34
34
4 ,
35
35
sizeof (PHP_MURMUR3A_CTX ),
36
36
0
37
- };/*}}}*/
37
+ };
38
38
39
39
PHP_HASH_API void PHP_MURMUR3AInit (PHP_MURMUR3A_CTX * ctx )
40
- {/*{{{*/
40
+ {
41
41
ctx -> h = 0 ;
42
42
ctx -> carry = 0 ;
43
43
ctx -> len = 0 ;
44
- }/*}}}*/
44
+ }
45
45
46
46
PHP_HASH_API void PHP_MURMUR3AUpdate (PHP_MURMUR3A_CTX * ctx , const unsigned char * in , size_t len )
47
- {/*{{{*/
47
+ {
48
48
ctx -> len += len ;
49
49
PMurHash32_Process (& ctx -> h , & ctx -> carry , in , len );
50
- }/*}}}*/
50
+ }
51
51
52
52
PHP_HASH_API void PHP_MURMUR3AFinal (unsigned char digest [4 ], PHP_MURMUR3A_CTX * ctx )
53
- {/*{{{*/
53
+ {
54
54
ctx -> h = PMurHash32_Result (ctx -> h , ctx -> carry , ctx -> len );
55
55
56
56
digest [0 ] = (unsigned char )((ctx -> h >> 24 ) & 0xff );
57
57
digest [1 ] = (unsigned char )((ctx -> h >> 16 ) & 0xff );
58
58
digest [2 ] = (unsigned char )((ctx -> h >> 8 ) & 0xff );
59
59
digest [3 ] = (unsigned char )(ctx -> h & 0xff );
60
- }/*}}}*/
60
+ }
61
61
62
62
PHP_HASH_API int PHP_MURMUR3ACopy (const php_hash_ops * ops , PHP_MURMUR3A_CTX * orig_context , PHP_MURMUR3A_CTX * copy_context )
63
- {/*{{{*/
63
+ {
64
64
copy_context -> h = orig_context -> h ;
65
65
copy_context -> carry = orig_context -> carry ;
66
66
copy_context -> len = orig_context -> len ;
67
67
return SUCCESS ;
68
- }/*}}}*/
68
+ }
69
69
70
- const php_hash_ops php_hash_murmur3c_ops = {/*{{{*/
70
+ const php_hash_ops php_hash_murmur3c_ops = {
71
71
"murmur3c" ,
72
72
(php_hash_init_func_t ) PHP_MURMUR3CInit ,
73
73
(php_hash_update_func_t ) PHP_MURMUR3CUpdate ,
@@ -80,23 +80,23 @@ const php_hash_ops php_hash_murmur3c_ops = {/*{{{*/
80
80
4 ,
81
81
sizeof (PHP_MURMUR3C_CTX ),
82
82
0
83
- };/*}}}*/
83
+ };
84
84
85
85
PHP_HASH_API void PHP_MURMUR3CInit (PHP_MURMUR3C_CTX * ctx )
86
- {/*{{{*/
86
+ {
87
87
memset (& ctx -> h , 0 , sizeof ctx -> h );
88
88
memset (& ctx -> carry , 0 , sizeof ctx -> carry );
89
89
ctx -> len = 0 ;
90
- }/*}}}*/
90
+ }
91
91
92
92
PHP_HASH_API void PHP_MURMUR3CUpdate (PHP_MURMUR3C_CTX * ctx , const unsigned char * in , size_t len )
93
- {/*{{{*/
93
+ {
94
94
ctx -> len += len ;
95
95
PMurHash128x86_Process (ctx -> h , ctx -> carry , in , len );
96
- }/*}}}*/
96
+ }
97
97
98
98
PHP_HASH_API void PHP_MURMUR3CFinal (unsigned char digest [4 ], PHP_MURMUR3C_CTX * ctx )
99
- {/*{{{*/
99
+ {
100
100
uint32_t h [4 ] = {0 };
101
101
PMurHash128x86_Result (ctx -> h , ctx -> carry , ctx -> len , h );
102
102
@@ -116,17 +116,17 @@ PHP_HASH_API void PHP_MURMUR3CFinal(unsigned char digest[4], PHP_MURMUR3C_CTX *c
116
116
digest [13 ] = (unsigned char )((h [3 ] >> 16 ) & 0xff );
117
117
digest [14 ] = (unsigned char )((h [3 ] >> 8 ) & 0xff );
118
118
digest [15 ] = (unsigned char )(h [3 ] & 0xff );
119
- }/*}}}*/
119
+ }
120
120
121
121
PHP_HASH_API int PHP_MURMUR3CCopy (const php_hash_ops * ops , PHP_MURMUR3C_CTX * orig_context , PHP_MURMUR3C_CTX * copy_context )
122
- {/*{{{*/
122
+ {
123
123
memcpy (& copy_context -> h , & orig_context -> h , sizeof orig_context -> h );
124
124
memcpy (& copy_context -> carry , & orig_context -> carry , sizeof orig_context -> carry );
125
125
copy_context -> len = orig_context -> len ;
126
126
return SUCCESS ;
127
- }/*}}}*/
127
+ }
128
128
129
- const php_hash_ops php_hash_murmur3f_ops = {/*{{{*/
129
+ const php_hash_ops php_hash_murmur3f_ops = {
130
130
"murmur3f" ,
131
131
(php_hash_init_func_t ) PHP_MURMUR3FInit ,
132
132
(php_hash_update_func_t ) PHP_MURMUR3FUpdate ,
@@ -139,23 +139,23 @@ const php_hash_ops php_hash_murmur3f_ops = {/*{{{*/
139
139
8 ,
140
140
sizeof (PHP_MURMUR3F_CTX ),
141
141
0
142
- };/*}}}*/
142
+ };
143
143
144
144
PHP_HASH_API void PHP_MURMUR3FInit (PHP_MURMUR3F_CTX * ctx )
145
- {/*{{{*/
145
+ {
146
146
memset (& ctx -> h , 0 , sizeof ctx -> h );
147
147
memset (& ctx -> carry , 0 , sizeof ctx -> carry );
148
148
ctx -> len = 0 ;
149
- }/*}}}*/
149
+ }
150
150
151
151
PHP_HASH_API void PHP_MURMUR3FUpdate (PHP_MURMUR3F_CTX * ctx , const unsigned char * in , size_t len )
152
- {/*{{{*/
152
+ {
153
153
ctx -> len += len ;
154
154
PMurHash128x64_Process (ctx -> h , ctx -> carry , in , len );
155
- }/*}}}*/
155
+ }
156
156
157
157
PHP_HASH_API void PHP_MURMUR3FFinal (unsigned char digest [4 ], PHP_MURMUR3F_CTX * ctx )
158
- {/*{{{*/
158
+ {
159
159
uint64_t h [2 ] = {0 };
160
160
PMurHash128x64_Result (ctx -> h , ctx -> carry , ctx -> len , h );
161
161
@@ -175,12 +175,12 @@ PHP_HASH_API void PHP_MURMUR3FFinal(unsigned char digest[4], PHP_MURMUR3F_CTX *c
175
175
digest [13 ] = (unsigned char )((h [1 ] >> 16 ) & 0xff );
176
176
digest [14 ] = (unsigned char )((h [1 ] >> 8 ) & 0xff );
177
177
digest [15 ] = (unsigned char )(h [1 ] & 0xff );
178
- }/*}}}*/
178
+ }
179
179
180
180
PHP_HASH_API int PHP_MURMUR3FCopy (const php_hash_ops * ops , PHP_MURMUR3F_CTX * orig_context , PHP_MURMUR3F_CTX * copy_context )
181
- {/*{{{*/
181
+ {
182
182
memcpy (& copy_context -> h , & orig_context -> h , sizeof orig_context -> h );
183
183
memcpy (& copy_context -> carry , & orig_context -> carry , sizeof orig_context -> carry );
184
184
copy_context -> len = orig_context -> len ;
185
185
return SUCCESS ;
186
- }/*}}}*/
186
+ }
0 commit comments