Skip to content

Apple's open-source XNU kernel on Android phones: its own loader and drivers, Metal on the Adreno. Runs from RAM; a reboot gives the phone back to Android.

C

userland/build.sh: the Metal plug-in from hakios-metal's plugin/ when it is beside the tree; tools/macos-bin: stat and timeout without MacPorts

shimoku74e114355e5a4a
diff --git a/tools/macos-bin/stat b/tools/macos-bin/stat
index 0424613..c622f54 100755
--- a/tools/macos-bin/stat
+++ b/tools/macos-bin/stat
@@ -1,2 +1,11 @@
#!/bin/sh
-exec /opt/local/bin/gstat "$@"
+# GNU stat for xl and the tools: MacPorts' gstat when it is there, else macOS's own for what they ask (stat -c %s|%Y FILE)
+[ -x /opt/local/bin/gstat ] && exec /opt/local/bin/gstat "$@"
+command -v gstat >/dev/null 2>&1 && exec gstat "$@"
+if [ "$1" = -c ]; then
+ case "$2" in
+ %s) shift 2; exec /usr/bin/stat -f %z "$@" ;;
+ %Y) shift 2; exec /usr/bin/stat -f %m "$@" ;;
+ esac
+fi
+exec /usr/bin/stat "$@"
diff --git a/tools/macos-bin/timeout b/tools/macos-bin/timeout
index 30d68d4..dec8179 100755
--- a/tools/macos-bin/timeout
+++ b/tools/macos-bin/timeout
@@ -1,2 +1,14 @@
#!/bin/sh
-exec /opt/local/bin/gtimeout "$@"
+# GNU timeout for xl: MacPorts' gtimeout when it is there, else the same in perl (timeout SECS COMMAND...: the command killed
+# with TERM after SECS, and the status 124 then, as GNU's)
+[ -x /opt/local/bin/gtimeout ] && exec /opt/local/bin/gtimeout "$@"
+command -v gtimeout >/dev/null 2>&1 && exec gtimeout "$@"
+exec perl -e '
+ my $secs = shift; $secs =~ s/s$//;
+ my $pid = fork() // die "timeout: fork: $!\n";
+ if ($pid == 0) { exec @ARGV or die "timeout: $ARGV[0]: $!\n"; }
+ local $SIG{ALRM} = sub { kill "TERM", $pid; waitpid($pid, 0); exit 124; };
+ alarm $secs;
+ waitpid($pid, 0);
+ exit($? & 127 ? 128 + ($? & 127) : $? >> 8);
+' "$@"
diff --git a/userland/build.sh b/userland/build.sh
index a3be697..b2bb53a 100755
--- a/userland/build.sh
+++ b/userland/build.sh
@@ -244,7 +244,14 @@ if [ -d $DARWIN/rootfs/usr/lib ]; then
METAL_GPU="-DHAKIOS_METAL_GPU -I$HM/include $HM/out/darwin/libhakios-metal.a -lc++ -framework IOKit"
echo "build.sh: HakiosMetal with hakios-metal ($HM)"
fi
- $DYN -bundle -framework Foundation -framework Metal -lobjc -o obj/HakiosMetal src/HakiosMetal.m src/hakios_metallib.c $METAL_GPU
+ # the plug-in itself is hakios-metal's now (plugin/, where it is tested); the copy in src/ is for a tree without it
+ METAL_SRC=src
+ if [ -f $HM/plugin/HakiosMetal.m ]; then
+ METAL_SRC=$HM/plugin
+ echo "build.sh: HakiosMetal from $HM/plugin"
+ fi
+ $DYN -bundle -framework Foundation -framework Metal -lobjc -I$METAL_SRC -o obj/HakiosMetal $METAL_SRC/HakiosMetal.m \
+ $METAL_SRC/hakios_metallib.c $METAL_GPU
if [ -n "$GL" ]; then
# the OpenGL ES library, and the table of functions that hands CoreAnimation's calls to it
# (Mesa says beside the library what it was built from: one from other patches is built again)