Skip to content

Commit

Permalink
QNX 7.0 support for 2.76.1 and forward
Browse files Browse the repository at this point in the history
  • Loading branch information
klausholstjacobsen committed Aug 28, 2023
1 parent a547bc7 commit e3ef6d4
Show file tree
Hide file tree
Showing 10 changed files with 877 additions and 3 deletions.
64 changes: 64 additions & 0 deletions recipes/glib/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,67 @@ patches:
patch_type: bugfix
patch_description: fix for clang compilation
patch_source: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2898
"2.76.1":
- patch_file: "patches/0002-2.76.x-qnx_meson_build.patch"
patch_type: portability
patch_description: Adding qnx version to defines
- patch_file: "patches/0003-2.76.x-glocalfile_c.patch"
patch_type: portability
patch_description: Adding missing qnx 700 implementation of openat and fdopendir include header
- patch_file: "patches/0004-qnx700_h.patch"
patch_type: portability
patch_description: Adding missing qnx 700 implementation of openat and fdopendir header file
- patch_file: "patches/0005-qnx700_c.patch"
patch_type: portability
patch_description: Adding missing qnx 700 implementation of openat and fdopendir source file
- patch_file: "patches/0006-2.76.x-build_qnx700_c.patch"
patch_type: portability
patch_description: Adding missing qnx 700 implementation of openat and fdopendir build source
"2.76.2":
- patch_file: "patches/0002-2.76.x-qnx_meson_build.patch"
patch_type: portability
patch_description: Adding qnx version to defines
- patch_file: "patches/0003-2.76.x-glocalfile_c.patch"
patch_type: portability
patch_description: Adding missing qnx 700 implementation of openat and fdopendir include header
- patch_file: "patches/0004-qnx700_h.patch"
patch_type: portability
patch_description: Adding missing qnx 700 implementation of openat and fdopendir header file
- patch_file: "patches/0005-qnx700_c.patch"
patch_type: portability
patch_description: Adding missing qnx 700 implementation of openat and fdopendir source file
- patch_file: "patches/0006-2.76.x-build_qnx700_c.patch"
patch_type: portability
patch_description: Adding missing qnx 700 implementation of openat and fdopendir build source
"2.76.3":
- patch_file: "patches/0002-2.76.x-qnx_meson_build.patch"
patch_type: portability
patch_description: Adding qnx version to defines
- patch_file: "patches/0003-2.76.x-glocalfile_c.patch"
patch_type: portability
patch_description: Adding missing qnx 700 implementation of openat and fdopendir
- patch_file: "patches/0004-qnx700_h.patch"
patch_type: portability
patch_description: Adding missing qnx 700 implementation of openat and fdopendir
- patch_file: "patches/0005-qnx700_c.patch"
patch_type: portability
patch_description: Adding missing qnx 700 implementation of openat and fdopendir
- patch_file: "patches/0006-2.76.x-build_qnx700_c.patch"
patch_type: portability
patch_description: Adding missing qnx 700 implementation of openat and fdopendir
"2.77.0":
- patch_file: "patches/0002-2.77.0-qnx_meson_build.patch"
patch_type: portability
patch_description: Adding qnx version to defines
- patch_file: "patches/0003-2.77.0-glocalfile_c.patch"
patch_type: portability
patch_description: Adding missing qnx 700 implementation of openat and fdopendir
- patch_file: "patches/0004-qnx700_h.patch"
patch_type: portability
patch_description: Adding missing qnx 700 implementation of openat and fdopendir
- patch_file: "patches/0005-qnx700_c.patch"
patch_type: portability
patch_description: Adding missing qnx 700 implementation of openat and fdopendir
- patch_file: "patches/0006-2.77.0-build_qnx700_c.patch"
patch_type: portability
patch_description: Adding missing qnx 700 implementation of openat and fdopendir
30 changes: 27 additions & 3 deletions recipes/glib/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ def config_options(self):
if is_msvc(self):
del self.options.with_elf

if self.settings.os == "Neutrino":
del self.options.with_elf


def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
Expand All @@ -79,7 +83,7 @@ def requirements(self):
self.requires("libselinux/3.3")
if self.settings.os != "Linux":
# for Linux, gettext is provided by libc
self.requires("libgettext/0.21", transitive_headers=True, transitive_libs=True)
self.requires("libgettext/0.22", transitive_headers=True, transitive_libs=True)

if is_apple_os(self):
self.requires("libiconv/1.17")
Expand All @@ -103,10 +107,18 @@ def generate(self):
tc.project_options["iconv"] = "external" # https://gitlab.gnome.org/GNOME/glib/issues/1557
tc.project_options["selinux"] = "enabled" if self.options.get_safe("with_selinux") else "disabled"
tc.project_options["libmount"] = "enabled" if self.options.get_safe("with_mount") else "disabled"
if self.settings.os == "FreeBSD":
if self.settings.os == "FreeBSD" or self.settings.os == "Neutrino":
tc.project_options["xattr"] = "false"
tc.project_options["tests"] = "false"
tc.project_options["libelf"] = "enabled" if self.options.get_safe("with_elf") else "disabled"

if self.settings.os == "Neutrino":
tc.cross_build["host"]["system"] = "qnx"
tc.properties["qnx_version"] = self.settings.get_safe('os.version')
tc.c_args = ["-Wno-nonnull", "-Wno-format-nonliteral", "-Wno-unused-variable", "-Wno-unused-function", "-Wno-sign-compare", "-Wno-error=implicit-function-declaration", "-Wno-int-conversion"]
tc.c_link_args.append("-lm")
tc.c_link_args.append("-lsocket")

tc.generate()

def _patch_sources(self):
Expand All @@ -124,7 +136,7 @@ def _patch_sources(self):
os.path.join(self.source_folder, "gio", "meson.build"),
]:
replace_in_file(self, filename, "subdir('tests')", "#subdir('tests')")
if self.settings.os != "Linux":
if self.settings.os != "Linux" and self.settings.os != "Neutrino":
# allow to find gettext
replace_in_file(self,
os.path.join(self.source_folder, "meson.build"),
Expand Down Expand Up @@ -215,6 +227,18 @@ def package_info(self):
self.cpp_info.components["gthread-2.0"].system_libs.append("pthread")
self.cpp_info.components["gio-2.0"].system_libs.append("dl")

if self.settings.os == "Neutrino":
self.cpp_info.components["gmodule-export-2.0"].sharedlinkflags.append("-Wl,--export-dynamic")
self.cpp_info.components["gmodule-2.0"].sharedlinkflags.append("-Wl,--export-dynamic")
self.cpp_info.components["glib-2.0"].system_libs.append("m")

if self.settings.os.version == "7.0":
self.cpp_info.components["gmodule-no-export-2.0"].system_libs.append("dl")
self.cpp_info.components["gio-2.0"].system_libs.append("dl")
elif self.settings.os.version == "7.1":
self.cpp_info.components["gmodule-no-export-2.0"].system_libs.append("c")
self.cpp_info.components["gio-2.0"].system_libs.append("c")

if self.settings.os == "Windows":
self.cpp_info.components["glib-2.0"].system_libs += ["ws2_32", "ole32", "shell32", "user32", "advapi32"]
self.cpp_info.components["gio-2.0"].system_libs.extend(["iphlpapi", "dnsapi", "shlwapi"])
Expand Down
14 changes: 14 additions & 0 deletions recipes/glib/all/patches/0002-2.76.x-qnx_meson_build.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--- meson_org.build 2023-07-28 08:17:35.282631200 +0200
+++ meson.build 2023-07-28 08:35:13.238165100 +0200
@@ -891,6 +891,11 @@

if host_system == 'qnx'
glib_conf.set('HAVE_QNX', 1)
+ if meson.get_external_property('qnx_version', '') == '7.0'
+ glib_conf.set('HAVE_QNX700', 1)
+ elif meson.get_external_property('qnx_version', '') == '7.1'
+ glib_conf.set('HAVE_QNX710', 1)
+ endif
endif

# Check for futex(2)
14 changes: 14 additions & 0 deletions recipes/glib/all/patches/0002-2.77.0-qnx_meson_build.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--- meson_org.build 2023-07-28 11:23:16.976552300 +0200
+++ meson.build 2023-07-28 11:24:04.173300500 +0200
@@ -905,6 +905,11 @@

if host_system == 'qnx'
glib_conf.set('HAVE_QNX', 1)
+ if meson.get_external_property('qnx_version', false) == '7.0'
+ glib_conf.set('HAVE_QNX700', 1)
+ elif meson.get_external_property('qnx_version', false) == '7.1'
+ glib_conf.set('HAVE_QNX710', 1)
+ endif
endif

# Check for futex(2)
20 changes: 20 additions & 0 deletions recipes/glib/all/patches/0003-2.76.x-glocalfile_c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- gio/glocalfile_org.c 2023-07-28 08:27:17.301625500 +0200
+++ gio/glocalfile.c 2023-07-28 09:37:34.323776200 +0200
@@ -22,12 +22,16 @@

#include "config.h"

+#ifdef HAVE_QNX700
+#include "qnx700.h"
+#endif
+
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
-#if G_OS_UNIX
+#ifdef G_OS_UNIX
#include <dirent.h>
#include <unistd.h>
#endif
20 changes: 20 additions & 0 deletions recipes/glib/all/patches/0003-2.77.0-glocalfile_c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- gio/glocalfile_org.c 2023-07-28 11:24:23.429163000 +0200
+++ gio/glocalfile.c 2023-07-28 11:24:52.849785800 +0200
@@ -22,12 +22,16 @@

#include "config.h"

+#ifdef HAVE_QNX700
+#include "qnx700.h"
+#endif
+
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
-#if G_OS_UNIX
+#ifdef G_OS_UNIX
#include <dirent.h>
#include <unistd.h>
#endif
115 changes: 115 additions & 0 deletions recipes/glib/all/patches/0004-qnx700_h.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
--- /dev/null 2023-07-28 07:48:39.050000000 +0200
+++ gio/qnx700.h 2023-07-28 09:06:15.733401700 +0200
@@ -0,0 +1,112 @@
+#include <assert.h>
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdlib.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <errno.h>
+#include <fcntl.h>
+
+#include <glib.h>
+
+# define REPLACE_FCHDIR 0
+
+#define EXPECTED_ERRNO(Errno) \
+ ((Errno) == ENOTDIR || (Errno) == ENOENT \
+ || (Errno) == EPERM || (Errno) == EACCES \
+ || (Errno) == ENOSYS /* Solaris 8 */ \
+ || (Errno) == EOPNOTSUPP /* FreeBSD */)
+
+#define SAFER_ALLOCA_MAX (4096 - 64)
+
+#define SAFER_ALLOCA(m) ((m) < SAFER_ALLOCA_MAX ? (m) : SAFER_ALLOCA_MAX)
+
+#if defined PATH_MAX
+# define OPENAT_BUFFER_SIZE SAFER_ALLOCA (PATH_MAX)
+#elif defined _XOPEN_PATH_MAX
+# define OPENAT_BUFFER_SIZE SAFER_ALLOCA (_XOPEN_PATH_MAX)
+#else
+# define OPENAT_BUFFER_SIZE SAFER_ALLOCA (1024)
+#endif
+
+#define INT_BITS_STRLEN_BOUND(b) (((b) * 146 + 484) / 485)
+
+#define INT_STRLEN_BOUND(t) \
+ (INT_BITS_STRLEN_BOUND (TYPE_WIDTH (t) - _GL_SIGNED_TYPE_OR_EXPR (t)) \
+ + _GL_SIGNED_TYPE_OR_EXPR (t))
+
+#define TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT)
+
+#if _GL_HAVE___TYPEOF__
+# define _GL_SIGNED_TYPE_OR_EXPR(t) TYPE_SIGNED (__typeof__ (t))
+#else
+# define _GL_SIGNED_TYPE_OR_EXPR(t) 1
+#endif
+
+#if GNULIB_FCNTL_SAFER
+# include "fcntl--.h"
+#else
+# define GNULIB_FCNTL_SAFER 0
+#endif
+
+# define assure(E) assert (E)
+
+#if (defined _WIN32 || defined __WIN32__ || \
+ defined __MSDOS__ || defined __CYGWIN__ || \
+ defined __EMX__ || defined __DJGPP__)
+ /* This internal macro assumes ASCII, but all hosts that support drive
+ letters use ASCII. */
+# define _IS_DRIVE_LETTER(C) (((unsigned int) (C) | ('a' - 'A')) - 'a' \
+ <= 'z' - 'a')
+# define FILE_SYSTEM_PREFIX_LEN(Filename) \
+ (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0)
+# ifndef __CYGWIN__
+# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1
+# endif
+# define ISSLASH(C) ((C) == '/' || (C) == '\\')
+#else
+# define FILE_SYSTEM_PREFIX_LEN(Filename) 0
+# define ISSLASH(C) ((C) == '/')
+#endif
+
+#if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
+# define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)])
+# else
+# define IS_ABSOLUTE_FILE_NAME(F) \
+ (ISSLASH ((F)[0]) || FILE_SYSTEM_PREFIX_LEN (F) != 0)
+#endif
+
+struct saved_cwd
+{
+ int desc;
+ char *name;
+};
+
+struct cd_buf
+{
+ int fd;
+};
+
+
+DIR *fdopendir (int fd);
+DIR *fdopendir_with_dup (int fd, int older_dupfd, struct saved_cwd const *cwd);
+int save_cwd (struct saved_cwd *cwd);
+int restore_cwd (const struct saved_cwd *cwd);
+_Noreturn void openat_save_fail (int errnum);
+void free_cwd (struct saved_cwd *cwd);
+static DIR *fd_clone_opendir (int fd, struct saved_cwd const *cwd);
+char *openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file);
+_Noreturn void openat_restore_fail (int errnum);
+int fd_safer_flag (int fd, int flag);
+int dup_safer_flag (int fd, int flag);
+int chdir_long (char *dir);
+static void cdb_init (struct cd_buf *cdb);
+static int cdb_advance_fd (struct cd_buf *cdb, char const *dir);
+static void cdb_free (struct cd_buf const *cdb);
+static char *find_non_slash (char const *s);
+static int cdb_fchdir (struct cd_buf const *cdb);
+void *memrchr (void const *s, int c_in, size_t n);
+int openat (int fd, char const *file, int flags, ...);
+int openat_permissive (int fd, char const *file, int flags, mode_t mode, int *cwd_errno);
Loading

0 comments on commit e3ef6d4

Please sign in to comment.