Skip to content

Instantly share code, notes, and snippets.

View Leandros's full-sized avatar

Arvid Gerstmann Leandros

View GitHub Profile
#!/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
@Leandros
Leandros / Swizzles.h
Created February 15, 2018 16:38 — forked from NocturnDragon/Swizzles.h
Swizzles in Clang, GCC, and Visual c++
#include <stdio.h>
// #define CLANG_OR_GCC
// Compile with -O3 -std=c++11 for Clang version
#define VS
// Compile with -O3 -fms-compatibility -std=c++11 for VS version
#if defined(CLANG_OR_GCC)
typedef float float2 __attribute__((ext_vector_type(2)));