From d13f30e08fb35ccc5afdebad87851637733ade1e Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Tue, 13 Nov 2007 09:46:38 -0800 Subject: x86-host-specific performance improvement If we're on an x86 host, we can do unaligned littleendian memory references directly. Just do'em. --- nasmlib.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'nasmlib.h') diff --git a/nasmlib.h b/nasmlib.h index 2e18f10c..15f69844 100644 --- a/nasmlib.h +++ b/nasmlib.h @@ -178,6 +178,41 @@ void standard_extension(char *inname, char *outname, char *extension, * format in memory */ +#if X86_MEMORY + +#define WRITECHAR(p,v) \ + do { \ + *(uint8_t *)(p) = (v); \ + (p) += 1; \ + } while (0) + +#define WRITESHORT(p,v) \ + do { \ + *(uint16_t *)(p) = (v); \ + (p) += 2; \ + } while (0) + +#define WRITELONG(p,v) \ + do { \ + *(uint32_t *)(p) = (v); \ + (p) += 4; \ + } while (0) + +#define WRITEDLONG(p,v) \ + do { \ + *(uint64_t *)(p) = (v); \ + (p) += 8; \ + } while (0) + +#define WRITEADDR(p,v,s) \ + do { \ + uint64_t _v = (v); \ + memcpy((p), &_v, (s)); \ + (p) += (s); \ + } while (0) + +#else /* !X86_MEMORY */ + #define WRITECHAR(p,v) \ do { \ *(p)++ = (v) & 0xFF; \ @@ -219,6 +254,8 @@ void standard_extension(char *inname, char *outname, char *extension, } \ } while(0) +#endif + /* * and routines to do the same thing to a file */ -- cgit v1.2.1