mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 00:14:44 +01:00
Merge libapparmor: swig: various build fixes for 32-bit systems and older systems
Changes include: - using `long` instead of `intmax_t` for `pid_t` typemap (32-bit build failure); see commit message for more details - specifying messages for `static_assert` declarations (required up until C23, was accepted as a compiler extension on the systems I had tested this on previously) - removing label-followed-by-declaration instance (also a C23 feature supported as extension) MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1536 Approved-by: John Johansen <john@jjmx.net> Merged-by: John Johansen <john@jjmx.net>
This commit is contained in:
commit
55889ef783
1 changed files with 18 additions and 5 deletions
|
@ -258,7 +258,13 @@ extern int aa_is_enabled(void);
|
|||
* allocation uninitialized (0) != SWIG_NEWOBJ
|
||||
*/
|
||||
%#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
|
||||
static_assert(SWIG_NEWOBJ != 0);
|
||||
/*
|
||||
* Some older versions of SWIG place this right after a goto label
|
||||
* This would then be a label followed by a declaration, a C23 extension (!)
|
||||
* To ensure this works for older SWIG versions and older compilers,
|
||||
* make this a block element with curly braces.
|
||||
*/
|
||||
{static_assert(SWIG_NEWOBJ != 0, "SWIG_NEWOBJ is 0");}
|
||||
%#endif
|
||||
if ($1 != NULL && alloc_tracking$argnum != NULL) {
|
||||
for (Py_ssize_t i=0; i<seq_len$argnum; i++) {
|
||||
|
@ -315,10 +321,17 @@ extern int aa_stack_onexec(const char *profile);
|
|||
* We can't use "typedef int pid_t" because we still support systems
|
||||
* with 16-bit PIDs and SWIG can't find sys/types.h
|
||||
*
|
||||
* Capture the passed-in value as an intmax_t because pid_t is guaranteed
|
||||
* to be a signed integer
|
||||
* Capture the passed-in value as a long because pid_t is guaranteed
|
||||
* to be a signed integer and because the aalogparse struct uses
|
||||
* (unsigned) longs to store pid values. While intmax_t would be more
|
||||
* technically correct, if sizeof(pid_t) > sizeof(long) then aalogparse
|
||||
* itself would also need fixing.
|
||||
*/
|
||||
%typemap(in,noblock=1,fragment="SWIG_AsVal_long") pid_t (int conv_pid, intmax_t pid_large) {
|
||||
%typemap(in,noblock=1,fragment="SWIG_AsVal_long") pid_t (int conv_pid, long pid_large) {
|
||||
%#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
|
||||
static_assert(sizeof(pid_t) <= sizeof(long),
|
||||
"pid_t type is too large to be stored in a long");
|
||||
%#endif
|
||||
conv_pid = SWIG_AsVal_long($input, &pid_large);
|
||||
if (!SWIG_IsOK(conv_pid)) {
|
||||
%argument_fail(conv_pid, "pid_t", $symname, $argnum);
|
||||
|
@ -328,7 +341,7 @@ extern int aa_stack_onexec(const char *profile);
|
|||
* Technically this is implementation-defined behaviour but we should be fine
|
||||
*/
|
||||
$1 = (pid_t) pid_large;
|
||||
if ((intmax_t) $1 != pid_large) {
|
||||
if ((long) $1 != pid_large) {
|
||||
SWIG_exception_fail(SWIG_OverflowError, "pid_t is too large");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue