VirtualBox

Changeset 68102 in vbox


Ignore:
Timestamp:
Jul 25, 2017 9:36:25 AM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
117154
Message:

R0 guest library: move HGCM globals out of global library structure.

bugref:8524: Additions/linux: play nicely with distribution-installed Additions
As part of elimitating dependencies of the HGCM R0 guest library code on the
rest of the library, move its global variables (handles and mutex) out of the
global library structure and into HGCM.cpp. The aim is to reduce the number
of library files included in the Linux shared folder driver.

Signed-off-by: Hans de Goede <hdegoede@…>
Reworked by Oracle.

Location:
trunk/src/VBox/Additions/common/VBoxGuestLib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuestLib/HGCM.cpp

    r62521 r68102  
    4040
    4141/**
    42  * Initializes the HGCM VBGL bits.
    43  *
    44  * @return VBox status code.
    45  */
    46 int vbglR0HGCMInit(void)
    47 {
    48     return RTSemFastMutexCreate(&g_vbgldata.mutexHGCMHandle);
    49 }
     42 * Fast heap for HGCM handles data.
     43 * @{
     44 */
     45
     46static RTSEMFASTMUTEX mutexHGCMHandle;
     47
     48static struct VBGLHGCMHANDLEDATA aHGCMHandleData[64];
     49
     50/** @} */
    5051
    5152/**
     
    5455 * @return VBox status code.
    5556 */
     57int vbglR0HGCMInit(void)
     58{
     59    AssertReturn(mutexHGCMHandle == NIL_RTSEMFASTMUTEX, VINF_ALREADY_INITIALIZED);
     60    return RTSemFastMutexCreate(&mutexHGCMHandle);
     61}
     62
     63/**
     64 * Initializes the HGCM VBGL bits.
     65 *
     66 * @return VBox status code.
     67 */
    5668int vbglR0HGCMTerminate(void)
    5769{
    58     RTSemFastMutexDestroy(g_vbgldata.mutexHGCMHandle);
    59     g_vbgldata.mutexHGCMHandle = NIL_RTSEMFASTMUTEX;
     70    RTSemFastMutexDestroy(mutexHGCMHandle);
     71    mutexHGCMHandle = NIL_RTSEMFASTMUTEX;
    6072
    6173    return VINF_SUCCESS;
     
    6476DECLINLINE(int) vbglHandleHeapEnter(void)
    6577{
    66     int rc = RTSemFastMutexRequest(g_vbgldata.mutexHGCMHandle);
     78    int rc = RTSemFastMutexRequest(mutexHGCMHandle);
    6779
    6880    VBGL_HGCM_ASSERT_MSG(RT_SUCCESS(rc), ("Failed to request handle heap mutex, rc = %Rrc\n", rc));
     
    7385DECLINLINE(void) vbglHandleHeapLeave(void)
    7486{
    75     RTSemFastMutexRelease(g_vbgldata.mutexHGCMHandle);
     87    RTSemFastMutexRelease(mutexHGCMHandle);
    7688}
    7789
     
    8698        /* Simple linear search in array. This will be called not so often, only connect/disconnect. */
    8799        /** @todo bitmap for faster search and other obvious optimizations. */
    88         for (i = 0; i < RT_ELEMENTS(g_vbgldata.aHGCMHandleData); i++)
     100        for (i = 0; i < RT_ELEMENTS(aHGCMHandleData); i++)
    89101        {
    90             if (!g_vbgldata.aHGCMHandleData[i].fAllocated)
     102            if (!aHGCMHandleData[i].fAllocated)
    91103            {
    92                 p = &g_vbgldata.aHGCMHandleData[i];
     104                p = &aHGCMHandleData[i];
    93105                p->fAllocated = 1;
    94106                break;
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBGLInternal.h

    r62841 r68102  
    108108
    109109    /** @} */
    110 
    111     /**
    112      * Fast heap for HGCM handles data.
    113      * @{
    114      */
    115 
    116     RTSEMFASTMUTEX mutexHGCMHandle;
    117 
    118     struct VBGLHGCMHANDLEDATA aHGCMHandleData[64];
    119 
    120     /** @} */
    121110#endif
    122111} VBGLDATA;
Note: See TracChangeset for help on using the changeset viewer.

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