VirtualBox

Ignore:
Timestamp:
Mar 24, 2010 10:14:20 PM (15 years ago)
Author:
vboxsync
Message:

Additons/common/VBoxGuestLibR3: make saving and restoring video modes work with XFree86 and clean up the code

Location:
trunk/src/VBox/Additions/common/VBoxGuestLib
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuestLib/Makefile.kmk

    r27602 r27687  
    149149        VBoxGuestR3LibMisc.cpp \
    150150        VBoxGuestR3LibSeamless.cpp \
    151         VBoxGuestR3LibVideo.cpp
     151        VBoxGuestR3LibVideo.cpp \
     152        VBoxGuestR3LibRuntimeXF86.cpp
     153VBoxGuestR3LibRuntimeXF86.cpp_CXXFLAGS = -Wno-shadow
    152154VBoxGuestR3LibXFree86_INCS     = \
    153155        $(VBOX_PATH_X11_XFREE_4_3)/programs/Xserver/hw/xfree86/common/ \
    154156        $(VBOX_PATH_X11_XFREE_4_3)/programs/Xserver/hw/xfree86/os-support \
    155157        $(VBOX_PATH_X11_XFREE_4_3)/programs/Xserver/include \
     158        $(VBOX_PATH_X11_XFREE_4_3)/include \
    156159        $(VBOX_PATH_X11_XFREE_4_3)/exports/include/X11
    157160
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBGLR3Internal.h

    r26425 r27687  
    3838#include <VBox/VBoxGuest.h>
    3939#include <VBox/VBoxGuestLib.h>
     40
     41#ifdef VBOX_VBGLR3_XFREE86
     42/* Rather than try to resolve all the header file conflicts, I will just
     43   prototype what we need here. */
     44typedef unsigned long xf86size_t;
     45extern "C" xf86size_t xf86strlen(const char*);
     46# undef strlen
     47# define strlen xf86strlen
     48#endif /* VBOX_VBGLR3_XFREE86 */
    4049
    4150RT_C_DECLS_BEGIN
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3Lib.cpp

    r26425 r27687  
    9999{
    100100    uint32_t cInits = ASMAtomicIncU32(&g_cInits);
    101 #ifndef VBOX_VBGLR3_XFREE86
    102101    Assert(cInits > 0);
    103 #endif
    104102    if (cInits > 1)
    105103    {
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibEvent.cpp

    r27083 r27687  
    5555VBGLR3DECL(int) VbglR3WaitEvent(uint32_t fMask, uint32_t cMillies, uint32_t *pfEvents)
    5656{
    57 #ifndef VBOX_VBGLR3_XFREE86
    5857    LogFlow(("VbglR3WaitEvent: fMask=0x%x, cMillies=%u, pfEvents=%p\n",
    5958             fMask, cMillies, pfEvents));
    6059    AssertReturn((fMask & ~VMMDEV_EVENT_VALID_EVENT_MASK) == 0, VERR_INVALID_PARAMETER);
    6160    AssertPtrNullReturn(pfEvents, VERR_INVALID_POINTER);
    62 #endif
    6361
    6462    VBoxGuestWaitEventInfo waitEvent;
     
    7068    if (RT_SUCCESS(rc))
    7169    {
    72 #if !defined(VBOX_VBGLR3_XFREE86) && !defined(RT_OS_WINDOWS)
    7370        AssertMsg(waitEvent.u32Result == VBOXGUEST_WAITEVENT_OK, ("%d rc=%Rrc\n", waitEvent.u32Result, rc));
    74 #endif
    7571        if (pfEvents)
    7672            *pfEvents = waitEvent.u32EventFlagsOut;
    7773    }
    7874
    79 #ifndef VBOX_VBGLR3_XFREE86
    8075    LogFlow(("VbglR3WaitEvent: rc=%Rrc, u32EventFlagsOut=0x%x. u32Result=%d\n",
    8176             rc, waitEvent.u32EventFlagsOut, waitEvent.u32Result));
    82 #endif
    8377    return rc;
    8478}
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibGR.cpp

    r26425 r27687  
    3333*   Header Files                                                               *
    3434*******************************************************************************/
    35 #ifdef VBOX_VBGLR3_XFREE86
    36 /* Rather than try to resolve all the header file conflicts, I will just
    37    prototype what we need here. */
    38 # define xalloc(size) Xalloc((unsigned long)(size))
    39 # define xfree(ptr) Xfree((pointer)(ptr))
    40 typedef void *pointer;
    41 extern "C" pointer Xalloc(unsigned long /*amount*/);
    42 extern "C" void Xfree(pointer /*ptr*/);
    43 #else
    44 # include <iprt/mem.h>
    45 # include <iprt/assert.h>
    46 # include <iprt/string.h>
    47 #endif
     35#include <iprt/mem.h>
     36#include <iprt/assert.h>
     37#include <iprt/string.h>
    4838#include <iprt/err.h>
    4939#include "VBGLR3Internal.h"
     
    5444    VMMDevRequestHeader *pReq;
    5545
    56 #ifdef VBOX_VBGLR3_XFREE86
    57     pReq = (VMMDevRequestHeader *)xalloc(cb);
    58 #else
    5946    AssertPtrReturn(ppReq, VERR_INVALID_PARAMETER);
    6047    AssertMsgReturn(cb >= sizeof(VMMDevRequestHeader), ("%#x vs %#zx\n", cb, sizeof(VMMDevRequestHeader)),
     
    6249
    6350    pReq = (VMMDevRequestHeader *)RTMemTmpAlloc(cb);
    64 #endif
    6551    if (RT_UNLIKELY(!pReq))
    6652        return VERR_NO_MEMORY;
     
    8773void vbglR3GRFree(VMMDevRequestHeader *pReq)
    8874{
    89 #ifdef VBOX_VBGLR3_XFREE86
    90     xfree(pReq);
    91 #else
    9275    RTMemTmpFree(pReq);
    93 #endif
    9476}
    9577
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibGuestProp.cpp

    r26425 r27687  
    4343#include "VBGLR3Internal.h"
    4444
     45#ifdef VBOX_VBGLR3_XFREE86
     46/* Rather than try to resolve all the header file conflicts, I will just
     47   prototype what we need here. */
     48extern "C" char* xf86strcpy(char*,const char*);
     49# undef strcpy
     50# define strcpy xf86strcpy
     51extern "C" void* xf86memchr(const void*,int,xf86size_t);
     52# undef memchr
     53# define memchr xf86memchr
     54#endif /* VBOX_VBGLR3_XFREE86 */
    4555
    4656/*******************************************************************************
     
    205215}
    206216
    207 
     217#ifndef VBOX_VBGLR3_XFREE86
    208218/**
    209219 * Write a property value where the value is formatted in RTStrPrintfV fashion.
     
    250260    return rc;
    251261}
    252 
     262#endif /* VBOX_VBGLR3_XFREE86 */
    253263
    254264/**
     
    347357}
    348358
    349 
     359#ifndef VBOX_VBGLR3_XFREE86
    350360/**
    351361 * Retrieve a property value, allocating space for it.
     
    427437    RTMemFree(pszValue);
    428438}
    429 
     439#endif /* VBOX_VBGLR3_XFREE86 */
    430440
    431441/**
     
    452462                                         uint32_t *pcchValueActual)
    453463{
    454     char *pszBuf = NULL;
    455     int rc = VbglR3GuestPropReadValueAlloc(u32ClientId, pszName, &pszBuf);
    456     if (RT_SUCCESS(rc))
    457     {
    458         size_t cchValueActual = strlen(pszBuf) + 1;
    459         if (cchValueActual <= cchValue)
    460             memcpy(pszValue, pszBuf, cchValueActual);
    461         else
    462         {
    463             if (pcchValueActual != NULL)
    464                 *pcchValueActual = (uint32_t)cchValueActual;
    465             rc = VERR_BUFFER_OVERFLOW;
    466         }
    467     }
    468     VbglR3GuestPropReadValueFree(pszBuf);
    469     return rc;
    470 }
    471 
    472 
     464    void *pvBuf = pszValue;
     465    uint32_t cchValueActual;
     466    int rc = VbglR3GuestPropRead(u32ClientId, pszName, pvBuf, cchValue,
     467                                 &pszValue, NULL, NULL, &cchValueActual);
     468    if (pcchValueActual != NULL)
     469        *pcchValueActual = cchValueActual;
     470    return rc;
     471}
     472
     473
     474#ifndef VBOX_VBGLR3_XFREE86
    473475/**
    474476 * Raw API for enumerating guest properties which match a given pattern.
     
    912914    return VINF_SUCCESS;
    913915}
    914 
     916#endif /* VBOX_VBGLR3_XFREE86 */
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibMisc.cpp

    r27083 r27687  
    7070    Req.u32NotMask = fNot;
    7171    int rc = vbglR3GRPerform(&Req.header);
    72 #if defined(DEBUG) && !defined(VBOX_VBGLR3_XFREE86)
     72#if defined(DEBUG)
    7373    if (RT_SUCCESS(rc))
    7474        LogRel(("Successfully changed guest capabilities: or mask 0x%x, not mask 0x%x.\n", fOr, fNot));
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibSeamless.cpp

    r27318 r27687  
    6767    int rc;
    6868
    69 #if !defined(VBOX_VBGLR3_XFREE86)
    7069    AssertPtrReturn(pMode, VERR_INVALID_PARAMETER);
    71 #endif
    7270    waitEvent.u32TimeoutIn = RT_INDEFINITE_WAIT;
    7371    waitEvent.u32EventMaskIn = VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST;
     
    111109    int rc;
    112110
    113 #if !defined(VBOX_VBGLR3_XFREE86)
    114111    AssertPtrReturn(pMode, VERR_INVALID_PARAMETER);
    115 #endif
    116112
    117113    /* get the seamless change request */
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibVideo.cpp

    r27508 r27687  
    151151    VMMDevDisplayChangeRequest2 Req;
    152152
    153 #ifndef VBOX_VBGLR3_XFREE86
    154153    AssertPtrReturn(pcx, VERR_INVALID_PARAMETER);
    155154    AssertPtrReturn(pcy, VERR_INVALID_PARAMETER);
    156155    AssertPtrReturn(pcBits, VERR_INVALID_PARAMETER);
    157156    AssertPtrReturn(piDisplay, VERR_INVALID_PARAMETER);
    158 #endif
    159157    RT_ZERO(Req);
    160158    vmmdevInitRequest(&Req.header, VMMDevReq_GetDisplayChangeRequest2);
     
    212210VBGLR3DECL(int) VbglR3SaveVideoMode(const char *pszName, uint32_t cx, uint32_t cy, uint32_t cBits)
    213211{
    214 #if defined(VBOX_WITH_GUEST_PROPS) && !defined(VBOX_VBGLR3_XFREE86)
     212#if defined(VBOX_WITH_GUEST_PROPS)
    215213    using namespace guestProp;
    216214
     
    226224        VbglR3GuestPropDisconnect(u32ClientId);  /* Return value ignored, because what can we do anyway? */
    227225    return rc;
    228 #else /* !VBOX_WITH_GUEST_PROPS || VBOX_VBGLR3_XFREE86 */
     226#else /* !VBOX_WITH_GUEST_PROPS */
    229227    return VERR_NOT_IMPLEMENTED;
    230 #endif /* !VBOX_WITH_GUEST_PROPS || VBOX_VBGLR3_XFREE86 */
     228#endif /* !VBOX_WITH_GUEST_PROPS */
    231229}
    232230
     
    243241VBGLR3DECL(int) VbglR3RetrieveVideoMode(const char *pszName, uint32_t *pcx, uint32_t *pcy, uint32_t *pcBits)
    244242{
    245 #if defined(VBOX_WITH_GUEST_PROPS) && !defined(VBOX_VBGLR3_XFREE86)
     243#if defined(VBOX_WITH_GUEST_PROPS)
    246244    using namespace guestProp;
    247245
     
    304302    }
    305303    return rc;
    306 #else /* !VBOX_WITH_GUEST_PROPS || VBOX_VBGLR3_XFREE86 */
     304#else /* !VBOX_WITH_GUEST_PROPS */
    307305    return VERR_NOT_IMPLEMENTED;
    308 #endif /* !VBOX_WITH_GUEST_PROPS || VBOX_VBGLR3_XFREE86 */
    309 }
     306#endif /* !VBOX_WITH_GUEST_PROPS */
     307}
Note: See TracChangeset for help on using the changeset viewer.

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