| 1 | /* $Header: d:/cvsroot/tads/TADS2/H_IX86.H,v 1.2 1999/05/17 02:52:12 MJRoberts Exp $ */ |
| 2 | |
| 3 | /* |
| 4 | * Copyright (c) 1998, 2002 Michael J. Roberts. All Rights Reserved. |
| 5 | * |
| 6 | * Please see the accompanying license file, LICENSE.TXT, for information |
| 7 | * on using and copying this software. |
| 8 | */ |
| 9 | /* |
| 10 | Name |
| 11 | h_ix86.h - hardware definitions for Intel x86. |
| 12 | Function |
| 13 | These definitions are for 16-bit and 32-bit Intel CPUs. (Note: for |
| 14 | 64-bit Intel hardware, use h_ix86_64.h instead. Don't use this file |
| 15 | for non-Intel platforms, as it assumes Intel byte order and type |
| 16 | sizes.) |
| 17 | Notes |
| 18 | |
| 19 | Modified |
| 20 | 10/17/98 MJRoberts - Creation |
| 21 | */ |
| 22 | |
| 23 | #ifndef H_IX86_H |
| 24 | #define H_IX86_H |
| 25 | |
| 26 | /* round a size to worst-case alignment boundary */ |
| 27 | #define osrndsz(s) (((s)+3) & ~3) |
| 28 | |
| 29 | /* round a pointer to worst-case alignment boundary */ |
| 30 | #define osrndpt(p) ((uchar *)((((unsigned long)(p)) + 3) & ~3)) |
| 31 | |
| 32 | /* read unaligned portable unsigned 2-byte value, returning int */ |
| 33 | #define osrp2(p) ((int)*(unsigned short *)(p)) |
| 34 | |
| 35 | /* read unaligned portable signed 2-byte value, returning int */ |
| 36 | #define osrp2s(p) ((int)*(short *)(p)) |
| 37 | |
| 38 | /* write int to unaligned portable 2-byte value */ |
| 39 | #define oswp2(p, i) (*(unsigned short *)(p)=(unsigned short)(i)) |
| 40 | #define oswp2s(p, i) oswp2(p, i) |
| 41 | |
| 42 | /* read unaligned portable 4-byte value, returning unsigned long */ |
| 43 | #define osrp4(p) (*(unsigned long *)(p)) |
| 44 | #define osrp4s(p) (*(long *)(p)) |
| 45 | |
| 46 | /* write long to unaligned portable 4-byte value */ |
| 47 | #define oswp4(p, l) (*(long *)(p)=(l)) |
| 48 | #define oswp4s(p, l) oswp4(p, l) |
| 49 | |
| 50 | /* read float from portable 4-byte buffer (IEEE 754-2008 format) */ |
| 51 | float osrpfloat(const void *p); |
| 52 | |
| 53 | /* write float to portable 4-byte buffer (IEEE 754-2008 format) */ |
| 54 | void oswpfloat(void *p, float f); |
| 55 | |
| 56 | /* write double to portable 8-byte buffer (IEEE 754-2008 format) */ |
| 57 | double osrpdouble(const void *p); |
| 58 | |
| 59 | /* read double from portable 8-byte buffer (IEEE 754-2008 format) */ |
| 60 | void oswpdouble(void *p, double d); |
| 61 | |
| 62 | #endif /* H_IX86_H */ |
| 63 |