Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/Backend/Backend.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Copyright (c) ChakraCore Project Contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#pragma once

#ifndef USING_PAL_STDLIB
#include <wchar.h>
#endif

// =================
// Runtime Includes
Expand Down
2 changes: 1 addition & 1 deletion lib/Common/Memory/CustomHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#if ENABLE_NATIVE_CODEGEN || DYNAMIC_INTERPRETER_THUNK

#include "Memory/XDataAllocator.h"
#if defined(_M_ARM)
#if defined(_M_ARM) && defined(_WIN32)
#include <wchar.h>
#endif
#include "CustomHeap.h"
Expand Down
7 changes: 1 addition & 6 deletions lib/Runtime/Base/ittnotify_config.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft Corporation and contributors. All rights reserved.
// Copyright (c) ChakraCore Project Contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#ifndef _ITTNOTIFY_CONFIG_H_
Expand Down Expand Up @@ -73,9 +74,6 @@
#include <tchar.h>
#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#include <stdint.h>
#if defined(UNICODE) || defined(_UNICODE)
#include <wchar.h>
#endif /* UNICODE || _UNICODE */
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */

#ifndef ITTAPI_CDECL
Expand Down Expand Up @@ -201,9 +199,6 @@ typedef CRITICAL_SECTION mutex_t;
#define strong_alias(name, aliasname) /* empty for Windows */
#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#include <dlfcn.h>
#if defined(UNICODE) || defined(_UNICODE)
#include <wchar.h>
#endif /* UNICODE */
#ifndef _GNU_SOURCE
#define _GNU_SOURCE 1 /* need for PTHREAD_MUTEX_RECURSIVE */
#endif /* _GNU_SOURCE */
Expand Down
17 changes: 8 additions & 9 deletions pal/inc/mbusafecrt.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
//-------------------------------------------------------------------------------------------------------
// ChakraCore/Pal
// Contains portions (c) copyright Microsoft, portions copyright (c) the .NET Foundation and Contributors
// and edits (c) copyright the ChakraCore Contributors.
// See THIRD-PARTY-NOTICES.txt in the project root for .NET Foundation license
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------

/***
* mbusafecrt.h - public declarations for SafeCRT lib
Expand Down Expand Up @@ -64,11 +67,7 @@ extern errno_t wcsncpy_s( WCHAR* outDest, size_t inDestBufferSize, const WCHAR*
extern char* strtok_s( char* inString, const char* inControl, char** ioContext );
extern WCHAR* wcstok_s( WCHAR* inString, const WCHAR* inControl, WCHAR** ioContext );

// strnlen is not required unless the source string is completely untrusted (e.g. anonymous input on a website)
#ifndef SUPPRESS_STRNLEN
extern size_t strnlen( const char* inString, size_t inMaxSize );
extern size_t wcsnlen( const WCHAR* inString, size_t inMaxSize );
#endif
extern size_t wcsnlen( const WCHAR* inString, size_t inMaxSize );

extern errno_t _itoa_s( int inValue, char* outBuffer, size_t inDestBufferSize, int inRadix );
extern errno_t _itow_s( int inValue, WCHAR* outBuffer, size_t inDestBufferSize, int inRadix );
Expand Down
7 changes: 2 additions & 5 deletions pal/inc/pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -6103,7 +6103,6 @@ CoCreateGuid(OUT GUID * pguid);
#define vswprintf PAL_vswprintf
#define fopen PAL_fopen
#define strtok PAL_strtok
#define strtoul PAL_strtoul
#define fprintf PAL_fprintf
#define fwprintf PAL_fwprintf
#define vfprintf PAL_vfprintf
Expand Down Expand Up @@ -6137,7 +6136,6 @@ CoCreateGuid(OUT GUID * pguid);
#define mkstemp PAL_mkstemp
#define rename PAL_rename
#define unlink PAL_unlink
#define _strdup PAL__strdup
#define _getcwd PAL__getcwd
#define _open PAL__open
#define _close PAL__close
Expand Down Expand Up @@ -6180,7 +6178,6 @@ PALIMPORT void * __cdecl memchr(const void *, int, size_t);
PALIMPORT size_t __cdecl strlen(const char *);
PALIMPORT int __cdecl strcmp(const char*, const char *);
PALIMPORT int __cdecl strncmp(const char*, const char *, size_t);
PALIMPORT int __cdecl _strnicmp(const char *, const char *, size_t);
PALIMPORT char * __cdecl strcat(char *, const char *);
PALIMPORT char * __cdecl strncat(char *, const char *, size_t);
PALIMPORT char * __cdecl strcpy(char *, const char *);
Expand All @@ -6198,7 +6195,7 @@ PALIMPORT int __cdecl sscanf(const char *, const char *, ...);
PALIMPORT int __cdecl atoi(const char *);
PALIMPORT LONG __cdecl atol(const char *);
//PALIMPORT long long int __cdecl atoll(const char *) __THROW;
PALIMPORT ULONG __cdecl strtoul(const char *, char **, int);
PALIMPORT unsigned long __cdecl strtoul(const char *, char **, int);
PALIMPORT double __cdecl atof(const char *);
PALIMPORT double __cdecl strtod(const char *, char **);
PALIMPORT int __cdecl isprint(int);
Expand All @@ -6218,7 +6215,7 @@ PALIMPORT errno_t __cdecl memcpy_s(void *, size_t, const void *, size_t);
PALIMPORT errno_t __cdecl memmove_s(void *, size_t, const void *, size_t);
PALIMPORT void * __cdecl memmove_xplat(void *, const void *, size_t);
PALIMPORT char * __cdecl _strlwr(char *);
PALIMPORT int __cdecl _stricmp(const char *, const char *);
PALIMPORT int __cdecl strcasecmp(const char *, const char *);
PALIMPORT int __cdecl _snprintf(char *, size_t, const char *, ...);
PALIMPORT char * __cdecl _gcvt_s(char *, int, double, int);
PALIMPORT char * __cdecl _ecvt(double, int, int *, int *);
Expand Down
37 changes: 8 additions & 29 deletions pal/inc/rt/safecrt.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
//
//-------------------------------------------------------------------------------------------------------
// ChakraCore/Pal
// Contains portions (c) copyright Microsoft, portions copyright (c) the .NET Foundation and Contributors
// and edits (c) copyright the ChakraCore Contributors.
// See THIRD-PARTY-NOTICES.txt in the project root for .NET Foundation license
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------

//
/***
Expand Down Expand Up @@ -2409,34 +2411,11 @@ unsigned char * __cdecl _mbstok_s(unsigned char *_String, const unsigned char *_
#endif /* _SAFECRT_DEFINE_MBS_FUNCTIONS */

#ifndef PAL_STDCPP_COMPAT
/* strnlen */
/*
* strnlen, wcsnlen ;
* wcsnlen ;
* returns inMaxSize if the null character is not found.
*/
_SAFECRT__EXTERN_C
size_t __cdecl strnlen(const char* inString, size_t inMaxSize);

#if _SAFECRT_USE_INLINES || _SAFECRT_IMPL

_SAFECRT__INLINE
size_t __cdecl strnlen(const char* inString, size_t inMaxSize)
{
size_t n;

/* Note that we do not check if s == nullptr, because we do not
* return errno_t...
*/

for (n = 0; n < inMaxSize && *inString; n++, inString++)
;

return n;
}

#endif

/* wcsnlen */
_SAFECRT__EXTERN_C
size_t __cdecl wcsnlen(const WCHAR *inString, size_t inMaxSize);

Expand Down
1 change: 0 additions & 1 deletion pal/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ set(SOURCES
cruntime/printf.cpp
cruntime/printfcpp.cpp
cruntime/silent_printf.cpp
cruntime/string.cpp
cruntime/stringtls.cpp
cruntime/thread.cpp
cruntime/wchar.cpp
Expand Down
1 change: 1 addition & 0 deletions pal/src/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#cmakedefine01 HAVE_GMTIME_R
#cmakedefine01 HAVE_TIMEGM
#cmakedefine01 HAVE__SNWPRINTF
#cmakedefine01 HAVE_WCSNLEN
#cmakedefine01 HAVE_POLL
#cmakedefine01 HAVE_STATVFS
#cmakedefine01 HAVE_THREAD_SELF
Expand Down
1 change: 1 addition & 0 deletions pal/src/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ check_function_exists(localtime_r HAVE_LOCALTIME_R)
check_function_exists(gmtime_r HAVE_GMTIME_R)
check_function_exists(timegm HAVE_TIMEGM)
check_function_exists(_snwprintf HAVE__SNWPRINTF)
check_function_exists(wcsnlen HAVE_WSCNLEN)
check_function_exists(poll HAVE_POLL)
check_function_exists(statvfs HAVE_STATVFS)
check_function_exists(thread_self HAVE_THREAD_SELF)
Expand Down
15 changes: 9 additions & 6 deletions pal/src/cruntime/file.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
//-------------------------------------------------------------------------------------------------------
// ChakraCore/Pal
// Contains portions (c) copyright Microsoft, portions copyright (c) the .NET Foundation and Contributors
// and edits (c) copyright the ChakraCore Contributors.
// See THIRD-PARTY-NOTICES.txt in the project root for .NET Foundation license
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------

/*++

Expand Down Expand Up @@ -283,10 +286,10 @@ PAL_fopen(const char * fileName, const char * mode)
goto done;
}

UnixFileName = PAL__strdup(fileName);
UnixFileName = strdup(fileName);
if (UnixFileName == NULL )
{
ERROR("PAL__strdup() failed\n");
ERROR("strdup() failed\n");
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
goto done;
}
Expand Down
30 changes: 7 additions & 23 deletions pal/src/cruntime/malloc.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
//-------------------------------------------------------------------------------------------------------
// ChakraCore/Pal
// Contains portions (c) copyright Microsoft, portions copyright (c) the .NET Foundation and Contributors
// and edits (c) copyright the ChakraCore Contributors.
// See THIRD-PARTY-NOTICES.txt in the project root for .NET Foundation license
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------

/*++

Expand Down Expand Up @@ -114,22 +117,3 @@ CorUnix::InternalMalloc(
pvMem = (void*)malloc(szSize);
return pvMem;
}

char *
__cdecl
PAL__strdup(
const char *c_szStr
)
{
return InternalStrdup(c_szStr);
}

char *
CorUnix::InternalStrdup(
const char *c_szStr
)
{
char *pszStrCopy;
pszStrCopy = strdup(c_szStr);
return pszStrCopy;
}
13 changes: 8 additions & 5 deletions pal/src/cruntime/misc.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
//-------------------------------------------------------------------------------------------------------
// ChakraCore/Pal
// Contains portions (c) copyright Microsoft, portions copyright (c) the .NET Foundation and Contributors
// and edits (c) copyright the ChakraCore Contributors.
// See THIRD-PARTY-NOTICES.txt in the project root for .NET Foundation license
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------

/*++

Expand Down Expand Up @@ -433,7 +436,7 @@ BOOL MiscPutenv(const char *string, BOOL deleteIfEmpty)
// See if we are replacing an item or adding one.

// Make our copy up front, since we'll use it either way.
copy = InternalStrdup(string);
copy = strdup(string);
if (copy == NULL)
{
goto done;
Expand Down
Loading