Fixes warnings in generated codes.
This commit is contained in:
parent
bbc8af1a5e
commit
5765321487
20
c/pack.h
20
c/pack.h
@ -6,21 +6,21 @@
|
|||||||
|
|
||||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||||
# define pack_Nbit_(N) \
|
# define pack_Nbit_(N) \
|
||||||
static inline void biner_pack_l##N(const int##N##_t* v, uint8_t* c, size_t s) { \
|
static inline void biner_pack_l##N(const void* v, uint8_t* c, size_t s) { \
|
||||||
assert(s < N/8); \
|
assert(s < N/8); \
|
||||||
*c = (*v >> s*8) & 0xff; \
|
*c = *((uint8_t*) v + s); \
|
||||||
} \
|
} \
|
||||||
static inline void biner_pack_b##N(const int##N##_t* v, uint8_t* c, size_t s) { \
|
static inline void biner_pack_b##N(const void* v, uint8_t* c, size_t s) { \
|
||||||
assert(s < N/8); \
|
assert(s < N/8); \
|
||||||
biner_pack_l##N(v, c, N/8-s-1); \
|
biner_pack_l##N(v, c, N/8-s-1); \
|
||||||
}
|
}
|
||||||
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||||
# define pack_Nbit_(N) \
|
# define pack_Nbit_(N) \
|
||||||
static inline void biner_pack_b##N(const int##N##_t* v, uint8_t* c, size_t s) { \
|
static inline void biner_pack_b##N(const void* v, uint8_t* c, size_t s) { \
|
||||||
assert(s < N/8); \
|
assert(s < N/8); \
|
||||||
*c = (*v >> s*8) & 0xff; \
|
*c = *((uint8_t*) v + s); \
|
||||||
} \
|
} \
|
||||||
static inline void biner_pack_l##N(const int##N##_t* v, uint8_t* c, size_t s) { \
|
static inline void biner_pack_l##N(const void* v, uint8_t* c, size_t s) { \
|
||||||
assert(s < N/8); \
|
assert(s < N/8); \
|
||||||
biner_pack_b##N(v, c, N/8-s-1); \
|
biner_pack_b##N(v, c, N/8-s-1); \
|
||||||
}
|
}
|
||||||
@ -28,9 +28,9 @@
|
|||||||
# error "byte order unknown"
|
# error "byte order unknown"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pack_Nbit_(8);
|
pack_Nbit_(8)
|
||||||
pack_Nbit_(16);
|
pack_Nbit_(16)
|
||||||
pack_Nbit_(32);
|
pack_Nbit_(32)
|
||||||
pack_Nbit_(64);
|
pack_Nbit_(64)
|
||||||
|
|
||||||
#undef pack_Nbit_
|
#undef pack_Nbit_
|
||||||
|
20
c/unpack.h
20
c/unpack.h
@ -6,21 +6,21 @@
|
|||||||
|
|
||||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||||
# define unpack_Nbit_(N) \
|
# define unpack_Nbit_(N) \
|
||||||
static inline void biner_unpack_l##N(int##N##_t* v, uint8_t c, size_t s) { \
|
static inline void biner_unpack_l##N(void* v, uint8_t c, size_t s) { \
|
||||||
assert(s < N/8); \
|
assert(s < N/8); \
|
||||||
*v = (*v & ~((uint##N##_t) 0xff << (s*8))) | (c << (s*8)); \
|
*((uint8_t*) v + s) = c; \
|
||||||
} \
|
} \
|
||||||
static inline void biner_unpack_b##N(int##N##_t* v, uint8_t c, size_t s) { \
|
static inline void biner_unpack_b##N(void* v, uint8_t c, size_t s) { \
|
||||||
assert(s < N/8); \
|
assert(s < N/8); \
|
||||||
biner_unpack_l##N(v, c, N/8-s-1); \
|
biner_unpack_l##N(v, c, N/8-s-1); \
|
||||||
}
|
}
|
||||||
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||||
# define unpack_Nbit_(N) \
|
# define unpack_Nbit_(N) \
|
||||||
static inline void biner_unpack_b##N(int##N##_t* v, uint8_t c, size_t s) { \
|
static inline void biner_unpack_b##N(void* v, uint8_t c, size_t s) { \
|
||||||
assert(s < N/8); \
|
assert(s < N/8); \
|
||||||
*v = (*v & ~((uint##N_t) 0xff << (s*8))) | (c << (s*8)); \
|
*((uint8_t*) v + s) = c; \
|
||||||
} \
|
} \
|
||||||
static inline void biner_unpack_l##N(int##N##_t* v, uint8_t c, size_t s) { \
|
static inline void biner_unpack_l##N(void* v, uint8_t c, size_t s) { \
|
||||||
assert(s < N/8); \
|
assert(s < N/8); \
|
||||||
biner_unpack_b##N(v, c, N/8-s-1); \
|
biner_unpack_b##N(v, c, N/8-s-1); \
|
||||||
}
|
}
|
||||||
@ -28,9 +28,9 @@
|
|||||||
# error "byte order unknown"
|
# error "byte order unknown"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
unpack_Nbit_(8);
|
unpack_Nbit_(8)
|
||||||
unpack_Nbit_(16);
|
unpack_Nbit_(16)
|
||||||
unpack_Nbit_(32);
|
unpack_Nbit_(32)
|
||||||
unpack_Nbit_(64);
|
unpack_Nbit_(64)
|
||||||
|
|
||||||
#undef unpack_Nbit_
|
#undef unpack_Nbit_
|
||||||
|
@ -244,7 +244,7 @@ static void print_enum_member_validation_code_(
|
|||||||
assert(m != NULL);
|
assert(m != NULL);
|
||||||
|
|
||||||
fprintf(p->dst, "return true");
|
fprintf(p->dst, "return true");
|
||||||
while ((uintptr_t*) m != (uintptr_t*) p->zone) {
|
while ((uintptr_t) m != (uintptr_t) p->zone) {
|
||||||
fprintf(p->dst, " && v == %s", p->zone+m->name);
|
fprintf(p->dst, " && v == %s", p->zone+m->name);
|
||||||
m = (const biner_tree_enum_member_t*) (p->zone+m->prev);
|
m = (const biner_tree_enum_member_t*) (p->zone+m->prev);
|
||||||
}
|
}
|
||||||
@ -307,18 +307,34 @@ static void print_struct_member_context_struct_(
|
|||||||
fprintf(p->dst, "size_t count_max; ");
|
fprintf(p->dst, "size_t count_max; ");
|
||||||
fprintf(p->dst, "size_t byte; ");
|
fprintf(p->dst, "size_t byte; ");
|
||||||
|
|
||||||
fprintf(p->dst, "union { ");
|
bool require_subctx = false;
|
||||||
while ((uintptr_t*) m != (uintptr_t*) p->zone) {
|
const biner_tree_struct_member_t* itr = m;
|
||||||
|
while ((uintptr_t) itr != (uintptr_t) p->zone) {
|
||||||
const biner_tree_struct_member_type_t* t =
|
const biner_tree_struct_member_type_t* t =
|
||||||
(const biner_tree_struct_member_type_t*) (p->zone+m->type);
|
(const biner_tree_struct_member_type_t*) (p->zone+itr->type);
|
||||||
if (t->name == BINER_TREE_STRUCT_MEMBER_TYPE_NAME_USER_DECL) {
|
if (t->name == BINER_TREE_STRUCT_MEMBER_TYPE_NAME_USER_DECL) {
|
||||||
const biner_tree_decl_t* d = (const biner_tree_decl_t*) (p->zone+t->decl);
|
require_subctx = true;
|
||||||
print_fixed_decl_name_(p, (const char*) (p->zone+d->name));
|
|
||||||
fprintf(p->dst, "%s %s; ", suffix, p->zone+m->name);
|
|
||||||
}
|
}
|
||||||
m = (const biner_tree_struct_member_t*) (p->zone+m->prev);
|
itr = (const biner_tree_struct_member_t*) (p->zone+itr->prev);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (require_subctx) {
|
||||||
|
fprintf(p->dst, "union { ");
|
||||||
|
|
||||||
|
itr = m;
|
||||||
|
while ((uintptr_t) itr != (uintptr_t) p->zone) {
|
||||||
|
const biner_tree_struct_member_type_t* t =
|
||||||
|
(const biner_tree_struct_member_type_t*) (p->zone+itr->type);
|
||||||
|
if (t->name == BINER_TREE_STRUCT_MEMBER_TYPE_NAME_USER_DECL) {
|
||||||
|
const biner_tree_decl_t* d = (const biner_tree_decl_t*) (p->zone+t->decl);
|
||||||
|
print_fixed_decl_name_(p, (const char*) (p->zone+d->name));
|
||||||
|
fprintf(p->dst, "%s %s; ", suffix, p->zone+itr->name);
|
||||||
|
}
|
||||||
|
itr = (const biner_tree_struct_member_t*) (p->zone+itr->prev);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(p->dst, "} subctx; ");
|
||||||
}
|
}
|
||||||
fprintf(p->dst, "} subctx; ");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_struct_member_pack_code_each_(
|
static void print_struct_member_pack_code_each_(
|
||||||
|
Loading…
Reference in New Issue
Block a user