[libc] Add entrypoint for iswxdigit (#185574)
This PR intends to add entrypoints and some smoke tests for `iswxdigit` function Changes made are :- - Added entrypoint for `iswxdigit` in wctype.yaml - Added CMake entrypoint object for `iswxdigit` - Added Header and implementation in `iswxdigit.h` and `iswxdigit.cpp` - Added test for `iswxdigit` in iswxdigit_test.cpp - Added `iswxdigit` in entrypoints.txt for available platforms Tested using = `ninja libc.test.src.wctype.iswxdigit_test.__unit__` passes all tests part of #185136
This commit is contained in:
parent
9480187a48
commit
49d9ba9572
@ -305,6 +305,7 @@ set(TARGET_LIBC_ENTRYPOINTS
|
||||
libc.src.wctype.iswlower
|
||||
libc.src.wctype.iswspace
|
||||
libc.src.wctype.iswblank
|
||||
libc.src.wctype.iswxdigit
|
||||
|
||||
# internal entrypoints
|
||||
libc.startup.baremetal.init
|
||||
|
||||
@ -302,6 +302,7 @@ set(TARGET_LIBC_ENTRYPOINTS
|
||||
libc.src.wctype.iswlower
|
||||
libc.src.wctype.iswspace
|
||||
libc.src.wctype.iswblank
|
||||
libc.src.wctype.iswxdigit
|
||||
|
||||
# internal entrypoints
|
||||
libc.startup.baremetal.init
|
||||
|
||||
@ -108,6 +108,7 @@ set(TARGET_LIBC_ENTRYPOINTS
|
||||
libc.src.wctype.iswlower
|
||||
libc.src.wctype.iswspace
|
||||
libc.src.wctype.iswblank
|
||||
libc.src.wctype.iswxdigit
|
||||
)
|
||||
|
||||
if(LLVM_LIBC_FULL_BUILD)
|
||||
|
||||
@ -375,6 +375,7 @@ set(TARGET_LIBC_ENTRYPOINTS
|
||||
libc.src.wctype.iswlower
|
||||
libc.src.wctype.iswspace
|
||||
libc.src.wctype.iswblank
|
||||
libc.src.wctype.iswxdigit
|
||||
|
||||
# sys/uio.h entrypoints
|
||||
libc.src.sys.uio.writev
|
||||
|
||||
@ -200,6 +200,7 @@ set(TARGET_LIBC_ENTRYPOINTS
|
||||
libc.src.wctype.iswlower
|
||||
libc.src.wctype.iswspace
|
||||
libc.src.wctype.iswblank
|
||||
libc.src.wctype.iswxdigit
|
||||
)
|
||||
|
||||
if(LLVM_LIBC_FULL_BUILD)
|
||||
|
||||
@ -379,6 +379,7 @@ set(TARGET_LIBC_ENTRYPOINTS
|
||||
libc.src.wctype.iswlower
|
||||
libc.src.wctype.iswspace
|
||||
libc.src.wctype.iswblank
|
||||
libc.src.wctype.iswxdigit
|
||||
|
||||
# sys/uio.h entrypoints
|
||||
libc.src.sys.uio.writev
|
||||
|
||||
@ -424,6 +424,7 @@ set(TARGET_LIBC_ENTRYPOINTS
|
||||
libc.src.wctype.iswlower
|
||||
libc.src.wctype.iswspace
|
||||
libc.src.wctype.iswblank
|
||||
libc.src.wctype.iswxdigit
|
||||
|
||||
# sys/uio.h entrypoints
|
||||
libc.src.sys.uio.writev
|
||||
|
||||
@ -113,6 +113,7 @@ set(TARGET_LIBC_ENTRYPOINTS
|
||||
libc.src.wctype.iswlower
|
||||
libc.src.wctype.iswspace
|
||||
libc.src.wctype.iswblank
|
||||
libc.src.wctype.iswxdigit
|
||||
)
|
||||
|
||||
set(TARGET_LIBM_ENTRYPOINTS
|
||||
|
||||
@ -38,3 +38,9 @@ functions:
|
||||
return_type: int
|
||||
arguments:
|
||||
- type: wint_t
|
||||
- name: iswxdigit
|
||||
standards:
|
||||
- stdc
|
||||
return_type: int
|
||||
arguments:
|
||||
- type: wint_t
|
||||
|
||||
@ -73,3 +73,14 @@ add_entrypoint_object(
|
||||
libc.src.__support.wctype_utils
|
||||
libc.hdr.types.wint_t
|
||||
)
|
||||
|
||||
add_entrypoint_object(
|
||||
iswxdigit
|
||||
SRCS
|
||||
iswxdigit.cpp
|
||||
HDRS
|
||||
iswxdigit.h
|
||||
DEPENDS
|
||||
libc.src.__support.wctype_utils
|
||||
libc.hdr.types.wint_t
|
||||
)
|
||||
|
||||
21
libc/src/wctype/iswxdigit.cpp
Normal file
21
libc/src/wctype/iswxdigit.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
//===-- Implementation of iswxdigit ---------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "src/wctype/iswxdigit.h"
|
||||
#include "src/__support/common.h"
|
||||
#include "src/__support/wctype_utils.h"
|
||||
|
||||
#include "hdr/types/wint_t.h"
|
||||
|
||||
namespace LIBC_NAMESPACE_DECL {
|
||||
|
||||
LLVM_LIBC_FUNCTION(int, iswxdigit, (wint_t c)) {
|
||||
return internal::isxdigit(static_cast<wchar_t>(c));
|
||||
}
|
||||
|
||||
} // namespace LIBC_NAMESPACE_DECL
|
||||
21
libc/src/wctype/iswxdigit.h
Normal file
21
libc/src/wctype/iswxdigit.h
Normal file
@ -0,0 +1,21 @@
|
||||
//===-- Implementation header for iswxdigit ---------------------*- C++ -*-===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_LIBC_SRC_WCTYPE_ISWXDIGIT_H
|
||||
#define LLVM_LIBC_SRC_WCTYPE_ISWXDIGIT_H
|
||||
|
||||
#include "hdr/types/wint_t.h"
|
||||
#include "src/__support/common.h"
|
||||
|
||||
namespace LIBC_NAMESPACE_DECL {
|
||||
|
||||
int iswxdigit(wint_t c);
|
||||
|
||||
} // namespace LIBC_NAMESPACE_DECL
|
||||
|
||||
#endif // LLVM_LIBC_SRC_WCTYPE_ISWXDIGIT_H
|
||||
@ -71,3 +71,13 @@ add_libc_test(
|
||||
DEPENDS
|
||||
libc.src.wctype.iswblank
|
||||
)
|
||||
|
||||
add_libc_test(
|
||||
iswxdigit_test
|
||||
SUITE
|
||||
libc_wctype_unittests
|
||||
SRCS
|
||||
iswxdigit_test.cpp
|
||||
DEPENDS
|
||||
libc.src.wctype.iswxdigit
|
||||
)
|
||||
|
||||
25
libc/test/src/wctype/iswxdigit_test.cpp
Normal file
25
libc/test/src/wctype/iswxdigit_test.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
//===-- Unittests for iswxdigit -------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "src/wctype/iswxdigit.h"
|
||||
#include "test/UnitTest/Test.h"
|
||||
|
||||
TEST(LlvmLibciswxdigit, SimpleTest) {
|
||||
EXPECT_NE(LIBC_NAMESPACE::iswxdigit(L'1'), 0);
|
||||
EXPECT_NE(LIBC_NAMESPACE::iswxdigit(L'2'), 0);
|
||||
EXPECT_NE(LIBC_NAMESPACE::iswxdigit(L'0'), 0);
|
||||
EXPECT_NE(LIBC_NAMESPACE::iswxdigit(L'a'), 0);
|
||||
EXPECT_NE(LIBC_NAMESPACE::iswxdigit(L'B'), 0);
|
||||
EXPECT_NE(LIBC_NAMESPACE::iswxdigit(L'F'), 0);
|
||||
|
||||
EXPECT_EQ(LIBC_NAMESPACE::iswxdigit(L'g'), 0);
|
||||
EXPECT_EQ(LIBC_NAMESPACE::iswxdigit(L'h'), 0);
|
||||
EXPECT_EQ(LIBC_NAMESPACE::iswxdigit(L'é'), 0);
|
||||
EXPECT_EQ(LIBC_NAMESPACE::iswxdigit(L' '), 0);
|
||||
EXPECT_EQ(LIBC_NAMESPACE::iswxdigit(L'!'), 0);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user