summaryrefslogtreecommitdiff
path: root/nasmlib.c
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.c
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.c')
-rw-r--r--nasmlib.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/nasmlib.c b/nasmlib.c
index b89c711f..dc55ce86 100644
--- a/nasmlib.c
+++ b/nasmlib.c
@@ -361,6 +361,34 @@ int32_t seg_alloc(void)
return (next_seg += 2) - 2;
}
+#if X86_MEMORY
+
+void fwriteint16_t(int data, FILE * fp)
+{
+ uint16_t d = data;
+ fwrite(&d, 1, 2, fp);
+}
+
+void fwriteint32_t(int32_t data, FILE * fp)
+{
+ uint32_t d = data;
+ fwrite(&d, 1, 4, fp);
+}
+
+void fwriteint64_t(int64_t data, FILE * fp)
+{
+ uint64_t d = data;
+ fwrite(&d, 1, 8, fp);
+}
+
+void fwriteaddr(int64_t data, int size, FILE * fp)
+{
+ uint64_t d = data;
+ fwrite(&d, 1, size, fp);
+}
+
+#else /* !X86_MEMORY */
+
void fwriteint16_t(int data, FILE * fp)
{
char buffer[2], *p = buffer;
@@ -389,6 +417,8 @@ void fwriteaddr(int64_t data, int size, FILE * fp)
fwrite(buffer, 1, size, fp);
}
+#endif
+
void standard_extension(char *inname, char *outname, char *extension,
efunc error)
{