From ebdfd16f0fa5a642930ab3afd19d214f1b0625b6 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 22 Sep 2020 17:09:13 -0600 Subject: [PATCH] Move gettid() implementation to /libs/libc/unistd Move sched/task/task/task_gettid.c to libs/libc/unistd/lib_gettid.c. gettid() is a dumb wrapper around getpid(). It is wasteful of resources to support TWO systme calls, one for getpid() and one for gettid(). Instead, move gettid() in the C library where it calls the single sysgtem call, getpid(). Much cleaner. --- include/sys/syscall_lookup.h | 1 - libs/libc/unistd/Make.defs | 1 + sched/task/task_gettid.c => libs/libc/unistd/lib_gettid.c | 2 +- sched/task/Make.defs | 2 +- syscall/syscall.csv | 1 - 5 files changed, 3 insertions(+), 4 deletions(-) rename sched/task/task_gettid.c => libs/libc/unistd/lib_gettid.c (98%) diff --git a/include/sys/syscall_lookup.h b/include/sys/syscall_lookup.h index 279671d4ec..8b1e1b3158 100644 --- a/include/sys/syscall_lookup.h +++ b/include/sys/syscall_lookup.h @@ -27,7 +27,6 @@ SYSCALL_LOOKUP1(_exit, 1) SYSCALL_LOOKUP(exit, 1) SYSCALL_LOOKUP(getpid, 0) -SYSCALL_LOOKUP(gettid, 0) SYSCALL_LOOKUP(sched_getparam, 2) SYSCALL_LOOKUP(sched_getscheduler, 1) diff --git a/libs/libc/unistd/Make.defs b/libs/libc/unistd/Make.defs index cd08f3a68c..40410dbd81 100644 --- a/libs/libc/unistd/Make.defs +++ b/libs/libc/unistd/Make.defs @@ -44,6 +44,7 @@ CSRCS += lib_getrusage.c lib_utimes.c CSRCS += lib_setrlimit.c lib_getrlimit.c CSRCS += lib_setpriority.c lib_getpriority.c CSRCS += lib_futimes.c lib_futimens.c +CSRCS += lib_gettid.c ifneq ($(CONFIG_SCHED_USER_IDENTITY),y) CSRCS += lib_setuid.c lib_setgid.c lib_getuid.c lib_getgid.c diff --git a/sched/task/task_gettid.c b/libs/libc/unistd/lib_gettid.c similarity index 98% rename from sched/task/task_gettid.c rename to libs/libc/unistd/lib_gettid.c index 50ff087350..dd07ad1a7e 100644 --- a/sched/task/task_gettid.c +++ b/libs/libc/unistd/lib_gettid.c @@ -1,5 +1,5 @@ /**************************************************************************** - * sched/task/task_gettid.c + * libs/libc/unistd/lib_gettid.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/sched/task/Make.defs b/sched/task/Make.defs index 46dc859c61..1fa00c7834 100644 --- a/sched/task/Make.defs +++ b/sched/task/Make.defs @@ -37,7 +37,7 @@ CSRCS += task_create.c task_init.c task_setup.c task_activate.c CSRCS += task_start.c task_delete.c task_exit.c task_exithook.c CSRCS += task_getgroup.c task_getpid.c task_prctl.c task_recover.c CSRCS += task_restart.c task_spawnparms.c task_setcancelstate.c -CSRCS += task_cancelpt.c task_terminate.c task_gettid.c exit.c +CSRCS += task_cancelpt.c task_terminate.c exit.c ifeq ($(CONFIG_ARCH_HAVE_VFORK),y) ifeq ($(CONFIG_SCHED_WAITPID),y) diff --git a/syscall/syscall.csv b/syscall/syscall.csv index ac544aa70f..ca91a5115f 100644 --- a/syscall/syscall.csv +++ b/syscall/syscall.csv @@ -35,7 +35,6 @@ "getitimer","sys/time.h","!defined(CONFIG_DISABLE_POSIX_TIMERS)","int","int","FAR struct itimerval *" "getpeername","sys/socket.h","defined(CONFIG_NET)","int","int","FAR struct sockaddr *","FAR socklen_t *" "getpid","unistd.h","","pid_t" -"gettid","unistd.h","","pid_t" "getrandom","sys/random.h","defined(CONFIG_CRYPTO_RANDOM_POOL)","void","FAR void *","size_t" "getsockname","sys/socket.h","defined(CONFIG_NET)","int","int","FAR struct sockaddr *","FAR socklen_t *" "getsockopt","sys/socket.h","defined(CONFIG_NET)","int","int","int","int","FAR void *","FAR socklen_t *"