Skip to content

Instantly share code, notes, and snippets.

View kjellwinblad's full-sized avatar

Kjell Winblad kjellwinblad

View GitHub Profile
@zmstone
zmstone / bin_element.erl
Created April 11, 2022 17:06
binary pattern match performance
-module(bin_element).
-export([run/1]).
-define(CHUNK_SIZE, 1049).
run(Chunks) ->
BinL = [crypto:strong_rand_bytes(?CHUNK_SIZE) || _ <- lists:seq(1, Chunks)],
TotalBytes = ?CHUNK_SIZE * Chunks,
compare([hd(BinL) | BinL], TotalBytes).
@kishmakov
kishmakov / Makefile
Last active May 9, 2024 14:35
Shared libraries and Address Sanitizer (ASAN)
SAN_CMP := -fno-omit-frame-pointer -fsanitize=address
SAN_STAT := -static-libstdc++ -static-libasan
BIN_CMP := -std=c++11 -c -I. main.cpp -O -g3 -o main.o
LIB_CMP := -std=c++11 my.cpp -o libmy.so -shared -fPIC -g3
RUN := LD_LIBRARY_PATH=. ASAN_OPTIONS=symbolize=1 ASAN_SYMBOLIZER_PATH=$(shell which llvm-symbolizer)
PRELOAD := LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.1
lib-gcc:
^([0-9]+)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])[Tt]([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?(([Zz])|([\+|\-]([01][0-9]|2[0-3]):[0-5][0-9]))$
@nhatminhle
nhatminhle / stdatomic.h
Last active November 23, 2022 10:15
A portable version of stdatomic.h extracted from the FreeBSD libc, for Clang 3.1+ and GCC 4.7+.
/*
* An implementation of C11 stdatomic.h directly borrowed from FreeBSD
* (original copyright follows), with minor modifications for
* portability to other systems. Works for recent Clang (that
* implement the feature c_atomic) and GCC 4.7+; includes
* compatibility for GCC below 4.7 but I wouldn't recommend it.
*
* Caveats and limitations:
* - Only the ``_Atomic parentheses'' notation is implemented, while
* the ``_Atomic space'' one is not.