Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define OP(a,b,op) ((a)op(b))
- #define MKFUNC_a_op_b(type, opname, op) void type##_##opname##_##type(const void *a, const void *b, void *out) \
- {\
- type tmp = OP(*(type*)a,*(type*)b,op);\
- memcpy(out,(void*)(&tmp),sizeof(type));\
- }
- #define MKALLF_int(type) \
- MKFUNC_a_op_b(type,plus,+) MKFUNC_a_op_b(type,minus,-) \
- MKFUNC_a_op_b(type,div,/) MKFUNC_a_op_b(type,mod,%) \
- MKFUNC_a_op_b(type,and,&) MKFUNC_a_op_b(type,or,|) \
- MKFUNC_a_op_b(type,xor,^)
- MKALLF_int(int8_t)
- MKALLF_int(uint8_t)
- MKALLF_int(int16_t)
- MKALLF_int(uint16_t)
- MKALLF_int(int32_t)
- MKALLF_int(uint32_t)
- MKALLF_int(int64_t)
- MKALLF_int(uint64_t)
- #define MKFUNC_conv_t(type1, type2) void type1##_to_##type2(const void *a, void *out) \
- {\
- type2 tmp = (type2)(*(type1*)a);\
- memcpy(out,(void*)(&tmp),sizeof(type2));\
- }
- #define MKFUNC_con_M(type) \
- MKFUNC_conv_t(type, int8_t) \
- MKFUNC_conv_t(type, uint8_t) \
- MKFUNC_conv_t(type, int16_t) \
- MKFUNC_conv_t(type, uint16_t) \
- MKFUNC_conv_t(type, int32_t) \
- MKFUNC_conv_t(type, uint32_t) \
- MKFUNC_conv_t(type, int64_t) \
- MKFUNC_conv_t(type, uint64_t)
- MKFUNC_con_M(int8_t)
- MKFUNC_con_M(uint8_t)
- MKFUNC_con_M(int16_t)
- MKFUNC_con_M(uint16_t)
- MKFUNC_con_M(int32_t)
- MKFUNC_con_M(uint32_t)
- MKFUNC_con_M(int64_t)
- MKFUNC_con_M(uint64_t)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement