948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync * IPRT - Lazy share library linking (2nd try).
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync * Copyright (C) 2013 Oracle Corporation
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync * available from http://www.virtualbox.org. This file is free software;
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync * you can redistribute it and/or modify it under the terms of the GNU
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync * General Public License (GPL) as published by the Free Software
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync * The contents of this file may alternatively be used under the terms
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync * of the Common Development and Distribution License Version 1.0
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync * VirtualBox OSE distribution, in which case the provisions of the
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync * CDDL are applicable instead of those of the GPL.
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync * You may elect to license modified versions of this file under the
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync * terms and conditions of either the GPL or the CDDL or both.
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync/** @defgroup grp_rt_ldrlazy Lazy shared library linking.
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync * @ingroup grp_rt
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync * Defines a module for use in lazy resolving.
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync * @param a_Mod The module name (C name).
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync * @param a_pszFile The file to tell RTLdrLoad to load.
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync * Defines a module for use in lazy resolving.
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync * @param a_Mod The module name (C name).
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync * @param a_pszFile The file to tell RTLdrLoad to load.
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync * @param a_pfnLoadIt Function to call for loading the DLL, replacing
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync * RTLdrLoad.
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync#define RTLDRLAZY_MODULE_EX(a_Mod, a_pszFile, a_pfnLoadIt) \
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync static bool rtLdrLazy_##a_Mod##_Resolve(const char *pszName, void **ppvSymbol) \
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync static bool volatile s_fLoaded = false; \
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync return false; \
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync return false; \
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync/** Function name mangler for preventing collision with system prototypes. */
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync#define RTLDRLAZY_FUNC_NAME(a_Mod, a_Name) a_Mod##__##a_Name
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync * Defines a function that should be lazily resolved.
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync#define RTLDRLAZY_FUNC(a_Mod, a_RetType, a_CallConv, a_Name, a_ParamDecl, a_ParamNames, a_ErrRet) \
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync DECLINLINE(a_RetType) RTLDRLAZY_FUNC_NAME(a_Mod, a_Name) a_ParamDecl \
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync static a_RetType (a_CallConv * s_pfn) a_ParamDecl; \
948e859a0f72976ea9b302a6b507dfb9409dc7e1vboxsync if (!rtLdrLazy_##a_Mod##_Resolve(#a_Name, (void **)&s_pfn)) \