VirtualBox

Changeset 85121 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
Jul 8, 2020 7:33:26 PM (5 years ago)
Author:
vboxsync
Message:

iprt/cdefs.h: Refactored the typedef use of DECLCALLBACK as well as DECLCALLBACKMEMBER to wrap the whole expression, similar to the DECLR?CALLBACKMEMBER macros. This allows adding a throw() at the end when compiling with the VC++ compiler to indicate that the callbacks won't throw anything, so we can stop supressing the C5039 warning about passing functions that can potential throw C++ exceptions to extern C code that can't necessarily cope with such (unwind,++). Introduced a few _EX variations that allows specifying different/no calling convention too, as that's handy when dynamically resolving host APIs. Fixed numerous places missing DECLCALLBACK and such. Left two angry @todos regarding use of CreateThread. bugref:9794

Location:
trunk/src/VBox/Main/src-server
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/HostVideoInputDeviceImpl.cpp

    r82968 r85121  
    119119
    120120/** @todo These typedefs must be in a header. */
    121 typedef DECLCALLBACK(int) FNVBOXHOSTWEBCAMADD(void *pvUser,
    122                                               const char *pszName,
    123                                               const char *pszPath,
    124                                               const char *pszAlias,
    125                                               uint64_t *pu64Result);
     121typedef DECLCALLBACKTYPE(int, FNVBOXHOSTWEBCAMADD,(void *pvUser,
     122                                                   const char *pszName,
     123                                                   const char *pszPath,
     124                                                   const char *pszAlias,
     125                                                   uint64_t *pu64Result));
    126126typedef FNVBOXHOSTWEBCAMADD *PFNVBOXHOSTWEBCAMADD;
    127127
    128 typedef DECLCALLBACK(int) FNVBOXHOSTWEBCAMLIST(PFNVBOXHOSTWEBCAMADD pfnWebcamAdd,
    129                                                void *pvUser,
    130                                                uint64_t *pu64WebcamAddResult);
     128typedef DECLCALLBACKTYPE(int, FNVBOXHOSTWEBCAMLIST,(PFNVBOXHOSTWEBCAMADD pfnWebcamAdd,
     129                                                    void *pvUser,
     130                                                    uint64_t *pu64WebcamAddResult));
    131131typedef FNVBOXHOSTWEBCAMLIST *PFNVBOXHOSTWEBCAMLIST;
    132132
  • trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp

    r84343 r85121  
    18441844
    18451845#ifdef DEBUG
     1846typedef DECLCALLBACKTYPE(void, FNTESTPRINTF,(const char *, ...));
    18461847/** Simple unit test/operation examples for sanitiseMachineFilename(). */
    1847 static unsigned testSanitiseMachineFilename(DECLCALLBACKMEMBER(void, pfnPrintf)(const char *, ...))
     1848static unsigned testSanitiseMachineFilename(FNTESTPRINTF *pfnPrintf)
    18481849{
    18491850    unsigned cErrors = 0;
  • trunk/src/VBox/Main/src-server/win/svcmain.cpp

    r83794 r85121  
    9797
    9898/** Passed to CreateThread to monitor the shutdown event. */
    99 static DWORD WINAPI MonitorProc(void *pv)
     99static DWORD WINAPI MonitorProc(void *pv) RT_NOTHROW_DEF
    100100{
    101101    CExeModule *p = (CExeModule *)pv;
     
    594594static BOOL ShutdownBlockReasonCreateAPI(HWND hWnd, LPCWSTR pwszReason)
    595595{
     596    typedef DECLCALLBACKPTR_EX(BOOL, WINAPI, PFNSHUTDOWNBLOCKREASONCREATE,(HWND hWnd, LPCWSTR pwszReason));
     597
     598    PFNSHUTDOWNBLOCKREASONCREATE pfn
     599        = (PFNSHUTDOWNBLOCKREASONCREATE)GetProcAddress(GetModuleHandle(L"User32.dll"), "ShutdownBlockReasonCreate");
     600    AssertPtr(pfn);
     601
    596602    BOOL fResult = FALSE;
    597     typedef BOOL(WINAPI *PFNSHUTDOWNBLOCKREASONCREATE)(HWND hWnd, LPCWSTR pwszReason);
    598 
    599     PFNSHUTDOWNBLOCKREASONCREATE pfn = (PFNSHUTDOWNBLOCKREASONCREATE)GetProcAddress(
    600             GetModuleHandle(L"User32.dll"), "ShutdownBlockReasonCreate");
    601     AssertPtr(pfn);
    602603    if (pfn)
    603604        fResult = pfn(hWnd, pwszReason);
     
    611612static BOOL ShutdownBlockReasonDestroyAPI(HWND hWnd)
    612613{
     614    typedef DECLCALLBACKPTR_EX(BOOL, WINAPI, PFNSHUTDOWNBLOCKREASONDESTROY,(HWND hWnd));
     615    PFNSHUTDOWNBLOCKREASONDESTROY pfn
     616        = (PFNSHUTDOWNBLOCKREASONDESTROY)GetProcAddress(GetModuleHandle(L"User32.dll"), "ShutdownBlockReasonDestroy");
     617    AssertPtr(pfn);
     618
    613619    BOOL fResult = FALSE;
    614     typedef BOOL(WINAPI *PFNSHUTDOWNBLOCKREASONDESTROY)(HWND hWnd);
    615 
    616     PFNSHUTDOWNBLOCKREASONDESTROY pfn = (PFNSHUTDOWNBLOCKREASONDESTROY)GetProcAddress(
    617         GetModuleHandle(L"User32.dll"), "ShutdownBlockReasonDestroy");
    618     AssertPtr(pfn);
    619620    if (pfn)
    620621        fResult = pfn(hWnd);
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