Skip to content

Instantly share code, notes, and snippets.

View folkertdev's full-sized avatar

Folkert de Vries folkertdev

View GitHub Profile
WARNING: The `change-id` is missing in the `config.toml`. This means that you will not be able to track the major changes made to the bootstrap configurations.
NOTE: to silence this warning, add `change-id = 127866` at the top of `config.toml`
Building stage0 library artifacts (x86_64-unknown-linux-gnu)
Building compiler artifacts (stage0 -> stage1, x86_64-unknown-linux-gnu)
Creating a sysroot for stage1 compiler (use `rustup toolchain link 'name' build/host/stage1`)
Building stage0 tool lld-wrapper (x86_64-unknown-linux-gnu)
Building stage1 library artifacts (x86_64-unknown-linux-gnu)
Building stage0 tool compiletest (x86_64-unknown-linux-gnu)
Testing stage1 compiletest suite=ui mode=ui (x86_64-unknown-linux-gnu)
@folkertdev
folkertdev / stable-order.rs
Created August 2, 2024 08:36
two files where one has inconsistent ordering of the generated error messages
//@ needs-asm-support
//@ ignore-nvptx64
//@ ignore-spirv
#![feature(asm_const)]
use std::arch::{asm, global_asm};
// Const operands must be integers and must be constants.
@folkertdev
folkertdev / comparison.svg
Created June 26, 2024 08:50
implicit coordinates are relative zero
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@folkertdev
folkertdev / example.py
Created June 18, 2024 09:37
tsp async pyo3 experiment
from dataclasses import dataclass
import tsp_python
from tsp_python import AsyncStore, OwnedVid, ReceivedTspMessageVariant, FlatReceivedTspMessage
class ReceivedTspMessage:
@staticmethod
def from_flat(msg: FlatReceivedTspMessage):
match msg.variant:
case ReceivedTspMessageVariant.GenericMessage:
@folkertdev
folkertdev / main.rs
Created June 14, 2024 14:48
PEXT experiment for lzma/xz variable width integer decoding
pub fn decode2(buf: &[u8], size_max: usize, num: &mut u64) -> usize {
let number = unsafe { core::ptr::read_unaligned(buf.as_ptr().cast()) };
let bits = unsafe { core::arch::x86_64::_pext_u64(number, 0x7F7F_7F7F_7F7F_7F7Fu64) };
let bytes_used = (number & !0x7F7F_7F7F_7F7F_7F7Fu64).count_ones();
*num = bits | (buf[8] as u64) << 56;
(size_max > 0) as usize + bytes_used as usize
}
@folkertdev
folkertdev / README.md
Created March 9, 2024 17:06
Creating a zip file with a unix extra field

run and validate with

rm -f extrafield.zip && python add_unix_extra_field.py && zipinfo -v extrafield.zip

this should show

Archive:  extrafield.zip
@folkertdev
folkertdev / crc32.c
Created February 19, 2024 14:43
a vectorized crc32 implementation (from the zlib-ng repository)
// compile with
//
// $ clang -shared -o libcrc32.so -Wall -Werror -fpic -march=native -O3 crc32.c
//
// This command only works on x86_64 systems that support the pclmulqdq instruction.
#include <immintrin.h>
#include <wmmintrin.h>
#include <smmintrin.h> // _mm_extract_epi32
#include <inttypes.h>
#include <stdio.h>
@folkertdev
folkertdev / main.roc
Created July 19, 2023 16:43
brainfuck interpreter using tail calls
app "brainroc"
packages {
pf: "https://github.com/roc-lang/basic-cli/releases/download/0.3.2/tE4xS_zLdmmxmHwHih9kHWQ7fsXtJr7W7h3425-eZFk.tar.br",
}
imports [
pf.File,
pf.Path,
pf.Stdout,
pf.Task,
]
@folkertdev
folkertdev / main.roc
Created July 19, 2023 12:05
brainroc
app "brainroc"
packages {
pf: "https://github.com/roc-lang/basic-cli/releases/download/0.3.2/tE4xS_zLdmmxmHwHih9kHWQ7fsXtJr7W7h3425-eZFk.tar.br",
}
imports [
pf.File,
pf.Path,
pf.Stdout,
pf.Task,
]
@folkertdev
folkertdev / mio_error_event.rs
Created June 7, 2023 19:42
mio responding to a message arriving on the error queue (EPOLLPRI)
use std::net::SocketAddr;
use std::os::unix::io::AsRawFd;
use std::thread;
use mio::net::UdpSocket;
use mio::{Events, Interest, Poll, Token};
const SOCKET_TOKEN: Token = Token(0);
fn main() {