Debian Codegraph @

terps/tads/tads2/h_ix86_64.h

raw symbols SCIP
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, 2008 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_64.h - hardware definitions for x86-64 (64-bit x86) platforms
12 Function
13 These definitions are designed ONLY for 64-bit x86 CPUs. Note that these
14 probably will NOT work on 16- and 32-bit x86 hardware.
15 Notes
16 IMPORTANT! See the note below about the typedef for hix_int32.
17 Modified
18 03/25/08 MJRoberts - created (from h_ix86.h)
19 */
20
21 #ifndef H_IX86_64_H
22 #define H_IX86_64_H
23
24 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
27
28 /* ------------------------------------------------------------------------ */
29 /*
30 * Define local covers for the 32-bit and 16-bit integer types.
31 *
32 * For some of our operations, we need to translate between the local
33 * native types and the portable types. The portable types are explicitly
34 * defined with exact byte sizes and byte orderings. One way to do these
35 * translations is to read and write the portable values one byte at a
36 * time, and do some arithmetic to carry out the translation to the native
37 * types. However, there's a more efficient approach: x86 CPUs happen to
38 * have native types that match our portable types in size and byte order,
39 * so the efficient way to do the translations is simply to use the correct
40 * native type that corresponds to each portable type.
41 *
42 * That's the purpose of these definitions - since the portable types are
43 * of specific sizes, we need to map the native type that exactly matches
44 * each portable type.
45 *
46 * This is complicated by a *second* level of mapping, which is from C
47 * types (short, int, long) to native types (WORD, DWORD, QWORD): this
48 * mapping can vary by compiler.
49 *
50 * So, our typedefs here are designed to give us the correct mapping from C
51 * types to portable types, by taking into account the way our compiler
52 * maps from C to native.
53 */
54
55 #ifdef GLK
56 #define SIZEOF_INT 4
57 #define SIZEOF_SHORT 2
58 #endif
59
60 #if SIZEOF_INT == 4
61 typedef int hix_int32;
62 typedef unsigned int hix_uint32;
63 #else
64 #error SIZEOF_INT must be defined in your makefile - \
65 set SIZEOF_INT to the number of bytes in an 'int' for your compiler
66 #endif
67
68 #if SIZEOF_SHORT == 2
69 typedef short hix_int16;
70 typedef unsigned short hix_uint16;
71 #else
72 #error SIZEOF_SHORT must be defined in your makefile - \
73 set SIZEOF_SHORT to the number of bytes in a 'short' for your compiler
74 #endif
75
76 /* ------------------------------------------------------------------------ */
77
78 /* round a size to worst-case alignment boundary */
79 #define osrndsz(s) (((s)+3) & ~3)
80
81 /* round a pointer to worst-case alignment boundary */
82 #define osrndpt(p) ((uchar *)((((unsigned long long)(p)) + 7) & ~7))
83
84 /* read unaligned portable unsigned 2-byte value, returning int */
85 #define osrp2(p) ((int)*(hix_uint16 *)(p))
86
87 /* read unaligned portable signed 2-byte value, returning int */
88 #define osrp2s(p) ((int)*(hix_int16 *)(p))
89
90 /* write int to unaligned portable 2-byte value */
91 #define oswp2(p, i) (*(hix_uint16 *)(p)=(hix_uint16)(i))
92 #define oswp2s(p, i) oswp2(p, i)
93
94 /* read unaligned portable 4-byte value, returning unsigned long */
95 #define osrp4(p) (*(hix_uint32 *)(p))
96
97 /* read unaligned portable 4-byte value, returning signed long */
98 #define osrp4s(p) (*(hix_int32 *)(p))
99
100 /* write unsigned/signed long to unaligned portable 4-byte value */
101 #define oswp4(p, l) (*(hix_int32 *)(p)=(l))
102 #define oswp4s(p, l) oswp4(p, l)
103
104
105 #endif /* H_IX86_64_H */
106