1From 8fc46d871639dbe799f6ff0a61b046412ef5dcc6 Mon Sep 17 00:00:00 2001
2From: Martin Jansa <martin.jansa@gmail.com>
3Date: Mon, 5 May 2025 08:16:30 +0200
4Subject: [PATCH] build_support: handle empty max_priority value as None
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9When cross-compiling these tests they fail when the host cannot execute
10the binaries built for target.
11
12On my local ubuntu-22.04 docker container running
13build_support/src/sniff_mq_prio_max results in:
14posix_ipc-1.2.0 $ ./build_support/src/foo
15bash: ./build_support/src/foo: cannot execute binary file: Exec format error
16which triggers the Exception in compile_and_run and returns None
17
18While on some other ubuntu-22.04 containers I see:
19posix_ipc-1.2.0$ ./build_support/src/sniff_mq_prio_max
20/usr/lib/ld-linux-aarch64.so.1: No such file or directory
21
22and the compile_and_run returns
23b''
24which then causes
25posix_ipc-1.2.0/build_support/discover_system_info.py", line 244, in sniff_mq_prio_max
26    if max_priority < 0:
27       ^^^^^^^^^^^^^^^^
28
29Handle the empty value the same as None to avoid this.
30
31Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
32Upstream-Status: Submitted [https://github.com/osvenskan/posix_ipc/pull/77]
33---
34 build_support/discover_system_info.py | 2 +-
35 1 file changed, 1 insertion(+), 1 deletion(-)
36
37diff --git a/build_support/discover_system_info.py b/build_support/discover_system_info.py
38index 6d059d9..f8a3c83 100644
39--- a/build_support/discover_system_info.py
40+++ b/build_support/discover_system_info.py
41@@ -223,7 +223,7 @@ def sniff_mq_prio_max():
42         except ValueError:
43             max_priority = None
44
45-    if max_priority is None:
46+    if not max_priority:
47         # Looking for a #define didn't work; ask sysconf() instead.
48         # Note that sys.sysconf_names doesn't exist under Cygwin.
49         if hasattr(os, "sysconf_names") and \
50