Slight refactoring to reduce code duplication.

This also comes with a performance bump due to inlining of reg_read/reg_write
(as they're only called once now) and the unlikely() on CHECK_REG_TYPE.
This commit is contained in:
Robert Xiao
2023-05-11 20:08:27 -07:00
parent 4055a5ab10
commit 074566cf69
13 changed files with 473 additions and 533 deletions

View File

@@ -129,14 +129,14 @@ static inline void uc_common_init(struct uc_struct* uc)
uc->release = release_common;
}
#define CHECK_REG_TYPE(type) do { \
if (size) { \
if (*size < sizeof(type)) { \
return UC_ERR_NOMEM; \
} \
*size = sizeof(type); \
} \
ret = UC_ERR_OK; \
#define CHECK_REG_TYPE(type) do { \
if (unlikely(size)) { \
if (unlikely(*size < sizeof(type))) { \
return UC_ERR_NOMEM; \
} \
*size = sizeof(type); \
} \
ret = UC_ERR_OK; \
} while(0)
#endif