Make more compatibility improvements

This commit is contained in:
Justine Tunney 2022-09-06 07:04:13 -07:00
parent 12d9e1e128
commit 55c6297e13
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
63 changed files with 513 additions and 80 deletions

View file

@ -16,10 +16,12 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/intrin/popcnt.h"
#include "libc/calls/calls.h"
#include "libc/calls/struct/cpuset.h"
#include "libc/dce.h"
#include "libc/intrin/popcnt.h"
#include "libc/runtime/runtime.h"
#include "libc/runtime/sysconf.h"
#include "libc/testlib/testlib.h"
void SetUp(void) {
@ -28,7 +30,25 @@ void SetUp(void) {
}
}
TEST(sched_getaffinity, test) {
uint64_t s[16];
EXPECT_SYS(0, 0, sched_getaffinity(0, sizeof(s), &s));
TEST(sched_getaffinity, firstOnly) {
cpu_set_t x, y;
CPU_ZERO(&x);
CPU_SET(0, &x);
ASSERT_SYS(0, 0, sched_setaffinity(0, sizeof(x), &x));
ASSERT_SYS(0, 0, sched_getaffinity(0, sizeof(y), &y));
EXPECT_EQ(1, CPU_COUNT(&y));
EXPECT_TRUE(CPU_ISSET(0, &y));
EXPECT_FALSE(CPU_ISSET(1, &y));
}
TEST(sched_getaffinity, secondOnly) {
if (GetCpuCount() < 2) return;
cpu_set_t x, y;
CPU_ZERO(&x);
CPU_SET(1, &x);
ASSERT_SYS(0, 0, sched_setaffinity(0, sizeof(x), &x));
ASSERT_SYS(0, 0, sched_getaffinity(0, sizeof(y), &y));
EXPECT_EQ(1, CPU_COUNT(&y));
EXPECT_FALSE(CPU_ISSET(0, &y));
EXPECT_TRUE(CPU_ISSET(1, &y));
}