diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2020-02-03 12:55:07 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2020-02-03 13:34:31 -0800 |
commit | 53ff16348973deef1295e123b20a218eb6b7e339 (patch) | |
tree | 6e2ad0a6914ca54e63cb8e6022c0b3c721ce501b /src/libs/sig/sig.c | |
parent | 4602ad14abf067da5332ce392dc4c82257396964 (diff) |
libs/sig: consideration for sig_t.ctxt alignment
The flexible array of void *'s would just align to a pointer,
which may not be safe for all members of whatever gets shoved in
here.
In an effort to make it more robust, make it an array of a junk
drawer union of types.
Diffstat (limited to 'src/libs/sig/sig.c')
-rw-r--r-- | src/libs/sig/sig.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/libs/sig/sig.c b/src/libs/sig/sig.c index fea83b6..865c6b4 100644 --- a/src/libs/sig/sig.c +++ b/src/libs/sig/sig.c @@ -4,10 +4,28 @@ #include "sig.h" +/* This is to try ensure ctxt's alignment accomodates all the base type sizes, + * it may waste some space in sig_t but since the caller supplies just a size + * via the supplied sig_ops_t.size(), we know nothing of the alignment reqs. + * + * XXX: If callers start using other types like xmmintrinsics __m128, this + * struct will have to get those added. + */ +typedef union sig_context_t { + float f; + double d; + long double ld; + char c; + short s; + int i; + long l; + long long ll; + void *p; +} sig_context_t; typedef struct sig_t { const sig_ops_t *ops; - void *ctxt[]; + sig_context_t ctxt[]; } sig_t; |