VirtualBox

Changeset 96043 in vbox


Ignore:
Timestamp:
Aug 4, 2022 10:08:07 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
152841
Message:

IPRT,/Config.kmk,iprt/asmdefs.mac,Add/3D/Config.kmk: Generate weak CRT name aliases for nocrt_xxx function using genalias on Windows (, OS/2 and possibly macOS), while for ELF targets we'll use a RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL/RT_NOCRT_BEGINPROC macros with the function definition. bugref:10261

Location:
trunk
Files:
1 added
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/Config.kmk

    r96038 r96043  
    23362336# bin2c (convert binary files into C arrays)
    23372337VBOX_BIN2C      ?= $(PATH_OBJ)/bin2c/bin2c$(HOSTSUFF_EXE)
     2338
     2339# genalias (generate aliases for nocrt_ functions)
     2340VBOX_GENALIAS   ?= $(PATH_OBJ)/genalias/genalias$(HOSTSUFF_EXE)
    23382341
    23392342# RTManifest (extension pack manifest utility)
     
    62736276 endif
    62746277 ifdef VBOX_WITH_NOCRT_STATIC
    6275   TEMPLATE_VBOXR3STATIC_DEFS           += RT_WITHOUT_NOCRT_WRAPPERS
    62766278  TEMPLATE_VBOXR3STATIC_CFLAGS          = $(filter-out -MD$(VBOX_VCC_CRT_TYPE) -EHsc, $(TEMPLATE_VBOXR3EXE_CFLAGS))   -Zl -EHc-s- -Gy
    62776279  TEMPLATE_VBOXR3STATIC_CXXFLAGS        = $(filter-out -MD$(VBOX_VCC_CRT_TYPE) -EHsc, $(TEMPLATE_VBOXR3EXE_CXXFLAGS)) -Zl -EHc-s- -Gy
     
    64896491        RT_NO_CRT \
    64906492        IN_RT_STATIC
     6493ifndef VBOX_WITH_NOCRT_STATIC
    64916494TEMPLATE_VBoxR3StaticNoCrt_DEFS.win      = $(TEMPLATE_VBoxR3Static_DEFS.win) \
    64926495        RT_WITHOUT_NOCRT_WRAPPERS
     6496endif
    64936497TEMPLATE_VBoxR3StaticNoCrt_LIBS          = \
    64946498        $(PATH_STAGE_LIB)/RuntimeR3NoCrt$(VBOX_SUFF_LIB)
     
    85678571        RT_NO_CRT \
    85688572        IN_RT_STATIC
     8573ifndef VBOX_WITH_NOCRT_STATIC
    85698574TEMPLATE_VBoxGuestR3NoCrtExe_DEFS.win        = $(TEMPLATE_VBoxGuestR3Exe_DEFS.win) \
    85708575        RT_WITHOUT_NOCRT_WRAPPERS
     8576endif
    85718577TEMPLATE_VBoxGuestR3NoCrtExe_LIBS            = \
    85728578        $(PATH_STAGE_LIB)/RuntimeR3NoCrt$(VBOX_SUFF_LIB)
  • trunk/include/iprt/asmdefs.mac

    r96015 r96043  
    11131113; Starts a NOCRT procedure, taking care of name wrapping and aliasing.
    11141114;
    1115 ; Aliasing (weak ones, if supported) will be created when RT_WITH_NOCRT_ALIASES
    1116 ; is defined and RT_WITHOUT_NOCRT_WRAPPERS isn't.
     1115; Weak aliases for regular crt (%1) names to the nocrt_ prefixed ones will be
     1116; added when RT_WITH_NOCRT_ALIASES is defined and the output is ELF.  If
     1117; RT_WITH_GENALIAS_NOCRT_ALIASES is undefined, strong aliases will be added for
     1118; for non-ELF targets, otherwise it's assumed the genalias build tool will do
     1119; the weak aliasing for us.
    11171120;
    11181121%macro RT_NOCRT_BEGINPROC 1
     
    11201123BEGINPROC_EXPORTED RT_NOCRT(%1)
    11211124  %ifdef ASM_FORMAT_ELF
     1125   ; ELF
    11221126   %ifdef RT_WITH_NOCRT_UNDERSCORE_ALIASES
    11231127global NAME(_ %+ %1):function
     
    11281132weak NAME(%1)
    11291133SAFE_LABEL NAME(%1)
    1130   %else
     1134
     1135  %elifndef RT_WITH_GENALIAS_NOCRT_ALIASES
     1136   ; non-ELF when not using genalias.
     1137   %ifdef RT_WITH_NOCRT_UNDERSCORE_ALIASES
     1138GLOBALNAME _%1
     1139   %endif
    11311140GLOBALNAME %1
    11321141  %endif
     
    11351144 %endif ; !RT_WITH_NOCRT_ALIASES
    11361145%endmacro ; RT_NOCRT_BEGINPROC
    1137 
    1138 %ifdef RT_WITH_NOCRT_ALIASES
    1139  %ifdef RT_WITHOUT_NOCRT_WRAPPERS
    1140   %error "RT_WITH_NOCRT_ALIASES and RT_WITHOUT_NOCRT_WRAPPERS doesn't mix."
    1141  %endif
    1142 %endif
    11431146
    11441147
  • trunk/src/VBox/Additions/3D/Config.kmk

    r96012 r96043  
    7878ifdef VBOX_WITH_NOCRT_STATIC
    7979TEMPLATE_VBoxMesa3DGuestR3Dll_DEFS    += \
    80         IPRT_NO_CRT_FOR_3RD_PARTY
     80        IPRT_NO_CRT_FOR_3RD_PARTY \
     81        RT_WITHOUT_NOCRT_WRAPPERS \
     82        RT_WITHOUT_NOCRT_WRAPPER_ALIASES
    8183endif
    8284TEMPLATE_VBoxMesa3DGuestR3Dll_DEFS.win = $(TEMPLATE_NewerVccVBoxGuestR3Dll_DEFS.win) \
  • trunk/src/VBox/Runtime/Makefile.kmk

    r96016 r96043  
    17081708
    17091709#
     1710# kBuild unit for generating nocrt aliases.
     1711#
     1712# This scans assembly, C and C++ source files for the target looking for macros
     1713# that defines functions and variables needing aliasing.
     1714#
     1715UNIT_VBoxNoCrtAliases = CRT symbol alias for the rtnocr_xxx implementations
     1716define def_unit_VBoxNoCrtAliases_double_expansion
     1717$$($(target)_2_VBOX_NOCRT_ALIAS_KMK_FILE): \
     1718                $$(abspathex \
     1719                        $$($(target)_SOURCES)\
     1720                        $$($(target)_SOURCES.$(bld_trg))\
     1721                        $$($(target)_SOURCES.$(bld_trg).$(bld_type))\
     1722                        $$($(target)_SOURCES.$(bld_trg).$(bld_trg_arch))\
     1723                        $$($(target)_SOURCES.$(bld_trg).$(bld_trg_arch).$(bld_type))\
     1724                        $$($(target)_SOURCES.$(bld_trg_arch))\
     1725                        $$($(target)_SOURCES.$(bld_trg_cpu))\
     1726                        $$($(target)_SOURCES.$(bld_type)) \
     1727                        , $(firstfile $(defpath) $(PATH_SUB_CURRENT))) \
     1728               $$(VBOX_PATH_RUNTIME_SRC)//nocrt-aliases.sed \
     1729                | $$$$(dir $$$$@)
     1730        $$(call MSG_GENERATE,$(target),$$@,)
     1731        $$(QUIET)$$(APPEND) -tn "$$@" "$(target)_2_VBOX_NOCRT_ALIASES := \\"
     1732        $$(xargs $$(QUIET)$$(SED) -rn -f "$$(VBOX_PATH_RUNTIME_SRC)/nocrt-aliases.sed" --append "$$@" , $$(filter %.c %.cpp %.asm, $$^) )
     1733        $$(QUIET)$$(APPEND) -n "$$@" "" ""
     1734
     1735$$($(target)_0_OUTDIR)/genalias/genalias.ts + $$($(target)_2_VBOX_NOCRT_ALIAS_FILES): | $$(VBOX_GENALIAS)
     1736        $$(call MSG_GENERATE,$(target),$$@,)
     1737        $$(QUIET)$$(MKDIR) -p -- "$$($(target)_0_OUTDIR)/genalias/"
     1738        $$(QUIET)$$(VBOX_GENALIAS) -f $$(if-expr "$(bld_trg)" == "win",coff,$$(if-expr "$(bld_trg)" == "darwin",macho,omf)) \
     1739                -D "$$($(target)_0_OUTDIR)/genalias/" $$($(target)_2_VBOX_NOCRT_ALIASES)
     1740        $$(QUIET)$$(APPEND) -tn "$$($(target)_0_OUTDIR)/genalias/genalias.ts" "$$($(target)_2_VBOX_NOCRT_ALIASES))"
     1741
     1742$(target)_2_OBJS += $$($(target)_2_VBOX_NOCRT_ALIAS_FILES)
     1743OTHER_CLEAN += $$($(target)_2_VBOX_NOCRT_ALIAS_KMK_FILE) $$($(target)_2_VBOX_NOCRT_ALIAS_KMK_FILE).ts
     1744endef
     1745
     1746define def_unit_VBoxNoCrtAliases_target_pre
     1747 if1of ($(bld_trg), win os2 darwin) # Only non-ELF targets as ELF does not support aliasing.
     1748  $(target)_2_VBOX_NOCRT_ALIAS_KMK_FILE := $(PATH_OUT)/nocrt-aliases-$(target).kmk
     1749  include $($(target)_2_VBOX_NOCRT_ALIAS_KMK_FILE)
     1750  $(target)_2_VBOX_NOCRT_ALIAS_FILES := \
     1751        $(foreach alias,$($(target)_2_VBOX_NOCRT_ALIASES), $($(target)_0_OUTDIR)/genalias/$(firstword $(subst =, $(SPACE),$(alias))).o)
     1752  $(eval $(def_unit_VBoxNoCrtAliases_double_expansion))
     1753 endif
     1754endef
     1755
     1756
     1757#
    17101758# RuntimeR3 - Static Runtime for Ring-3 executables.
    17111759#
     
    17141762ifdef VBOX_WITH_NOCRT_STATIC
    17151763 if1of ($(KBUILD_TARGET), win)
     1764  RuntimeR3_USES  = $(RuntimeBaseR3_USES) VBoxNoCrtAliases
     1765  RuntimeR3_DEFS += $(filter-out RT_WITHOUT_NOCRT_WRAPPERS,$(RuntimeBaseR3_DEFS)) \
     1766        RT_FORCE_NOCRT_WRAPPERS \
     1767        RT_WITH_NOCRT_ALIASES RT_WITH_NOCRT_UNDERSCORE_ALIASES RT_WITH_GENALIAS_NOCRT_ALIASES
     1768
    17161769  RuntimeR3_SOURCES = $(filter-out \
    17171770        r3/alloc.cpp \
  • trunk/src/VBox/Runtime/common/string/memchr.cpp

    r93115 r96043  
    2929*   Header Files                                                                                                                 *
    3030*********************************************************************************************************************************/
     31#include "internal/iprt.h"
    3132#include <iprt/string.h>
    3233
     
    4142 * @param   cb          The size of the block.
    4243 */
    43 #ifdef _MSC_VER /* Silly 'safeness' from MS. */
    44 # if _MSC_VER >= 1400
    45 _CRTIMP __checkReturn _CONST_RETURN void *  __cdecl memchr( __in_bcount_opt(_MaxCount) const void * pv, __in int ch, __in size_t cb)
    46 # else
    47 void *memchr(const void *pv, int ch, size_t cb)
    48 # endif
     44#ifdef IPRT_NO_CRT
     45# undef memchr
     46void *RT_NOCRT(memchr)(const void *pv, int ch, size_t cb)
     47#elif RT_MSC_PREREQ(RT_MSC_VER_VS2005)
     48_CRTIMP __checkReturn _CONST_RETURN void * __cdecl
     49memchr(__in_bcount_opt(_MaxCount) const void *pv, __in int ch, __in size_t cb)
    4950#else
    5051void *memchr(const void *pv, int ch, size_t cb)
     
    6162    return NULL;
    6263}
     64RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(memchr);
    6365
  • trunk/src/VBox/Runtime/common/string/memcmp.cpp

    r93115 r96043  
    2929*   Header Files                                                                                                                 *
    3030*********************************************************************************************************************************/
     31#include "internal/iprt.h"
    3132#include <iprt/string.h>
    32 #include <iprt/types.h>
    3333
    3434
     
    4444 * @param   cb          The size of the block.
    4545 */
    46 #ifdef _MSC_VER
    47 # if _MSC_VER >= 1400
    48 __checkReturn int __cdecl memcmp(__in_bcount_opt(_Size) const void * pvDst, __in_bcount_opt(_Size) const void * pvSrc, __in size_t cb)
    49 # else
    50 int __cdecl memcmp(const void *pvDst, const void *pvSrc, size_t cb)
    51 # endif
     46#ifdef IPRT_NO_CRT
     47# undef memcmp
     48int RT_NOCRT(memcmp)(const void *pvDst, const void *pvSrc, size_t cb)
     49#elif RT_MSC_PREREQ(RT_MSC_VER_VS2005)
     50__checkReturn int __cdecl
     51memcmp(__in_bcount_opt(_Size) const void *pvDst, __in_bcount_opt(_Size) const void *pvSrc, __in size_t cb)
    5252#else
    5353int memcmp(const void *pvDst, const void *pvSrc, size_t cb)
     
    8484    return 0;
    8585}
     86RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(memcmp);
    8687
  • trunk/src/VBox/Runtime/common/string/memcpy.cpp

    r93115 r96043  
    2929*   Header Files                                                                                                                 *
    3030*********************************************************************************************************************************/
     31#include "internal/iprt.h"
    3132#include <iprt/string.h>
    3233
     
    4041 * @param   cb          The size of the block.
    4142 */
    42 #ifdef _MSC_VER
    43 # if _MSC_VER >= 1400
    44 _CRT_INSECURE_DEPRECATE_MEMORY(memcpy_s) void *  __cdecl memcpy(__out_bcount_full_opt(_Size) void * pvDst, __in_bcount_opt(_Size) const void * pvSrc, __in size_t cb)
    45 # else
    46 void *memcpy(void *pvDst, const void *pvSrc, size_t cb)
    47 # endif
     43#ifdef IPRT_NO_CRT
     44# undef memcpy
     45void *RT_NOCRT(memcpy)(void *pvDst, const void *pvSrc, size_t cb)
     46#elif RT_MSC_PREREQ(RT_MSC_VER_VS2005)
     47_CRT_INSECURE_DEPRECATE_MEMORY(memcpy_s) void * __cdecl
     48memcpy(__out_bcount_full_opt(_Size) void *pvDst, __in_bcount_opt(_Size) const void *pvSrc, __in size_t cb)
    4849#else
    4950void *memcpy(void *pvDst, const void *pvSrc, size_t cb)
     
    7879    return pvDst;
    7980}
     81RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(memcpy);
    8082
  • trunk/src/VBox/Runtime/common/string/mempcpy.cpp

    r93959 r96043  
    2929*   Header Files                                                                                                                 *
    3030*********************************************************************************************************************************/
     31#include "internal/iprt.h"
    3132#include <iprt/string.h>
    3233
    3334
     35#ifdef IPRT_NO_CRT
     36# undef mempcpy
     37void * RT_NOCRT(mempcpy)(void *pvDst, const void *pvSrc, size_t cb)
     38#else
    3439RTDECL(void *) mempcpy(void *pvDst, const void *pvSrc, size_t cb)
     40#endif
    3541{
    3642    return (char *)memcpy(pvDst, pvSrc, cb) + cb;
    3743}
     44RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(mempcpy);
    3845
  • trunk/src/VBox/Runtime/common/string/memrchr.cpp

    r93115 r96043  
    2929*   Header Files                                                                                                                 *
    3030*********************************************************************************************************************************/
     31#include "internal/iprt.h"
    3132#include <iprt/string.h>
    3233
     
    4041 * @param   cb      The size of the block.
    4142 */
    42 void *memrchr(const void *pv, int ch, size_t cb)
     43#undef memrchr
     44void *RT_NOCRT(memrchr)(const void *pv, int ch, size_t cb)
    4345{
    4446    if (cb)
     
    5759    return NULL;
    5860}
     61RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(memrchr);
    5962
  • trunk/src/VBox/Runtime/common/string/memset.cpp

    r93115 r96043  
    2929*   Header Files                                                                                                                 *
    3030*********************************************************************************************************************************/
     31#include "internal/iprt.h"
    3132#include <iprt/string.h>
    3233
     
    4041 * @param   cb      The size of the block.
    4142 */
     43#undef memset
    4244#ifdef _MSC_VER
    4345# if _MSC_VER >= 1400
    44 void *  __cdecl memset(__out_bcount_full_opt(_Size) void *pvDst, __in int ch, __in size_t cb)
     46void *  __cdecl RT_NOCRT(memset)(__out_bcount_full_opt(_Size) void *pvDst, __in int ch, __in size_t cb)
    4547# else
    46 void *memset(void *pvDst, int ch, size_t cb)
     48void *RT_NOCRT(memset)(void *pvDst, int ch, size_t cb)
    4749# endif
    4850#else
    49 void *memset(void *pvDst, int ch, size_t cb)
     51void *RT_NOCRT(memset)(void *pvDst, int ch, size_t cb)
    5052#endif
    5153{
     
    7274    return pvDst;
    7375}
    74 
     76RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(memset);
  • trunk/src/VBox/Runtime/common/string/strchr.cpp

    r93137 r96043  
    2525 */
    2626
     27
     28/*********************************************************************************************************************************
     29*   Header Files                                                                                                                 *
     30*********************************************************************************************************************************/
     31#include "internal/iprt.h"
    2732#include <iprt/string.h>
    2833
     34#ifdef IPRT_NO_CRT
     35# undef strchr
     36char *RT_NOCRT(strchr)(const char *pszStr, int ch)
    2937#ifdef _MSC_VER
    30 _CRTIMP char * __cdecl strchr
     38_CRTIMP char * __cdecl strchr(const char *pszStr, int ch)
    3139#elif defined(__WATCOMC__) && !defined(IPRT_NO_CRT)
    32 _WCRTLINK char *std::strchr
     40_WCRTLINK char *std::strchr(const char *pszStr, int ch)
    3341#else
    34 char *strchr
    35 #endif
    36     (const char *pszStr, int ch)
    37 #if defined(__THROW) && !defined(RT_OS_WINDOWS) && !defined(RT_OS_OS2)
     42char *strchr(const char *pszStr, int ch)
     43# if defined(__THROW) && !defined(RT_OS_WINDOWS) && !defined(RT_OS_OS2)
    3844    __THROW
     45# endif
    3946#endif
    4047{
     
    4754    return NULL;
    4855}
     56RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(strchr);
    4957
  • trunk/src/VBox/Runtime/common/string/strcpy.cpp

    r93115 r96043  
    2929*   Header Files                                                                                                                 *
    3030*********************************************************************************************************************************/
     31#include "internal/iprt.h"
    3132#include <iprt/string.h>
    3233
     
    3940 * @param   pszSrc      Zero terminated string.
    4041 */
    41 char* strcpy(char *pszDst, const char *pszSrc)
     42#ifdef IPRT_NO_CRT
     43# undef strlen
     44char *RT_NOCRT(strcpy)(char *pszDst, const char *pszSrc)
     45#else
     46char *strcpy(char *pszDst, const char *pszSrc)
     47#endif
    4248{
    43     char *psz = pszDst;
    44     while ((*psz++ = *pszSrc++))
    45         ;
     49    char * const pszRet = pszDst;
     50    while ((*pszDst = *pszSrc++) != '\0')
     51        pszDst++;
    4652
    47     return pszDst;
     53    return pszRet;
    4854}
     55RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(strcpy);
     56
  • trunk/src/VBox/Runtime/common/string/strcspn.cpp

    r95814 r96043  
    2929*   Header Files                                                                                                                 *
    3030*********************************************************************************************************************************/
     31#include "internal/iprt.h"
    3132#include <iprt/string.h>
    3233
     
    3536 * strpbrk with a offset return instead of a pointer.
    3637 */
    37 size_t strcspn(const char *pszString, const char *pszBreakChars)
     38#undef strcspn
     39size_t RT_NOCRT(strcspn)(const char *pszString, const char *pszBreakChars)
    3840{
    3941    const char * const pszStringStart = pszString;
     
    5052    return (size_t)(pszString - pszStringStart);
    5153}
     54RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(strcspn);
    5255
  • trunk/src/VBox/Runtime/common/string/strformat.cpp

    r95932 r96043  
    8383 * @param     cchMax  Max length.
    8484 */
    85 static unsigned _strnlen(const char *psz, unsigned cchMax)
     85static unsigned rtStrFormatStrNLen(const char *psz, unsigned cchMax)
    8686{
    8787    const char *pszC = psz;
     
    100100 * @param     cchMax  Max length.
    101101 */
    102 static unsigned _strnlenUtf16(PCRTUTF16 pwsz, unsigned cchMax)
     102static unsigned rtStrFormatStrNLenUtf16(PCRTUTF16 pwsz, unsigned cchMax)
    103103{
    104104#ifdef IN_RING3
     
    131131 * @param     cchMax  Max length.
    132132 */
    133 static unsigned _strnlenUni(PCRTUNICP pusz, unsigned cchMax)
     133static unsigned rtStrFormatStrNLenUni(PCRTUNICP pusz, unsigned cchMax)
    134134{
    135135    PCRTUNICP   puszC = pusz;
     
    547547                            if (RT_VALID_PTR(pwszStr))
    548548                            {
    549                                 int cwcStr = _strnlenUtf16(pwszStr, (unsigned)cchPrecision);
     549                                int cwcStr = rtStrFormatStrNLenUtf16(pwszStr, (unsigned)cchPrecision);
    550550                                if (!(fFlags & RTSTR_F_LEFT))
    551551                                    while (--cchWidth >= cwcStr)
     
    579579                            if (RT_VALID_PTR(puszStr))
    580580                            {
    581                                 int cchStr = _strnlenUni(puszStr, (unsigned)cchPrecision);
     581                                int cchStr = rtStrFormatStrNLenUni(puszStr, (unsigned)cchPrecision);
    582582                                if (!(fFlags & RTSTR_F_LEFT))
    583583                                    while (--cchWidth >= cchStr)
     
    608608                            if (RT_VALID_PTR(pszStr))
    609609                            {
    610                                 int cchStr = _strnlen(pszStr, (unsigned)cchPrecision);
     610                                int cchStr = rtStrFormatStrNLen(pszStr, (unsigned)cchPrecision);
    611611                                if (!(fFlags & RTSTR_F_LEFT))
    612612                                    while (--cchWidth >= cchStr)
  • trunk/src/VBox/Runtime/common/string/strlen.cpp

    r93115 r96043  
    2929*   Header Files                                                                                                                 *
    3030*********************************************************************************************************************************/
     31#include "internal/iprt.h"
    3132#include <iprt/string.h>
    3233
     
    3839 * @param   pszString   Zero terminated string.
    3940 */
    40 #ifdef _MSC_VER
    41 # if _MSC_VER >= 1400
     41#ifdef IPRT_NO_CRT
     42# undef strlen
     43size_t strlen(const char *pszString)
     44#elif RT_MSC_PREREQ(RT_MSC_VER_VS2005)
    4245__checkReturn size_t  __cdecl strlen(__in_z  const char *pszString)
    43 # else
    44 size_t strlen(const char *pszString)
    45 # endif
    4646#else
    4747size_t strlen(const char *pszString)
     
    5353    return psz - pszString;
    5454}
     55RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(strlen);
    5556
  • trunk/src/VBox/Runtime/common/string/strncmp.cpp

    r93135 r96043  
    2525 */
    2626
     27
     28/*********************************************************************************************************************************
     29*   Header Files                                                                                                                 *
     30*********************************************************************************************************************************/
     31#include "internal/iprt.h"
    2732#include <iprt/string.h>
    2833
    29 #ifdef _MSC_VER
    30 _CRTIMP int __cdecl strncmp
     34#ifdef IPRT_NO_CRT
     35# undef strncmp
     36int RT_NOCRT(strncmp)(const char *pszStr1, const char *pszStr2, size_t cb)
     37#elif defined( _MSC_VER)
     38_CRTIMP int __cdecl strncmp(const char *pszStr1, const char *pszStr2, size_t cb)
    3139#elif defined(__WATCOMC__) && !defined(IPRT_NO_CRT)
    32 _WCRTLINK int std::strncmp
     40_WCRTLINK int std::strncmp(const char *pszStr1, const char *pszStr2, size_t cb)
    3341#else
    34 int strncmp
    35 #endif
    36     (const char *pszStr1, const char *pszStr2, size_t cb)
    37 #if defined(__THROW) && !defined(RT_OS_WINDOWS) && !defined(RT_OS_OS2)
     42int strncmp(const char *pszStr1, const char *pszStr2, size_t cb)
     43# if defined(__THROW) && !defined(RT_OS_WINDOWS) && !defined(RT_OS_OS2)
    3844    __THROW
     45# endif
    3946#endif
    4047{
     
    5057    return 0;
    5158}
     59RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(strncmp);
     60
  • trunk/src/VBox/Runtime/common/string/strpbrk.cpp

    r95767 r96043  
    2929*   Header Files                                                                                                                 *
    3030*********************************************************************************************************************************/
     31#include "internal/iprt.h"
    3132#include <iprt/string.h>
    3233
     
    3839 */
    3940#ifdef IPRT_NO_CRT
    40 char *strpbrk(const char *pszStr, const char *pszBreakChars)
     41# undef strpbrk
     42char *RT_NOCRT(strpbrk)(const char *pszStr, const char *pszBreakChars)
    4143#elif defined(_MSC_VER)
    4244# if _MSC_VER >= 1400
     
    6668    return NULL;
    6769}
     70RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(strpbrk);
    6871
  • trunk/src/VBox/Runtime/common/string/strrchr.cpp

    r95814 r96043  
    2929*   Header Files                                                                                                                 *
    3030*********************************************************************************************************************************/
     31#include "internal/iprt.h"
    3132#include <iprt/string.h>
    3233
    3334
    34 char *strrchr(const char *pszString, int ch)
     35#undef strrchr
     36char *RT_NOCRT(strrchr)(const char *pszString, int ch)
    3537{
    36     /** @todo check out what strrchr(psz, '\\0') is supposed to return. */
    37     return (char *)memrchr(pszString, ch, strlen(pszString));
     38    /* We must search the terminator too, so strrchr(str, '\0') returns a pointer to it. */
     39    return (char *)memrchr(pszString, ch, strlen(pszString) + 1);
    3840}
     41RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(strrchr);
    3942
  • trunk/src/VBox/Runtime/common/string/strstr.cpp

    r95814 r96043  
    2929*   Header Files                                                                                                                 *
    3030*********************************************************************************************************************************/
     31#include "internal/iprt.h"
    3132#include <iprt/string.h>
    3233
     
    4041 * @param   pszSubStr   The substring to search for.
    4142 */
    42 char *strstr(const char *pszString, const char *pszSubStr)
     43#undef strstr
     44char *RT_NOCRT(strstr)(const char *pszString, const char *pszSubStr)
    4345{
    4446    char const  ch0Sub = *pszSubStr;
     
    5961    return NULL;
    6062}
     63RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(strstr);
    6164
  • trunk/src/VBox/Runtime/include/internal/iprt.h

    r93115 r96043  
    6464#endif
    6565
     66/** @def RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL
     67 * Creates symbol alias and export a RT_NOCRT symbol.
     68 *
     69 * For targets using ELF this macro generates weak symbol aliases, for the other
     70 * object formats the makefile scans source files for this macro and produces
     71 * separate object files with the aliases.
     72 *
     73 * @param   a_Name      The CRT function or variable name.
     74 *
     75 * @todo    Does not support ELF targets using underscore prefixed symbols.
     76 */
     77#if defined(__ELF__) && defined(RT_WITH_NOCRT_ALIASES) && !defined(RT_WITHOUT_NOCRT_ALIASES)
     78# ifdef RT_WITH_NOCRT_UNDERSCORE_ALIASES
     79#  define RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(a_Name) RT_EXPORT_SYMBOL(a_Name) \
     80    __asm__(".weak " #a_Name "\n\t" \
     81            ".set  " #a_Name "," RT_NOCRT_STR(a_Name) "\n\t" \
     82            ".weak _" #a_Name "\n\t" \
     83            ".set  _" #a_Name "," RT_NOCRT_STR(a_Name) "\n\t")
     84# else
     85#  define RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(a_Name) RT_EXPORT_SYMBOL(a_Name) \
     86    __asm__(".weak " #a_Name "\n\t" \
     87            ".set  " #a_Name "," RT_NOCRT_STR(a_Name) "\n\t")
     88# endif
     89#else
     90# define RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(a_Name) RT_EXPORT_SYMBOL(a_Name)
     91#endif
     92
     93/** @def RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL_WITHOUT_UNDERSCORE
     94 * Variant of RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL that omits the
     95 * underscore-prefixed variant of the symbol.
     96 *
     97 * @param   a_Name      The CRT function or variable name.
     98 */
     99#if defined(__ELF__) && defined(RT_WITH_NOCRT_ALIASES) && !defined(RT_WITHOUT_NOCRT_ALIASES)
     100# define RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL_WITHOUT_UNDERSCORE(a_Name) RT_EXPORT_SYMBOL(a_Name) \
     101    __asm__(".weak " #a_Name "\n\t" \
     102            ".set  " #a_Name "," RT_NOCRT_STR(a_Name) "\n\t")
     103#else
     104# define RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL_WITHOUT_UNDERSCORE(a_Name) RT_EXPORT_SYMBOL(a_Name)
     105#endif
     106
    66107
    67108/** @def RT_MORE_STRICT
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