From patchwork Tue Aug 7 12:43:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guo Ren X-Patchwork-Id: 954499 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=uclibc-ng.org (client-ip=2a00:1828:2000:679::23; helo=helium.openadk.org; envelope-from=devel-bounces@uclibc-ng.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=c-sky.com Received: from helium.openadk.org (helium.openadk.org [IPv6:2a00:1828:2000:679::23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41lDhr2FHnz9s0n for ; Tue, 7 Aug 2018 22:43:38 +1000 (AEST) Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id 5F82D10402; Tue, 7 Aug 2018 14:43:35 +0200 (CEST) X-Original-To: devel@uclibc-ng.org Delivered-To: devel@helium.openadk.org Received: from smtp2200-217.mail.aliyun.com (smtp2200-217.mail.aliyun.com [121.197.200.217]) by helium.openadk.org (Postfix) with ESMTPS id BAE0E10299; Tue, 7 Aug 2018 14:43:31 +0200 (CEST) X-Alimail-AntiSpam: AC=CONTINUE; BC=0.07475899|-1; CH=green; FP=0|0|0|0|0|-1|-1|-1; HT=e02c03292; MF=ren_guo@c-sky.com; NM=1; PH=DS; RN=3; RT=3; SR=0; TI=SMTPD_---.Caud1.y_1533645803; Received: from localhost(mailfrom:ren_guo@c-sky.com fp:SMTPD_---.Caud1.y_1533645803) by smtp.aliyun-inc.com(10.147.41.231); Tue, 07 Aug 2018 20:43:23 +0800 From: Guo Ren To: devel@uclibc-ng.org, wbx@uclibc-ng.org Date: Tue, 7 Aug 2018 20:43:21 +0800 Message-Id: <1533645801-9554-1-git-send-email-ren_guo@c-sky.com> X-Mailer: git-send-email 2.7.4 Cc: Guo Ren Subject: [uclibc-ng-devel] [PATCH] sched_setaffinity: use the same style with glibc's X-BeenThere: devel@uclibc-ng.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: uClibc-ng Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: devel-bounces@uclibc-ng.org Sender: "devel" Call getpid() in INTERNAL_SYSCALL will break the argument regs, because gcc couldn't save destoryed regs for system call asm. Ref to glibc, we could just remove all the check code. Signed-off-by: Guo Ren --- libc/sysdeps/linux/common/sched_setaffinity.c | 34 --------------------------- 1 file changed, 34 deletions(-) diff --git a/libc/sysdeps/linux/common/sched_setaffinity.c b/libc/sysdeps/linux/common/sched_setaffinity.c index 3d513ef..39f6ec8 100644 --- a/libc/sysdeps/linux/common/sched_setaffinity.c +++ b/libc/sysdeps/linux/common/sched_setaffinity.c @@ -27,42 +27,8 @@ static __always_inline _syscall3(int, __syscall_sched_setaffinity, __kernel_pid_t, pid, size_t, cpusetsize, const cpu_set_t *, cpuset) -static size_t __kernel_cpumask_size; - int sched_setaffinity(pid_t pid, size_t cpusetsize, const cpu_set_t *cpuset) { - size_t cnt; - int res; - size_t psize = 128; - void *p = alloca (psize); - - if (unlikely (__kernel_cpumask_size == 0)) { - - INTERNAL_SYSCALL_DECL (err); - while (res = INTERNAL_SYSCALL (sched_getaffinity, err, 3, getpid (), - psize, p), - INTERNAL_SYSCALL_ERROR_P (res, err) - && INTERNAL_SYSCALL_ERRNO (res, err) == EINVAL) - p = extend_alloca (p, psize, 2 * psize); - - if (res == 0 || INTERNAL_SYSCALL_ERROR_P (res, err)) { - __set_errno (INTERNAL_SYSCALL_ERRNO (res, err)); - return -1; - } - - __kernel_cpumask_size = res; - } - - /* We now know the size of the kernel cpumask_t. Make sure the user - does not request to set a bit beyond that. */ - for (cnt = __kernel_cpumask_size; cnt < cpusetsize; ++cnt) - if (((char *) cpuset)[cnt] != '\0') { - /* Found a nonzero byte. This means the user request cannot be - fulfilled. */ - __set_errno (EINVAL); - return -1; - } - return __syscall_sched_setaffinity(pid, cpusetsize, cpuset); } #endif