VirtualBox

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

Last change on this file since 69085 was 69085, checked in by vboxsync, 7 years ago

Additions/x11/vboxvideo: always pull in stdint.h, even on XFree86.
bugref:9017: Additions/x11: put vboxvideo into upstream X.Org

Because XFree86 tried to provide its own versions of everything, including
part of the standard C library, including standard headers when building
XFree86 libraries tends to cause problems, and I was trying to recreate
part of stdint.h in the IPRT replacement header file. Reading the XFree86
header files and testing seem to indicate though that including stdint.h is
doable. So this change removes the stdint.h replacement code, which was
causing build problems on Debian 9.0, and includes stdint.h unconditionally.

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