⛏️ index : haiku.git

author Christof Meerwald <cmeerw@cmeerw.org> 2025-12-19 19:46:04.0 +00:00:00
committer Adrien Destugues <pulkomandy@pulkomandy.tk> 2025-12-23 9:01:45.0 +00:00:00
commit
09115ce009b0878ee845106a8875111b899dff51 [patch]
tree
70fcd8a516f742d4a931d4127c1d22ffb916510e
parent
ad4a31e93cc9e4a8fba647b4ff6485e92b778d51
download
09115ce009b0878ee845106a8875111b899dff51.tar.gz

build: Fix NetBSD build issues

* Use LITTLE_ENDIAN instead of __LITTLE_ENDIAN (LITTLE_ENDIAN is what
  POSIX now specifies and everyone seems to define - NetBSD also
  defines _LITTLE_ENDIAN, but not __LITTLE_ENDIAN)

* file descriptors greater than 2 must be explicitly passed to a child
  on NetBSD. POSIX leaves that unspecified, see
  https://pubs.opengroup.org/onlinepubs/9799919799/utilities/V3_chap02.html#exec

* system library functions get declared with visibility "default" on
  NetBSD, so a "hidden" visibility attribute is ignored on a
  redeclaration. Work around by putting the functions in a namespace -
  as they are extern "C", they still end up in the object file without
  the namespace qualifier.

* remove the cast on the NULL pointer on the funopen call - it's not
  needed and the types are different between FreeBSD (fpos_t) and
  NetBSD/OpenBSD (off_t); also trying to change that upstream
  https://github.com/openSUSE/libsolv/pull/603

Change-Id: I6ab7f3c74d18960d7589b403a1c219cdac85a453
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10133
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>

Diff

 build/scripts/build_haiku_image            |  2 +-
 headers/os/support/ByteOrder.h             |  2 +-
 headers/private/fs_shell/fssh_byte_order.h |  2 +-
 src/build/libroot/function_remapper.cpp    | 13 +++++++++++++
 src/libs/libsolv/ext/solv_xfopen.c         |  2 +-
 5 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/build/scripts/build_haiku_image b/build/scripts/build_haiku_image
index 025f34e..5d01a8d 100755
--- a/build/scripts/build_haiku_image
+++ b/build/scripts/build_haiku_image
@@ -112,7 +112,7 @@

		fsShellCommandWrapper()
		{
			$actualFSShellCommand 5>&- 6>&- "$@"
			$actualFSShellCommand 3<&3 4>&4 5>&- 6>&- "$@"
		}

		bfsShellWrapper()
diff --git a/headers/os/support/ByteOrder.h b/headers/os/support/ByteOrder.h
index 67b6879..7ad560b 100644
--- a/headers/os/support/ByteOrder.h
+++ b/headers/os/support/ByteOrder.h
@@ -30,7 +30,7 @@
#define B_SWAP_INT32(arg)    __swap_int32(arg)
#define B_SWAP_INT16(arg)    __swap_int16(arg)

#if BYTE_ORDER == __LITTLE_ENDIAN

#if BYTE_ORDER == LITTLE_ENDIAN

/* Host is little endian */

#define B_HOST_IS_LENDIAN 1
diff --git a/headers/private/fs_shell/fssh_byte_order.h b/headers/private/fs_shell/fssh_byte_order.h
index b6e9407..76acc01 100644
--- a/headers/private/fs_shell/fssh_byte_order.h
+++ b/headers/private/fs_shell/fssh_byte_order.h
@@ -37,7 +37,7 @@
#define FSSH_B_SWAP_INT32(arg)    __fssh_swap_int32(arg)
#define FSSH_B_SWAP_INT16(arg)    __fssh_swap_int16(arg)

#if BYTE_ORDER == __LITTLE_ENDIAN

#if BYTE_ORDER == LITTLE_ENDIAN

// Host is little endian

#define FSSH_B_HOST_IS_LENDIAN 1
diff --git a/src/build/libroot/function_remapper.cpp b/src/build/libroot/function_remapper.cpp
index f8af40d..a53b32a 100644
--- a/src/build/libroot/function_remapper.cpp
+++ b/src/build/libroot/function_remapper.cpp
@@ -11,6 +11,15 @@

#include "remapped_functions.h"

#if defined(__NetBSD__)

/* NetBSD explicitly sets the visibility to "default" when declaring public
   functions, so any visibility attribute on a redeclaration is
   ignored. However, we can work around this by placing the
   declarations in a namespace. Since we are dealing with extern "C"
   declarations, there is no name mangling. */
namespace hidden_functions
{
#endif

extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
fchmod(int fd, mode_t mode)
@@ -387,3 +396,7 @@
}

#endif // defined(HAIKU_HOST_USE_XATTR) && defined(HAIKU_HOST_PLATFORM_HAIKU)

#if defined(__NetBSD__)

}
#endif
diff --git a/src/libs/libsolv/ext/solv_xfopen.c b/src/libs/libsolv/ext/solv_xfopen.c
index 639ce72..592fdf8 100644
--- a/src/libs/libsolv/ext/solv_xfopen.c
+++ b/src/libs/libsolv/ext/solv_xfopen.c
@@ -28,7 +28,7 @@
  return funopen(cookie, 
      (int (*)(void *, char *, int))(*mode == 'r' ? cread : NULL),		/* readfn */
      (int (*)(void *, const char *, int))(*mode == 'w' ? cwrite : NULL),	/* writefn */
      (fpos_t (*)(void *, fpos_t, int))NULL,					/* seekfn */
      NULL,									/* seekfn */
      cclose
      );
#elif defined(HAVE_FOPENCOOKIE)