1 /*BEGIN_LEGAL
2 
3 Copyright (c) 2018 Intel Corporation
4 
5   Licensed under the Apache License, Version 2.0 (the "License");
6   you may not use this file except in compliance with the License.
7   You may obtain a copy of the License at
8 
9       http://www.apache.org/licenses/LICENSE-2.0
10 
11   Unless required by applicable law or agreed to in writing, software
12   distributed under the License is distributed on an "AS IS" BASIS,
13   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   See the License for the specific language governing permissions and
15   limitations under the License.
16 
17 END_LEGAL */
18 /// @file xed-types.h
19 ///
20 
21 
22 #ifndef XED_TYPES_H
23 # define XED_TYPES_H
24 
25 ////////////////////////////////////////////////////////////////////////////
26 
27 #include "xed-common-hdrs.h"
28 
29 #if defined(__GNUC__) || defined(__ICC)
30 #  include <stdint.h>
31 #  define xed_uint8_t   uint8_t
32 #  define xed_uint16_t  uint16_t
33 #  define xed_uint32_t  uint32_t
34 #  define xed_uint64_t  uint64_t
35 #  define xed_int8_t     int8_t
36 #  define xed_int16_t 	 int16_t
37 #  define xed_int32_t    int32_t
38 #  define xed_int64_t    int64_t
39 #elif defined(_WIN32)
40 #  define xed_uint8_t  unsigned __int8
41 #  define xed_uint16_t unsigned __int16
42 #  define xed_uint32_t unsigned __int32
43 #  define xed_uint64_t unsigned __int64
44 #  define xed_int8_t   __int8
45 #  define xed_int16_t  __int16
46 #  define xed_int32_t  __int32
47 #  define xed_int64_t  __int64
48 #else
49 #  error "XED types unsupported platform? Need windows, gcc, or icc."
50 #endif
51 
52 typedef unsigned int  xed_uint_t;
53 typedef          int  xed_int_t;
54 typedef unsigned int  xed_bits_t;
55 typedef unsigned int  xed_bool_t;
56 
57 #if defined(__LP64__)  || defined (_M_X64)
58 typedef xed_uint64_t xed_addr_t;
59 #else
60 typedef xed_uint32_t xed_addr_t;
61 #endif
62 
63 
64 typedef union {
65    xed_uint8_t   byte[2];
66    xed_int8_t  s_byte[2];
67 
68   struct {
69     xed_uint8_t b0; /*low 8 bits*/
70     xed_uint8_t b1; /*high 8 bits*/
71   } b;
72   xed_int16_t  i16;
73   xed_uint16_t u16;
74 } xed_union16_t ;
75 
76 typedef union {
77    xed_uint8_t   byte[4];
78    xed_uint16_t  word[2];
79    xed_int8_t  s_byte[4];
80    xed_int16_t s_word[2];
81 
82   struct {
83     xed_uint8_t b0; /*low 8 bits*/
84     xed_uint8_t b1;
85     xed_uint8_t b2;
86     xed_uint8_t b3; /*high 8 bits*/
87   } b;
88 
89   struct {
90     xed_uint16_t w0; /*low 16 bits*/
91     xed_uint16_t w1; /*high 16 bits*/
92   } w;
93   xed_int32_t  i32;
94   xed_uint32_t u32;
95 } xed_union32_t ;
96 
97 typedef union {
98    xed_uint8_t      byte[8];
99    xed_uint16_t     word[4];
100    xed_uint32_t    dword[2];
101    xed_int8_t     s_byte[8];
102    xed_int16_t    s_word[4];
103    xed_int32_t   s_dword[2];
104 
105   struct {
106     xed_uint8_t b0; /*low 8 bits*/
107     xed_uint8_t b1;
108     xed_uint8_t b2;
109     xed_uint8_t b3;
110     xed_uint8_t b4;
111     xed_uint8_t b5;
112     xed_uint8_t b6;
113     xed_uint8_t b7; /*high 8 bits*/
114   } b;
115 
116   struct {
117     xed_uint16_t w0; /*low 16 bits*/
118     xed_uint16_t w1;
119     xed_uint16_t w2;
120     xed_uint16_t w3; /*high 16 bits*/
121   } w;
122   struct {
123     xed_uint32_t lo32;
124     xed_uint32_t hi32;
125   } s;
126     xed_uint64_t u64;
127     xed_int64_t i64;
128 } xed_union64_t ;
129 
130 ////////////////////////////////////////////////////////////////////////////
131 #endif
132