summaryrefslogtreecommitdiff
path: root/StdLib/LibC/Wchar
diff options
context:
space:
mode:
authordarylm503 <darylm503@6f19259b-4bc3-4df7-8a09-765794883524>2011-04-27 21:42:16 +0000
committerdarylm503 <darylm503@6f19259b-4bc3-4df7-8a09-765794883524>2011-04-27 21:42:16 +0000
commit2aa62f2bc9a9654687b377d9ca8a8c2c860a3852 (patch)
tree62a0991a44327154fb88bf95bd6f7522053db7bb /StdLib/LibC/Wchar
parent98790d814871cc30bbd536673d3a0948047cd2f0 (diff)
downloadedk2-platforms-2aa62f2bc9a9654687b377d9ca8a8c2c860a3852.tar.xz
Standard Libraries for EDK II.
This set of three packages: AppPkg, StdLib, StdLibPrivateInternalFiles; contains the implementation of libraries based upon non-UEFI standards such as ISO/IEC-9899, the library portion of the C Language Standard, POSIX, etc. AppPkg contains applications that make use of the standard libraries defined in the StdLib Package. StdLib contains header (include) files and the implementations of the standard libraries. StdLibPrivateInternalFiles contains files for the exclusive use of the library implementations in StdLib. These files should never be directly referenced from applications or other code. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11600 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'StdLib/LibC/Wchar')
-rw-r--r--StdLib/LibC/Wchar/Comparison.c97
-rw-r--r--StdLib/LibC/Wchar/Concatenation.c48
-rw-r--r--StdLib/LibC/Wchar/ConsDecons.c64
-rw-r--r--StdLib/LibC/Wchar/Copying.c80
-rw-r--r--StdLib/LibC/Wchar/Searching.c268
-rw-r--r--StdLib/LibC/Wchar/String.c43
-rw-r--r--StdLib/LibC/Wchar/Wchar.inf59
7 files changed, 659 insertions, 0 deletions
diff --git a/StdLib/LibC/Wchar/Comparison.c b/StdLib/LibC/Wchar/Comparison.c
new file mode 100644
index 0000000000..17244b4ccb
--- /dev/null
+++ b/StdLib/LibC/Wchar/Comparison.c
@@ -0,0 +1,97 @@
+/** @file
+ Comparison Functions for <wchar.h>.
+
+ Unless explicitly stated otherwise, the functions defined in this file order
+ two wide characters the same way as two integers of the underlying integer
+ type designated by wchar_t.
+
+ Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+**/
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+
+#include <LibConfig.h>
+
+#include <wchar.h>
+
+/** The wcscmp function compares the wide string pointed to by s1 to the wide
+ string pointed to by s2.
+
+ @return The wcscmp function returns an integer greater than, equal to, or
+ less than zero, accordingly as the wide string pointed to by s1
+ is greater than, equal to, or less than the wide string
+ pointed to by s2.
+**/
+int wcscmp(const wchar_t *s1, const wchar_t *s2)
+{
+ return (int)StrCmp( (CONST CHAR16 *)s1, (CONST CHAR16 *)s2);
+}
+
+/** The wcscoll function compares the wide string pointed to by s1 to the wide
+ string pointed to by s2, both interpreted as appropriate to the LC_COLLATE
+ category of the current locale.
+
+ @return The wcscoll function returns an integer greater than, equal to,
+ or less than zero, accordingly as the wide string pointed to by
+ s1 is greater than, equal to, or less than the wide string
+ pointed to by s2 when both are interpreted as appropriate to
+ the current locale.
+**/
+//int wcscoll(const wchar_t *s1, const wchar_t *s2)
+//{
+// return -1; // STUBB
+//}
+
+/** The wcsncmp function compares not more than n wide characters (those that
+ follow a null wide character are not compared) from the array pointed to by
+ s1 to the array pointed to by s2.
+
+ @return The wcsncmp function returns an integer greater than, equal to,
+ or less than zero, accordingly as the possibly null-terminated
+ array pointed to by s1 is greater than, equal to, or less than
+ the possibly null-terminated array pointed to by s2.
+**/
+int wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n)
+{
+ return (int)StrnCmp( (CONST CHAR16 *)s1, (CONST CHAR16 *)s2, (UINTN)n);
+}
+
+/** The wcsxfrm function transforms the wide string pointed to by s2 and places
+ the resulting wide string into the array pointed to by s1. The
+ transformation is such that if the wcscmp function is applied to two
+ transformed wide strings, it returns a value greater than, equal to, or
+ less than zero, corresponding to the result of the wcscoll function applied
+ to the same two original wide strings. No more than n wide characters are
+ placed into the resulting array pointed to by s1, including the terminating
+ null wide character. If n is zero, s1 is permitted to be a null pointer.
+
+ @return The wcsxfrm function returns the length of the transformed wide
+ string (not including the terminating null wide character). If
+ the value returned is n or greater, the contents of the array
+ pointed to by s1 are indeterminate.
+**/
+//size_t wcsxfrm(wchar_t * __restrict s1, const wchar_t * __restrict s2, size_t n)
+//{
+// return n; // STUBB
+//}
+
+/** The wmemcmp function compares the first n wide characters of the object
+ pointed to by s1 to the first n wide characters of the object pointed to
+ by s2.
+
+ @return The wmemcmp function returns an integer greater than, equal to,
+ or less than zero, accordingly as the object pointed to by s1 is
+ greater than, equal to, or less than the object pointed to by s2.
+**/
+int wmemcmp(const wchar_t *s1, const wchar_t *s2, size_t n)
+{
+ return (int)CompareMem( s1, s2, (UINTN)(n * sizeof(wchar_t)));
+}
diff --git a/StdLib/LibC/Wchar/Concatenation.c b/StdLib/LibC/Wchar/Concatenation.c
new file mode 100644
index 0000000000..cf595a461f
--- /dev/null
+++ b/StdLib/LibC/Wchar/Concatenation.c
@@ -0,0 +1,48 @@
+/** @file
+ Concatenation Functions for <wchar.h>.
+
+ Unless explicitly stated otherwise, if the execution of a function declared
+ in this file causes copying to take place between objects that overlap, the
+ behavior is undefined.
+
+ Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+**/
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+
+#include <LibConfig.h>
+
+#include <wchar.h>
+
+/** The wcscat function appends a copy of the wide string pointed to by s2
+ (including the terminating null wide character) to the end of the wide
+ string pointed to by s1. The initial wide character of s2 overwrites the
+ null wide character at the end of s1.
+
+ @return The wcscat function returns the value of s1.
+**/
+wchar_t *wcscat(wchar_t * __restrict s1, const wchar_t * __restrict s2)
+{
+ return (wchar_t *)StrCat( (CHAR16 *)s1, (CONST CHAR16 *)s2);
+}
+
+/** The wcsncat function appends not more than n wide characters (a null wide
+ character and those that follow it are not appended) from the array pointed
+ to by s2 to the end of the wide string pointed to by s1. The initial wide
+ character of s2 overwrites the null wide character at the end of s1.
+ A terminating null wide character is always appended to the result.
+
+ @return The wcsncat function returns the value of s1.
+**/
+wchar_t *wcsncat(wchar_t * __restrict s1, const wchar_t * __restrict s2, size_t n)
+{
+ return (wchar_t *)StrnCat( (CHAR16 *)s1, (CONST CHAR16 *)s2, (UINTN)n);
+}
diff --git a/StdLib/LibC/Wchar/ConsDecons.c b/StdLib/LibC/Wchar/ConsDecons.c
new file mode 100644
index 0000000000..ab139405fc
--- /dev/null
+++ b/StdLib/LibC/Wchar/ConsDecons.c
@@ -0,0 +1,64 @@
+/** @file
+ Constructor and Deconstructor functions for <wchar.h>.
+
+ Unless explicitly stated otherwise, the functions defined in this file order
+ two wide characters the same way as two integers of the underlying integer
+ type designated by wchar_t.
+
+ Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+**/
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+
+#include <LibConfig.h>
+
+#include <errno.h>
+#include <wchar.h>
+
+/* Data initialized by the library constructor */
+UINT8 *__wchar_bitmap = NULL;
+UINTN __wchar_bitmap_size;
+UINTN __wchar_bitmap_64;
+
+EFI_STATUS
+EFIAPI
+__wchar_construct(
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ if( __wchar_bitmap == NULL) {
+ __wchar_bitmap_size = (WCHAR_MAX + 8) / 8U;
+ __wchar_bitmap = AllocatePool(__wchar_bitmap_size);
+ if( __wchar_bitmap == NULL) {
+ EFIerrno = RETURN_OUT_OF_RESOURCES;
+ errno = ENOMEM;
+ return EFIerrno;
+ }
+ return RETURN_SUCCESS;
+ }
+ return RETURN_ALREADY_STARTED;
+}
+
+EFI_STATUS
+EFIAPI
+__wchar_deconstruct(
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ if( __wchar_bitmap != NULL) {
+ FreePool( __wchar_bitmap);
+ __wchar_bitmap = NULL;
+ }
+ return RETURN_SUCCESS;
+}
diff --git a/StdLib/LibC/Wchar/Copying.c b/StdLib/LibC/Wchar/Copying.c
new file mode 100644
index 0000000000..7075437965
--- /dev/null
+++ b/StdLib/LibC/Wchar/Copying.c
@@ -0,0 +1,80 @@
+/** @file
+ Copying Functions for <wchar.h>.
+
+ Unless explicitly stated otherwise, if the execution of a function declared
+ in this file causes copying to take place between objects that overlap, the
+ behavior is undefined.
+
+ Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+**/
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+
+#include <LibConfig.h>
+
+#include <wchar.h>
+
+/** The wcscpy function copies the wide string pointed to by s2 (including the
+ terminating null wide character) into the array pointed to by s1.
+
+ @return The wcscpy function returns the value of s1.
+**/
+wchar_t *wcscpy(wchar_t * __restrict s1, const wchar_t * __restrict s2)
+{
+ return (wchar_t *)StrCpy( (CHAR16 *)s1, (CONST CHAR16 *)s2);
+}
+
+/** The wcsncpy function copies not more than n wide characters (those that
+ follow a null wide character are not copied) from the array pointed to by
+ s2 to the array pointed to by s1.
+
+ If the array pointed to by s2 is a wide string that is shorter than n wide
+ characters, null wide characters are appended to the copy in the array
+ pointed to by s1, until n wide characters in all have been written.
+
+ @return The wcsncpy function returns the value of s1.
+**/
+wchar_t *wcsncpy(wchar_t * __restrict s1, const wchar_t * __restrict s2, size_t n)
+{
+ return (wchar_t *)StrnCpy( (CHAR16 *)s1, (CONST CHAR16 *)s2, (UINTN)n);
+}
+
+/** The wmemcpy function copies n wide characters from the object pointed to by
+ s2 to the object pointed to by s1.
+
+ Use this function if you know that s1 and s2 DO NOT Overlap. Otherwise,
+ use wmemmove.
+
+ @return The wmemcpy function returns the value of s1.
+**/
+wchar_t *wmemcpy(wchar_t * __restrict s1, const wchar_t * __restrict s2, size_t n)
+{
+ return (wchar_t *)CopyMem( s1, s2, (UINTN)(n * sizeof(wchar_t)));
+}
+
+/** The wmemmove function copies n wide characters from the object pointed to by
+ s2 to the object pointed to by s1. The objects pointed to by s1 and s2 are
+ allowed to overlap.
+
+ Because the UEFI BaseMemoryLib function CopyMem explicitly handles
+ overlapping source and destination objects, this function and wmemcpy are
+ implemented identically.
+
+ For programming clarity, it is recommended that you use wmemcpy if you know
+ that s1 and s2 DO NOT Overlap. If s1 and s2 might possibly overlap, then
+ use wmemmove.
+
+ @return The wmemmove function returns the value of s1.
+**/
+wchar_t *wmemmove(wchar_t *s1, const wchar_t *s2, size_t n)
+{
+ return (wchar_t *)CopyMem( s1, s2, (UINTN)(n * sizeof(wchar_t)));
+}
diff --git a/StdLib/LibC/Wchar/Searching.c b/StdLib/LibC/Wchar/Searching.c
new file mode 100644
index 0000000000..c345dfe838
--- /dev/null
+++ b/StdLib/LibC/Wchar/Searching.c
@@ -0,0 +1,268 @@
+/** @file
+ Search Functions for <wchar.h>.
+
+ Unless explicitly stated otherwise, the functions defined in this file order
+ two wide characters the same way as two integers of the underlying integer
+ type designated by wchar_t.
+
+ Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+**/
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+
+#include <LibConfig.h>
+
+#include <wchar.h>
+
+/* Data initialized by the library constructor */
+extern UINT8 *__wchar_bitmap;
+extern UINTN __wchar_bitmap_size;
+extern UINTN __wchar_bitmap_64;
+
+/** The wcschr function locates the first occurrence of c in the wide string
+ pointed to by s. The terminating null wide character is considered to be
+ part of the wide string.
+
+ @return The wcschr function returns a pointer to the located wide
+ character, or a null pointer if the wide character does not occur
+ in the wide string.
+**/
+wchar_t *wcschr(const wchar_t *s, wchar_t c)
+{
+ do {
+ if( *s == c) {
+ return (wchar_t *)s;
+ }
+ } while(*s++ != 0);
+ return NULL;
+}
+
+static UINT8 BitMask[] = {
+ 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
+ };
+
+#define WHICH8(c) ((unsigned short)(c) >> 3)
+#define WHICH_BIT(c) (BitMask[((c) & 0x7)])
+#define BITMAP64 ((UINT64 *)bitmap)
+
+static
+void
+BuildBitmap(unsigned char * bitmap, const wchar_t *s2, UINTN n)
+{
+ UINT8 bit;
+ UINTN index;
+
+ //// Initialize bitmap. Bit 0 is always 1 which corresponds to '\0'
+ //for (BITMAP64[0] = index = 1; index < n; index++)
+ // BITMAP64[index] = 0;
+ (void)wmemset( (wchar_t *)bitmap, 0, n / sizeof(wchar_t));
+ bitmap[0] = 1;
+
+ // Set bits in bitmap corresponding to the characters in s2
+ for (; *s2 != 0; ++s2) {
+ index = WHICH8(*s2);
+ bit = WHICH_BIT(*s2);
+ bitmap[index] |= bit;
+ }
+}
+
+/** The wcscspn function computes the length of the maximum initial segment of
+ the wide string pointed to by s1 which consists entirely of wide characters
+ not from the wide string pointed to by s2.
+
+ @return The wcscspn function returns the length of the segment.
+**/
+size_t wcscspn(const wchar_t *s1, const wchar_t *s2)
+{
+ const wchar_t *str;
+ UINT8 bit;
+ int index;
+
+ if(*s1 == 0) return 0;
+
+ BuildBitmap( __wchar_bitmap, s2, __wchar_bitmap_size);
+
+ for(str = s1; ; str++) {
+ index = WHICH8(*str);
+ bit = WHICH_BIT(*str);
+ if ((__wchar_bitmap[index] & bit) != 0)
+ break;
+ }
+ return (str - s1);
+}
+
+/** The wcspbrk function locates the first occurrence in the wide string
+ pointed to by s1 of any wide character from the wide string
+ pointed to by s2.
+
+ @return The wcspbrk function returns a pointer to the wide character
+ in s1, or a null pointer if no wide character from s2 occurs
+ in s1.
+**/
+wchar_t *wcspbrk(const wchar_t *s1, const wchar_t *s2)
+{
+ UINT8 bit;
+ int index;
+
+ BuildBitmap( __wchar_bitmap, s2, __wchar_bitmap_size);
+
+ for( ; *s1 != 0; ++s1) {
+ index = WHICH8(*s1);
+ bit = WHICH_BIT(*s1);
+ if( (__wchar_bitmap[index] & bit) != 0) {
+ return (wchar_t *)s1;
+ }
+ }
+ return NULL;
+}
+
+/** The wcsrchr function locates the last occurrence of c in the wide string
+ pointed to by s. The terminating null wide character is considered to be
+ part of the wide string.
+
+ @return The wcsrchr function returns a pointer to the wide character,
+ or a null pointer if c does not occur in the wide string.
+**/
+wchar_t *wcsrchr(const wchar_t *s, wchar_t c)
+{
+ wchar_t *found = NULL;
+
+ do {
+ if( *s == c) found = (wchar_t *)s;
+ } while( *s++ != 0);
+
+ return found;
+}
+
+/** The wcsspn function computes the length of the maximum initial segment of
+ the wide string pointed to by s1 which consists entirely of wide characters
+ from the wide string pointed to by s2.
+
+ @return The wcsspn function returns the length of the segment.
+**/
+size_t wcsspn(const wchar_t *s1, const wchar_t *s2)
+{
+ size_t length = 0;
+ int index;
+ UINT8 bit;
+
+ BuildBitmap( __wchar_bitmap, s2, __wchar_bitmap_size);
+
+ for( ; *s1 != 0; ++s1) {
+ index = WHICH8(*s1);
+ bit = WHICH_BIT(*s1);
+ if( (__wchar_bitmap[index] & bit) == 0) break;
+ ++length;
+ }
+ return length;
+}
+
+/** The wcsstr function locates the first occurrence in the wide string pointed
+ to by s1 of the sequence of wide characters (excluding the terminating null
+ wide character) in the wide string pointed to by s2.
+
+ @return The wcsstr function returns a pointer to the located wide string,
+ or a null pointer if the wide string is not found. If s2 points
+ to a wide string with zero length, the function returns s1.
+**/
+wchar_t *wcsstr(const wchar_t *s1, const wchar_t *s2)
+{
+ return (wchar_t *)StrStr( (CONST CHAR16 *)s1, (CONST CHAR16 *)s2);
+}
+
+/** A sequence of calls to the wcstok function breaks the wide string pointed
+ to by s1 into a sequence of tokens, each of which is delimited by a wide
+ character from the wide string pointed to by s2. The third argument points
+ to a caller-provided wchar_t pointer into which the wcstok function stores
+ information necessary for it to continue scanning the same wide string.
+
+ The first call in a sequence has a non-null first argument and stores an
+ initial value in the object pointed to by ptr. Subsequent calls in the
+ sequence have a null first argument and the object pointed to by ptr is
+ required to have the value stored by the previous call in the sequence,
+ which is then updated. The separator wide string pointed to by s2 may be
+ different from call to call.
+
+ The first call in the sequence searches the wide string pointed to by s1
+ for the first wide character that is not contained in the current separator
+ wide string pointed to by s2. If no such wide character is found, then
+ there are no tokens in the wide string pointed to by s1 and the wcstok
+ function returns a null pointer. If such a wide character is found, it is
+ the start of the first token.
+
+ The wcstok function then searches from there for a wide character that is
+ contained in the current separator wide string. If no such wide character
+ is found, the current token extends to the end of the wide string pointed
+ to by s1, and subsequent searches in the same wide string for a token
+ return a null pointer. If such a wide character is found, it is overwritten
+ by a null wide character, which terminates the current token.
+
+ In all cases, the wcstok function stores sufficient information in the
+ pointer pointed to by ptr so that subsequent calls, with a null pointer for
+ s1 and the unmodified pointer value for ptr, shall start searching just
+ past the element overwritten by a null wide character (if any).
+
+ @return The wcstok function returns a pointer to the first wide character
+ of a token, or a null pointer if there is no token.
+**/
+wchar_t *wcstok(wchar_t * __restrict s1, const wchar_t * __restrict s2, wchar_t ** __restrict ptr)
+{
+ wchar_t *Token = NULL;
+ int index;
+ UINT8 bit;
+
+ if( (s1 == NULL)
+ && ((s1 = *ptr) == NULL))
+ {
+ return NULL;
+ }
+
+ // s2 can be different on each call, so build the bitmap each time.
+ BuildBitmap( __wchar_bitmap, s2, __wchar_bitmap_size);
+
+ // skip leading delimiters: all chars in s2
+ for( ; *s1 != 0; ++s1) {
+ index = WHICH8(*s1);
+ bit = WHICH_BIT(*s1);
+ if( (__wchar_bitmap[index] & bit) == 0) break;
+ }
+ if( *s1 != 0)
+ {
+ // Remember this point, it is the start of the token
+ Token = s1++;
+
+ // find the next delimiter and replace it with a '\0'
+ for( ; *s1 != 0; ++s1) {
+ index = WHICH8(*s1);
+ bit = WHICH_BIT(*s1);
+ if( (__wchar_bitmap[index] & bit) != 0) {
+ *s1++ = 0;
+ *ptr = s1;
+ return Token;
+ }
+ }
+ }
+ *ptr = NULL;
+ return Token;
+}
+
+/** The wmemchr function locates the first occurrence of c in the initial n
+ wide characters of the object pointed to by s.
+
+ @return The wmemchr function returns a pointer to the located wide
+ character, or a null pointer if the wide character does not occur
+ in the object.
+**/
+wchar_t *wmemchr(const wchar_t *s, wchar_t c, size_t n)
+{
+ return (wchar_t *)ScanMem16( s, (UINTN)(n * sizeof(wchar_t)), (UINT16)c);
+}
diff --git a/StdLib/LibC/Wchar/String.c b/StdLib/LibC/Wchar/String.c
new file mode 100644
index 0000000000..70f6d9aedf
--- /dev/null
+++ b/StdLib/LibC/Wchar/String.c
@@ -0,0 +1,43 @@
+/** @file
+ Miscelaneous Functions for <wchar.h>.
+
+ Unless explicitly stated otherwise, if the execution of a function declared
+ in this file causes copying to take place between objects that overlap, the
+ behavior is undefined.
+
+ Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+**/
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+
+#include <LibConfig.h>
+
+#include <wchar.h>
+
+/** The wcslen function computes the length of the wide string pointed to by s.
+
+ @return The wcslen function returns the number of wide characters that
+ precede the terminating null wide character.
+**/
+size_t wcslen(const wchar_t *s)
+{
+ return (size_t)StrLen( (CONST CHAR16 *)s);
+}
+
+/** The wmemset function copies the value of c into each of the first n wide
+ characters of the object pointed to by s.
+
+ @return The wmemset function returns the value of s.
+**/
+wchar_t *wmemset(wchar_t *s, wchar_t c, size_t n)
+{
+ return (wchar_t *)SetMem16( s, (UINTN)(n * sizeof(wchar_t)), (UINT16)c);
+}
diff --git a/StdLib/LibC/Wchar/Wchar.inf b/StdLib/LibC/Wchar/Wchar.inf
new file mode 100644
index 0000000000..427d615742
--- /dev/null
+++ b/StdLib/LibC/Wchar/Wchar.inf
@@ -0,0 +1,59 @@
+## @file
+# Standard C library: Miscelaneous implementations.
+#
+# Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+#
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php.
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = LibWchar
+ FILE_GUID = 42c078ef-14a8-4e30-9329-6f12d796e54a
+ MODULE_TYPE = UEFI_APPLICATION
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = LibWchar
+ CONSTRUCTOR = __wchar_construct
+ DESTRUCTOR = __wchar_deconstruct
+
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF
+#
+
+[Sources]
+ ConsDecons.c
+ Copying.c
+ Concatenation.c
+ Comparison.c
+ Searching.c
+ String.c
+
+[Packages]
+ StdLib/StdLib.dec
+ StdLibPrivateInternalFiles/DoNotUse.dec
+ MdePkg/MdePkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ MemoryAllocationLib
+ LibC
+
+################################################################
+#
+# The Build Options, below, are only used when building the C library.
+# DO NOT use them when building your application!
+# Nasty things could happen if you do.
+#
+# /Oi is required for Microsoft VC++ to allow "intrinsic" functions to be
+# defined in this library.
+#
+[BuildOptions]
+ MSFT:*_*_*_CC_FLAGS = /Oi-