mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 16:22:29 +00:00
Introduce sigtimedwait() and sigwaitinfo()
This change also invents sigcountset() and strsignal_r() and improves the quality of siginfo_t handling.
This commit is contained in:
parent
7ae556463a
commit
467a332e38
41 changed files with 887 additions and 345 deletions
|
@ -49,10 +49,6 @@ static uint64_t Rando(void) {
|
|||
return x;
|
||||
}
|
||||
|
||||
void SetUp(void) {
|
||||
__print_maps();
|
||||
}
|
||||
|
||||
static const struct {
|
||||
const char *want;
|
||||
const char *fmt;
|
||||
|
@ -356,6 +352,30 @@ TEST(ksnprintf, badUtf16) {
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ksnprintf, negativeOverflowIdiom_isSafe) {
|
||||
int i, n;
|
||||
char golden[11];
|
||||
struct {
|
||||
char underflow[11];
|
||||
char buf[11];
|
||||
char overflow[11];
|
||||
} u;
|
||||
memset(golden, -1, 11);
|
||||
memset(u.underflow, -1, 11);
|
||||
memset(u.overflow, -1, 11);
|
||||
i = 0;
|
||||
n = 11;
|
||||
i += ksnprintf(u.buf + i, n - i, "hello");
|
||||
ASSERT_STREQ("hello", u.buf);
|
||||
i += ksnprintf(u.buf + i, n - i, " world");
|
||||
ASSERT_STREQ("hello w...", u.buf);
|
||||
i += ksnprintf(u.buf + i, n - i, " i love you");
|
||||
ASSERT_STREQ("hello w...", u.buf);
|
||||
ASSERT_EQ(i, 5 + 6 + 11);
|
||||
ASSERT_EQ(0, memcmp(golden, u.underflow, 11));
|
||||
ASSERT_EQ(0, memcmp(golden, u.overflow, 11));
|
||||
}
|
||||
|
||||
TEST(ksnprintf, truncation) {
|
||||
char buf[16] = {0};
|
||||
rngset(buf, sizeof(buf) - 1, lemur64, -1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue