Skip to content

Instantly share code, notes, and snippets.

View colemancda's full-sized avatar
🏎️
Working with Swift on ARM

Alsey Coleman Miller colemancda

🏎️
Working with Swift on ARM
View GitHub Profile
@colemancda
colemancda / Program.cs
Created April 18, 2024 03:55 — forked from angelsl/Program.cs
NX Benchmarks
// reNX is copyright angelsl, 2011 to 2012 inclusive.
//
// This file is part of reNX.
//
// reNX is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// reNX is distributed in the hope that it will be useful,
@colemancda
colemancda / CashRegister.swift
Last active July 28, 2023 18:29
Swift Register Command LIne
import Foundation
while let line: String = readLine() {
print(processInput(line))
}
func processInput(_ line: String) -> String {
let components = line.components(separatedBy: ";")
guard components.count == 2,
let price = Float(components[0]),
@colemancda
colemancda / DarwinNotificationCenter.swift
Created March 29, 2023 07:17 — forked from AvdLee/DarwinNotificationCenter.swift
A notification center for Darwin Notifications. MIT License applies.
//
// DarwinNotificationCenter.swift
//
// Copyright © 2017 WeTransfer. All rights reserved.
//
import Foundation
/// A Darwin notification payload. It does not contain any userInfo, a Darwin notification is purely event handling.
public struct DarwinNotification {
@colemancda
colemancda / main.go
Created December 13, 2022 09:15 — forked from diamondo25/main.go
Golang TinyMapleServer
package main
import (
"bufio"
"bytes"
"encoding/binary"
"encoding/hex"
"flag"
"fmt"
"net"
@colemancda
colemancda / 0001-stdlib-Add-RISCV64-support.patch
Last active November 3, 2022 07:36
Swift 5.7 StdLib patches for RISCV64
From a2e3e205250b3f0eddf06e5b0bc3c45231b85350 Mon Sep 17 00:00:00 2001
From: Alsey Coleman Miller <alseycmiller@gmail.com>
Date: Thu, 3 Nov 2022 00:27:15 -0700
Subject: [PATCH 1/1] [stdlib] Add RISCV64 support
---
CMakeLists.txt | 2 ++
cmake/modules/SwiftConfigureSDK.cmake | 2 +-
cmake/modules/SwiftSetIfArchBitness.cmake | 3 ++-
lib/Basic/LangOptions.cpp | 5 +++++
@colemancda
colemancda / swift-5.6-AtomicWaitQueue.patch
Last active May 26, 2022 23:49
Swift 5.6.1 runtime patch for AtomicWaitQueue
diff --git a/include/swift/Runtime/AtomicWaitQueue.h b/include/swift/Runtime/AtomicWaitQueue.h
index 9fdd9288fe2..0985067828b 100644
--- a/include/swift/Runtime/AtomicWaitQueue.h
+++ b/include/swift/Runtime/AtomicWaitQueue.h
@@ -19,6 +19,8 @@
#ifndef SWIFT_RUNTIME_ATOMICWAITQUEUE_H
#define SWIFT_RUNTIME_ATOMICWAITQUEUE_H
+#include "swift/Runtime/Heap.h"
+#include "swift/Runtime/HeapObject.h"
@colemancda
colemancda / build-swift-package-buildroot.sh
Created May 23, 2022 20:21
Cross compile Swift package and embed into Buildroot
#!/bin/sh
# Configuration
SWIFT_BUILD_MODE="${SWIFT_BUILD_MODE:=release}"
# exit for failures
set -e
# build swift package
echo "Build Swift Package"
@colemancda
colemancda / swift-armv5-qemu-buildroot-config
Created May 23, 2022 04:42
swift-armv5-qemu-buildroot-config
#
# Automatically generated file; DO NOT EDIT.
# Buildroot -g4176269-dirty Configuration
#
BR2_HAVE_DOT_CONFIG=y
BR2_EXTERNAL_SwiftPackage_PATH="/home/coleman/Developer/swift-cross-compile-action"
BR2_HOST_GCC_AT_LEAST_4_9=y
BR2_HOST_GCC_AT_LEAST_5=y
BR2_HOST_GCC_AT_LEAST_6=y
BR2_HOST_GCC_AT_LEAST_7=y
@colemancda
colemancda / Float16.patch
Created May 21, 2022 04:23
swift-5.6.1-armv7
diff --git a/stdlib/public/runtime/Float16Support.cpp b/stdlib/public/runtime/Float16Support.cpp
index 817739d4cdf..b1896a4e364 100644
--- a/stdlib/public/runtime/Float16Support.cpp
+++ b/stdlib/public/runtime/Float16Support.cpp
@@ -29,7 +29,7 @@
// Android NDK <r21 do not provide `__aeabi_d2h` in the compiler runtime,
// provide shims in that case.
-#if (defined(__ANDROID__) && defined(__ARM_ARCH_7A__) && defined(__ARM_EABI__)) || \
+#if ((defined(__ANDROID__) || defined(__linux__)) && defined(__arm__)) || \
@colemancda
colemancda / arm-yield.patch
Created May 21, 2022 04:20
libdispatch-5.6.1-armv7
diff --git a/src/shims/yield.c b/src/shims/yield.c
index 43f0017..d0c5fff 100644
--- a/src/shims/yield.c
+++ b/src/shims/yield.c
@@ -36,7 +36,7 @@ void *
_dispatch_wait_for_enqueuer(void **ptr)
{
#if !DISPATCH_HW_CONFIG_UP
-#if defined(__arm__) || defined(__arm64__)
+#if (defined(__arm__) && defined(__APPLE__)) || defined(__arm64__)