Skip to content

Instantly share code, notes, and snippets.

View hpux735's full-sized avatar

William Dillon hpux735

View GitHub Profile
@hpux735
hpux735 / proposal.md
Last active March 4, 2016 02:46
Draft Swift Evolution proposal

Improve the portability of Swift with differently signed char.

Introduction

In C, the signness of char is undefined. A convention is set by either the platform, such as Windows, or by the architecture ABI specification, as is typical on System-V derived systems. A subset of known platforms germane to this discussion and their char signness is provided below.

/opt/local/bin/cmake -G Ninja -DCMAKE_C_COMPILER:PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -DCMAKE_CXX_COMPILER:PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_C_FLAGS= -fno-stack-protector -DCMAKE_CXX_FLAGS= -fno-stack-protector -DCMAKE_OSX_SYSROOT:PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 /Users/admin/swift-build/cmark
/opt/local/bin/cmake -G Ninja -DCMAKE_C_COMPILER:PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -DCMAKE_CXX_COMPILER:PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -DCMAKE_C_FLAGS= -fno-stack-protector -DCMAKE_CXX_FLAGS= -fno-stack-protector -DCMAKE_BUILD_TYPE:STRING=Release -DLLVM_ENABLE_ASSERTIONS:BOOL=TRUE -DSWIFT_ANALYZE_CODE_COVERAGE:STRING
I suspect it's related to linking…
So, a while back Orlando had fixed some things in Foundation (which still haven't been merged yet).
The symptom is that you'll get an error from unwrapping a nil.
When I test OSULogger (b, in the example above) without the patched Foundation I get the error.
Once I patched it, the tests pass. Then, with the same libraries and everything,
if I pull in OSUOpenCL (a) which depends on OSULogger, the tests in logger fail in the
same way as the unpatched Foundation
wdillon@beast:~/OSULogger$ swift test
Compiling Swift Module 'OSULoggertest' (2 sources)
@hpux735
hpux735 / build.swift-build
Last active February 17, 2016 18:32
llbuild script for swiftpm
client:
name: swift-build
tools: {}
targets:
"": ["<target-PackageDescription>", "<target-libc>", "<target-POSIX>", "<target-sys>", "<target-dep>", "<target-swift-build>", "<target-XCTestCaseProvider>", "<target-PackageDescription-tests>", "<target-sys-tests>", "<target-dep-tests>", "<target-Functional-tests>"]
all: ["<target-PackageDescription>", "<target-libc>", "<target-POSIX>", "<target-sys>", "<target-dep>", "<target-swift-build>", "<target-XCTestCaseProvider>", "<target-PackageDescription-tests>", "<target-sys-tests>", "<target-dep-tests>", "<target-Functional-tests>"]
PackageDescription: ["<target-PackageDescription>"]
libc: ["<target-libc>"]
[9/39] cd /Users/admin/swift-build/build/Ninja-ReleaseAssert/swift-linux-armv7/stdlib/private/SwiftPrivate && /opt/local/bin/cmake -E make_directory /Users/admin/swift-build/build/Ninja-ReleaseAssert/swift-linux-armv7/stdlib/private/SwiftPrivate/linux/armv7-unknown-linux-gnueabihf && /opt/local/bin/cmake -E make_directory /Users/admin/swift-build/build/Ninja-ReleaseAssert/swift-linux-armv7/./lib/swift/linux/armv7-unknown-linux-gnueabihf && /Users/admin/swift-build/swift/utils/line-directive /Users/admin/swift-build/swift/stdlib/private/SwiftPrivate/SwiftPrivate.swift /Users/admin/swift-build/swift/stdlib/private/SwiftPrivate/IO.swift /Users/admin/swift-build/swift/stdlib/private/SwiftPrivate/PRNG.swift /Users/admin/swift-build/swift/stdlib/private/SwiftPrivate/ShardedAtomicCounter.swift -- /Users/admin/swift-build/build/Ninja-ReleaseAssert/swift-macosx-x86_64/bin//swiftc -c -sdk / -target armv7-unknown-linux-gnueabihf -O -D INTERNAL_CHECKS_ENABLED -I /Users/admin/swift-build/build/Ninja-ReleaseAssert/swift-li
@hpux735
hpux735 / gist:53abdafbab9eeeeb0329
Created February 8, 2015 03:06
Writing a string to an i2c eprom with Arduino
/*
* Use the I2C bus with EEPROM 24LC64
*
*/
#include <Wire.h> //I2C library
void writeEEPROM(char *string, unsigned char block, unsigned char address);
void printEEPRIOM();
void eraseEEPROM();
@hpux735
hpux735 / rtl-formatter.swift
Last active August 29, 2015 14:13
RTL-SDR file formatter for GNURadio. Uses Swift and Accelerate framework. It's MUCH faster than the GRC on the rtlsdr website.
//
// main.swift
// rtl-formater
//
// Created by William Dillon on 1/21/15.
// Copyright (c) 2015 HouseDillon. All rights reserved.
//
import Foundation
import Accelerate
@hpux735
hpux735 / gist:9815330
Created March 27, 2014 18:57
OpenCL FIR
#define num_taps 150
__constant float taps[num_taps] = {
4.5528412686211801e-04, 4.7143479283810269e-04, 4.9265664783479932e-04, 5.1935133206458756e-04, 5.5190883344588668e-04, 5.9070568604295396e-04, 6.3610320042731044e-04, 6.8844573336344591e-04, 7.4805900411431905e-04, 8.1524846452430972e-04, 8.9029772986915878e-04, 9.7346707726454198e-04, 1.0649920181980451e-03, 1.1650819514941403e-03, 1.2739189027393427e-03, 1.3916563558860344e-03, 1.5184181824196682e-03, 1.6542976731164991e-03, 1.7993566770389934e-03, 1.9536248520151279e-03, 2.1170990304274768e-03, 2.2897427036999980e-03, 2.4714856284164220e-03, 2.6622235565360503e-03, 2.8618180916923654e-03, 3.0700966730691317e-03, 3.2868526878496000e-03, 3.5118457127290654e-03, 3.7448018844713667e-03, 3.9854143989781774e-03, 4.2333441378280190e-03, 4.4882204207321872e-03, 4.7496418818490762e-03, 5.0171774673990199e-03, 5.2903675515306690e-03, 5.5687251669092235e-03, 5.8517373460285097e-03, 6.1388665687948886e-03, 6.4295523114932876e-03, 6.7232126918258892e-03, 7.0192
<?xml version='1.0' encoding='ASCII'?>
<flow_graph>
<timestamp>Sat Mar 22 10:54:05 2014</timestamp>
<block>
<key>options</key>
<param>
<key>id</key>
<value>top_block</value>
</param>
<param>
@hpux735
hpux735 / gist:9649071
Created March 19, 2014 19:13
Reverse geocache (pic18)
#include <pic18.h>
#include <htc.h>
#include <peripheral/usart.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include "delay.h"