Skip to content

Instantly share code, notes, and snippets.

View robstewart57's full-sized avatar

Rob Stewart robstewart57

View GitHub Profile
@robstewart57
robstewart57 / clang-cross-compiler-error-arm7a
Created November 27, 2013 13:52
Clang unable to cross-compile from x86_64 to ARM, Cortex a9
$ clang -v -target arm-none-eabi -mcpu=cortex-a9 -mfloat-abi=soft helloworld.c
clang version 3.3 (tags/RELEASE_33/rc3)
Target: arm-none--eabi
Thread model: posix
"/usr/bin/clang" -cc1 -triple armv7-none--eabi -S -disable-free -disable-llvm-verifier -main-file-name helloworld.c -mrelocation-model static -mdisable-fp-elim -fmath-errno -mconstructor-aliases -target-abi aapcs -target-cpu cortex-a9 -msoft-float -mfloat-abi soft -target-feature +soft-float -target-feature +soft-float-abi -target-feature -neon -target-linker-version 2.23.52.0.1 -v -resource-dir /usr/bin/../lib/clang/3.3 -fno-dwarf-directory-asm -fdebug-compilation-dir /home/rob/code/c/llvm -ferror-limit 19 -fmessage-length 157 -mstackrealign -fno-signed-char -fobjc-runtime=gcc -fobjc-default-synthesize-properties -fdiagnostics-show-option -fcolor-diagnostics -backend-option -vectorize-loops -o /tmp/helloworld-Iarp5R.s -x c helloworld.c
clang -cc1 version 3.3 based upon LLVM 3.3 default target x86_64-redhat-linux-gnu
#include "..." search starts he
{-# LANGUAGE ScopedTypeVariables #-}
module TwoDArray where
import Data.Int
import Data.Word
import LLVM.Core
import LLVM.Util.Loop
import Data.TypeLevel (D2,D4)
@robstewart57
robstewart57 / NotFirstClass.hs
Last active December 27, 2015 10:09
Using values that are not first class in LLVM
module Main where
import Data.Int
import LLVM.Core
import LLVM.ExecutionEngine
notFirstClass :: CodeGenModule (Function ([Int8] -> IO [Int8]))
notFirstClass = do
test <- createNamedFunction ExternalLinkage "test" $ \x -> do
@robstewart57
robstewart57 / hello-world-llvm.hs
Created October 28, 2013 09:51
generating hello world LLVM function from Haskell
import Control.Monad
import Data.Word
import LLVM.Core
import LLVM.Util.File
-- prints out "hello world"
bldGreet :: CodeGenModule (Function (IO ()))
bldGreet = do
puts <- newNamedFunction ExternalLinkage "puts" :: TFunction (Ptr Word8 -> IO Word32)
func <- withStringNul "Hello, World!" $ \greetz ->
-module(ammunition_factory).
-export([repeat_explosion/2,time_bomb/1]).
time_bomb(0) -> exit("boom!");
time_bomb(N) ->
timer:sleep(1000),
time_bomb(N-1).
repeat_explosion(0,N) ->
_Pid = spawn_monitor(fun() -> time_bomb(N) end),
@robstewart57
robstewart57 / three CCI-tcp runs
Created May 14, 2013 14:00
3 runs identifying CCI_EVENT_NONE in tcp implementation
### FIRST RUN
cci: only keeping CTP list: (null)
cci: In sock post_load
cci: In tcp post_load
cci: entering ctp_sock_init
cci: querying interface en0 info with socket ioctls and ethtool...
cci: adding device [en0] (transport sock)
cci: exiting ctp_sock_init
cci: entering ctp_tcp_init
cci: querying interface en0 info with socket ioctls and ethtool...
@robstewart57
robstewart57 / table-new-exporter.org
Created March 27, 2013 13:52
Org mode's new exporter for tables
..........
..........
-- API Module: Transport API as typeclass
class Transport t where
createTransport :: IO (Either IOException t)
newEndPoint :: t -> IO (Either (TransportError NewEndPointErrorCode) EndPoint)
closeTransport :: t -> IO ()
-- Separate module: TCP implementation
newtype TCPTransport = TCPTransport (N.HostName,N.ServiceName,MVar TransportState,TCPParameters)
@robstewart57
robstewart57 / typeclassstate.hs
Last active December 14, 2015 11:39
Haskell type class with state
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Concurrent.MVar
class Foo a where
mkFoo :: IO a
readFoo :: a -> IO Int
operateOnFoo :: a -> IO ()
newtype Bar = Bar (MVar Int)
@robstewart57
robstewart57 / spin_never_verification.txt
Created January 8, 2013 14:49
odd verification claim
/////////////
// Before
syntax check
the model contains 7 never claims: never_6, never_5, never_4, never_3, never_2, never_1, never_0
spin -a -o3 model.pml
the model contains 7 never claims: never_6, never_5, never_4, never_3, never_2, never_1, never_0
only one claim is used in a verification run
choose which one with ./pan -N name (defaults to -N never_0)
gcc -DMEMLIM=1024 -O2 -DXUSAFE -DNOREDUCE -w -o pan pan.c
./pan -m10000 -a -c1 -N never_6