VirtualBox

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

Last change on this file since 85959 was 85123, checked in by vboxsync, 4 years ago

iprt/cdefs.h: Some cleaning up. bugref:9794

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

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