bsnes_libretro-0.94_20171227.patchset revision c3c96ee8
1From 14cffc4226e26fae9179841806780800592927d7 Mon Sep 17 00:00:00 2001
2From: Puck Meerburg <puck@puckipedia.nl>
3Date: Sat, 17 Jan 2015 19:54:22 +0100
4Subject: Fix Haiku build
5
6
7diff --git a/Makefile b/Makefile
8index e208c15..073dc3c 100644
9--- a/Makefile
10+++ b/Makefile
11@@ -62,6 +62,9 @@ ifeq ($(findstring libretro,$(ui)),)
12   ifeq ($(platform),x)
13     flags += -march=native
14     link += -Wl,-export-dynamic -ldl -lX11 -lXext
15+  else ifeq ($(platform),haiku)
16+    flags += -march=native
17+    link += -Wl,-export-dynamic
18   else ifeq ($(platform),win)
19     ifeq ($(arch),win32)
20       flags += -m32
21diff --git a/nall/Makefile b/nall/Makefile
22index 94b58fc..6d7174e 100644
23--- a/nall/Makefile
24+++ b/nall/Makefile
25@@ -22,6 +22,8 @@ ifeq ($(platform),)
26     platform := windows
27   else ifneq ($(findstring Darwin,$(uname)),)
28     platform := osx
29+  else ifneq ($(findstring Haiku,$(uname)),)
30+    platform := haiku
31   else
32     platform := unix
33   endif
34diff --git a/nall/directory.hpp b/nall/directory.hpp
35index 691b31e..a930191 100644
36--- a/nall/directory.hpp
37+++ b/nall/directory.hpp
38@@ -190,12 +190,18 @@ private:
39       while((ep = readdir(dp))) {
40         if(!strcmp(ep->d_name, ".")) continue;
41         if(!strcmp(ep->d_name, "..")) continue;
42+#if defined(PLATFORM_HAIKU)
43+        struct stat sp = {0};
44+        stat(string{pathname, ep->d_name}, &sp);
45+        bool is_directory = S_ISDIR(sp.st_mode);
46+#else
47         bool is_directory = ep->d_type & DT_DIR;
48         if(ep->d_type & DT_UNKNOWN) {
49           struct stat sp = {0};
50           stat(string{pathname, ep->d_name}, &sp);
51           is_directory = S_ISDIR(sp.st_mode);
52         }
53+#endif
54         if(is_directory) {
55           if(strmatch(ep->d_name, pattern)) list.append(ep->d_name);
56         }
57@@ -215,7 +221,13 @@ private:
58       while((ep = readdir(dp))) {
59         if(!strcmp(ep->d_name, ".")) continue;
60         if(!strcmp(ep->d_name, "..")) continue;
61+#if defined(PLATFORM_HAIKU)
62+        struct stat sp = {0};
63+        stat(string{pathname, ep->d_name}, &sp);
64+        if(S_ISDIR(sp.st_mode)) {
65+#else
66         if((ep->d_type & DT_DIR) == 0) {
67+#endif
68           if(strmatch(ep->d_name, pattern)) list.append(ep->d_name);
69         }
70       }
71diff --git a/nall/intrinsics.hpp b/nall/intrinsics.hpp
72index 7377ed1..7a4784a 100644
73--- a/nall/intrinsics.hpp
74+++ b/nall/intrinsics.hpp
75@@ -3,7 +3,7 @@
76 
77 struct Intrinsics {
78   enum class Compiler : unsigned { Clang, GCC, VisualCPP, Unknown };
79-  enum class Platform : unsigned { Windows, MacOSX, X, Unknown };  //X = Linux, BSD, etc
80+  enum class Platform : unsigned { Windows, MacOSX, X, BeAPI, Unknown };  //X = Linux, BSD, etc
81   enum class Architecture : unsigned { x86, amd64, ARM, aarch64, Unknown };
82   enum class Endian : unsigned { LSB, MSB, Unknown };
83 
84@@ -38,6 +38,9 @@ struct Intrinsics {
85 #elif defined(linux) || defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__GNU__)
86   #define PLATFORM_X
87   Intrinsics::Platform Intrinsics::platform() { return Intrinsics::Platform::X; }
88+#elif defined(__HAIKU__)
89+  #define PLATFORM_HAIKU
90+  Intrinsics::Platform Intrinsics::platform() { return Intrinsics::Platform::BeAPI; }
91 #else
92   #warning "unable to detect platform"
93   #define PLATFORM_UNKNOWN
94diff --git a/target-libretro/Makefile b/target-libretro/Makefile
95index 997cd48..13dc9ba 100644
96--- a/target-libretro/Makefile
97+++ b/target-libretro/Makefile
98@@ -9,6 +9,8 @@ core_installdir := $(prefix)/lib
99 
100 ifeq ($(platform),linux)
101   flags += -fPIC
102+else ifeq ($(platform),haiku)
103+  flags += -fPIC
104 else ifeq ($(platform),osx)
105   flags += -fPIC
106 else ifneq (,$(findstring ios,$(platform)))
107@@ -47,6 +49,8 @@ obj/libretro-$(profile).o: $(ui)/libretro.cpp $(ui)/*
108 build: $(objects)
109 ifeq ($(platform),linux)
110 	$(compiler) -o out/bsnes_$(profile)_libretro.so -shared $(objects) -ldl -Wl,--no-undefined -Wl,--version-script=$(ui)/link.T
111+else ifeq ($(platform),haiku)
112+	$(compiler) -o out/bsnes_$(profile)_libretro.so -shared $(objects) -lnetwork -Wl,--no-undefined -Wl,--version-script=$(ui)/link.T
113 else ifneq (,$(findstring ios,$(platform)))
114   ifeq ($(platform),ios-arm64)
115 		$(compiler) -o out/bsnes_$(profile)_libretro_ios.dylib -dynamiclib $(objects) -isysroot $(IOSSDK) -arch arm64
116-- 
1172.16.2
118
119
120From 246e7cdeb44452454c4c4b8e3f148f1a09693a04 Mon Sep 17 00:00:00 2001
121From: Benjamin FRANCOIS <kwyxz@kwyxz.org>
122Date: Sat, 3 Mar 2018 02:06:40 +0000
123Subject: Fix endianness
124
125
126diff --git a/nall/platform.hpp b/nall/platform.hpp
127index e5e3f8e..36f0f6c 100644
128--- a/nall/platform.hpp
129+++ b/nall/platform.hpp
130@@ -44,7 +44,11 @@ namespace Math {
131   #ifdef __linux__
132     #include <endian.h>
133   #else
134-    #include <machine/endian.h>
135+    #if defined(__HAIKU__)
136+      #include <posix/endian.h>
137+    #else
138+      #include <machine/endian.h>
139+    #endif
140   #endif
141   #include <unistd.h>
142   #include <pwd.h>
143-- 
1442.16.2
145
146