mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 05:42:29 +00:00
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few breaking changes needed to be made to help this go smoothly. - Rename nothrow to dontthrow - Rename nodiscard to dontdiscard - Add some libm functions, e.g. lgamma, nan, etc. - Change intmax_t from int128 to int64 like everything else - Introduce %jjd formatting directive for int128_t - Introduce strtoi128(), strtou128(), etc. - Rename bsrmax() to bsr128() Some of the templates that should be working currently are std::vector, std::string, std::map, std::set, std::deque, etc.
This commit is contained in:
parent
5022f9e920
commit
868af3f950
286 changed files with 123987 additions and 507 deletions
|
@ -572,7 +572,7 @@ TEST(xasprintf, hugeNtoa) {
|
|||
ASSERT_STREQ(
|
||||
"0b1111111111111111111111111111111111111111111111111111111111111111111111"
|
||||
"1111111111111111111111111111111111111111111111111111111111",
|
||||
gc(xasprintf("%#jb", UINT128_MAX)));
|
||||
gc(xasprintf("%#jjb", UINT128_MAX)));
|
||||
}
|
||||
|
||||
TEST(xasprintf, twosBane) {
|
||||
|
@ -591,20 +591,19 @@ TEST(snprintf, testFixedWidthString_wontOverrunInput) {
|
|||
free(buf);
|
||||
}
|
||||
|
||||
/* TODO(jart): why is this weird in TINY mode? */
|
||||
/* TEST(snprintf, testFixedWidthStringIsNull_wontOverrunBuffer) { */
|
||||
/* int N = 3; */
|
||||
/* char *buf = malloc(N + 1); */
|
||||
/* EXPECT_EQ(3, snprintf(buf, N + 1, "%.*s", pushpop(N), pushpop(NULL))); */
|
||||
/* EXPECT_STREQ("(nu", buf); */
|
||||
/* EXPECT_EQ(3, snprintf(buf, N + 1, "%#.*s", pushpop(N), pushpop(NULL))); */
|
||||
/* EXPECT_STREQ("(nu", buf); */
|
||||
/* EXPECT_EQ(3, snprintf(buf, N + 1, "%`'.*s", pushpop(N), pushpop(NULL))); */
|
||||
/* EXPECT_STREQ("NUL", buf); */
|
||||
/* EXPECT_EQ(3, snprintf(buf, N + 1, "%`#.*s", pushpop(N), pushpop(NULL))); */
|
||||
/* EXPECT_STREQ("NUL", buf); */
|
||||
/* free(buf); */
|
||||
/* } */
|
||||
TEST(snprintf, testFixedWidthStringIsNull_wontOverrunBuffer) {
|
||||
int N = 3;
|
||||
char *buf = malloc(N + 1);
|
||||
EXPECT_EQ(3, snprintf(buf, N + 1, "%.*s", pushpop(N), pushpop(NULL)));
|
||||
EXPECT_STREQ("(nu", buf);
|
||||
EXPECT_EQ(3, snprintf(buf, N + 1, "%#.*s", pushpop(N), pushpop(NULL)));
|
||||
EXPECT_STREQ("(nu", buf);
|
||||
EXPECT_EQ(3, snprintf(buf, N + 1, "%`'.*s", pushpop(N), pushpop(NULL)));
|
||||
EXPECT_STREQ("NUL", buf);
|
||||
EXPECT_EQ(3, snprintf(buf, N + 1, "%`#.*s", pushpop(N), pushpop(NULL)));
|
||||
EXPECT_STREQ("NUL", buf);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
TEST(snprintf, twosBaneWithTypePromotion) {
|
||||
int16_t x = 0x8000;
|
||||
|
@ -646,14 +645,10 @@ BENCH(palandprintf, bench) {
|
|||
EZBENCH2("INT_MIN %d", donothing, Format("%d", VEIL("r", INT_MIN)));
|
||||
EZBENCH2("INT_MIN %,d", donothing, Format("%,d", VEIL("r", INT_MIN)));
|
||||
EZBENCH2("INT_MIN %ld", donothing, Format("%ld", (long)VEIL("r", INT_MIN)));
|
||||
EZBENCH2("INT_MIN %jd", donothing,
|
||||
Format("%jd", (intmax_t)VEIL("r", INT_MIN)));
|
||||
EZBENCH2("LONG_MIN %lx", donothing, Format("%lx", VEIL("r", LONG_MIN)));
|
||||
EZBENCH2("LONG_MIN %ld", donothing, Format("%ld", VEIL("r", LONG_MIN)));
|
||||
EZBENCH2("LONG_MIN %jd", donothing,
|
||||
Format("%jd", (intmax_t)VEIL("r", LONG_MIN)));
|
||||
EZBENCH2("LONG_MIN %jx", donothing,
|
||||
Format("%jx", (intmax_t)VEIL("r", LONG_MIN)));
|
||||
EZBENCH2("INT128_MIN %jjd", donothing, Format("%jjd", INT128_MIN));
|
||||
EZBENCH2("INT128_MIN %jjx", donothing, Format("%jjx", INT128_MIN));
|
||||
EZBENCH2("int64toarray 23", donothing, int64toarray_radix10(23, buffer));
|
||||
EZBENCH2("int64toarray min", donothing,
|
||||
int64toarray_radix10(INT_MIN, buffer));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue