From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/9435 Path: news.gmane.org!not-for-mail From: Nathan Zadoks Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH 1/2] add sched_getcpu Date: Wed, 2 Mar 2016 17:26:26 +0100 Message-ID: <1456935987-24047-2-git-send-email-nathan@nathan7.eu> References: <20160302055542.GN9349@brightrain.aerifal.cx> <1456935987-24047-1-git-send-email-nathan@nathan7.eu> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1456936078 2161 80.91.229.3 (2 Mar 2016 16:27:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 2 Mar 2016 16:27:58 +0000 (UTC) Cc: Nathan Zadoks To: musl@lists.openwall.com Original-X-From: musl-return-9448-gllmg-musl=m.gmane.org@lists.openwall.com Wed Mar 02 17:27:49 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1ab9co-0006Tl-4Q for gllmg-musl@m.gmane.org; Wed, 02 Mar 2016 17:27:46 +0100 Original-Received: (qmail 30624 invoked by uid 550); 2 Mar 2016 16:27:44 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 28576 invoked from network); 2 Mar 2016 16:26:45 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nathan7.eu; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TeWZT3Dca9QVTnz6WTsuWhyvXbhg6UvI/CV4l+IH8D0=; b=dL5uIxgZxBhR2OLxudjKCs+1OpQ5Zk5bzAUyQDu0PqwuYEWNXof3Pk5LElJ/aUmTwV 1n7+uJkcClgmxmH65mxGqOdLL9vllMzCyOTkuLZxxTLtYMxPZue4+PPfDYJ7XyRA4oyD Bi7GPMghWeSgL5kwMeEio9YfOoumQvKCXczOU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TeWZT3Dca9QVTnz6WTsuWhyvXbhg6UvI/CV4l+IH8D0=; b=m21vAI6yfVyytqRCSYpN96ZU7ZX3rJDtE2Eso4+P3ZdZEiOTK96z5FEN7+NXgHk8v+ zDkJy9zjTPXY4O7Y/0tVxhUbTLEVgnYIAnsOJtHydv6Hq6DsgZ3Txh89FQIy4r4PziNu Do0lx15U3Gstu5tjxcWWrJfNrZFVrFZzSBw0HFcteQpthqAyJ4Rub85sf970WMdzoXU3 cFt6/SulAfnarclkQ2JPHC33midNfzMR/5HyXhlAHorzPk5f9/ojBgme7Uhm5LaQ/Au1 ZO6WSGfVMqKMEWrHuPc8CsmYDAZz70Yxz9iZeP67Grdj6vjqqpy+AOBe3uxtcL3eL79i crAA== X-Gm-Message-State: AD7BkJINf3HO15vT9tMoywABndtuke34jn+2QwOvsHx3P/W0z/a7DStfi5KDs3oqAhcyjw== X-Received: by 10.28.51.74 with SMTP id z71mr771193wmz.15.1456935994715; Wed, 02 Mar 2016 08:26:34 -0800 (PST) X-Mailer: git-send-email 2.7.1 In-Reply-To: <1456935987-24047-1-git-send-email-nathan@nathan7.eu> Xref: news.gmane.org gmane.linux.lib.musl.general:9435 Archived-At: This is a GNU extension, but a fairly minor one, for a system call that otherwise has no libc wrapper. Adding it was discussed previously, without any objections: http://www.openwall.com/lists/musl/2015/05/08/24 --- include/sched.h | 1 + src/sched/sched_getcpu.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 src/sched/sched_getcpu.c diff --git a/include/sched.h b/include/sched.h index 3e34a72..7e88f09 100644 --- a/include/sched.h +++ b/include/sched.h @@ -76,6 +76,7 @@ void free(void *); typedef struct cpu_set_t { unsigned long __bits[128/sizeof(long)]; } cpu_set_t; int __sched_cpucount(size_t, const cpu_set_t *); +int sched_getcpu(void); int sched_getaffinity(pid_t, size_t, cpu_set_t *); int sched_setaffinity(pid_t, size_t, const cpu_set_t *); diff --git a/src/sched/sched_getcpu.c b/src/sched/sched_getcpu.c new file mode 100644 index 0000000..760e4d5 --- /dev/null +++ b/src/sched/sched_getcpu.c @@ -0,0 +1,13 @@ +#define _GNU_SOURCE +#include +#include "syscall.h" + +int sched_getcpu(void) +{ + int r; + unsigned cpu; + + r = __syscall(SYS_getcpu, &cpu, 0, 0); + if (!r) return cpu; + return __syscall_ret(r); +} -- 2.7.1