Skip to content

Instantly share code, notes, and snippets.

@yalue
yalue / mandelbrot.S
Last active July 30, 2025 18:59
Mandelbrot set printed to stdout on Linux in ARM32 assembly
// Assemble using:
// arm-linux-gnueabihf-as -mfpu=neon -o mandelbrot.o mandelbrot.S
// arm-linux-gnueabihf-ld -o mandelbrot mandelbrot.o
.syntax unified
.section .data
message:
canvas_width = 40
canvas_height = 30
max_iters = 100
@yalue
yalue / ARM mnemonics.txt
Created January 15, 2025 17:05
List of ARM mnemonics. May include some ARM64 mnemonics, probably missing a few.
adc
adcal
adcals
adccc
adcccs
adccs
adccss
adceq
adceqs
adcge
@yalue
yalue / ffmpeg_reencode.rb
Created January 11, 2025 01:57
Ruby snippet for reencoding .mp4 videos using ffmpeg
# Returns the file path with extension removed
def strip_extension(filepath)
File.join(
File.dirname(filepath),
File.basename(filepath, File.extname(filepath))
)
end
# Re-encodes the given file as .mp4 using libh264 and MP3 audio. Returns the
# filename of the new file.
@yalue
yalue / litmus_config.txt
Last active March 2, 2022 15:13
The config file for building my version of litmus at commit d74240785e132966b9ce4f35a594ebf4440e4757
#
# Automatically generated file; DO NOT EDIT.
# Linux/x86 5.16.0-rc6 Kernel Configuration
#
CONFIG_CC_VERSION_TEXT="gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0"
CONFIG_CC_IS_GCC=y
CONFIG_GCC_VERSION=70500
CONFIG_CLANG_VERSION=0
CONFIG_AS_IS_GNU=y
CONFIG_AS_VERSION=23000
@yalue
yalue / litmus-5.16-rc7-config
Created February 3, 2022 21:00
The config file I was using for my (mostly) working build of my LITMUS update.
#
# Automatically generated file; DO NOT EDIT.
# Linux/x86 5.16.0-rc6 Kernel Configuration
#
CONFIG_CC_VERSION_TEXT="gcc (Debian 10.2.1-6) 10.2.1 20210110"
CONFIG_CC_IS_GCC=y
CONFIG_GCC_VERSION=100201
CONFIG_CLANG_VERSION=0
CONFIG_AS_IS_GNU=y
CONFIG_AS_VERSION=23502
@yalue
yalue / string_replace.c
Created February 1, 2022 16:32
Just a quick string replacement function in C, so I don't need to think about it next time I need it.
#include <stdint.h>
#include <string.h>
// Replaces all instances of the string match in input with r. Returns a new
// null-terminated string, or NULL on error. The returned string must be freed
// by the caller when no longer needed. Even if no replacements are made, this
// will return a new copy of the input string.
char* StringReplace(const char *input, const char *match, const char *r) {
char *input_pos = NULL;
const char *prev_input_pos = NULL;
@yalue
yalue / litmus_porting_notes.txt
Last active March 2, 2022 14:29
Notes I made while porting LITMUS^RT to Linux 5.16.
To compare Joshua's changes vs. the baseline 5.4 he used:
https://github.com/JoshuaJB/litmus-rt/compare/b90344f7d6000deba0709d75225f30cbf79ec2f0...55ce62849f94dd9c9fc0a5397b4f8cf40b40a324
General notes:
- The "state" field in task_struct is now __state and should be accessed using
the READ_ONCE and WRITE_ONCE accessors, or other macros from sched.h.
- The "lock" field in "struct rq" is now __lock, and should be
@yalue
yalue / bit_accessor.h
Created October 11, 2021 00:30
A mega-union for directly accessing any bits in a uint64_t in C.
#ifndef BIT_ACCESSOR_H
#define BIT_ACCESSOR_H
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
// This header defines the BitAccessor type, which can be used for setting any
// series of consecutive bits in a uint64_t. For example, to set bits 7-13 in
// a 64-bit value:
@yalue
yalue / write_to_pipe.c
Created November 12, 2020 20:49
An example of writing to a child process' stdin, in C.
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
// A minimal-ish example of writing data to a child process' stdin.
int main(int argc, char **argv) {
char print_buffer[256];
int stdin_pipe[2];
int result;
@yalue
yalue / AMD driver fail.txt
Created August 14, 2020 21:22
dmesg output when I tried running "import torch"
[ 347.582485] BUG: kernel NULL pointer dereference, address: 0000000000000028
[ 347.582489] #PF: supervisor write access in kernel mode
[ 347.582490] #PF: error_code(0x0002) - not-present page
[ 347.582491] PGD 0 P4D 0
[ 347.582494] Oops: 0002 [#1] PREEMPT SMP
[ 347.582496] CPU: 15 PID: 7937 Comm: python Not tainted 5.8.0+ #1
[ 347.582497] Hardware name: Dell Inc. Precision Tower 7910/0NK5PH, BIOS A13 05/20/2016
[ 347.582626] RIP: 0010:amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu+0x48d/0x900 [amdgpu]
[ 347.582628] Code: 03 c1 e8 96 bf b2 dd e9 94 fd ff ff 83 bd 40 ff ff ff 02 48 8b 85 78 ff ff ff 75 12 48 8b 90 30 02 00 00 4c 89 b0 90 02 00 00 <4c> 89 72 28 48 8b 13 48 83 bd 48 ff ff ff 00 48 89 90 90 03 00 00
[ 347.582629] RSP: 0018:ffff9c00c2037cc0 EFLAGS: 00010246