Why is sigset_t in glibc/musl 128 bytes large on 64-bit Linux?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Why is sigset_t
on 64-bit Linux 128 bytes large in glibc and musl?
#include <signal.h>
#include <stdio.h>
int main()
printf("%zun", sizeof(sigset_t)); //prints 128 with both glibc and musl
Shouldn't 64 / 8 = 8 (number_of_signals / CHAR_BIT
) be enough?
linux c signals glibc
add a comment |Â
up vote
0
down vote
favorite
Why is sigset_t
on 64-bit Linux 128 bytes large in glibc and musl?
#include <signal.h>
#include <stdio.h>
int main()
printf("%zun", sizeof(sigset_t)); //prints 128 with both glibc and musl
Shouldn't 64 / 8 = 8 (number_of_signals / CHAR_BIT
) be enough?
linux c signals glibc
@thrig elixir.free-electrons.com/linux/latest/source/arch/ia64/include/⦠suggests the kernel's defining it as a 64 bit quantity (8 bytes), so I have no idea what the libc's are doing. I wish they at least commented that stuff.
â PSkocik
Oct 20 '17 at 14:09
my bad: glibc HAS commented it.
â PSkocik
Oct 20 '17 at 14:17
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Why is sigset_t
on 64-bit Linux 128 bytes large in glibc and musl?
#include <signal.h>
#include <stdio.h>
int main()
printf("%zun", sizeof(sigset_t)); //prints 128 with both glibc and musl
Shouldn't 64 / 8 = 8 (number_of_signals / CHAR_BIT
) be enough?
linux c signals glibc
Why is sigset_t
on 64-bit Linux 128 bytes large in glibc and musl?
#include <signal.h>
#include <stdio.h>
int main()
printf("%zun", sizeof(sigset_t)); //prints 128 with both glibc and musl
Shouldn't 64 / 8 = 8 (number_of_signals / CHAR_BIT
) be enough?
linux c signals glibc
edited Oct 20 '17 at 18:22
kiamlaluno
362220
362220
asked Oct 20 '17 at 13:22
PSkocik
17.2k24589
17.2k24589
@thrig elixir.free-electrons.com/linux/latest/source/arch/ia64/include/⦠suggests the kernel's defining it as a 64 bit quantity (8 bytes), so I have no idea what the libc's are doing. I wish they at least commented that stuff.
â PSkocik
Oct 20 '17 at 14:09
my bad: glibc HAS commented it.
â PSkocik
Oct 20 '17 at 14:17
add a comment |Â
@thrig elixir.free-electrons.com/linux/latest/source/arch/ia64/include/⦠suggests the kernel's defining it as a 64 bit quantity (8 bytes), so I have no idea what the libc's are doing. I wish they at least commented that stuff.
â PSkocik
Oct 20 '17 at 14:09
my bad: glibc HAS commented it.
â PSkocik
Oct 20 '17 at 14:17
@thrig elixir.free-electrons.com/linux/latest/source/arch/ia64/include/⦠suggests the kernel's defining it as a 64 bit quantity (8 bytes), so I have no idea what the libc's are doing. I wish they at least commented that stuff.
â PSkocik
Oct 20 '17 at 14:09
@thrig elixir.free-electrons.com/linux/latest/source/arch/ia64/include/⦠suggests the kernel's defining it as a 64 bit quantity (8 bytes), so I have no idea what the libc's are doing. I wish they at least commented that stuff.
â PSkocik
Oct 20 '17 at 14:09
my bad: glibc HAS commented it.
â PSkocik
Oct 20 '17 at 14:17
my bad: glibc HAS commented it.
â PSkocik
Oct 20 '17 at 14:17
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
5
down vote
accepted
I donâÂÂt know the original reason; back in 1996, the Linux-specific header was added with the following definition:
/* A `sigset_t' has a bit for each signal. Having 32 * 4 * 8 bits gives
us up to 1024 signals. */
#define _SIGSET_NWORDS 32
typedef struct
unsigned int __val[_SIGSET_NWORDS];
__sigset_t;
and this âÂÂ1024 signalâ limit has been preserved in the current definition:
/* A `sigset_t' has a bit for each signal. */
#define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int)))
typedef struct
unsigned long int __val[_SIGSET_NWORDS];
__sigset_t;
which makes the 1024-based calculation clearer (and results in 16 unsigned longs on 64-bit x86, i.e. 128 bytes).
Presumably the glibc maintainers wanted to leave room for growth...
musl aims for ABI compatibility with glibc for sigaction
, so it uses the same 1024-bit (128-byte) size:
TYPEDEF struct __sigset_t unsigned long __bits[128/sizeof(long)]; sigset_t;
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
accepted
I donâÂÂt know the original reason; back in 1996, the Linux-specific header was added with the following definition:
/* A `sigset_t' has a bit for each signal. Having 32 * 4 * 8 bits gives
us up to 1024 signals. */
#define _SIGSET_NWORDS 32
typedef struct
unsigned int __val[_SIGSET_NWORDS];
__sigset_t;
and this âÂÂ1024 signalâ limit has been preserved in the current definition:
/* A `sigset_t' has a bit for each signal. */
#define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int)))
typedef struct
unsigned long int __val[_SIGSET_NWORDS];
__sigset_t;
which makes the 1024-based calculation clearer (and results in 16 unsigned longs on 64-bit x86, i.e. 128 bytes).
Presumably the glibc maintainers wanted to leave room for growth...
musl aims for ABI compatibility with glibc for sigaction
, so it uses the same 1024-bit (128-byte) size:
TYPEDEF struct __sigset_t unsigned long __bits[128/sizeof(long)]; sigset_t;
add a comment |Â
up vote
5
down vote
accepted
I donâÂÂt know the original reason; back in 1996, the Linux-specific header was added with the following definition:
/* A `sigset_t' has a bit for each signal. Having 32 * 4 * 8 bits gives
us up to 1024 signals. */
#define _SIGSET_NWORDS 32
typedef struct
unsigned int __val[_SIGSET_NWORDS];
__sigset_t;
and this âÂÂ1024 signalâ limit has been preserved in the current definition:
/* A `sigset_t' has a bit for each signal. */
#define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int)))
typedef struct
unsigned long int __val[_SIGSET_NWORDS];
__sigset_t;
which makes the 1024-based calculation clearer (and results in 16 unsigned longs on 64-bit x86, i.e. 128 bytes).
Presumably the glibc maintainers wanted to leave room for growth...
musl aims for ABI compatibility with glibc for sigaction
, so it uses the same 1024-bit (128-byte) size:
TYPEDEF struct __sigset_t unsigned long __bits[128/sizeof(long)]; sigset_t;
add a comment |Â
up vote
5
down vote
accepted
up vote
5
down vote
accepted
I donâÂÂt know the original reason; back in 1996, the Linux-specific header was added with the following definition:
/* A `sigset_t' has a bit for each signal. Having 32 * 4 * 8 bits gives
us up to 1024 signals. */
#define _SIGSET_NWORDS 32
typedef struct
unsigned int __val[_SIGSET_NWORDS];
__sigset_t;
and this âÂÂ1024 signalâ limit has been preserved in the current definition:
/* A `sigset_t' has a bit for each signal. */
#define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int)))
typedef struct
unsigned long int __val[_SIGSET_NWORDS];
__sigset_t;
which makes the 1024-based calculation clearer (and results in 16 unsigned longs on 64-bit x86, i.e. 128 bytes).
Presumably the glibc maintainers wanted to leave room for growth...
musl aims for ABI compatibility with glibc for sigaction
, so it uses the same 1024-bit (128-byte) size:
TYPEDEF struct __sigset_t unsigned long __bits[128/sizeof(long)]; sigset_t;
I donâÂÂt know the original reason; back in 1996, the Linux-specific header was added with the following definition:
/* A `sigset_t' has a bit for each signal. Having 32 * 4 * 8 bits gives
us up to 1024 signals. */
#define _SIGSET_NWORDS 32
typedef struct
unsigned int __val[_SIGSET_NWORDS];
__sigset_t;
and this âÂÂ1024 signalâ limit has been preserved in the current definition:
/* A `sigset_t' has a bit for each signal. */
#define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int)))
typedef struct
unsigned long int __val[_SIGSET_NWORDS];
__sigset_t;
which makes the 1024-based calculation clearer (and results in 16 unsigned longs on 64-bit x86, i.e. 128 bytes).
Presumably the glibc maintainers wanted to leave room for growth...
musl aims for ABI compatibility with glibc for sigaction
, so it uses the same 1024-bit (128-byte) size:
TYPEDEF struct __sigset_t unsigned long __bits[128/sizeof(long)]; sigset_t;
edited Oct 20 '17 at 14:28
answered Oct 20 '17 at 14:15
Stephen Kitt
144k22313378
144k22313378
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f399342%2fwhy-is-sigset-t-in-glibc-musl-128-bytes-large-on-64-bit-linux%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
@thrig elixir.free-electrons.com/linux/latest/source/arch/ia64/include/⦠suggests the kernel's defining it as a 64 bit quantity (8 bytes), so I have no idea what the libc's are doing. I wish they at least commented that stuff.
â PSkocik
Oct 20 '17 at 14:09
my bad: glibc HAS commented it.
â PSkocik
Oct 20 '17 at 14:17