VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/vboxvideo/VBoxVideoIPRT.h@ 71590

最後變更 在這個檔案從71590是 71590,由 vboxsync 提交於 7 年 前

DevVGA,HGSMI,++: Code cleanup in progress. bugref:9094

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 6.9 KB
 
1/* $Id: VBoxVideoIPRT.h 71590 2018-03-31 18:34:28Z vboxsync $ */
2/*
3 * Copyright (C) 2017 Oracle Corporation
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without
8 * restriction, including without limitation the rights to use,
9 * copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following
12 * conditions:
13 *
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 * OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27/* In builds inside of the VirtualBox source tree we override the default
28 * VBoxVideoIPRT.h using -include, therefore this define must match the one
29 * there. */
30#ifndef ___VBox_Graphics_VBoxVideoIPRT_h
31#define ___VBox_Graphics_VBoxVideoIPRT_h
32
33# include "VBoxVideoErr.h"
34
35#ifndef __cplusplus
36typedef enum
37{
38 false = 0,
39 true
40} bool;
41# define RT_C_DECLS_BEGIN
42# define RT_C_DECLS_END
43#else
44# define RT_C_DECLS_BEGIN extern "C" {
45# define RT_C_DECLS_END }
46#endif
47
48#if defined(IN_XF86_MODULE) && !defined(NO_ANSIC)
49# ifdef __cplusplus
50/* xf86Module.h redefines this. */
51# define NULL 0
52# endif
53RT_C_DECLS_BEGIN
54# include "xf86_ansic.h"
55RT_C_DECLS_END
56#endif /* defined(IN_XF86_MODULE) && !defined(NO_ANSIC) */
57#define __STDC_LIMIT_MACROS /* define *INT*_MAX on C++ too. */
58#include "compiler.h" /* Can pull in <sdtint.h>. Must come after xf86_ansic.h on XFree86. */
59#include <X11/Xfuncproto.h>
60#include <stdint.h>
61#if defined(IN_XF86_MODULE) && !defined(NO_ANSIC)
62/* XFree86 did not have these. Not that I care much for micro-optimisations
63 * in most cases anyway. */
64# define _X_LIKELY(x) (x)
65# define _X_UNLIKELY(x) (x)
66# ifndef offsetof
67# define offsetof(type, member) ( (int)(uintptr_t)&( ((type *)(void *)0)->member) )
68# endif
69#else /* !(defined(IN_XF86_MODULE) && !defined(NO_ANSIC)) */
70# include <stdarg.h>
71# include <stddef.h>
72# include <string.h>
73#endif /* !(defined(IN_XF86_MODULE) && !defined(NO_ANSIC)) */
74
75RT_C_DECLS_BEGIN
76extern int RTASSERTVAR[1];
77RT_C_DECLS_END
78
79#define AssertCompile(expr) \
80 extern int RTASSERTVAR[1] __attribute__((__unused__)), \
81 RTASSERTVAR[(expr) ? 1 : 0] __attribute__((__unused__))
82#define AssertCompileSize(type, size) \
83 AssertCompile(sizeof(type) == (size))
84#define AssertPtrNullReturnVoid(a) do { } while(0)
85
86#if !defined(IN_XF86_MODULE) && defined(DEBUG)
87# include <assert.h>
88# define Assert assert
89# define AssertFailed() assert(0)
90# define AssertMsg(expr, msg) \
91 do { \
92 if (!(expr)) xf86ErrorF msg; \
93 assert((expr)); \
94 } while (0)
95# define AssertPtr assert
96# define AssertPtrReturn(pv, rcRet) do { assert(pv); if (pv) {} else return(rcRet); } while(0)
97# define AssertRC(expr) assert (!expr)
98#else
99# define Assert(expr) do { } while(0)
100# define AssertFailed() do { } while(0)
101# define AssertMsg(expr, msg) do { } while(0)
102# define AssertPtr(ptr) do { } while(0)
103# define AssertPtrReturn(pv, rcRet) do { if (pv) {} else return(rcRet); } while(0)
104# define AssertRC(expr) do { } while(0)
105#endif
106
107#define DECLCALLBACK(type) type
108#define DECLCALLBACKMEMBER(type, name) type (* name)
109#if __GNUC__ >= 4
110# define DECLHIDDEN(type) __attribute__((visibility("hidden"))) type
111#else
112# define DECLHIDDEN(type) type
113#endif
114#define DECLINLINE(type) static __inline__ type
115
116#define _1K 1024
117#define ASMCompilerBarrier mem_barrier
118#define RT_BIT(bit) ( 1U << (bit) )
119#define RT_BOOL(Value) ( !!(Value) )
120#define RT_BZERO(pv, cb) do { memset((pv), 0, cb); } while (0)
121#define RT_CLAMP(Value, Min, Max) ( (Value) > (Max) ? (Max) : (Value) < (Min) ? (Min) : (Value) )
122#define RT_ELEMENTS(aArray) ( sizeof(aArray) / sizeof((aArray)[0]) )
123#define RTIOPORT unsigned short
124#define RT_NOREF(...) (void)(__VA_ARGS__)
125#define RT_OFFSETOF(type, member) offsetof(type, member)
126#define RT_ZERO(Obj) RT_BZERO(&(Obj), sizeof(Obj))
127#define VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U )
128#ifndef INT16_C
129# define INT16_C(Value) (Value)
130#endif
131#ifndef UINT16_C
132# define UINT16_C(Value) (Value)
133#endif
134#ifndef INT32_C
135# define INT32_C(Value) (Value ## U)
136#endif
137#ifndef UINT32_C
138# define UINT32_C(Value) (Value ## U)
139#endif
140#define RT_UNTRUSTED_GUEST
141#define RT_UNTRUSTED_VOLATILE_GUEST volatile
142#define RT_UNTRUSTED_HOST
143#define RT_UNTRUSTED_VOLATILE_HOST volatile
144#define RT_UNTRUSTED_HSTGST
145#define RT_UNTRUSTED_VOLATILE_HSTGST volatile
146
147#define likely _X_LIKELY
148#define unlikely _X_UNLIKELY
149
150/**
151 * A point in a two dimentional coordinate system.
152 */
153typedef struct RTPOINT
154{
155 /** X coordinate. */
156 int32_t x;
157 /** Y coordinate. */
158 int32_t y;
159} RTPOINT;
160
161/**
162 * Rectangle data type, double point.
163 */
164typedef struct RTRECT
165{
166 /** left X coordinate. */
167 int32_t xLeft;
168 /** top Y coordinate. */
169 int32_t yTop;
170 /** right X coordinate. (exclusive) */
171 int32_t xRight;
172 /** bottom Y coordinate. (exclusive) */
173 int32_t yBottom;
174} RTRECT;
175
176/**
177 * Rectangle data type, point + size.
178 */
179typedef struct RTRECT2
180{
181 /** X coordinate.
182 * Unless stated otherwise, this is the top left corner. */
183 int32_t x;
184 /** Y coordinate.
185 * Unless stated otherwise, this is the top left corner. */
186 int32_t y;
187 /** The width.
188 * Unless stated otherwise, this is to the right of (x,y) and will not
189 * be a negative number. */
190 int32_t cx;
191 /** The height.
192 * Unless stated otherwise, this is down from (x,y) and will not be a
193 * negative number. */
194 int32_t cy;
195} RTRECT2;
196
197/**
198 * The size of a rectangle.
199 */
200typedef struct RTRECTSIZE
201{
202 /** The width (along the x-axis). */
203 uint32_t cx;
204 /** The height (along the y-axis). */
205 uint32_t cy;
206} RTRECTSIZE;
207
208/** @name Port I/O helpers
209 * @{ */
210
211/** Write an 8-bit value to an I/O port. */
212#define VBVO_PORT_WRITE_U8(Port, Value) \
213 outb(Port, Value)
214/** Write a 16-bit value to an I/O port. */
215#define VBVO_PORT_WRITE_U16(Port, Value) \
216 outw(Port, Value)
217/** Write a 32-bit value to an I/O port. */
218#define VBVO_PORT_WRITE_U32(Port, Value) \
219 outl(Port, Value)
220/** Read an 8-bit value from an I/O port. */
221#define VBVO_PORT_READ_U8(Port) \
222 inb(Port)
223/** Read a 16-bit value from an I/O port. */
224#define VBVO_PORT_READ_U16(Port) \
225 inw(Port)
226/** Read a 32-bit value from an I/O port. */
227#define VBVO_PORT_READ_U32(Port) \
228 inl(Port)
229
230/** @} */
231
232#endif
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette