Skip to content

Instantly share code, notes, and snippets.

View Leandros's full-sized avatar
🦀
Available for Rust contracting

Arvid Gerstmann Leandros

🦀
Available for Rust contracting
View GitHub Profile
#pragma once
struct Type0 { int x; };
struct Type1 { int x; };
struct Type2 { int x; };
struct Type3 { int x; };
struct Type4 { int x; };
struct Type5 { int x; };
struct Type6 { int x; };
struct Type7 { int x; };
#!/bin/bash
cflags="-O3 -std=c++14 -ggdb3 -frecord-gcc-switches"
ldflags="-grecord-gcc-switches -gcolumn-info"
# Cleanup
rm -rf obj
rm test test.pdb
mkdir -p obj
#include <sys/mman.h>
#include <stdio.h>
int main(void)
{
int *map = mmap(
0,
4096,
PROT_READ|PROT_WRITE|PROT_EXEC,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS,
@Leandros
Leandros / make.sh
Created April 15, 2018 19:35
build re2c
#!/bin/bash
export PATH=$PATH:$HOME/x86_64-linux-musl/bin
export CC=x86_64-linux-musl-gcc
export CXX=x86_64-linux-musl-g++
# If needed
export CC="$CC -static --static"
export CXX="$CXX -static --static"
@Leandros
Leandros / benchmark.cxx
Created April 2, 2018 21:45
Virtual Memory Benchmark
#ifdef BENCHMARK_HAS_CXX11
#undef BENCHMARK_HAS_CXX11
#endif
#include <benchmark/benchmark.h>
#include <windows.h>
static constexpr size_t MemorySize = 0x10'000 * 4800; /* 300 MiB */
/* #define MEMSET \ */
/* do { \ */
#include <stdatomic.h>
#include <stdint.h>
#include <x86intrin.h>
#include <stdio.h>
#include <stdlib.h>
#include <linux/futex.h>
#include <sys/time.h>
#include <pthread.h>
static uint64_t
#include <stdio.h>
#include <string.h>
#include <math.h>
#define clamp(d, min, max) ((d) < (min) ? (min) : ((d) > (max) ? (max) : (d)))
float
sRGB_encode(float v)
{
@Leandros
Leandros / make.sh
Created February 24, 2018 17:09
Compile NASM
#!/bin/bash
export PATH=$PATH:$HOME/x86_64-linux-musl/bin
export CC=x86_64-linux-musl-gcc
export CXX=x86_64-linux-musl-g++
# If needed
export CC="$CC -static --static"
export CXX="$CXX -static --static"
@Leandros
Leandros / make.sh
Created February 17, 2018 19:51
Compile ccache
#!/bin/bash
export PATH=$PATH:$HOME/x86_64-linux-musl/bin
export CC=x86_64-linux-musl-gcc
export CXX=x86_64-linux-musl-g++
# If needed
export CC="$CC -static --static"
export CXX="$CXX -static --static"
@Leandros
Leandros / touch.cmd
Created February 16, 2018 10:03
*nix like touch on Windows
@echo off
setlocal enableextensions disabledelayedexpansion
(for %%a in (%*) do if exist "%%~a" (
pushd "%%~dpa" && ( copy /b "%%~nxa"+,, & popd )
) else (
type nul > "%%~fa"
)) >nul 2>&1