VirtualBox

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/win/cfg/VBoxNetCfg.cpp

    r84345 r85121  
    6060# define AssertMsg(expr, msg) do{}while (0)
    6161#endif
    62 static LOG_ROUTINE g_Logger = NULL;
    63 
    64 static VOID DoLogging(LPCSTR szString, ...);
     62static PFNVBOXNETCFGLOGGER volatile g_pfnLogger = NULL;
     63
     64static void DoLogging(const char *pszString, ...);
    6565#define NonStandardLog DoLogging
    6666#define NonStandardLogFlow(x) DoLogging x
     
    865865 * logging
    866866 */
    867 static VOID DoLogging(LPCSTR szString, ...)
    868 {
    869     LOG_ROUTINE pfnRoutine = (LOG_ROUTINE)(*((void * volatile *)&g_Logger));
    870     if (pfnRoutine)
     867static void DoLogging(const char *pszString, ...)
     868{
     869    PFNVBOXNETCFGLOGGER pfnLogger = g_pfnLogger;
     870    if (pfnLogger)
    871871    {
    872872        char szBuffer[4096] = {0};
    873873        va_list va;
    874         va_start(va, szString);
    875         _vsnprintf(szBuffer, RT_ELEMENTS(szBuffer), szString, va);
     874        va_start(va, pszString);
     875        _vsnprintf(szBuffer, RT_ELEMENTS(szBuffer), pszString, va);
    876876        va_end(va);
    877877
    878         pfnRoutine(szBuffer);
    879     }
    880 }
    881 
    882 VBOXNETCFGWIN_DECL(VOID) VBoxNetCfgWinSetLogging(IN LOG_ROUTINE pfnLog)
    883 {
    884     *((void * volatile *)&g_Logger) = pfnLog;
     878        pfnLogger(szBuffer);
     879    }
     880}
     881
     882VBOXNETCFGWIN_DECL(void) VBoxNetCfgWinSetLogging(IN PFNVBOXNETCFGLOGGER pfnLogger)
     883{
     884    g_pfnLogger = pfnLogger;
    885885}
    886886
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