Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
c06334d
done
yug105 May 30, 2026
e4a4e52
c
yug105 Jun 1, 2026
ae6819e
Revert "c"
yug105 Jun 2, 2026
7cb3d67
update readme
yug105 Jun 2, 2026
699bc36
ci haiku
yug105 Jun 5, 2026
eafaecb
ci haiku
yug105 Jun 6, 2026
41ca9c1
haiku ci
yug105 Jun 6, 2026
0f51250
haiku ci
yug105 Jun 6, 2026
c45a206
haiku ci
yug105 Jun 8, 2026
f45a74f
haiku os
yug105 Jun 8, 2026
8822b22
haiku os
yug105 Jun 8, 2026
385583f
haiku os
yug105 Jun 8, 2026
96b0655
haiku os
yug105 Jun 8, 2026
11f1330
haiku os
yug105 Jun 8, 2026
9ab3da6
haiku os
yug105 Jun 8, 2026
26d9eeb
plthook change
yug105 Jun 9, 2026
c7491bc
haiku os
yug105 Jun 9, 2026
cbab87e
haiku os
yug105 Jun 9, 2026
78f1f2c
haiku os
yug105 Jun 9, 2026
e3d2232
haiku os
yug105 Jun 9, 2026
4672ad9
haiku os
yug105 Jun 11, 2026
c876248
haiku os
yug105 Jun 11, 2026
0b429ef
haiku os
yug105 Jun 11, 2026
8f6775d
haiku os
yug105 Jun 11, 2026
fb6fc18
haiku os
yug105 Jun 11, 2026
59ba618
haiku os
yug105 Jun 12, 2026
152141d
haiku os
yug105 Jun 12, 2026
d0155cd
Merge remote-tracking branch 'origin/develop' into haiku-metacall-v1
yug105 Jun 12, 2026
281b3d8
haiku os
yug105 Jun 16, 2026
afcbdd9
Update haiku-test.yml
viferga Jun 16, 2026
4cd2651
Update Portability.cmake
viferga Jun 16, 2026
6d2ae5c
Update CMakeLists.txt
viferga Jun 16, 2026
b1670cb
freebsd o2
yug105 Jun 17, 2026
d552d93
rapid to metacall
yug105 Jun 17, 2026
77dd621
haiku
yug105 Jun 24, 2026
5954997
haiku syslog
yug105 Jun 25, 2026
be3e9cf
format specifier
yug105 Jun 25, 2026
4cc3be6
revert to rapidjson
yug105 Jun 25, 2026
51cf4c0
image_id warning
yug105 Jun 25, 2026
801f73a
commenting unload
yug105 Jun 25, 2026
07f0b72
O2 to O3
yug105 Jun 25, 2026
cbe6e41
haiku to beos
yug105 Jun 25, 2026
b6dd827
revert
yug105 Jun 25, 2026
cd7b837
haiku
yug105 Jun 25, 2026
c42135f
Merge remote-tracking branch 'origin/develop' into haiku-metacall-v1
yug105 Jun 26, 2026
4df62bc
added comment
yug105 Jun 26, 2026
d2e84ba
experimenting
yug105 Jun 26, 2026
c973e48
experimenting
yug105 Jun 27, 2026
71060f7
experimenting
yug105 Jun 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/haiku-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Haiku Test

on:
workflow_dispatch:
pull_request:
push:
branches:
- master
- develop
tags:
- v*.*.*

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
name: Haiku Test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
build: [debug, relwithdebinfo, release]
arch: [x86-64]

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Run Haiku VM
uses: cross-platform-actions/action@v1.2.0
with:
operating_system: haiku
version: r1beta5
architecture: ${{ matrix.arch }}
shell: sh
run: |
mkdir -p /boot/home/config/settings/system/debug_server
printf 'default_action report\n' > /boot/home/config/settings/system/debug_server/settings

sh ./tools/metacall-environment.sh base

mkdir -p build && cd build
sh ../tools/metacall-configure.sh ${{ matrix.build }} scripts tests

sh ../tools/metacall-build.sh ${{ matrix.build }}

echo "===== HAIKU DESKTOP FILES ====="
ctest -j2 --timeout 120 --output-on-failure -C ${{ matrix.build }} || res=$?
ls -la /boot/home/Desktop/ 2>/dev/null || true

echo "===== HAIKU CRASH REPORTS ====="
cat /boot/home/Desktop/*report* 2>/dev/null || true

echo "===== HAIKU SYSLOG TAIL ====="
tail -n 200 /boot/system/var/log/syslog 2>/dev/null || true

exit ${res:-0}
2 changes: 1 addition & 1 deletion cmake/CompileOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ if(WIN32 AND MSVC)

endif()

if (PROJECT_OS_FAMILY MATCHES "unix" OR PROJECT_OS_FAMILY MATCHES "macos")
if (PROJECT_OS_FAMILY MATCHES "unix" OR PROJECT_OS_FAMILY MATCHES "macos" OR PROJECT_OS_FAMILY MATCHES "beos")

if(PROJECT_OS_FAMILY MATCHES "macos")
# We cannot enable "stack-protector-strong" On OS X due to a bug in clang compiler (current version 7.0.2)
Expand Down
12 changes: 0 additions & 12 deletions cmake/Portability.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,6 @@ if(PROJECT_OS_HAIKU)
set(PROJECT_OS_NAME "Haiku")
set(PROJECT_OS_FAMILY beos)
add_compile_definitions(__HAIKU__)

# Workaround to enable Haiku with export headers
# This can be removed once export headers support Haiku
if(PROJECT_OS_HAIKU)
# As the function is already patched, repatch it again
function(_GENERATE_EXPORT_HEADER)
set(WIN32 1)
# When the function is redefined, the old function can be accessed through underscore
__GENERATE_EXPORT_HEADER(${ARGN})
unset(WIN32)
endfunction()
endif()
endif()

# Check Windows
Expand Down
4 changes: 4 additions & 0 deletions source/dynlink/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ set(generated_source_path "${CMAKE_CURRENT_BINARY_DIR}/source")
if(APPLE AND PROJECT_OS_VERSION GREATER 8)
# From macOS 10.5 (version 9), dlopen compatible library is available
set(DYNLINK_IMPL_INTERFACE_NAME unix)
elseif(PROJECT_OS_HAIKU)
# Haiku can use dlopen although it's BeOS family
set(DYNLINK_IMPL_INTERFACE_NAME haiku)
else()
set(DYNLINK_IMPL_INTERFACE_NAME ${PROJECT_OS_FAMILY})

endif()

set(headers
Expand Down
55 changes: 55 additions & 0 deletions source/dynlink/include/dynlink/dynlink_impl_haiku.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Dynamic Link Library by Parra Studios
* A library for dynamic loading and linking shared objects at run-time.
*
* Copyright (C) 2016 - 2026 Vicente Eduardo Ferrer Garcia <vic798@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#ifndef DYNLINK_IMPL_HAIKU_H
#define DYNLINK_IMPL_HAIKU_H 1

/* -- Headers -- */

#include <dynlink/dynlink_api.h>

#ifdef __cplusplus
extern "C" {
#endif

/* -- Forward declarations -- */

struct dynlink_impl_interface_type;

/* -- Type definitions -- */

typedef struct dynlink_impl_interface_type *dynlink_impl_interface;

/* -- Methods -- */

/**
* @brief
* Haiku image add-on object implementation singleton
*
* @return
* A pointer to the Haiku image add-on object implementation singleton
*/
DYNLINK_API dynlink_impl_interface dynlink_impl_interface_singleton(void);

#ifdef __cplusplus
}
#endif

#endif /* DYNLINK_IMPL_HAIKU_H */
171 changes: 171 additions & 0 deletions source/dynlink/source/dynlink_impl_haiku.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
/*
* Dynamic Link Library by Parra Studios
* A library for dynamic loading and linking shared objects at run-time.
*
* Copyright (C) 2016 - 2026 Vicente Eduardo Ferrer Garcia <vic798@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#if defined(__HAIKU__)

/* -- Headers -- */

#include <dynlink/dynlink.h>

#include <dynlink/dynlink_impl.h>

#include <log/log.h>

#include <string.h>

#include <stdint.h>

#include <dlfcn.h>

#include <be/kernel/image.h>

/* -- Methods -- */

const char *dynlink_impl_interface_prefix_haiku(void)
{
static const char prefix_haiku[] = "lib";

return prefix_haiku;
}

const char *dynlink_impl_interface_extension_haiku(void)
{
static const char extension_haiku[] = "so";

return extension_haiku;
}

dynlink_impl dynlink_impl_interface_load_haiku(dynlink handle)
{
dynlink_flags flags = dynlink_get_flags(handle);
image_id impl = 0;

if (DYNLINK_FLAGS_CHECK(flags, DYNLINK_FLAGS_BIND_SELF))
{
int mode;
void *self_impl;

DYNLINK_FLAGS_SET(mode, 0);

if (DYNLINK_FLAGS_CHECK(flags, DYNLINK_FLAGS_BIND_NOW))
{
DYNLINK_FLAGS_ADD(mode, RTLD_NOW);
}

if (DYNLINK_FLAGS_CHECK(flags, DYNLINK_FLAGS_BIND_LAZY))
{
DYNLINK_FLAGS_ADD(mode, RTLD_LAZY);
}

if (DYNLINK_FLAGS_CHECK(flags, DYNLINK_FLAGS_BIND_LOCAL))
{
DYNLINK_FLAGS_ADD(mode, RTLD_LOCAL);
}

if (DYNLINK_FLAGS_CHECK(flags, DYNLINK_FLAGS_BIND_GLOBAL))
{
DYNLINK_FLAGS_ADD(mode, RTLD_GLOBAL);
}

self_impl = dlopen(NULL, mode);

if (self_impl == NULL)
{
log_write("metacall", LOG_LEVEL_ERROR, "DynLink error: %s", dlerror());
return NULL;
}

return self_impl;
}

impl = load_add_on(dynlink_get_path(handle));

if (impl < B_NO_ERROR)
{
log_write("metacall", LOG_LEVEL_ERROR, "DynLink error: failed to load BeOS/Haiku image add-on with error code %d", (int)impl);
return NULL;
}

return (dynlink_impl)(intptr_t)impl;
}

int dynlink_impl_interface_symbol_haiku(dynlink handle, dynlink_impl impl, const char *name, dynlink_symbol_addr *addr)
{
void *symbol = NULL;

if (DYNLINK_FLAGS_CHECK(dynlink_get_flags(handle), DYNLINK_FLAGS_BIND_SELF))
{
symbol = dlsym(impl, name);
}
else
{
int err = get_image_symbol((image_id)(intptr_t)impl, name, B_SYMBOL_TYPE_ANY, &symbol);

if (err != B_OK)
{
log_write("metacall", LOG_LEVEL_ERROR, "DynLink error: failed to load BeOS/Haiku symbol %s", name);
return 1;
}
}

dynlink_symbol_cast(void *, symbol, *addr);

return (*addr == NULL);
}

int dynlink_impl_interface_unload_haiku(dynlink handle, dynlink_impl impl)
{
dynlink_flags flags = dynlink_get_flags(handle);

(void)handle;

/* Skip unlink when using global handle for loading symbols of the current process */
if (DYNLINK_FLAGS_CHECK(flags, DYNLINK_FLAGS_BIND_SELF))
{
return 0;
}

#if defined(__MEMORYCHECK__) || defined(__ADDRESS_SANITIZER__) || defined(__THREAD_SANITIZER__) || defined(__MEMORY_SANITIZER__)
/* Disable dlclose when running with address sanitizer in order to maintain stacktraces */
(void)impl;
return 0;
#else
return ((image_id)(intptr_t)impl > 0) && (unload_add_on((image_id)(intptr_t)impl) < B_NO_ERROR);
// (void)impl;
// return 0;
#endif
}

dynlink_impl_interface dynlink_impl_interface_singleton(void)
{
static struct dynlink_impl_interface_type impl_interface_haiku = {
&dynlink_impl_interface_prefix_haiku,
&dynlink_impl_interface_extension_haiku,
&dynlink_impl_interface_load_haiku,
&dynlink_impl_interface_symbol_haiku,
&dynlink_impl_interface_unload_haiku,
};

return &impl_interface_haiku;
}

#elif defined(__BEOS__)
#include "dynlink_impl_beos.c"
#endif
4 changes: 2 additions & 2 deletions source/format/include/format/format_specifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ extern "C" {
(defined(unix) || defined(__unix__) || defined(__unix) || \
defined(linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux) || \
defined(__CYGWIN__) || defined(__CYGWIN32__) || \
(defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__))
(defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__)) || defined(__HAIKU__) || defined(__BEOS__)

#include <unistd.h>

Expand Down Expand Up @@ -97,7 +97,7 @@ extern "C" {
#elif defined(FORMAT_32BIT) || \
(defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER >= 1900)) || \
defined(_BSD_SOURCE) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 500) || \
defined(_ISOC99_SOURCE) || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L)
defined(_ISOC99_SOURCE) || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) || defined(__HAIKU__) || defined(__BEOS__)
#define FORMAT_PREFIX "z"
#elif defined(FORMAT_64BIT)
#if (defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__)
Expand Down
10 changes: 5 additions & 5 deletions source/log/source/log_policy_stream_syslog.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#endif
#elif defined(linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux) || \
defined(__FreeBSD__) || \
(defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__)
(defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__) || defined(__HAIKU__) || defined(__BEOS__)
#include <syslog.h>
#endif

Expand Down Expand Up @@ -56,7 +56,7 @@ struct log_policy_stream_syslog_data_type
HANDLE handle;
#elif defined(linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux) || \
defined(__FreeBSD__) || \
(defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__)
(defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__) || defined(__HAIKU__) || defined(__BEOS__)
/* ... */
#endif
};
Expand Down Expand Up @@ -106,7 +106,7 @@ static int log_policy_stream_syslog_create(log_policy policy, const log_policy_c
syslog_data->handle = RegisterEventSource(NULL, syslog_data->name);
#elif defined(linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux) || \
defined(__FreeBSD__) || \
(defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__)
(defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__) || defined(__HAIKU__) || defined(__BEOS__)
openlog(syslog_data->name, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER);
#endif

Expand Down Expand Up @@ -134,7 +134,7 @@ static int log_policy_stream_syslog_write(log_policy policy, const void *buffer,
NULL, 1, 0, (LPTSTR *)lpt_str, NULL);
#elif defined(linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux) || \
defined(__FreeBSD__) || \
(defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__)
(defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__) || defined(__HAIKU__) || defined(__BEOS__)
(void)syslog_data;

syslog(LOG_INFO, "%s", (const char *)buffer);
Expand Down Expand Up @@ -163,7 +163,7 @@ static int log_policy_stream_syslog_destroy(log_policy policy)
}
#elif defined(linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux) || \
defined(__FreeBSD__) || \
(defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__)
(defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__) || defined(__HAIKU__) || defined(__BEOS__)
closelog();
#endif

Expand Down
Loading