summaryrefslogtreecommitdiff
path: root/src/pal
diff options
context:
space:
mode:
authorFrederik Carlier <frederik.carlier@quamotion.mobi>2017-01-26 23:35:37 +0100
committerJan Vorlicek <janvorli@microsoft.com>2017-01-26 23:35:37 +0100
commit69b5d5c46e007cbb580c411b60dc501362af0486 (patch)
tree8a8c9052eab15f23c962c9451cfd1df4611ad79b /src/pal
parent10b85acbf6f635b9b2094b28758e60e86ab9e5d1 (diff)
downloadcoreclr-69b5d5c46e007cbb580c411b60dc501362af0486.tar.gz
coreclr-69b5d5c46e007cbb580c411b60dc501362af0486.tar.bz2
coreclr-69b5d5c46e007cbb580c411b60dc501362af0486.zip
Clean up PAL functions (#9149)
Clean up PAL functions to enable cross-compiling for Android * Rename wcsnlen to PAL_wcsnlen, avoids a name collision on Android * Remove unuwed _getw and _putw functions
Diffstat (limited to 'src/pal')
-rw-r--r--src/pal/inc/mbusafecrt.h2
-rw-r--r--src/pal/inc/pal.h1
-rw-r--r--src/pal/src/cruntime/file.cpp78
-rw-r--r--src/pal/src/include/pal/palinternal.h1
-rw-r--r--src/pal/src/safecrt/sscanf_s.cpp6
-rw-r--r--src/pal/src/safecrt/wcslen_s.cpp2
-rw-r--r--src/pal/tests/palsuite/c_runtime/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/c_runtime/_getw/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/c_runtime/_getw/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/c_runtime/_getw/test1/test.datbin28 -> 0 bytes
-rw-r--r--src/pal/tests/palsuite/c_runtime/_getw/test1/test1.cpp96
-rw-r--r--src/pal/tests/palsuite/c_runtime/_getw/test1/testinfo.dat15
-rw-r--r--src/pal/tests/palsuite/c_runtime/_putw/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/c_runtime/_putw/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/c_runtime/_putw/test1/test1.cpp112
-rw-r--r--src/pal/tests/palsuite/c_runtime/_putw/test1/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/paltestlist.txt1
17 files changed, 7 insertions, 368 deletions
diff --git a/src/pal/inc/mbusafecrt.h b/src/pal/inc/mbusafecrt.h
index 8cf050f419..f030b7ded2 100644
--- a/src/pal/inc/mbusafecrt.h
+++ b/src/pal/inc/mbusafecrt.h
@@ -56,7 +56,7 @@ extern WCHAR* wcstok_s( WCHAR* inString, const WCHAR* inControl, WCHAR** ioConte
// strnlen is not required unless the source string is completely untrusted (e.g. anonymous input on a website)
#ifndef SUPPRESS_STRNLEN
extern size_t PAL_strnlen( const char* inString, size_t inMaxSize );
- extern size_t wcsnlen( const WCHAR* inString, size_t inMaxSize );
+ extern size_t PAL_wcsnlen( const WCHAR* inString, size_t inMaxSize );
#endif
extern errno_t _itoa_s( int inValue, char* outBuffer, size_t inDestBufferSize, int inRadix );
diff --git a/src/pal/inc/pal.h b/src/pal/inc/pal.h
index fdcec58c24..46f4688cb5 100644
--- a/src/pal/inc/pal.h
+++ b/src/pal/inc/pal.h
@@ -4954,6 +4954,7 @@ CoCreateGuid(OUT GUID * pguid);
#define _wcstoui64 PAL__wcstoui64
#define _flushall PAL__flushall
#define strnlen PAL_strnlen
+#define wcsnlen PAL_wcsnlen
#ifdef _AMD64_
#define _mm_getcsr PAL__mm_getcsr
diff --git a/src/pal/src/cruntime/file.cpp b/src/pal/src/cruntime/file.cpp
index 5fe2b671f3..0eb2cea151 100644
--- a/src/pal/src/cruntime/file.cpp
+++ b/src/pal/src/cruntime/file.cpp
@@ -196,45 +196,6 @@ static BOOL WriteOnlyMode(FILE* pFile)
/*++
Function:
- _getw
-
-Gets an integer from a stream.
-
-Return Value
-
-_getw returns the integer value read. A return value of EOF indicates
-either an error or end of file. However, because the EOF value is also
-a legitimate integer value, use feof or ferror to verify an
-end-of-file or error condition.
-
-Parameter
-
-file Pointer to FILE structure
-
---*/
-int
-__cdecl
-_getw(PAL_FILE *f)
-{
- INT ret = 0;
-
- PERF_ENTRY(_getw);
- ENTRY("_getw (f=%p)\n", f);
-
- _ASSERTE(f != NULL);
-
- CLEARERR(f);
-
- ret = getw( f->bsdFilePtr );
- LOGEXIT( "returning %d\n", ret );
- PERF_EXIT(_getw);
-
- return ret;
-}
-
-
-/*++
-Function:
_fdopen
see MSDN
@@ -448,45 +409,6 @@ _wfsopen(
}
/*++
-Function:
- _putw
-
-Writes an integer to a stream.
-
-Return Value
-
-_putw returns the value written. A return value of EOF may indicate an
-error. Because EOF is also a legitimate integer value, use ferror to
-verify an error.
-
-Parameters
-
-c Binary integer to be output
-file Pointer to FILE structure
-
---*/
-int
-__cdecl
-_putw(int c, PAL_FILE *f)
-{
- INT ret = 0;
-
- PERF_ENTRY(_putw);
- ENTRY("_putw (c=0x%x, f=%p)\n", c, f);
-
- _ASSERTE(f != NULL);
-
- CLEARERR(f);
-
- ret = putw(c, f->bsdFilePtr );
- LOGEXIT( "returning %d\n", ret );
- PERF_EXIT(_putw);
-
- return ret;
-}
-
-
-/*++
Function
PAL_get_stdout.
diff --git a/src/pal/src/include/pal/palinternal.h b/src/pal/src/include/pal/palinternal.h
index dbf288c127..878fbcf6ea 100644
--- a/src/pal/src/include/pal/palinternal.h
+++ b/src/pal/src/include/pal/palinternal.h
@@ -358,6 +358,7 @@ function_name() to call the system's implementation
#undef memchr
#undef strlen
#undef strnlen
+#undef wcsnlen
#undef stricmp
#undef strstr
#undef strcmp
diff --git a/src/pal/src/safecrt/sscanf_s.cpp b/src/pal/src/safecrt/sscanf_s.cpp
index 4f548bccc6..7a481b580f 100644
--- a/src/pal/src/safecrt/sscanf_s.cpp
+++ b/src/pal/src/safecrt/sscanf_s.cpp
@@ -21,7 +21,7 @@
typedef int (*INPUTFN)(miniFILE *, const unsigned char*, va_list);
typedef int (*WINPUTFN)(miniFILE *, const wchar_t*, va_list);
-
+extern size_t PAL_wcsnlen(const WCHAR* inString, size_t inMaxSize);
/***
*static int v[nw]scan_fn([w]inputfn, string, [count], format, ...)
@@ -115,7 +115,7 @@ static int __cdecl vwscan_fn (
miniFILE str;
miniFILE *infile = &str;
int retval;
- size_t count = wcsnlen(string, INT_MAX);
+ size_t count = PAL_wcsnlen(string, INT_MAX);
_VALIDATE_RETURN( (string != NULL), EINVAL, EOF);
_VALIDATE_RETURN( (format != NULL), EINVAL, EOF);
@@ -149,7 +149,7 @@ static int __cdecl vnwscan_fn (
miniFILE str;
miniFILE *infile = &str;
int retval;
- size_t length = wcsnlen(string, INT_MAX);
+ size_t length = PAL_wcsnlen(string, INT_MAX);
_VALIDATE_RETURN( (string != NULL), EINVAL, EOF);
_VALIDATE_RETURN( (format != NULL), EINVAL, EOF);
diff --git a/src/pal/src/safecrt/wcslen_s.cpp b/src/pal/src/safecrt/wcslen_s.cpp
index 4fd5371035..0688148b5d 100644
--- a/src/pal/src/safecrt/wcslen_s.cpp
+++ b/src/pal/src/safecrt/wcslen_s.cpp
@@ -42,7 +42,7 @@
*
*******************************************************************************/
-size_t __cdecl wcsnlen(const wchar_t *wcs, size_t maxsize)
+size_t __cdecl PAL_wcsnlen(const wchar_t *wcs, size_t maxsize)
{
size_t n;
diff --git a/src/pal/tests/palsuite/c_runtime/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/CMakeLists.txt
index 8225ed2dd4..7a6b2cd919 100644
--- a/src/pal/tests/palsuite/c_runtime/CMakeLists.txt
+++ b/src/pal/tests/palsuite/c_runtime/CMakeLists.txt
@@ -148,7 +148,6 @@ add_subdirectory(_fullpath)
# TODO: make this test compile
# add_subdirectory(_gcvt)
-add_subdirectory(_getw)
add_subdirectory(_isnan)
add_subdirectory(_isnanf)
add_subdirectory(_itow)
@@ -157,7 +156,6 @@ add_subdirectory(_mbsinc)
add_subdirectory(_mbsninc)
add_subdirectory(_open_osfhandle)
add_subdirectory(_putenv)
-add_subdirectory(_putw)
add_subdirectory(_rotl)
add_subdirectory(_rotr)
add_subdirectory(_snprintf_s)
diff --git a/src/pal/tests/palsuite/c_runtime/_getw/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_getw/CMakeLists.txt
deleted file mode 100644
index f6aa0cb2d9..0000000000
--- a/src/pal/tests/palsuite/c_runtime/_getw/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-cmake_minimum_required(VERSION 2.8.12.2)
-
-add_subdirectory(test1)
-
diff --git a/src/pal/tests/palsuite/c_runtime/_getw/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_getw/test1/CMakeLists.txt
deleted file mode 100644
index 4f763bed6b..0000000000
--- a/src/pal/tests/palsuite/c_runtime/_getw/test1/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-cmake_minimum_required(VERSION 2.8.12.2)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(SOURCES
- test1.cpp
-)
-
-add_executable(paltest_getw_test1
- ${SOURCES}
-)
-
-add_dependencies(paltest_getw_test1 coreclrpal)
-
-target_link_libraries(paltest_getw_test1
- pthread
- m
- coreclrpal
-)
diff --git a/src/pal/tests/palsuite/c_runtime/_getw/test1/test.dat b/src/pal/tests/palsuite/c_runtime/_getw/test1/test.dat
deleted file mode 100644
index b20eae054c..0000000000
--- a/src/pal/tests/palsuite/c_runtime/_getw/test1/test.dat
+++ /dev/null
Binary files differ
diff --git a/src/pal/tests/palsuite/c_runtime/_getw/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_getw/test1/test1.cpp
deleted file mode 100644
index 34ce4ee7de..0000000000
--- a/src/pal/tests/palsuite/c_runtime/_getw/test1/test1.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*============================================================================
-**
-** Source: test1.c
-**
-** Purpose: Several integers are read from a previously written file
-** using _getw. The test passes if the values read match those known to
-** be in the file.
-**
-**
-**==========================================================================*/
-
-#include <palsuite.h>
-
-/*Tests _getw using a previously written data file */
-int __cdecl main(int argc, char **argv)
-{
- const int testValues[] =
- {
- 0,
- 1,
- -1,
- 0x7FFFFFFF, /* largest positive integer on 32 bit systems */
- 0x80000000, /* largest negative integer on 32 bit systems */
- 0xFFFFFFFF,
- 0xFFFFAAAA
- };
-
- int i = 0;
- int input = 0;
-
- const char filename[] = "test.dat";
-
-
- FILE *fp = NULL;
-
- /*
- * Initialize the PAL and return FAIL if this fails
- */
- if (0 != (PAL_Initialize(argc, argv)))
- {
- return FAIL;
- }
-
- /* write the file that we will use to test */
-
-
- /*
- Don't uncomment this code, it was used to create the data file
- initially on windows, but if it is run on all test platforms, the
- tests will always pass.
-
- fp = fopen(filename, "w");
- if (fp == NULL)
- {
- Fail("Unable to open file for write.\n");
- }
- for (i = 0; i < sizeof(testValues) / sizeof(testValues[0]); i++)
- {
- _putw(testValues[i], fp);
- }
-
- if (fclose(fp) != 0)
- {
- Fail("Error closing file after writing to it with _putw.\n");
- }
- */
-
-
- /*Now read values back from the file and see if they match.*/
- fp = fopen(filename, "r");
- if (fp == NULL)
- {
- Fail ("Unable to open file for read.\n");
- }
- for (i = 0; i < sizeof(testValues) / sizeof(testValues[0]); i++)
- {
- input = _getw(fp);
- if (VAL32(input) != testValues[i])
- {
- Fail ("_getw did not get the expected values when reading "
- "from a file.\n");
- }
- }
-
- if (fclose(fp) != 0)
- {
- Fail ("Error closing file after reading from it with _getw\n");
- }
- PAL_Terminate();
- return PASS;
-}
-
diff --git a/src/pal/tests/palsuite/c_runtime/_getw/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_getw/test1/testinfo.dat
deleted file mode 100644
index 4044dadbcc..0000000000
--- a/src/pal/tests/palsuite/c_runtime/_getw/test1/testinfo.dat
+++ /dev/null
@@ -1,15 +0,0 @@
-# Licensed to the .NET Foundation under one or more agreements.
-# The .NET Foundation licenses this file to you under the MIT license.
-# See the LICENSE file in the project root for more information.
-
-Version = 1.0
-Section = C Runtime
-Function = _getw
-Name = Positive Test for _getw
-TYPE = DEFAULT
-EXE1 = test1
-Description
-=Several integers are read from a previously written file
-=using _getw. The test passes if the values read match those known to
-=be in the file.
-
diff --git a/src/pal/tests/palsuite/c_runtime/_putw/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_putw/CMakeLists.txt
deleted file mode 100644
index f6aa0cb2d9..0000000000
--- a/src/pal/tests/palsuite/c_runtime/_putw/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-cmake_minimum_required(VERSION 2.8.12.2)
-
-add_subdirectory(test1)
-
diff --git a/src/pal/tests/palsuite/c_runtime/_putw/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_putw/test1/CMakeLists.txt
deleted file mode 100644
index 78833d4e13..0000000000
--- a/src/pal/tests/palsuite/c_runtime/_putw/test1/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-cmake_minimum_required(VERSION 2.8.12.2)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(SOURCES
- test1.cpp
-)
-
-add_executable(paltest_putw_test1
- ${SOURCES}
-)
-
-add_dependencies(paltest_putw_test1 coreclrpal)
-
-target_link_libraries(paltest_putw_test1
- pthread
- m
- coreclrpal
-)
diff --git a/src/pal/tests/palsuite/c_runtime/_putw/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_putw/test1/test1.cpp
deleted file mode 100644
index 02b7cc7a49..0000000000
--- a/src/pal/tests/palsuite/c_runtime/_putw/test1/test1.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*============================================================================
-**
-** Source: test1.c
-**
-** Purpose: Writes a series of integers to a file, test.dat,
-** then verifies the results.
-**
-** Dependency: fopen(...)
-** fclose(...)
-** CloseHandle(...)
-** DeleteFileA(...)
-** _getw(...)
-**
-**
-**
-**==========================================================================*/
-
-
-#include <palsuite.h>
-
-const char testFileName[] = "test.dat";
-
-static void Cleanup(HANDLE hFile)
-{
- if (fclose((PAL_FILE*)hFile))
- {
- Trace("_putw: ERROR -> Unable to close file \"%s\".\n",
- testFileName);
- }
- if (!DeleteFileA(testFileName))
- {
- Trace("_putw: ERROR -> Unable to delete file \"%s\". ",
- "GetLastError returned %u.\n",
- testFileName,
- GetLastError());
- }
-}
-
-
-int __cdecl main(int argc, char **argv)
-{
-
- FILE * pfTest = NULL;
- int testArray[] = {0,1,-1,0x7FFFFFFF,0x80000000,0xFFFFFFFF,0xFFFFAAAA};
- int i = 0;
- int retValue = 0;
-
- /*
- * Initialize the PAL and return FAIL if this fails
- */
- if (0 != (PAL_Initialize(argc, argv)))
- {
- return FAIL;
- }
-
- /*write the file that we will use to test */
- pfTest = fopen(testFileName, "w");
- if (pfTest == NULL)
- {
- Fail ("Unable to write test file.\n");
- }
-
- for (i = 0; i < sizeof(testArray)/sizeof(int) ; i++)
- {
- _putw(testArray[i], pfTest);
-
- if( ferror( pfTest ) )
- {
- Cleanup(pfTest);
- Fail( "Error:in _putw -> error has occurred in the "
- "stream while writing to the file: \"test.dat\"\n");
- }
-
- }
-
- if (fclose(pfTest) != 0)
- {
- Cleanup(pfTest);
- Fail ("Error closing file after writing with _putw(..).\n");
- }
-
- /*open the new test file and compare*/
- pfTest = fopen(testFileName, "r");
- if (pfTest == NULL)
- {
- Fail ("Error opening \"%s\", which is odd, since I just finished "
- "creating that file.\n", testFileName);
- }
- retValue =_getw( pfTest );
- i = 0;
- while(retValue != EOF)
- {
- if(retValue != testArray[i])
- {
- Cleanup(pfTest);
- Fail ("Integers written by _putw are not in the correct format\n",
- testFileName);
- }
- retValue = _getw( pfTest );
- i++ ;
- }
-
- Cleanup(pfTest);
- PAL_Terminate();
- return PASS;
-}
-
-
diff --git a/src/pal/tests/palsuite/c_runtime/_putw/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_putw/test1/testinfo.dat
deleted file mode 100644
index 3007b82407..0000000000
--- a/src/pal/tests/palsuite/c_runtime/_putw/test1/testinfo.dat
+++ /dev/null
@@ -1,13 +0,0 @@
-# Licensed to the .NET Foundation under one or more agreements.
-# The .NET Foundation licenses this file to you under the MIT license.
-# See the LICENSE file in the project root for more information.
-
-Version = 1.0
-Section = C Runtime
-Function = _putw
-Name = Positive test for _putw
-TYPE = DEFAULT
-EXE1 = test1
-Description
-= Several integers are written to a new file using _putw. This file is
-= closed, reopened and read from to verify the writes were successful.
diff --git a/src/pal/tests/palsuite/paltestlist.txt b/src/pal/tests/palsuite/paltestlist.txt
index 98b17fa6f9..600c2a533b 100644
--- a/src/pal/tests/palsuite/paltestlist.txt
+++ b/src/pal/tests/palsuite/paltestlist.txt
@@ -355,7 +355,6 @@ c_runtime/_putenv/test1/paltest_putenv_test1
c_runtime/_putenv/test2/paltest_putenv_test2
c_runtime/_putenv/test3/paltest_putenv_test3
c_runtime/_putenv/test4/paltest_putenv_test4
-c_runtime/_putw/test1/paltest_putw_test1
c_runtime/_rotl/test1/paltest_rotl_test1
c_runtime/_rotr/test1/paltest_rotr_test1
c_runtime/_snprintf_s/test1/paltest_snprintf_test1