aboutsummaryrefslogtreecommitdiff
path: root/nptl
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2022-04-21 09:41:59 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2022-06-30 14:56:21 -0300
commita1bdd81664aa681364da368154c48501db249df9 (patch)
tree29f01a9ad8bcda2794869dd0555537a2de16fa38 /nptl
parentc22d2021a9f9bdea62398976eea4f0e6ef668b7d (diff)
downloadglibc-a1bdd81664aa681364da368154c48501db249df9.zip
glibc-a1bdd81664aa681364da368154c48501db249df9.tar.gz
glibc-a1bdd81664aa681364da368154c48501db249df9.tar.bz2
Refactor internal-signals.h
The main drive is to optimize the internal usage and required size when sigset_t is embedded in other data structures. On Linux, the current supported signal set requires up to 8 bytes (16 on mips), was lower than the user defined sigset_t (128 bytes). A new internal type internal_sigset_t is added, along with the functions to operate on it similar to the ones for sigset_t. The internal-signals.h is also refactored to remove unused functions Besides small stack usage on some functions (posix_spawn, abort) it lower the struct pthread by about 120 bytes (112 on mips). Checked on x86_64-linux-gnu. Reviewed-by: Arjun Shankar <arjun@redhat.com>
Diffstat (limited to 'nptl')
-rw-r--r--nptl/descr.h3
-rw-r--r--nptl/pthread_attr_setsigmask.c2
-rw-r--r--nptl/pthread_create.c16
-rw-r--r--nptl/pthread_kill.c10
-rw-r--r--nptl/pthread_sigmask.c2
5 files changed, 17 insertions, 16 deletions
diff --git a/nptl/descr.h b/nptl/descr.h
index b585263..5cacb28 100644
--- a/nptl/descr.h
+++ b/nptl/descr.h
@@ -35,6 +35,7 @@
#include <kernel-features.h>
#include <tls-internal-struct.h>
#include <sys/rseq.h>
+#include <internal-sigset.h>
#ifndef TCB_ALIGNMENT
# define TCB_ALIGNMENT 32
@@ -387,7 +388,7 @@ struct pthread
/* Signal mask for the new thread. Used during thread startup to
restore the signal mask. (Threads are launched with all signals
masked.) */
- sigset_t sigmask;
+ internal_sigset_t sigmask;
/* Indicates whether is a C11 thread created by thrd_creat. */
bool c11;
diff --git a/nptl/pthread_attr_setsigmask.c b/nptl/pthread_attr_setsigmask.c
index a6e650f..908a0c1 100644
--- a/nptl/pthread_attr_setsigmask.c
+++ b/nptl/pthread_attr_setsigmask.c
@@ -28,7 +28,7 @@ pthread_attr_setsigmask_np (pthread_attr_t *attr, const sigset_t *sigmask)
/* Filter out internal signals. */
struct pthread_attr *iattr = (struct pthread_attr *) attr;
- __clear_internal_signals (&iattr->extension->sigmask);
+ clear_internal_signals (&iattr->extension->sigmask);
return 0;
}
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
index a06d611..308db65 100644
--- a/nptl/pthread_create.c
+++ b/nptl/pthread_create.c
@@ -423,7 +423,7 @@ start_thread (void *arg)
/* Store the new cleanup handler info. */
THREAD_SETMEM (pd, cleanup_jmp_buf, &unwind_buf);
- __libc_signal_restore_set (&pd->sigmask);
+ internal_signal_restore_set (&pd->sigmask);
LIBC_PROBE (pthread_start, 3, (pthread_t) pd, pd->start_routine, pd->arg);
@@ -501,8 +501,8 @@ start_thread (void *arg)
signal to be delivered. (SIGSETXID cannot run application code,
nor does it use pthread_kill.) Reuse the pd->sigmask space for
computing the signal mask, to save stack space. */
- __sigfillset (&pd->sigmask);
- __sigdelset (&pd->sigmask, SIGSETXID);
+ internal_sigfillset (&pd->sigmask);
+ internal_sigdelset (&pd->sigmask, SIGSETXID);
INTERNAL_SYSCALL_CALL (rt_sigprocmask, SIG_BLOCK, &pd->sigmask, NULL,
__NSIG_BYTES);
@@ -769,14 +769,14 @@ __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr,
/* Block all signals, so that the new thread starts out with
signals disabled. This avoids race conditions in the thread
startup. */
- sigset_t original_sigmask;
- __libc_signal_block_all (&original_sigmask);
+ internal_sigset_t original_sigmask;
+ internal_signal_block_all (&original_sigmask);
if (iattr->extension != NULL && iattr->extension->sigmask_set)
/* Use the signal mask in the attribute. The internal signals
have already been filtered by the public
pthread_attr_setsigmask_np interface. */
- pd->sigmask = iattr->extension->sigmask;
+ internal_sigset_from_sigset (&pd->sigmask, &iattr->extension->sigmask);
else
{
/* Conceptually, the new thread needs to inherit the signal mask
@@ -786,7 +786,7 @@ __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr,
pd->sigmask = original_sigmask;
/* Reset the cancellation signal mask in case this thread is
running cancellation. */
- __sigdelset (&pd->sigmask, SIGCANCEL);
+ internal_sigdelset (&pd->sigmask, SIGCANCEL);
}
/* Start the thread. */
@@ -833,7 +833,7 @@ __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr,
/* Return to the previous signal mask, after creating the new
thread. */
- __libc_signal_restore_set (&original_sigmask);
+ internal_signal_restore_set (&original_sigmask);
if (__glibc_unlikely (retval != 0))
{
diff --git a/nptl/pthread_kill.c b/nptl/pthread_kill.c
index 8015e10..178d38d 100644
--- a/nptl/pthread_kill.c
+++ b/nptl/pthread_kill.c
@@ -45,8 +45,8 @@ __pthread_kill_implementation (pthread_t threadid, int signo, int no_tid)
}
/* Block all signals, as required by pd->exit_lock. */
- sigset_t old_mask;
- __libc_signal_block_all (&old_mask);
+ internal_sigset_t old_mask;
+ internal_signal_block_all (&old_mask);
__libc_lock_lock (pd->exit_lock);
int ret;
@@ -64,7 +64,7 @@ __pthread_kill_implementation (pthread_t threadid, int signo, int no_tid)
}
__libc_lock_unlock (pd->exit_lock);
- __libc_signal_restore_set (&old_mask);
+ internal_signal_restore_set (&old_mask);
return ret;
}
@@ -83,7 +83,7 @@ __pthread_kill (pthread_t threadid, int signo)
{
/* Disallow sending the signal we use for cancellation, timers,
for the setxid implementation. */
- if (__is_internal_signal (signo))
+ if (is_internal_signal (signo))
return EINVAL;
return __pthread_kill_internal (threadid, signo);
@@ -102,7 +102,7 @@ int
attribute_compat_text_section
__pthread_kill_esrch (pthread_t threadid, int signo)
{
- if (__is_internal_signal (signo))
+ if (is_internal_signal (signo))
return EINVAL;
return __pthread_kill_implementation (threadid, signo, ESRCH);
diff --git a/nptl/pthread_sigmask.c b/nptl/pthread_sigmask.c
index 20f811c..977740b 100644
--- a/nptl/pthread_sigmask.c
+++ b/nptl/pthread_sigmask.c
@@ -32,7 +32,7 @@ __pthread_sigmask (int how, const sigset_t *newmask, sigset_t *oldmask)
|| __glibc_unlikely (__sigismember (newmask, SIGSETXID))))
{
local_newmask = *newmask;
- __clear_internal_signals (&local_newmask);
+ clear_internal_signals (&local_newmask);
newmask = &local_newmask;
}