VirtualBox

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

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.3 KB
Line 
1/* $Id: VBoxVideoIPRT.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/*
3 * Copyright (C) 2017-2023 Oracle and/or its affiliates.
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
31#ifndef VBOX_INCLUDED_Graphics_VBoxVideoIPRT_h
32#define VBOX_INCLUDED_Graphics_VBoxVideoIPRT_h
33#ifndef RT_WITHOUT_PRAGMA_ONCE
34# pragma once
35#endif
36
37# include "VBoxVideoErr.h"
38
39#ifndef __cplusplus
40typedef enum
41{
42 false = 0,
43 true
44} bool;
45# define RT_C_DECLS_BEGIN
46# define RT_C_DECLS_END
47#else
48# define RT_C_DECLS_BEGIN extern "C" {
49# define RT_C_DECLS_END }
50#endif
51
52#if defined(IN_XF86_MODULE) && !defined(NO_ANSIC)
53# ifdef __cplusplus
54/* xf86Module.h redefines this. */
55# define NULL 0
56# endif
57RT_C_DECLS_BEGIN
58# include "xf86_ansic.h"
59RT_C_DECLS_END
60#endif /* defined(IN_XF86_MODULE) && !defined(NO_ANSIC) */
61#define __STDC_LIMIT_MACROS /* define *INT*_MAX on C++ too. */
62#include "compiler.h" /* Can pull in <sdtint.h>. Must come after xf86_ansic.h on XFree86. */
63#include <X11/Xfuncproto.h>
64#include <stdint.h>
65#if defined(IN_XF86_MODULE) && !defined(NO_ANSIC)
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
75/* XFree86 (and newer Xfuncproto.h) do not have these. Not that I care much for micro-optimisations
76 * in most cases anyway. */
77#ifndef _X_LIKELY
78# define _X_LIKELY(x) (x)
79#endif
80#ifndef _X_UNLIKELY
81# define _X_UNLIKELY(x) (x)
82#endif
83
84RT_C_DECLS_BEGIN
85extern int RTASSERTVAR[1];
86RT_C_DECLS_END
87
88#define AssertCompile(expr) \
89 extern int RTASSERTVAR[1] __attribute__((__unused__)), \
90 RTASSERTVAR[(expr) ? 1 : 0] __attribute__((__unused__))
91#define AssertCompileSize(type, size) \
92 AssertCompile(sizeof(type) == (size))
93#define AssertPtrNullReturnVoid(a) do { } while(0)
94
95#if !defined(IN_XF86_MODULE) && defined(DEBUG)
96# include <assert.h>
97# define Assert assert
98# define AssertFailed() assert(0)
99# define AssertMsg(expr, msg) \
100 do { \
101 if (!(expr)) xf86ErrorF msg; \
102 assert((expr)); \
103 } while (0)
104# define AssertPtr assert
105# define AssertPtrReturn(pv, rcRet) do { assert(pv); if (pv) {} else return(rcRet); } while(0)
106# define AssertRC(expr) assert (!expr)
107#else
108# define Assert(expr) do { } while(0)
109# define AssertFailed() do { } while(0)
110# define AssertMsg(expr, msg) do { } while(0)
111# define AssertPtr(ptr) do { } while(0)
112# define AssertPtrReturn(pv, rcRet) do { if (pv) {} else return(rcRet); } while(0)
113# define AssertRC(expr) do { } while(0)
114#endif
115
116#define DECLCALLBACK(a_RetType) a_RetType
117#define DECLCALLBACKTYPE(a_RetType, a_Name, a_Args) a_RetType a_Name a_Args
118#define DECLCALLBACKMEMBER(a_RetType, a_Name, a_Args) a_RetType (*a_Name) a_Args
119#if __GNUC__ >= 4
120# define DECLHIDDEN(type) __attribute__((visibility("hidden"))) type
121#else
122# define DECLHIDDEN(type) type
123#endif
124#define DECLINLINE(type) static __inline__ type
125
126#define _1K 1024
127#define ASMCompilerBarrier mem_barrier
128#define RT_BIT(bit) ( 1U << (bit) )
129#define RT_BOOL(Value) ( !!(Value) )
130#define RT_BZERO(pv, cb) do { memset((pv), 0, cb); } while (0)
131#define RT_CLAMP(Value, Min, Max) ( (Value) > (Max) ? (Max) : (Value) < (Min) ? (Min) : (Value) )
132#define RT_ELEMENTS(aArray) ( sizeof(aArray) / sizeof((aArray)[0]) )
133#define RTIOPORT unsigned short
134#define RT_NOREF(...) (void)(__VA_ARGS__)
135#define RT_OFFSETOF(type, member) offsetof(type, member)
136#define RT_UOFFSETOF(type, member) offsetof(type, member)
137#define RT_ZERO(Obj) RT_BZERO(&(Obj), sizeof(Obj))
138#define RT_VALID_PTR(ptr) ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U )
139#ifndef INT16_C
140# define INT16_C(Value) (Value)
141#endif
142#ifndef UINT16_C
143# define UINT16_C(Value) (Value)
144#endif
145#ifndef INT32_C
146# define INT32_C(Value) (Value ## U)
147#endif
148#ifndef UINT32_C
149# define UINT32_C(Value) (Value ## U)
150#endif
151#define RT_UNTRUSTED_GUEST
152#define RT_UNTRUSTED_VOLATILE_GUEST volatile
153#define RT_UNTRUSTED_HOST
154#define RT_UNTRUSTED_VOLATILE_HOST volatile
155#define RT_UNTRUSTED_HSTGST
156#define RT_UNTRUSTED_VOLATILE_HSTGST volatile
157
158#define likely _X_LIKELY
159#define unlikely _X_UNLIKELY
160
161/**
162 * A point in a two dimentional coordinate system.
163 */
164typedef struct RTPOINT
165{
166 /** X coordinate. */
167 int32_t x;
168 /** Y coordinate. */
169 int32_t y;
170} RTPOINT;
171
172/**
173 * Rectangle data type, double point.
174 */
175typedef struct RTRECT
176{
177 /** left X coordinate. */
178 int32_t xLeft;
179 /** top Y coordinate. */
180 int32_t yTop;
181 /** right X coordinate. (exclusive) */
182 int32_t xRight;
183 /** bottom Y coordinate. (exclusive) */
184 int32_t yBottom;
185} RTRECT;
186
187/**
188 * Rectangle data type, point + size.
189 */
190typedef struct RTRECT2
191{
192 /** X coordinate.
193 * Unless stated otherwise, this is the top left corner. */
194 int32_t x;
195 /** Y coordinate.
196 * Unless stated otherwise, this is the top left corner. */
197 int32_t y;
198 /** The width.
199 * Unless stated otherwise, this is to the right of (x,y) and will not
200 * be a negative number. */
201 int32_t cx;
202 /** The height.
203 * Unless stated otherwise, this is down from (x,y) and will not be a
204 * negative number. */
205 int32_t cy;
206} RTRECT2;
207
208/**
209 * The size of a rectangle.
210 */
211typedef struct RTRECTSIZE
212{
213 /** The width (along the x-axis). */
214 uint32_t cx;
215 /** The height (along the y-axis). */
216 uint32_t cy;
217} RTRECTSIZE;
218
219/** @name Port I/O helpers
220 * @{ */
221
222/** Write an 8-bit value to an I/O port. */
223#define VBVO_PORT_WRITE_U8(Port, Value) \
224 outb(Port, Value)
225/** Write a 16-bit value to an I/O port. */
226#define VBVO_PORT_WRITE_U16(Port, Value) \
227 outw(Port, Value)
228/** Write a 32-bit value to an I/O port. */
229#define VBVO_PORT_WRITE_U32(Port, Value) \
230 outl(Port, Value)
231/** Read an 8-bit value from an I/O port. */
232#define VBVO_PORT_READ_U8(Port) \
233 inb(Port)
234/** Read a 16-bit value from an I/O port. */
235#define VBVO_PORT_READ_U16(Port) \
236 inw(Port)
237/** Read a 32-bit value from an I/O port. */
238#define VBVO_PORT_READ_U32(Port) \
239 inl(Port)
240
241/** @} */
242
243#endif /* !VBOX_INCLUDED_Graphics_VBoxVideoIPRT_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use