Skip to content

Instantly share code, notes, and snippets.

View kassane's full-sized avatar

Matheus C. França kassane

View GitHub Profile
@kassane
kassane / diff_cpp_mangle.md
Last active January 13, 2025 19:54
C++ Different mangling (Itanium ABI)
@kassane
kassane / alloc_nogc.d
Created November 24, 2024 15:17
Dlang betterC mode test - DynArray w/ Arena Allocator (like zig) & ScopedRef D class instanciation
// Works in betterC mode (tested on: ldc2 & opend-ldc2)
module arena;
struct Arena
{
void* start;
size_t used;
size_t capacity;
static scope Arena* create(size_t capacity)
@kassane
kassane / dragonbox_test.zig
Created September 28, 2024 18:46
Dragonbox: float format (based on https://github.com/jk-jeon/dragonbox)
const std = @import("std");
const math = std.math;
const assert = std.debug.assert;
const testing = std.testing;
pub const Policy = struct {
pub const SignPolicy = enum {
return_sign,
ignore_sign,
};
@kassane
kassane / safety.md
Last active September 16, 2024 16:53 — forked from pbackus/safety.md
issue c zig (release-safe) rust (release) Nim (release) Nim (danger) D (@safe) Swift modern C++
out-of-bounds heap read/write none runtime runtime runtime none runtime runtime none³
null pointer dereference none runtime runtime runtime none runtime¹ runtime none⁴
type confusion none runtime, partial runtime compile time compile time compile time compile time partial⁵
integer overflow none runtime runtime runtime none wraps runtime (checked) undefined behavior
use after free none none
@kassane
kassane / build.zig
Created August 10, 2024 17:21
Build c3c (v0.62.x) compiler using `build.zig` (bootstrap)
//! Zig v0.13.0 or master
//! Recommended `-Doptimize=ReleaseSmall` or `-Doptimize=ReleaseFast` (disabling sanitizer)
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// -Duse_tb
const use_tb = b.option(bool, "use_tb", "Enable the tild backend") orelse false;
@kassane
kassane / build.zig
Created June 12, 2024 16:41
build ldc2-druntime using Zig build
//! Based on: https://github.com/denizzzka/ldc-external_druntime_backend/blob/external_druntime_backend_support/runtime/druntime/meson.build
const std = @import("std");
const abs = @import("abs");
const builtin = @import("builtin");
pub fn build(b: *std.Build) !void {
// ldc2/ldmd2 not have mingw-support
const target = b.standardTargetOptions(.{
.default_target = if (builtin.os.tag == .windows)
@kassane
kassane / bench.md
Last active May 23, 2024 06:41
sieve-cache bench: Zig vs D impl vs C++ impl (Release mode)

System Spec

  • CPU: Ryzen 7 5700G (Zen3)
  • RAM: 16 GiB
  • DISK: SSD 470GiB (format: btrfs)
  • SO: ArchLinux (last upd installed: 20-05-2024)

@kassane
kassane / sieve-cache.md
Last active May 21, 2024 03:31
About SIEVE-cache :en:

Original post: kubo39/gist 🇯🇵


About SIEVE Cache

A cache algorithm called [SIEVE][sieve-website] was announced in 2023. It claims to be simpler than LRU, and indeed it is a fairly simple algorithm, but it is said to perform as well as existing superior cache algorithms such as S3-FIFO and TinyLFU.

@kassane
kassane / zig-mos.md
Last active May 4, 2024 17:46
zig-mos

Zig on MOS6502 (nes, c64, atari8, atari2600)

Zig toolchain [forked] uses LLVM codegen for mos target.

Current version: