am b632857a
: Merge "Add missing include and function prototype for sched_getaffinity."
* commit 'b632857a50a1fd2b759316d07ace6c36f6f418cf': Add missing include and function prototype for sched_getaffinity.
This commit is contained in:
commit
76db50ddc9
2 changed files with 15 additions and 11 deletions
|
@ -170,7 +170,6 @@ libc_common_src_files := \
|
||||||
bionic/recv.c \
|
bionic/recv.c \
|
||||||
bionic/sched_cpualloc.c \
|
bionic/sched_cpualloc.c \
|
||||||
bionic/sched_cpucount.c \
|
bionic/sched_cpucount.c \
|
||||||
bionic/sched_getaffinity.c \
|
|
||||||
bionic/sched_getcpu.c \
|
bionic/sched_getcpu.c \
|
||||||
bionic/semaphore.c \
|
bionic/semaphore.c \
|
||||||
bionic/send.c \
|
bionic/send.c \
|
||||||
|
@ -264,6 +263,7 @@ libc_bionic_src_files := \
|
||||||
bionic/raise.cpp \
|
bionic/raise.cpp \
|
||||||
bionic/sbrk.cpp \
|
bionic/sbrk.cpp \
|
||||||
bionic/scandir.cpp \
|
bionic/scandir.cpp \
|
||||||
|
bionic/sched_getaffinity.cpp \
|
||||||
bionic/__set_errno.cpp \
|
bionic/__set_errno.cpp \
|
||||||
bionic/setlocale.cpp \
|
bionic/setlocale.cpp \
|
||||||
bionic/signalfd.cpp \
|
bionic/signalfd.cpp \
|
||||||
|
|
|
@ -25,17 +25,21 @@
|
||||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _GNU_SOURCE 1
|
#define _GNU_SOURCE 1
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
int sched_getaffinity(pid_t pid, size_t setsize, cpu_set_t* set)
|
extern "C" int __sched_getaffinity(pid_t, size_t, cpu_set_t*);
|
||||||
{
|
|
||||||
int ret = __sched_getaffinity(pid, setsize, set);
|
int sched_getaffinity(pid_t pid, size_t set_size, cpu_set_t* set) {
|
||||||
if (ret >= 0) {
|
int rc = __sched_getaffinity(pid, set_size, set);
|
||||||
if ((size_t)ret < setsize) {
|
if (rc == -1) {
|
||||||
memset((char*)set + ret, '\0', setsize - (size_t)ret);
|
return -1;
|
||||||
}
|
}
|
||||||
ret = 0;
|
|
||||||
}
|
// Clear any bytes the kernel didn't touch.
|
||||||
return ret;
|
// (The kernel returns the number of bytes written on success.)
|
||||||
|
memset(reinterpret_cast<char*>(set) + rc, 0, set_size - rc);
|
||||||
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in a new issue