tccelf: introduce add32/64le()

This commit is contained in:
grischka
2016-11-20 14:52:56 +01:00
parent 4a3741bf02
commit a52a39179a
3 changed files with 28 additions and 24 deletions

6
tcc.h
View File

@ -1423,12 +1423,18 @@ static inline uint32_t read32le(unsigned char *p) {
static inline void write32le(unsigned char *p, uint32_t x) {
write16le(p, x), write16le(p + 2, x >> 16);
}
static inline void add32le(unsigned char *p, int32_t x) {
write32le(p, read32le(p) + x);
}
static inline uint64_t read64le(unsigned char *p) {
return read32le(p) | (uint64_t)read32le(p + 4) << 32;
}
static inline void write64le(unsigned char *p, uint64_t x) {
write32le(p, x), write32le(p + 4, x >> 32);
}
static inline void add64le(unsigned char *p, int64_t x) {
write64le(p, read64le(p) + x);
}
/* ------------ i386-gen.c ------------ */
#if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64