diff options
author | H. Peter Anvin <hpa@zytor.com> | 2008-02-16 15:25:02 -0800 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2008-02-16 15:25:02 -0800 |
commit | 338a3b6882e79aa7f4dc7dd1d508898a7c631ecb (patch) | |
tree | ac0997e2075f5de2fc0ad1b9e81e7a18c0523d30 /nasmlib.h | |
parent | 848dbc8ff8e7d0854ff47d7524a3d4847834319d (diff) | |
download | nasm-338a3b6882e79aa7f4dc7dd1d508898a7c631ecb.tar.gz nasm-338a3b6882e79aa7f4dc7dd1d508898a7c631ecb.tar.bz2 nasm-338a3b6882e79aa7f4dc7dd1d508898a7c631ecb.zip |
Clear up WRITE macros causing compile failures with Watcom
The OpenWatcom compiler warns about invalid shifts (correctly, it
appears) due to the non-X86_MEMORY versions of the various WRITE
macros. Fix.
Diffstat (limited to 'nasmlib.h')
-rw-r--r-- | nasmlib.h | 76 |
1 files changed, 44 insertions, 32 deletions
@@ -213,38 +213,50 @@ void standard_extension(char *inname, char *outname, char *extension, #else /* !X86_MEMORY */ -#define WRITECHAR(p,v) \ - do { \ - *(p)++ = (v) & 0xFF; \ - } while (0) - -#define WRITESHORT(p,v) \ - do { \ - WRITECHAR(p,v); \ - WRITECHAR(p,(v) >> 8); \ - } while (0) - -#define WRITELONG(p,v) \ - do { \ - WRITECHAR(p,v); \ - WRITECHAR(p,(v) >> 8); \ - WRITECHAR(p,(v) >> 16); \ - WRITECHAR(p,(v) >> 24); \ - } while (0) - -#define WRITEDLONG(p,v) \ - do { \ - WRITECHAR(p,v); \ - WRITECHAR(p,(v) >> 8); \ - WRITECHAR(p,(v) >> 16); \ - WRITECHAR(p,(v) >> 24); \ - WRITECHAR(p,(v) >> 32); \ - WRITECHAR(p,(v) >> 40); \ - WRITECHAR(p,(v) >> 48); \ - WRITECHAR(p,(v) >> 56); \ - } while (0) - -#define WRITEADDR(p,v,s) \ +#define WRITECHAR(p,v) \ + do { \ + uint8_t *_p = (uint8_t *)(p); \ + uint8_t _v = (v); \ + _p[0] = _v; \ + (p) = (void *)(_p + 1); \ + } while (0) + +#define WRITESHORT(p,v) \ + do { \ + uint8_t *_p = (uint8_t *)(p); \ + uint16_t _v = (v); \ + _p[0] = _v; \ + _p[1] = _v >> 8; \ + (p) = (void *)(_p + 2); \ + } while (0) + +#define WRITELONG(p,v) \ + do { \ + uint8_t *_p = (uint8_t *)(p); \ + uint32_t _v = (v); \ + _p[0] = _v; \ + _p[1] = _v >> 8; \ + _p[2] = _v >> 16; \ + _p[3] = _v >> 24; \ + (p) = (void *)(_p + 4); \ + } while (0) + +#define WRITEDLONG(p,v) \ + do { \ + uint8_t *_p = (uint8_t *)(p); \ + uint64_t _v = (v); \ + _p[0] = _v; \ + _p[1] = _v >> 8; \ + _p[2] = _v >> 16; \ + _p[3] = _v >> 24; \ + _p[4] = _v >> 32; \ + _p[5] = _v >> 40; \ + _p[6] = _v >> 48; \ + _p[7] = _v >> 56; \ + (p) = (void *)(_p + 8); \ + } while (0) + +#define WRITEADDR(p,v,s) \ do { \ int _s = (s); \ uint64_t _v = (v); \ |