summaryrefslogtreecommitdiff
path: root/nasmlib.h
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2007-11-13 09:46:38 -0800
committerH. Peter Anvin <hpa@zytor.com>2007-11-13 09:46:38 -0800
commitd13f30e08fb35ccc5afdebad87851637733ade1e (patch)
tree330358d20cf15bb478aca25f350e935ed25d1f15 /nasmlib.h
parentd1fb15c154b99f9ca8d2356fa9057827b0ab89af (diff)
downloadnasm-d13f30e08fb35ccc5afdebad87851637733ade1e.tar.gz
x86-host-specific performance improvement
If we're on an x86 host, we can do unaligned littleendian memory references directly. Just do'em.
Diffstat (limited to 'nasmlib.h')
-rw-r--r--nasmlib.h37
1 files changed, 37 insertions, 0 deletions
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
*/