Changeset 6538 in vbox for trunk/src/VBox/Additions/common
- Timestamp:
- Jan 28, 2008 7:50:14 PM (17 years ago)
- Location:
- trunk/src/VBox/Additions/common/VBoxGuestLib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuestLib/Makefile.kmk
r6494 r6538 48 48 endif 49 49 LIBRARIES += \ 50 VBoxGuestR3LibLinux 50 VBoxGuestR3LibLinux \ 51 VBoxGuestR3LibLinuxXFree86 51 52 endif 52 53 ifdef VBOX_WITH_OS2_ADDITIONS … … 92 93 93 94 # 94 # VBoxGuestR3Lib Base95 # VBoxGuestR3Lib 95 96 # 96 97 VBoxGuestR3Lib_TEMPLATE = VBOXGUESTR3LIB … … 107 108 VBoxGuestR3LibVideo.cpp 108 109 110 # 111 # VBoxGuestR3LibXFree86 - a reduced version of the guest library which uses 112 # the X server runtime instead of iprt, for use with old servers where the 113 # C library is not available. 114 # 115 VBoxGuestR3LibXFree86_SOURCES = \ 116 VBoxGuestR3Lib.cpp \ 117 VBoxGuestR3LibGR.cpp \ 118 VBoxGuestR3LibMouse.cpp \ 119 VBoxGuestR3LibMisc.cpp \ 120 VBoxGuestR3LibVideo.cpp 109 121 110 122 … … 154 166 155 167 # 156 # VBoxGuestR3Lib BaseLinux168 # VBoxGuestR3LibLinux 157 169 # 158 170 VBoxGuestR3LibLinux_TEMPLATE = VBOXLNX32GUESTR3LIB 159 171 VBoxGuestR3LibLinux_SOURCES = $(VBoxGuestR3Lib_SOURCES) 160 172 VBoxGuestR3LibLinux_DEFS = VBOX_HGCM 173 174 175 # 176 # VBoxGuestR3LibLinuxXFree86 177 # 178 VBoxGuestR3LibLinuxXFree86_TEMPLATE = VBOXLNX32GUESTR3LIB 179 VBoxGuestR3LibLinuxXFree86_SOURCES = $(VBoxGuestR3LibXFree86_SOURCES) 180 VBoxGuestR3LibLinuxXFree86_DEFS = VBOX_HGCM VBOX_VBGLR3_XFREE86 181 VBoxGuestR3LibLinuxXFree86_INCS = \ 182 ../../x11/x11include/4.2/programs/Xserver/hw/xfree86/common/ \ 183 ../../x11/x11include/4.2/programs/Xserver/hw/xfree86/os-support \ 184 ../../x11/x11include/4.2/programs/Xserver/include \ 185 ../../x11/x11include/4.2/exports/include/X11 161 186 162 187 -
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3Lib.cpp
r6470 r6538 34 34 #include <iprt/asm.h> 35 35 #include <iprt/string.h> 36 #include <iprt/file.h> 37 #include <iprt/assert.h> 38 #include <iprt/mem.h> 39 #include <iprt/alloca.h> 36 #ifdef VBOX_VBGLR3_XFREE86 37 /* Definitions for X server library functions such as xf86open and mappings to C functions. */ 38 /* Make the headers C++-compatible */ 39 # define class xf86_vbox_class 40 # define bool xf86_vbox_bool 41 # define private xf86_vbox_private 42 # define new xf86_vbox_new 43 extern "C" 44 { 45 # include "xf86.h" 46 # include "xf86_OSproc.h" 47 # include "xf86Resources.h" 48 # include "xf86_ansic.h" 49 } 50 # undef class 51 # undef bool 52 # undef private 53 # undef new 54 #else 55 # include <iprt/file.h> 56 # include <iprt/assert.h> 57 # include <iprt/thread.h> 58 #endif 40 59 #include <VBox/VBoxGuest.h> 41 60 #include "VBGLR3Internal.h" … … 46 65 *******************************************************************************/ 47 66 /** The VBoxGuest device handle. */ 67 #ifdef VBOX_VBGLR3_XFREE86 68 static int g_File = -1; 69 #else 48 70 static RTFILE g_File = NIL_RTFILE; 49 71 #endif 72 /** 73 * A counter of the number of times the library has been initialised, for use with 74 * X.org drivers, where the library may be shared by multiple independant modules 75 * inside a single process space. 76 */ 77 static uint32_t g_cInits = 0; 50 78 51 79 VBGLR3DECL(int) VbglR3Init(void) 52 80 { 53 if (g_File != NIL_RTFILE) 81 uint32_t cInits = ASMAtomicIncU32(&g_cInits); 82 #ifdef VBOX_VBGLR3_XFREE86 83 if (1 != cInits) 54 84 return VINF_SUCCESS; 85 if (-1 != g_File) 86 return VERR_INTERNAL_ERROR; 87 #else 88 Assert(cInits > 0); 89 if (1 > cInits) 90 { 91 /* This will not work when the library is shared inside a multi-threaded 92 process. Hopefully no-one will try that, as we can't use the threads 93 APIs here. */ 94 if (NIL_RTFILE == g_File) 95 return VERR_INTERNAL_ERROR; 96 return VINF_SUCCESS; 97 } 98 if (NIL_RTFILE != g_File) 99 return VERR_INTERNAL_ERROR; 100 #endif 55 101 56 102 #if defined(RT_OS_OS2) … … 105 151 g_File = hf; 106 152 107 /* PORTME */ 153 #elif defined(VBOX_VBGLR3_XFREE86) 154 int File = open(VBOXGUEST_DEVICE_NAME, O_RDWR); 155 if (-1 == File) 156 { 157 return VERR_UNRESOLVED_ERROR; 158 } 159 g_File = File; 160 108 161 #else 109 162 /* the default implemenation. (linux, solaris) */ … … 122 175 VBGLR3DECL(void) VbglR3Term(void) 123 176 { 177 uint32_t cInits = ASMAtomicDecU32(&g_cInits); 178 if (cInits > 0) 179 return; 180 #ifndef VBOX_VBGLR3_XFREE86 181 AssertReturnVoid(0 == cInits); 124 182 RTFILE File = g_File; 125 183 g_File = NIL_RTFILE; 126 if (File == NIL_RTFILE) 184 AssertReturnVoid(NIL_RTFILE != File); 185 #else 186 int File = g_File; 187 g_File = -1; 188 if (-1 == File) 127 189 return; 190 #endif 128 191 #if defined(RT_OS_OS2) 129 192 APIRET rc = DosClose(File); 130 193 AssertMsg(!rc, ("%ld\n", rc)); 194 #elif defined(VBOX_VBGLR3_XFREE86) 195 /* if (-1 == close(File)) 196 { 197 int iErr = errno; 198 AssertRC(RTErrConvertFromErrno(iErr)); 199 } */ 200 close(File); /* iprt is not available here. */ 201 File = -1; 131 202 #else 132 203 int rc = RTFileClose(File); … … 171 242 int rc = ioctl((int)g_File, iFunction, &Hdr); 172 243 if (rc == -1) 244 { 173 245 rc = errno; 174 return rc; 246 return RTErrConvertFromErrno(rc); 247 } 248 return VINF_SUCCESS; 175 249 176 250 #else 177 251 /* Default implementation - PORTME: Do not use this without testings that error passing works! */ 252 # ifdef VBOX_VBGLR3_XFREE86 253 int rc = ioctl(g_File, (int) iFunction, pvData); 254 if (rc == -1) 255 { 256 rc = errno; 257 return RTErrConvertFromErrno(rc); 258 } 259 return VINF_SUCCESS; 260 # else 178 261 int rc2 = VERR_INTERNAL_ERROR; 179 262 int rc = RTFileIoCtl(g_File, (int)iFunction, pvData, cbData, &rc2); … … 181 264 rc = rc2; 182 265 return rc; 183 #endif 184 } 185 266 # endif 267 #endif 268 } 269 -
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibGR.cpp
r6470 r6538 20 20 * Header Files * 21 21 *******************************************************************************/ 22 #include <iprt/mem.h> 23 #include <iprt/assert.h> 24 #include <iprt/string.h> 22 #ifdef VBOX_VBGLR3_XFREE86 23 /* For the definitions of standard X server library functions like xalloc. */ 24 /* Make the headers C++-compatible */ 25 # define class xf86_vbox_class 26 # define bool xf86_vbox_bool 27 # define private xf86_vbox_private 28 # define new xf86_vbox_new 29 extern "C" 30 { 31 # include "xf86.h" 32 # include "xf86_OSproc.h" 33 # include "xf86Resources.h" 34 # include "xf86_ansic.h" 35 } 36 # undef class 37 # undef bool 38 # undef private 39 # undef new 40 #else 41 # include <iprt/mem.h> 42 # include <iprt/assert.h> 43 # include <iprt/string.h> 44 #endif 25 45 #include <iprt/err.h> 26 46 #include <VBox/VBoxGuest.h> … … 32 52 VMMDevRequestHeader *pReq; 33 53 54 #ifdef VBOX_VBGLR3_XFREE86 55 pReq = (VMMDevRequestHeader *)xalloc(cb); 56 #else 34 57 AssertPtrReturn(ppReq, VERR_INVALID_PARAMETER); 35 58 AssertMsgReturn(cb >= sizeof(VMMDevRequestHeader), ("%#x vs %#zx\n", cb, sizeof(VMMDevRequestHeader)), … … 37 60 38 61 pReq = (VMMDevRequestHeader *)RTMemTmpAlloc(cb); 62 #endif 39 63 if (RT_UNLIKELY(!pReq)) 40 64 return VERR_NO_MEMORY; … … 61 85 void vbglR3GRFree(VMMDevRequestHeader *pReq) 62 86 { 87 #ifdef VBOX_VBGLR3_XFREE86 88 xfree(pReq); 89 #else 63 90 RTMemTmpFree(pReq); 91 #endif 64 92 } 65 93 -
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibMisc.cpp
r6531 r6538 20 20 * Header Files * 21 21 *******************************************************************************/ 22 #include <iprt/assert.h> 22 #ifndef VBOX_VBGLR3_XFREE86 23 # include <iprt/assert.h> 24 #endif 23 25 #include "VBGLR3Internal.h" 24 26
Note:
See TracChangeset
for help on using the changeset viewer.