VirtualBox

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

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

*: Made RT_UOFFSETOF, RT_OFFSETOF, RT_UOFFSETOF_ADD and RT_OFFSETOF_ADD work like builtin_offsetof() and require compile time resolvable requests, adding RT_UOFFSETOF_DYN for the dynamic questions that can only be answered at runtime.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 7.0 KB
 
1/* $Id: VBoxVideoIPRT.h 73097 2018-07-12 21:06:33Z 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_UOFFSETOF(type, member) offsetof(type, member)
127#define RT_ZERO(Obj) RT_BZERO(&(Obj), sizeof(Obj))
128#define VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U )
129#ifndef INT16_C
130# define INT16_C(Value) (Value)
131#endif
132#ifndef UINT16_C
133# define UINT16_C(Value) (Value)
134#endif
135#ifndef INT32_C
136# define INT32_C(Value) (Value ## U)
137#endif
138#ifndef UINT32_C
139# define UINT32_C(Value) (Value ## U)
140#endif
141#define RT_UNTRUSTED_GUEST
142#define RT_UNTRUSTED_VOLATILE_GUEST volatile
143#define RT_UNTRUSTED_HOST
144#define RT_UNTRUSTED_VOLATILE_HOST volatile
145#define RT_UNTRUSTED_HSTGST
146#define RT_UNTRUSTED_VOLATILE_HSTGST volatile
147
148#define likely _X_LIKELY
149#define unlikely _X_UNLIKELY
150
151/**
152 * A point in a two dimentional coordinate system.
153 */
154typedef struct RTPOINT
155{
156 /** X coordinate. */
157 int32_t x;
158 /** Y coordinate. */
159 int32_t y;
160} RTPOINT;
161
162/**
163 * Rectangle data type, double point.
164 */
165typedef struct RTRECT
166{
167 /** left X coordinate. */
168 int32_t xLeft;
169 /** top Y coordinate. */
170 int32_t yTop;
171 /** right X coordinate. (exclusive) */
172 int32_t xRight;
173 /** bottom Y coordinate. (exclusive) */
174 int32_t yBottom;
175} RTRECT;
176
177/**
178 * Rectangle data type, point + size.
179 */
180typedef struct RTRECT2
181{
182 /** X coordinate.
183 * Unless stated otherwise, this is the top left corner. */
184 int32_t x;
185 /** Y coordinate.
186 * Unless stated otherwise, this is the top left corner. */
187 int32_t y;
188 /** The width.
189 * Unless stated otherwise, this is to the right of (x,y) and will not
190 * be a negative number. */
191 int32_t cx;
192 /** The height.
193 * Unless stated otherwise, this is down from (x,y) and will not be a
194 * negative number. */
195 int32_t cy;
196} RTRECT2;
197
198/**
199 * The size of a rectangle.
200 */
201typedef struct RTRECTSIZE
202{
203 /** The width (along the x-axis). */
204 uint32_t cx;
205 /** The height (along the y-axis). */
206 uint32_t cy;
207} RTRECTSIZE;
208
209/** @name Port I/O helpers
210 * @{ */
211
212/** Write an 8-bit value to an I/O port. */
213#define VBVO_PORT_WRITE_U8(Port, Value) \
214 outb(Port, Value)
215/** Write a 16-bit value to an I/O port. */
216#define VBVO_PORT_WRITE_U16(Port, Value) \
217 outw(Port, Value)
218/** Write a 32-bit value to an I/O port. */
219#define VBVO_PORT_WRITE_U32(Port, Value) \
220 outl(Port, Value)
221/** Read an 8-bit value from an I/O port. */
222#define VBVO_PORT_READ_U8(Port) \
223 inb(Port)
224/** Read a 16-bit value from an I/O port. */
225#define VBVO_PORT_READ_U16(Port) \
226 inw(Port)
227/** Read a 32-bit value from an I/O port. */
228#define VBVO_PORT_READ_U32(Port) \
229 inl(Port)
230
231/** @} */
232
233#endif
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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