1f08c3bdfSopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 2f08c3bdfSopenharmony_ci/* 3f08c3bdfSopenharmony_ci * Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved. 4f08c3bdfSopenharmony_ci */ 5f08c3bdfSopenharmony_ci 6f08c3bdfSopenharmony_ci/* 7f08c3bdfSopenharmony_ci * Some old libcs (like glibc < 2.7) do not provide interfaces for 8f08c3bdfSopenharmony_ci * dynamically sized cpu sets, but provide only static cpu_set_t type 9f08c3bdfSopenharmony_ci * with no more than CPU_SETSIZE cpus in it. 10f08c3bdfSopenharmony_ci * 11f08c3bdfSopenharmony_ci * This file is a wrapper of the dynamic interfaces using the static ones. 12f08c3bdfSopenharmony_ci * 13f08c3bdfSopenharmony_ci * If the number of cpus available on the system is greater than 14f08c3bdfSopenharmony_ci * CPU_SETSIZE, this interface will not work. Update libc in this case :) 15f08c3bdfSopenharmony_ci */ 16f08c3bdfSopenharmony_ci 17f08c3bdfSopenharmony_ci#define _GNU_SOURCE 18f08c3bdfSopenharmony_ci#include <sched.h> 19f08c3bdfSopenharmony_ci 20f08c3bdfSopenharmony_ci#ifndef LAPI_CPUSET_H__ 21f08c3bdfSopenharmony_ci#define LAPI_CPUSET_H__ 22f08c3bdfSopenharmony_ci 23f08c3bdfSopenharmony_ci#ifndef CPU_ALLOC 24f08c3bdfSopenharmony_ci#define CPU_ALLOC(ncpus) malloc(sizeof(cpu_set_t)); \ 25f08c3bdfSopenharmony_ciif (ncpus > CPU_SETSIZE) { \ 26f08c3bdfSopenharmony_ci tst_brk(TCONF, \ 27f08c3bdfSopenharmony_ci "Your libc does not support masks with %ld cpus", (long)ncpus); \ 28f08c3bdfSopenharmony_ci} 29f08c3bdfSopenharmony_ci#endif 30f08c3bdfSopenharmony_ci 31f08c3bdfSopenharmony_ci#ifndef CPU_FREE 32f08c3bdfSopenharmony_ci#define CPU_FREE(ptr) free(ptr) 33f08c3bdfSopenharmony_ci#endif 34f08c3bdfSopenharmony_ci 35f08c3bdfSopenharmony_ci#ifndef CPU_ALLOC_SIZE 36f08c3bdfSopenharmony_ci#define CPU_ALLOC_SIZE(size) sizeof(cpu_set_t) 37f08c3bdfSopenharmony_ci#endif 38f08c3bdfSopenharmony_ci 39f08c3bdfSopenharmony_ci#ifndef CPU_ZERO_S 40f08c3bdfSopenharmony_ci#define CPU_ZERO_S(size, mask) CPU_ZERO(mask) 41f08c3bdfSopenharmony_ci#endif 42f08c3bdfSopenharmony_ci 43f08c3bdfSopenharmony_ci#ifndef CPU_SET_S 44f08c3bdfSopenharmony_ci#define CPU_SET_S(cpu, size, mask) CPU_SET(cpu, mask) 45f08c3bdfSopenharmony_ci#endif 46f08c3bdfSopenharmony_ci 47f08c3bdfSopenharmony_ci#ifndef CPU_ISSET_S 48f08c3bdfSopenharmony_ci#define CPU_ISSET_S(cpu, size, mask) CPU_ISSET(cpu, mask) 49f08c3bdfSopenharmony_ci#endif 50f08c3bdfSopenharmony_ci 51f08c3bdfSopenharmony_ci#endif /* LAPI_CPUSET_H__ */ 52