summaryrefslogtreecommitdiffstats
path: root/libc/bionic
diff options
context:
space:
mode:
Diffstat (limited to 'libc/bionic')
-rw-r--r--libc/bionic/sched_getcpu.cpp (renamed from libc/bionic/sched_getcpu.c)17
1 files changed, 9 insertions, 8 deletions
diff --git a/libc/bionic/sched_getcpu.c b/libc/bionic/sched_getcpu.cpp
index 954df37..1f92e54 100644
--- a/libc/bionic/sched_getcpu.c
+++ b/libc/bionic/sched_getcpu.cpp
@@ -25,16 +25,17 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+
#define _GNU_SOURCE 1
#include <sched.h>
-extern int __getcpu(unsigned *cpu, unsigned *node, void* unused);
-
-int sched_getcpu(void)
-{
- unsigned cpu;
- if (__getcpu(&cpu, NULL, NULL) < 0)
- return 0;
+extern "C" int __getcpu(unsigned*, unsigned*, void*);
- return (int)cpu;
+int sched_getcpu() {
+ unsigned cpu;
+ int rc = __getcpu(&cpu, NULL, NULL);
+ if (rc == -1) {
+ return -1; // errno is already set.
+ }
+ return cpu;
}