VirtualBox

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

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

vboxvideo: scm updates (mit license formatting, 'this file is based on' instead of 'this code is based on').

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 6.5 KB
 
1/* $Id: VBoxVideoIPRT.h 69346 2017-10-26 13:36: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 AssertRC(expr) assert (!expr)
97#else
98# define Assert(expr) do { } while(0)
99# define AssertFailed() do { } while(0)
100# define AssertMsg(expr, msg) do { } while(0)
101# define AssertPtr(expr) do { } while(0)
102# define AssertRC(expr) do { } while(0)
103#endif
104
105#define DECLCALLBACK(type) type
106#define DECLCALLBACKMEMBER(type, name) type (* name)
107#if __GNUC__ >= 4
108# define DECLHIDDEN(type) __attribute__((visibility("hidden"))) type
109#else
110# define DECLHIDDEN(type) type
111#endif
112#define DECLINLINE(type) static __inline__ type
113
114#define _1K 1024
115#define ASMCompilerBarrier mem_barrier
116#define RT_BIT(bit) ( 1U << (bit) )
117#define RT_BOOL(Value) ( !!(Value) )
118#define RT_BZERO(pv, cb) do { memset((pv), 0, cb); } while (0)
119#define RT_CLAMP(Value, Min, Max) ( (Value) > (Max) ? (Max) : (Value) < (Min) ? (Min) : (Value) )
120#define RT_ELEMENTS(aArray) ( sizeof(aArray) / sizeof((aArray)[0]) )
121#define RTIOPORT unsigned short
122#define RT_NOREF(...) (void)(__VA_ARGS__)
123#define RT_OFFSETOF(type, member) offsetof(type, member)
124#define RT_ZERO(Obj) RT_BZERO(&(Obj), sizeof(Obj))
125#define VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U )
126#ifndef INT16_C
127# define INT16_C(Value) (Value)
128#endif
129#ifndef UINT16_C
130# define UINT16_C(Value) (Value)
131#endif
132#ifndef INT32_C
133# define INT32_C(Value) (Value ## U)
134#endif
135#ifndef UINT32_C
136# define UINT32_C(Value) (Value ## U)
137#endif
138
139#define likely _X_LIKELY
140#define unlikely _X_UNLIKELY
141
142/**
143 * A point in a two dimentional coordinate system.
144 */
145typedef struct RTPOINT
146{
147 /** X coordinate. */
148 int32_t x;
149 /** Y coordinate. */
150 int32_t y;
151} RTPOINT;
152
153/**
154 * Rectangle data type, double point.
155 */
156typedef struct RTRECT
157{
158 /** left X coordinate. */
159 int32_t xLeft;
160 /** top Y coordinate. */
161 int32_t yTop;
162 /** right X coordinate. (exclusive) */
163 int32_t xRight;
164 /** bottom Y coordinate. (exclusive) */
165 int32_t yBottom;
166} RTRECT;
167
168/**
169 * Rectangle data type, point + size.
170 */
171typedef struct RTRECT2
172{
173 /** X coordinate.
174 * Unless stated otherwise, this is the top left corner. */
175 int32_t x;
176 /** Y coordinate.
177 * Unless stated otherwise, this is the top left corner. */
178 int32_t y;
179 /** The width.
180 * Unless stated otherwise, this is to the right of (x,y) and will not
181 * be a negative number. */
182 int32_t cx;
183 /** The height.
184 * Unless stated otherwise, this is down from (x,y) and will not be a
185 * negative number. */
186 int32_t cy;
187} RTRECT2;
188
189/**
190 * The size of a rectangle.
191 */
192typedef struct RTRECTSIZE
193{
194 /** The width (along the x-axis). */
195 uint32_t cx;
196 /** The height (along the y-axis). */
197 uint32_t cy;
198} RTRECTSIZE;
199
200/** @name Port I/O helpers
201 * @{ */
202
203/** Write an 8-bit value to an I/O port. */
204#define VBVO_PORT_WRITE_U8(Port, Value) \
205 outb(Port, Value)
206/** Write a 16-bit value to an I/O port. */
207#define VBVO_PORT_WRITE_U16(Port, Value) \
208 outw(Port, Value)
209/** Write a 32-bit value to an I/O port. */
210#define VBVO_PORT_WRITE_U32(Port, Value) \
211 outl(Port, Value)
212/** Read an 8-bit value from an I/O port. */
213#define VBVO_PORT_READ_U8(Port) \
214 inb(Port)
215/** Read a 16-bit value from an I/O port. */
216#define VBVO_PORT_READ_U16(Port) \
217 inw(Port)
218/** Read a 32-bit value from an I/O port. */
219#define VBVO_PORT_READ_U32(Port) \
220 inl(Port)
221
222/** @} */
223
224#endif
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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