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
@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 { \ */
@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"
#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,
#!/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
#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; };
@Leandros
Leandros / foo.cxx
Last active May 15, 2018 18:42
How I pimpl
#include "foo.hxx"
struct Foo::Implementation
{
int bar = 0;
};
PIMPL_UNIQUE_IMPL(Foo)
Foo::Foo()
<html>
<head>
<meta charset="utf-8">
<meta property="og:url" content="https://foo.bar">
<style>
#h1 {
font-size: 32px;
color: #fff;
}
</style>
@Leandros
Leandros / main.z
Created June 23, 2018 15:04
Zlang Example
import Vec3;
import std::Concepts;
import std::Gc;
func Square(x: int) -> int {
return x * x;
}
/* PrintTest is overloaded on different concepts. */
@Leandros
Leandros / random.h
Created July 2, 2018 05:22
C++ Pseudo Random Number Generators
/* Copyright (c) 2018 Arvid Gerstmann. */
/* This code is licensed under MIT license. */
#ifndef AG_RANDOM_H
#define AG_RANDOM_H
class splitmix
{
public:
using result_type = uint32_t;
static constexpr result_type (min)() { return 0; }
@Leandros
Leandros / results.txt
Last active July 2, 2018 05:29
PractRand Results
################################### SPLITMIX
############################################
$ ./splitmix | ./PractRand/RNG_test stdin32 -multithreaded
RNG_test using PractRand version 0.93
RNG = RNG_stdin32, seed = 0x1c3196f9
test set = normal, folding = standard (32 bit)
rng=RNG_stdin32, seed=0x1c3196f9
length= 256 megabytes (2^28 bytes), time= 3.0 seconds
no anomalies in 124 test result(s)