saa: make saa_wleb128[us]() take appropriate types; recode

Make saa_wleb128[us]() take uint64_t and int64_t, respectively, rather
than int.

Notably, if saa_wleb128u() were to receive negative int, it would have
looped forever.

Recode these functions in a style more consistent with NASM code in
general, and possibly a bit simpler.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin (Intel) 2026-04-06 15:55:02 -07:00
parent 9fdc7eab6e
commit 8d4733962e
2 changed files with 51 additions and 48 deletions

View file

@ -57,8 +57,8 @@ void saa_write8(struct SAA *s, uint8_t v);
void saa_write16(struct SAA *s, uint16_t v);
void saa_write32(struct SAA *s, uint32_t v);
void saa_write64(struct SAA *s, uint64_t v);
void saa_wleb128u(struct SAA *, int); /* write unsigned LEB128 value */
void saa_wleb128s(struct SAA *, int); /* write signed LEB128 value */
void saa_writeaddr(struct SAA *, uint64_t, size_t);
void saa_wleb128u(struct SAA *, uint64_t v); /* unsigned LEB128 value */
void saa_wleb128s(struct SAA *, int64_t v); /* signed LEB128 value */
void saa_writeaddr(struct SAA *, uint64_t, size_t); /* specific size integer */
#endif /* NASM_SAA_H */