Skip to content

Instantly share code, notes, and snippets.

View kassane's full-sized avatar
🏠
Working from home

Matheus C. França kassane

🏠
Working from home
View GitHub Profile
@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 / leds_swift.swift
Created August 25, 2024 19:46
[wip]: NuttX LED-sample
/****************************************************************************
* apps/examples/leds_rust/leds_rust_main.rs
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
@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:

../zig-bootstrap/out/zig-x86_64-linux-musl-baseline/zig build -Dtarget=native-native-msvc -DBUILD_SHARED_LIBS=true -Ddisable_handle_fork=false -Denable_cplusplus=true -Denable_gc_assertions=true -Denable_gc_debug=true -Denable_large_config=false -Denable_munmap=true -Denable_parallel_mark=false -Denable_redirect_malloc=false -Denable_rwlock=true -Denable_thread_local_alloc=true -Denable_threads=true -Denable_werror test -fwine
steps [5/43] zig build-exe initfromthreadtest Debug native-native-msvc... Created 205 threads (174 ended)
GC_check_heap_block: found 1 smashed heap objects:
0x79c926ed4db8 in or near object at 0x79c926ed4d90 (/app/bdwgc/tests/smash.c:34, sz= 40)
Call chain at allocation:
steps [12/43] zig build-exe realloctest Debug native-native-msvc... Heap size: 65536
Heap size: 131072
sh: 1: /usr/bin/addr2line: not found
/app/bdwgc/zig-cache/o/ed2c75516bbcd33b227e2d90c7f211f1/libgc.so(+0x4596b) [0x79c9272a596b]
/app/bdwgc/zig-cache/o/ed2c75516bbcd33b227e2d90c