Skip to content

Commit

Permalink
Merge pull request #2 from netzbasis/obsd331
Browse files Browse the repository at this point in the history
Merge netzbasis's work to finish porting 3.3.1 to OpenBSD
  • Loading branch information
kmosiejczuk authored Jun 11, 2023
2 parents cf6925b + 4f76b85 commit 8d7dfbc
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 124 deletions.
93 changes: 64 additions & 29 deletions config/openbsd/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<attribute name="flags" default=""/>
<attribute name="simple" default="false"/>
<attribute name="relative" default="true"/>
<attribute name="stdincludes" default="true"/>
<element name="source" implicit="true" optional="true"/>
<sequential>
<local name="cpp"/>
Expand All @@ -31,9 +32,9 @@
<arg line="-O3 -flto -fPIC @{flags} -pthread -DNDEBUG -DLWJGL_OPENBSD -DLWJGL_${build.arch}"/>
<arg line="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -D_GNU_SOURCE"/>

<arg value="-I/usr/include"/>
<arg value="-I/usr/local/include"/>
<arg value="-I/usr/X11R6/include"/>
<arg value="-I/usr/include" if:true="@{stdincludes}"/>
<arg value="-I/usr/local/include" if:true="@{stdincludes}"/>
<arg value="-I/usr/X11R6/include" if:true="@{stdincludes}"/>

<arg value="-I${jni.headers}"/>
<arg value="-I${jni.headers}/openbsd"/>
Expand All @@ -59,6 +60,8 @@
<attribute name="gpp.exec" default="c++"/>
<attribute name="flags" default=""/>
<attribute name="simple" default="false"/>
<attribute name="stdincludes" default="true"/>
<attribute name="dolink" default="true"/>
<element name="beforeCompile" optional="true"/>
<element name="source" optional="true"/>
<element name="beforeLink" optional="true"/>
Expand All @@ -80,12 +83,8 @@
<property name="dest" value="${bin.native}/@{module}"/>

<beforeCompile/>
<compile lang="@{lang}" gcc.exec="@{gcc.exec}" gpp.exec="@{gpp.exec}" flags="@{flags}" simple="@{simple}">
<source>
<arg value="-I/usr/include"/>
<arg value="-I/usr/local/include"/>
<arg value="-I/usr/X11R6/include"/>
</source>
<compile lang="@{lang}" gcc.exec="@{gcc.exec}" gpp.exec="@{gpp.exec}" flags="@{flags}" simple="@{simple}" stdincludes="@{stdincludes}">
<source/>
</compile>

<local name="lib.arch"/>
Expand Down Expand Up @@ -114,7 +113,7 @@
<echo message="Linking ${name}" taskname="${gcc}" unless:set="lib-uptodate"/>
<mkdir dir="${lib.arch}" unless:set="lib-uptodate"/>
<beforeLink unless:set="lib-uptodate"/>
<apply executable="${gcc}" failonerror="true" parallel="true" taskname="Linker" unless:set="lib-uptodate">
<apply executable="${gcc}" failonerror="true" parallel="true" taskname="Linker" unless:set="lib-uptodate" if:true="@{dolink}">
<srcfile/>
<arg value="-shared"/>
<arg value="-m64" if:set="build.arch.x64"/>
Expand Down Expand Up @@ -145,16 +144,12 @@
</macrodef>

<target name="compile-native-platform">
<exec executable="ksh" outputproperty="gcc.version" unless:set="gcc.version">
<arg value="-c"/>
<arg value="cc --version | head -1"/>
</exec>
<echo message="Building with ${gcc.version} (command: cc)"/>
<echo message="Building with native compiler (command: cc)"/>

<parallel threadsPerProcessor="1">

<!-- CORE -->
<build module="core" flags="-Wall -Wextra -pedantic">
<build module="core" flags="-Wall -Wextra -pedantic" stdincludes="false">
<source>
<arg value="-I${src.main.rel}/libffi"/>
<arg value="-I${src.main.rel}/libffi/aarch64" if:set="build.arch.arm64"/>
Expand All @@ -173,11 +168,8 @@
</fileset>
</source>
<link>
<fileset dir="/usr/local/lib">
<include name="libffi.a"/>
</fileset>
<arg value="-L/usr/local/lib"/>
<arg value="-lc"/>
<arg value="/usr/local/lib/libffi.a"/>
</link>
</build>

Expand All @@ -199,6 +191,12 @@
<arg value="-I/usr/X11R6/include"/>

<arg value="-I${src.main.rel}"/>

<fileset dir=".">
<include name="${src.main}/*.c"/>
<include name="${src.generated}/*.c"/>
<include name="${src.generated}/${platform}/*.c"/>
</fileset>
</compile>
</beforeCompile>
<link>
Expand Down Expand Up @@ -228,7 +226,9 @@
</compile>
</beforeCompile>
<link>
<arg value="-L/usr/local/lib"/>
<arg value="-lc"/>
<arg value="-llmdb"/>
</link>
</build>

Expand All @@ -247,7 +247,8 @@
</compile>
</beforeCompile>
<link>
<arg value="-lc"/>
<arg value="-lc"/>
<arg value="/usr/local/lib/liblz4.a"/>
</link>
</build>

Expand Down Expand Up @@ -390,7 +391,24 @@
</build>

<!-- tinyexr -->
<!-- FIXME
<!-- precompile c files, do not link in first step -->
<build module="tinyexr" simple="true" dolink="false" if:true="${binding.tinyexr}">
<beforeCompile>
<compile>
<arg value="-I/usr/include"/>
<arg value="-I/usr/local/include"/>
<arg value="-I/usr/X11R6/include"/>

<arg value="-I${src.main.rel}"/>

<fileset dir=".">
<include name="${src.main}/*.c"/>
<include name="${src.generated}/*.c"/>
<include name="${src.generated}/${platform}/*.c"/>
</fileset>
</compile>
</beforeCompile>
</build>
<build module="tinyexr" simple="true" linker="c++" if:true="${binding.tinyexr}">
<beforeCompile>
<compile lang="c++">
Expand All @@ -404,9 +422,10 @@
</beforeCompile>
<link>
<arg value="-lc"/>
<arg value="-lc++"/>
<arg value="-lc++abi"/>
</link>
</build>
-->

<!-- tiny file dialogs -->
<build module="tinyfd" simple="true" if:true="${binding.tinyfd}">
Expand Down Expand Up @@ -470,7 +489,6 @@
-->

<!-- Vulkan Memory Allocator -->
<!-- FIXME
<build module="vma" lang="c++" if:true="${binding.vma}">
<source>
<arg value="-I/usr/include"/>
Expand All @@ -479,22 +497,37 @@

<arg value="-I${src.main.rel}"/>
<arg value="-I${module.lwjgl.rel}/vulkan/src/main/c"/>
<arg value="-I${module.lwjgl.rel}/vma/src/main/c"/>
<arg value="-I${module.lwjgl.rel}/core/src/main/c"/>
<fileset dir="." includes="${src.generated}/*.cpp"/>
</source>
<link>
<arg value="-lc"/>
<arg value="-lc++"/>
<arg value="-lc++abi"/>
</link>
</build>
-->

<!-- xxHash -->
<!-- FIXME
<build simple="true" module="xxhash">
<build module="xxhash" simple="true" if:true="${binding.xxhash}">
<beforeCompile>
<compile>
<arg value="-I/usr/include"/>
<arg value="-I/usr/local/include"/>
<arg value="-I/usr/X11R6/include"/>

<arg value="-I${src.main.rel}"/>

<fileset dir=".">
<include name="${src.generated}/*.c"/>
<include name="${src.generated}/${platform}/*.c"/>
</fileset>
</compile>
</beforeCompile>
<link>
<arg value="-lc"/>
</link>
</build>
-->
</build>

<!-- yoga -->
<build module="yoga" simple="true" lang="c++" if:true="${binding.yoga}">
Expand All @@ -512,6 +545,8 @@
<arg value="-L/usr/local/lib"/>
<arg value="-L/usr/X11R6/lib"/>
<arg value="-lc"/>
<arg value="-lc++"/>
<arg value="-lc++abi"/>
<arg value="-lm"/>
</link>
</build>
Expand Down
10 changes: 0 additions & 10 deletions modules/lwjgl/glfw/src/templates/kotlin/glfw/GLFWTypes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -269,16 +269,6 @@ val GLFWerrorfun = Module.GLFW.callback {
}
}

val GLFWallocator = struct(Module.GLFW, "GLFWAllocator", nativeName = "GLFWallocator") {
documentation = "A custom memory allocator that can be set with #InitAllocator()."
since = "version 3.4"

GLFWallocatefun("allocate", "the memory allocation callback")
GLFWreallocatefun("reallocate", "the memory reallocation callback")
GLFWdeallocatefun("deallocate", "the memory deallocation callback")
nullable..opaque_p("user", "a user-defined pointer that will be passed to the callbacks")
}

val GLFWmonitorfun = Module.GLFW.callback {
void(
"GLFWMonitorCallback",
Expand Down
70 changes: 0 additions & 70 deletions modules/lwjgl/glfw/src/templates/kotlin/glfw/templates/GLFW.kt
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,6 @@ val GLFW = "GLFW".nativeClass(Module.GLFW, prefix = "GLFW", binding = GLFW_BINDI
a terminal that does not have the necessary environment variables. Fall back to a different platform if possible or notify the user that no usable
platform was detected.
Failure to detect a specific platform may have the same cause as above or because support for that platform was not compiled in. Call
#PlatformSupported() to check whether a specific platform is supported by a library binary.
""",
0x0001000E
)
Expand Down Expand Up @@ -1084,27 +1082,6 @@ val GLFW = "GLFW".nativeClass(Module.GLFW, prefix = "GLFW", binding = GLFW_BINDI
since = "version 3.3"
)

void(
"InitAllocator",
"""
Sets the init allocator to the desired value.
To use the default allocator, call this function with a #NULL argument.
If you specify an allocator struct, every member must be a valid function pointer. If any member is #NULL, this function emits #INVALID_VALUE and the
init allocator is unchanged.
${note(ul(
"Possible errors include #INVALID_VALUE.",
"The specified allocator is copied before this function returns.",
"This function must only be called from the main thread."
))}
""",

nullable..GLFWallocator.const.p("allocator", "the allocator to use at the next initialization, or #NULL to use the default one"),
since = "version 3.4"
)

void(
"GetVersion",
"""
Expand Down Expand Up @@ -1135,8 +1112,6 @@ val GLFW = "GLFW".nativeClass(Module.GLFW, prefix = "GLFW", binding = GLFW_BINDI
<b>Do not use the version string</b> to parse the GLFW library version. The #GetVersion() function already provides the version of the library binary
in numerical format.
<b>Do not use the version string</b> to parse what platforms are supported. The #PlatformSupported() function lets you query platform support.
${note(ul(
"This function always succeeds.",
"This function may be called before #Init().",
Expand Down Expand Up @@ -1199,51 +1174,6 @@ val GLFW = "GLFW".nativeClass(Module.GLFW, prefix = "GLFW", binding = GLFW_BINDI
since = "version 3.0"
)

int(
"GetPlatform",
"""
Returns the currently selected platform.
This function returns the platform that was selected during initialization. The returned value will be one of #PLATFORM_WIN32, #PLATFORM_COCOA,
#PLATFORM_WAYLAND, #PLATFORM_X11 or #PLATFORM_NULL.
This function may be called from any thread.
""",

void(),

returnDoc =
"""
the currently selected platform, or zero if an error occurred.
Possible errors include #NOT_INITIALIZED.
""",
since = "version 3.4"
)

intb(
"PlatformSupported",
"""
Returns whether the library includes support for the specified platform.
This function returns whether the library was compiled with support for the specified platform.
This function may be called before #Init().
This function may be called from any thread.
""",

int("platform", "the platform to query", "#PLATFORM_WIN32 #PLATFORM_COCOA #PLATFORM_WAYLAND #PLATFORM_X11 #PLATFORM_NULL"),

returnDoc =
"""
#TRUE if the platform is supported, or #FALSE otherwise.
Possible errors include #INVALID_ENUM.
""",
since = "version 3.4"
)

GLFWmonitor.p.p(
"GetMonitors",
"""
Expand Down
2 changes: 1 addition & 1 deletion modules/lwjgl/vma/src/main/c/vk_mem_alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -2626,7 +2626,7 @@ static void* vma_aligned_alloc(size_t alignment, size_t size)

return memalign(alignment, size);
}
#elif defined(__APPLE__) || defined(__ANDROID__) || (defined(__linux__) && defined(__GLIBCXX__) && !defined(_GLIBCXX_HAVE_ALIGNED_ALLOC))
#elif defined(__OpenBSD__) || defined(__APPLE__) || defined(__ANDROID__) || (defined(__linux__) && defined(__GLIBCXX__) && !defined(_GLIBCXX_HAVE_ALIGNED_ALLOC))
#include <cstdlib>

#if defined(__APPLE__)
Expand Down
13 changes: 0 additions & 13 deletions modules/samples/src/test/java/org/lwjgl/demo/glfw/Gears.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
/** The Gears demo implemented using GLFW. */
public class Gears {

private GLFWAllocator allocator;
private Callback debugProc;

private long window;
Expand Down Expand Up @@ -60,13 +59,6 @@ private void framebufferSizeChanged(long window, int width, int height) {
}

private void init() {
allocator = GLFWAllocator.calloc()
.allocate((size, user) -> nmemAllocChecked(size))
.reallocate((block, size, user) -> nmemReallocChecked(block, size))
.deallocate((block, user) -> nmemFree(block));

glfwInitAllocator(allocator);

GLFWErrorCallback.createPrint().set();
if (!glfwInit()) {
throw new IllegalStateException("Unable to initialize glfw");
Expand Down Expand Up @@ -233,11 +225,6 @@ private void destroy() {

glfwTerminate();
Objects.requireNonNull(glfwSetErrorCallback(null)).free();

allocator.deallocate().free();
allocator.reallocate().free();
allocator.allocate().free();
allocator.free();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static XrSessionCreateInfo createGraphicsBindingOpenGL(
}
switch (Platform.get()) {
case LINUX:
int platform = glfwGetPlatform();
int platform = GLFW_PLATFORM_X11;
if (platform == GLFW_PLATFORM_X11) {
long display = glfwGetX11Display();
long glxConfig = glfwGetGLXFBConfig(window);
Expand Down

0 comments on commit 8d7dfbc

Please sign in to comment.