File tree Expand file tree Collapse file tree 2 files changed +32
-9
lines changed Expand file tree Collapse file tree 2 files changed +32
-9
lines changed Original file line number Diff line number Diff line change @@ -146,30 +146,50 @@ pack_int64(char *buf, int64_t x)
146
146
}
147
147
148
148
149
- static inline int16_t
150
- unpack_int16 (const char * buf )
149
+
150
+ static inline uint16_t
151
+ unpack_uint16 (const char * buf )
151
152
{
152
153
uint16_t nx ;
153
154
memcpy ((char * )& nx , buf , sizeof (uint16_t ));
154
- return ( int16_t ) apg_ntoh16 (nx );
155
+ return apg_ntoh16 (nx );
155
156
}
156
157
157
158
158
- static inline int32_t
159
- unpack_int32 (const char * buf )
159
+ static inline int16_t
160
+ unpack_int16 (const char * buf )
161
+ {
162
+ return (int16_t )unpack_uint16 (buf );
163
+ }
164
+
165
+
166
+ static inline uint32_t
167
+ unpack_uint32 (const char * buf )
160
168
{
161
169
uint32_t nx ;
162
170
memcpy ((char * )& nx , buf , sizeof (uint32_t ));
163
- return ( int32_t ) apg_ntoh32 (nx );
171
+ return apg_ntoh32 (nx );
164
172
}
165
173
166
174
167
- static inline int64_t
168
- unpack_int64 (const char * buf )
175
+ static inline int32_t
176
+ unpack_int32 (const char * buf )
177
+ {
178
+ return (int32_t )unpack_uint32 (buf );
179
+ }
180
+
181
+ static inline uint64_t
182
+ unpack_uint64 (const char * buf )
169
183
{
170
184
uint64_t nx ;
171
185
memcpy ((char * )& nx , buf , sizeof (uint64_t ));
172
- return (int64_t )apg_ntoh64 (nx );
186
+ return apg_ntoh64 (nx );
187
+ }
188
+
189
+ static inline int64_t
190
+ unpack_int64 (const char * buf )
191
+ {
192
+ return (int64_t )unpack_uint64 (buf );
173
193
}
174
194
175
195
Original file line number Diff line number Diff line change @@ -15,7 +15,10 @@ cdef extern from "./hton.h":
15
15
cdef void pack_float(char * buf, float f);
16
16
cdef void pack_double(char * buf, double f);
17
17
cdef int16_t unpack_int16(const char * buf);
18
+ cdef uint16_t unpack_uint16(const char * buf);
18
19
cdef int32_t unpack_int32(const char * buf);
20
+ cdef uint32_t unpack_uint32(const char * buf);
19
21
cdef int64_t unpack_int64(const char * buf);
22
+ cdef uint64_t unpack_uint64(const char * buf);
20
23
cdef float unpack_float(const char * buf);
21
24
cdef double unpack_double(const char * buf);
You can’t perform that action at this time.
0 commit comments