Waterfall/BungeeCord-Patches/0053-OSX-native-zlib-and-crypto.patch

157 lines
7.9 KiB
Diff
Raw Normal View History

2019-04-17 02:05:47 +02:00
From 1571a7bc5b1d57a9ddd988b131b7b146af67721a Mon Sep 17 00:00:00 2001
From: Colin Godsey <crgodsey@gmail.com>
Date: Tue, 16 Apr 2019 07:25:52 -0600
Subject: [PATCH] OSX native zlib and crypto
diff --git a/native/compile-native.sh b/native/compile-native.sh
index 98baf0e2..f378c7fc 100755
--- a/native/compile-native.sh
+++ b/native/compile-native.sh
@@ -1,6 +1,17 @@
#!/bin/sh
-CXX="g++ -shared -fPIC -O3 -Wall -Werror -I$JAVA_HOME/include/ -I$JAVA_HOME/include/linux/"
+# Waterfall - rewrite below to extend platform support
-$CXX src/main/c/NativeCipherImpl.cpp -o src/main/resources/native-cipher.so -lcrypto
-$CXX src/main/c/NativeCompressImpl.cpp -o src/main/resources/native-compress.so -lz
+if [[ "$OSTYPE" == "darwin"* ]]; then
+ # brew install mbedtls zlib
+ PREFIX="osx-"
+ CXX_ARGS="-lmbedcrypto -lz -I$JAVA_HOME/include/ -I$JAVA_HOME/include/darwin/"
+else
+ # apt-get install libmbedtls-dev zlib1g-dev
+ CXX_ARGS="-lcrypto -lz -I$JAVA_HOME/include/ -I$JAVA_HOME/include/linux/"
+fi
+
+CXX="g++ -shared -fPIC -O3 -Wall -Werror"
+
+$CXX src/main/c/NativeCipherImpl.cpp -o src/main/resources/${PREFIX}native-cipher.so $CXX_ARGS
+$CXX src/main/c/NativeCompressImpl.cpp -o src/main/resources/${PREFIX}native-compress.so $CXX_ARGS
diff --git a/native/src/main/c/NativeCipherImpl.cpp b/native/src/main/c/NativeCipherImpl.cpp
index aa7a12b4..0cedd7e5 100644
--- a/native/src/main/c/NativeCipherImpl.cpp
+++ b/native/src/main/c/NativeCipherImpl.cpp
@@ -1,5 +1,7 @@
// Support for CentOS 6
+#if __linux__ // Waterfall
__asm__(".symver memcpy,memcpy@GLIBC_2.2.5");
+#endif // Waterfall
#include <stdlib.h>
#include <string.h>
diff --git a/native/src/main/java/net/md_5/bungee/jni/NativeCode.java b/native/src/main/java/net/md_5/bungee/jni/NativeCode.java
index 6c92c1f5..9695c6e4 100644
--- a/native/src/main/java/net/md_5/bungee/jni/NativeCode.java
+++ b/native/src/main/java/net/md_5/bungee/jni/NativeCode.java
@@ -19,6 +19,7 @@ public final class NativeCode<T>
public NativeCode(String name, Class<? extends T> javaImpl, Class<? extends T> nativeImpl)
{
+ if ("Mac OS X".equals( System.getProperty( "os.name" ))) name = "osx-" + name; // Waterfall
this.name = name;
this.javaImpl = javaImpl;
this.nativeImpl = nativeImpl;
@@ -80,6 +81,6 @@ public final class NativeCode<T>
public static boolean isSupported()
{
- return "Linux".equals( System.getProperty( "os.name" ) ) && "amd64".equals( System.getProperty( "os.arch" ) );
+ return ("Linux".equals( System.getProperty( "os.name" ) ) || "Mac OS X".equals( System.getProperty( "os.name" ) )) && ("amd64".equals( System.getProperty( "os.arch" ) ) || "x86_64".equals( System.getProperty( "os.arch" )) ); // Waterfall
}
}
diff --git a/native/src/main/resources/osx-native-cipher.so b/native/src/main/resources/osx-native-cipher.so
new file mode 100755
index 0000000000000000000000000000000000000000..26e990efaf2be16799ead915dd958a37cb5e1cbf
GIT binary patch
literal 9016
zcmeHNUuauZ82{3CE_3VJL6NAP%f!~{Skq3$K8WP%3O6$y)wXM4#<L{7wVBCHmU}ao
zjY(imb_|6g2tFvXJ&E|BV~A65bxth!VAk!)|L9f{nc|az56161_uO!s+CB8ihx5TX
z-=FiH-#PbpPRqUL<m<nG`)56XuN44p!_tYR(gtu!SO9mTf7%DY*x1nI7&^^D9lRoa
z#DsNN5K0JRwsF*!4yqM+o1L~^97_oLZeQWILCI-wYQ`+Pkgyt|X1v}Gr|ChNLB0!3
zA-}|<XC`s**o=|R8F}F^f8G&^w_jufkl!M0p;pYVV7{0#r&!9I&i)79I}&eFVvxTK
z&x?&VtwR+HV|%nQ&C}@ezlx@HptW_e88g$&DrOSdG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-xN=o
zDVy>Ko8p#XzhD%ZVT!TBG_sLN=8Bjr#K-o=kHnd2*eo-}1|DIFg895*utR2wIoG&s
zpSaY0QrziAGPyK^N1;`WH!NoJjFSfwtx)R5Gm^?ytV;I?_)>Sp*N+yRuXNBUi9F|c
zO!^i1dj;EVm;QU`V>;edI&!Yb|Jd;x=Prv)KAkgRW261gCV#Wj*ucM|$)__PYNX#@
z;6a(VtEYQVx?{(iVUqBza)Pi1UL}uf=qc7=4gJI_I{VVyk*n>+WpQUb@2+)_yb;gN
LbNAeezYX{oXB-T<
literal 0
HcmV?d00001
diff --git a/native/src/main/resources/osx-native-compress.so b/native/src/main/resources/osx-native-compress.so
new file mode 100755
index 0000000000000000000000000000000000000000..0f90cf0d1c53df0660401f6773084a54f9419fbb
GIT binary patch
literal 9676
zcmeHNeQaA-6~AtiHEotUDNUP+kGhOb&7#H0M%0cC6mK?rUfqz9q?DHI#<5>wr_QtM
z_uNl)%4jm};aW26OP~tMgb=iU5F~`QN|d0Mtz#1lY}!CVqQEFlJ4E1*u7Wk@cka8-
zv0qxyD)AS-%Dv~~-gDkL=bn4>-o1YPpMPCg!I*0~W9$~xM%44Qj7?260b}eo)Ze%m
z<GeqxvtO_(8xklll7>zOHKI~C=Z1Q~Aj~RGeY15I|I;LdLUfIVT5S!RC?`4Bjm)rK
zVmbA#UTt+fAV&}lH%g^W>LZ`2So(NOO{CPcpez0DmHHkNqZuQ5nZyNHVqZiz(s6B6
zj&a)eOR4Ww*>BUf$_m|Ja-Pxl$F(SrYa>ZPSK4>nZAnI@0-~KdWS0OmuTP43_51pL
zWj*$M-T>0PQm)u@!?~8=`oZzxWP+!RH0->-K3g3n7|Gj(;$LqQfSive%hF_tzDB7?
zrVAt5sjs0zUn2aU>}!$wc1jtd%k`1Ja;n4#&WH8ItRs6X{Y^=I5(t@cedRewoiq;$
zD(9hK&$fU+Xs<C3m{e><9zn6!<oY1H%5{;?q^HHf*V7U2csQ<k)2g1#q$8^CP3i~k
z(!xf3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