File tree 2 files changed +26
-12
lines changed
2 files changed +26
-12
lines changed Original file line number Diff line number Diff line change @@ -146,38 +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 )
160
161
{
161
- uint32_t nx ;
162
- memcpy ((char * )& nx , buf , sizeof (uint32_t ));
163
- return (int32_t )apg_ntoh32 (nx );
162
+ return (int16_t )unpack_uint16 (buf );
164
163
}
165
164
165
+
166
166
static inline uint32_t
167
167
unpack_uint32 (const char * buf )
168
168
{
169
169
uint32_t nx ;
170
170
memcpy ((char * )& nx , buf , sizeof (uint32_t ));
171
- return ( uint32_t ) apg_ntoh32 (nx );
171
+ return apg_ntoh32 (nx );
172
172
}
173
173
174
174
175
- static inline int64_t
176
- unpack_int64 (const char * buf )
175
+ static inline int32_t
176
+ unpack_int32 (const char * buf )
177
+ {
178
+ return (int32_t )unpack_uint32 (nx );
179
+ }
180
+
181
+ static inline uint64_t
182
+ unpack_uint64 (const char * buf )
177
183
{
178
184
uint64_t nx ;
179
185
memcpy ((char * )& nx , buf , sizeof (uint64_t ));
180
- 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 );
181
193
}
182
194
183
195
Original file line number Diff line number Diff line change @@ -15,8 +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);
19
20
cdef uint32_t unpack_uint32(const char * buf);
20
21
cdef int64_t unpack_int64(const char * buf);
22
+ cdef uint64_t unpack_uint64(const char * buf);
21
23
cdef float unpack_float(const char * buf);
22
24
cdef double unpack_double(const char * buf);
You can’t perform that action at this time.
0 commit comments