24
24
* THE SOFTWARE.
25
25
*/
26
26
27
- #include <stddef.h>
28
27
#include <stdio.h>
29
28
#include <inttypes.h>
30
29
@@ -57,7 +56,7 @@ STATIC msgpack_stream_t get_stream(mp_obj_t stream_obj, int flags) {
57
56
////////////////////////////////////////////////////////////////
58
57
// readers
59
58
60
- STATIC void read (msgpack_stream_t * s , void * buf , mp_uint_t size ) {
59
+ STATIC void read_bytes (msgpack_stream_t * s , void * buf , mp_uint_t size ) {
61
60
if (size == 0 ) return ;
62
61
mp_uint_t ret = s -> read (s -> stream_obj , buf , size , & s -> errcode );
63
62
if (s -> errcode != 0 ) {
@@ -70,21 +69,21 @@ STATIC void read(msgpack_stream_t *s, void *buf, mp_uint_t size) {
70
69
71
70
STATIC uint8_t read1 (msgpack_stream_t * s ) {
72
71
uint8_t res = 0 ;
73
- read (s , & res , 1 );
72
+ read_bytes (s , & res , 1 );
74
73
return res ;
75
74
}
76
75
77
76
STATIC uint16_t read2 (msgpack_stream_t * s ) {
78
77
uint16_t res = 0 ;
79
- read (s , & res , 2 );
78
+ read_bytes (s , & res , 2 );
80
79
int n = 1 ;
81
80
if (* (char * )& n == 1 ) res = __builtin_bswap16 (res );
82
81
return res ;
83
82
}
84
83
85
84
STATIC uint32_t read4 (msgpack_stream_t * s ) {
86
85
uint32_t res = 0 ;
87
- read (s , & res , 4 );
86
+ read_bytes (s , & res , 4 );
88
87
int n = 1 ;
89
88
if (* (char * )& n == 1 ) res = __builtin_bswap32 (res );
90
89
return res ;
@@ -104,7 +103,7 @@ STATIC size_t read_size(msgpack_stream_t *s, uint8_t len_index) {
104
103
////////////////////////////////////////////////////////////////
105
104
// writers
106
105
107
- STATIC void write (msgpack_stream_t * s , const void * buf , mp_uint_t size ) {
106
+ STATIC void write_bytes (msgpack_stream_t * s , const void * buf , mp_uint_t size ) {
108
107
mp_uint_t ret = s -> write (s -> stream_obj , buf , size , & s -> errcode );
109
108
if (s -> errcode != 0 ) {
110
109
mp_raise_OSError (s -> errcode );
@@ -115,19 +114,19 @@ STATIC void write(msgpack_stream_t *s, const void *buf, mp_uint_t size) {
115
114
}
116
115
117
116
STATIC void write1 (msgpack_stream_t * s , uint8_t obj ) {
118
- write (s , & obj , 1 );
117
+ write_bytes (s , & obj , 1 );
119
118
}
120
119
121
120
STATIC void write2 (msgpack_stream_t * s , uint16_t obj ) {
122
121
int n = 1 ;
123
122
if (* (char * )& n == 1 ) obj = __builtin_bswap16 (obj );
124
- write (s , & obj , 2 );
123
+ write_bytes (s , & obj , 2 );
125
124
}
126
125
127
126
STATIC void write4 (msgpack_stream_t * s , uint32_t obj ) {
128
127
int n = 1 ;
129
128
if (* (char * )& n == 1 ) obj = __builtin_bswap32 (obj );
130
- write (s , & obj , 4 );
129
+ write_bytes (s , & obj , 4 );
131
130
}
132
131
133
132
// compute and write msgpack size code (array structures)
@@ -294,7 +293,7 @@ mp_obj_t unpack(msgpack_stream_t *s) {
294
293
size_t len = code & 0b11111 ;
295
294
// allocate on stack; len < 32
296
295
char str [len ];
297
- read (s , & str , len );
296
+ read_bytes (s , & str , len );
298
297
return mp_obj_new_str (str , len );
299
298
}
300
299
if ((code & 0b11110000 ) == 0b10010000 ) {
@@ -327,7 +326,7 @@ mp_obj_t unpack(msgpack_stream_t *s) {
327
326
vstr_t vstr ;
328
327
vstr_init_len (& vstr , size );
329
328
byte * p = (byte * )vstr .buf ;
330
- read (s , p , size );
329
+ read_bytes (s , p , size );
331
330
return mp_obj_new_str_from_vstr (& mp_type_bytes , & vstr );
332
331
}
333
332
case 0xcc :
@@ -356,7 +355,7 @@ mp_obj_t unpack(msgpack_stream_t *s) {
356
355
vstr_t vstr ;
357
356
vstr_init_len (& vstr , size );
358
357
byte * p = (byte * )vstr .buf ;
359
- read (s , p , size );
358
+ read_bytes (s , p , size );
360
359
return mp_obj_new_str_from_vstr (& mp_type_str , & vstr );
361
360
}
362
361
case 0xde :
0 commit comments