VirtualBox

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


Ignore:
Timestamp:
Jul 8, 2020 7:33:26 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
139061
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
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/Makefile.kmk

    r85007 r85121  
    14431443                '# pragma warning(disable:4005)' \
    14441444                '#endif' \
     1445                '#if _MSC_VER >= 1900 /* RT_MSC_VER_VC140 */' \
     1446                '# pragma warning(disable:5039)' \
     1447                '#endif' \
    14451448               ''
    14461449        $(QUIET)$(CAT_EXT) "$1.tmp" >> "$1"
  • trunk/src/VBox/Main/cbinding/capiidl.xsl

    r82970 r85121  
    9696
    9797#ifdef _WIN32
    98 # pragma warning(push)
    99 # pragma warning(disable:4668 4255) /* -Wall and windows.h */
    100 # if _MSC_VER >= 1800 /*RT_MSC_VER_VC120*/
    101 #  pragma warning(disable:4005) /* sdk/v7.1/include/sal_supp.h(57) : warning C4005: '__useHeader' : macro redefinition */
     98# ifdef _MSC_VER
     99#  pragma warning(push)
     100#  pragma warning(disable:4668 4255) /* -Wall and windows.h */
     101#  if _MSC_VER >= 1800 /*RT_MSC_VER_VC120*/
     102#   pragma warning(disable:4005) /* sdk/v7.1/include/sal_supp.h(57) : warning C4005: '__useHeader' : macro redefinition */
     103#  endif
     104#  ifdef __cplusplus
     105#   if _MSC_VER >= 1900 /*RT_MSC_VER_VC140*/
     106#    pragma warning(disable:5039) /* winbase.h(13179): warning C5039: 'TpSetCallbackCleanupGroup': pointer or reference to potentially throwing function passed to 'extern "C"' function under -EHc. Undefined behavior may occur if this function throws an exception. */
     107#   endif
     108#  endif
    102109# endif
    103110# undef COBJMACROS
  • trunk/src/VBox/Main/glue/initterm.cpp

    r82968 r85121  
    201201 * Replacement function for the InvokeStub method for the IRundown stub.
    202202 */
    203 static HRESULT STDMETHODCALLTYPE Rundown_InvokeStub(IRpcStubBuffer *pThis, RPCOLEMESSAGE *pMsg, IRpcChannelBuffer *pBuf)
     203static HRESULT STDMETHODCALLTYPE
     204Rundown_InvokeStub(IRpcStubBuffer *pThis, RPCOLEMESSAGE *pMsg, IRpcChannelBuffer *pBuf) RT_NOTHROW_DEF
    204205{
    205206    /*
     
    422423                    {
    423424                        void *pv;
    424                         DECLCALLBACKMEMBER(uint32_t, pfnRegUpdate)(void);
     425                        DECLCALLBACKMEMBER(uint32_t, pfnRegUpdate,(void));
    425426                    } u;
    426427                    vrc = RTLdrGetSymbol(hMod, "VbpsUpdateRegistrations", &u.pv);
  • trunk/src/VBox/Main/include/DisplayImpl.h

    r84740 r85121  
    410410public:
    411411
    412     static int i_displayTakeScreenshotEMT(Display *pDisplay, ULONG aScreenId, uint8_t **ppbData, size_t *pcbData,
    413                                           uint32_t *pcx, uint32_t *pcy, bool *pfMemFree);
     412    static DECLCALLBACK(int) i_displayTakeScreenshotEMT(Display *pDisplay, ULONG aScreenId, uint8_t **ppbData, size_t *pcbData,
     413                                                        uint32_t *pcx, uint32_t *pcy, bool *pfMemFree);
    414414
    415415private:
    416     static int i_InvalidateAndUpdateEMT(Display *pDisplay, unsigned uId, bool fUpdateAll);
    417     static int i_drawToScreenEMT(Display *pDisplay, ULONG aScreenId, BYTE *address, ULONG x, ULONG y, ULONG width, ULONG height);
     416    static DECLCALLBACK(int) i_InvalidateAndUpdateEMT(Display *pDisplay, unsigned uId, bool fUpdateAll);
     417    static DECLCALLBACK(int) i_drawToScreenEMT(Display *pDisplay, ULONG aScreenId, BYTE *address, ULONG x, ULONG y,
     418                                               ULONG width, ULONG height);
    418419
    419420    void i_updateGuestGraphicsFacility(void);
  • trunk/src/VBox/Main/include/GuestDnDPrivate.h

    r85018 r85121  
    953953
    954954/** Guest DnD callback function definition. */
    955 typedef DECLCALLBACKPTR(int, PFNGUESTDNDCALLBACK) (uint32_t uMsg, void *pvParms, size_t cbParms, void *pvUser);
     955typedef DECLCALLBACKPTR(int, PFNGUESTDNDCALLBACK,(uint32_t uMsg, void *pvParms, size_t cbParms, void *pvUser));
    956956
    957957/**
  • trunk/src/VBox/Main/include/HGCMThread.h

    r82968 r85121  
    5555 *         (shouldn't happen).
    5656 */
    57 typedef DECLCALLBACK(int) HGCMMSGCALLBACK(int32_t result, HGCMMsgCore *pMsgCore);
     57typedef DECLCALLBACKTYPE(int, FNHGCMMSGCALLBACK,(int32_t result, HGCMMsgCore *pMsgCore));
    5858/** Pointer to a message completeion callback function. */
    59 typedef HGCMMSGCALLBACK *PHGCMMSGCALLBACK;
     59typedef FNHGCMMSGCALLBACK *PFNHGCMMSGCALLBACK;
    6060
    6161
     
    7676
    7777        /** Callback function pointer. */
    78         PHGCMMSGCALLBACK m_pfnCallback;
     78        PFNHGCMMSGCALLBACK m_pfnCallback;
    7979
    8080        /** Next element in a message queue. */
     
    115115 *  @param pvUser        User specified thread parameter.
    116116 */
    117 typedef DECLCALLBACK(void) FNHGCMTHREAD(HGCMThread *pThread, void *pvUser);
     117typedef DECLCALLBACKTYPE(void, FNHGCMTHREAD,(HGCMThread *pThread, void *pvUser));
    118118typedef FNHGCMTHREAD *PFNHGCMTHREAD;
    119119
     
    179179 * @thread any
    180180 */
    181 int hgcmMsgPost(HGCMMsgCore *pMsg, PHGCMMSGCALLBACK pfnCallback);
     181int hgcmMsgPost(HGCMMsgCore *pMsg, PFNHGCMMSGCALLBACK pfnCallback);
    182182
    183183/** Send a message to HGCM worker thread.
  • trunk/src/VBox/Main/include/MachineDebuggerImpl.h

    r82968 r85121  
    141141
    142142    /** RTLogGetFlags, RTLogGetGroupSettings and RTLogGetDestinations function. */
    143     typedef DECLCALLBACK(int) FNLOGGETSTR(PRTLOGGER, char *, size_t);
     143    typedef DECLCALLBACKTYPE(int, FNLOGGETSTR,(PRTLOGGER, char *, size_t));
    144144    /** Function pointer.  */
    145145    typedef FNLOGGETSTR *PFNLOGGETSTR;
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

    r83169 r85121  
    146146
    147147#ifdef RT_OS_WINDOWS
    148     typedef DECLCALLBACKPTR(HRESULT, SVCHelperClientFunc)
    149         (SVCHlpClient *aClient, Progress *aProgress, void *aUser, int *aVrc);
     148    typedef DECLCALLBACKPTR(HRESULT, SVCHelperClientFunc,(SVCHlpClient *aClient, Progress *aProgress, void *aUser, int *aVrc));
    150149    HRESULT i_startSVCHelperClient(bool aPrivileged,
    151150                                   SVCHelperClientFunc aFunc,
  • trunk/src/VBox/Main/src-all/DisplayPNGUtil.cpp

    r82968 r85121  
    3333} PNGWriteCtx;
    3434
    35 static void PNGAPI png_write_data_fn(png_structp png_ptr, png_bytep p, png_size_t cb)
     35static void PNGAPI png_write_data_fn(png_structp png_ptr, png_bytep p, png_size_t cb) RT_NOTHROW_DEF
    3636{
    3737    PNGWriteCtx *pCtx = (PNGWriteCtx *)png_get_io_ptr(png_ptr);
     
    6262}
    6363
    64 static void PNGAPI png_output_flush_fn(png_structp png_ptr)
     64static void PNGAPI png_output_flush_fn(png_structp png_ptr) RT_NOTHROW_DEF
    6565{
    6666    NOREF(png_ptr);
     
    144144                if (info_ptr)
    145145                {
     146#if RT_MSC_PREREQ(RT_MSC_VER_VC140)
     147#pragma warning(push,3)
    146148                    if (!setjmp(png_jmpbuf(png_ptr)))
     149#pragma warning(pop)
     150#else
     151                    if (!setjmp(png_jmpbuf(png_ptr)))
     152#endif
    147153                    {
    148154                        PNGWriteCtx ctx;
  • trunk/src/VBox/Main/src-client/DisplayImpl.cpp

    r85015 r85121  
    17631763}
    17641764
    1765 /* static */
    1766 int Display::i_displayTakeScreenshotEMT(Display *pDisplay, ULONG aScreenId, uint8_t **ppbData, size_t *pcbData,
    1767                                         uint32_t *pcx, uint32_t *pcy, bool *pfMemFree)
     1765/*static*/ DECLCALLBACK(int)
     1766Display::i_displayTakeScreenshotEMT(Display *pDisplay, ULONG aScreenId, uint8_t **ppbData, size_t *pcbData,
     1767                                    uint32_t *pcx, uint32_t *pcy, bool *pfMemFree)
    17681768{
    17691769    int rc;
     
    21472147#endif /* VBOX_WITH_RECORDING */
    21482148
    2149 int Display::i_drawToScreenEMT(Display *pDisplay, ULONG aScreenId, BYTE *address,
    2150                               ULONG x, ULONG y, ULONG width, ULONG height)
     2149/*static*/ DECLCALLBACK(int)
     2150Display::i_drawToScreenEMT(Display *pDisplay, ULONG aScreenId, BYTE *address, ULONG x, ULONG y, ULONG width, ULONG height)
    21512151{
    21522152    int rc = VINF_SUCCESS;
     
    23122312}
    23132313
    2314 int Display::i_InvalidateAndUpdateEMT(Display *pDisplay, unsigned uId, bool fUpdateAll)
     2314/*static*/ DECLCALLBACK(int) Display::i_InvalidateAndUpdateEMT(Display *pDisplay, unsigned uId, bool fUpdateAll)
    23152315{
    23162316    LogRelFlowFunc(("uId=%d, fUpdateAll %d\n", uId, fUpdateAll));
  • trunk/src/VBox/Main/src-client/HGCMThread.cpp

    r82968 r85121  
    146146        int MsgAlloc(HGCMMsgCore **pMsg, uint32_t u32MsgId, PFNHGCMNEWMSGALLOC pfnNewMessage);
    147147        int MsgGet(HGCMMsgCore **ppMsg);
    148         int MsgPost(HGCMMsgCore *pMsg, PHGCMMSGCALLBACK pfnCallback, bool bWait);
     148        int MsgPost(HGCMMsgCore *pMsg, PFNHGCMMSGCALLBACK pfnCallback, bool bWait);
    149149        int MsgComplete(HGCMMsgCore *pMsg, int32_t result);
    150150};
     
    400400}
    401401
    402 int HGCMThread::MsgPost(HGCMMsgCore *pMsg, PHGCMMSGCALLBACK pfnCallback, bool fWait)
     402int HGCMThread::MsgPost(HGCMMsgCore *pMsg, PFNHGCMMSGCALLBACK pfnCallback, bool fWait)
    403403{
    404404    LogFlow(("HGCMThread::MsgPost: thread = %p, pMsg = %p, pfnCallback = %p\n", this, pMsg, pfnCallback));
     
    694694}
    695695
    696 DECLINLINE(int) hgcmMsgPostInternal(HGCMMsgCore *pMsg, PHGCMMSGCALLBACK pfnCallback, bool fWait)
     696DECLINLINE(int) hgcmMsgPostInternal(HGCMMsgCore *pMsg, PFNHGCMMSGCALLBACK pfnCallback, bool fWait)
    697697{
    698698    LogFlow(("MAIN::hgcmMsgPostInternal: pMsg = %p, pfnCallback = %p, fWait = %d\n", pMsg, pfnCallback, fWait));
     
    709709}
    710710
    711 int hgcmMsgPost(HGCMMsgCore *pMsg, PHGCMMSGCALLBACK pfnCallback)
     711int hgcmMsgPost(HGCMMsgCore *pMsg, PFNHGCMMSGCALLBACK pfnCallback)
    712712{
    713713    int rc = hgcmMsgPostInternal(pMsg, pfnCallback, false);
  • trunk/src/VBox/Main/src-client/UsbCardReader.cpp

    r82968 r85121  
    595595}
    596596
    597 static int drvCardReaderWakeupFunc(PUSBCARDREADER pThis)
     597static DECLCALLBACK(int) drvCardReaderWakeupFunc(PUSBCARDREADER pThis)
    598598{
    599599    NOREF(pThis);
  • 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);
  • trunk/src/VBox/Main/webservice/Makefile.kmk

    r84490 r85121  
    219219 # -wd4774: string(532): warning C4774: 'sprintf_s' : format string expected in argument 3 is not a string literal
    220220 # -wd4458: stdsoap2.h(2644): warning C4458: declaration of 'type' hides class member
     221 # -wd5039: x509v3.h(883): warning C5039: 'OPENSSL_sk_set_cmp_func': pointer or reference to potentially throwing function passed to 'extern "C"' function under -EHc. Undefined behavior may occur if this function throws an exception.
    221222 # soapc-1.cpp(182) : warning C4883: 'soap_getelement': function size suppresses optimizations
    222  TEMPLATE_VBOXWEBR3EXE_CXXFLAGS.win = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.win) -wd4774 -wd4458 -wd4883
     223 TEMPLATE_VBOXWEBR3EXE_CXXFLAGS.win = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.win) -wd4774 -wd4458 -wd4883 -wd5039
    223224endif
    224225
     
    389390  vboxwebsrv_CXXFLAGS.win += -wd4774 # string(532): warning C4774: 'sprintf_s' : format string expected in argument 3 is not a string literal
    390391  vboxwebsrv_CXXFLAGS.win += -wd4458 # stdsoap2.h(2644): warning C4458: declaration of 'type' hides class member
     392  vboxwebsrv_CXXFLAGS.win += -wd5039 # x509v3.h(883): warning C5039: 'OPENSSL_sk_set_cmp_func': pointer or reference to potentially throwing function passed to 'extern "C"' function under -EHc. Undefined behavior may occur if this function throws an exception.
    391393 endif
    392394 ifn1of ($(KBUILD_TARGET), win)
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