Skip to content

Instantly share code, notes, and snippets.

@kernigh
kernigh / disksize.c
Created June 8, 2018 17:22
size of OpenBSD disk partition
#include <sys/types.h>
#include <sys/disklabel.h>
#include <sys/dkio.h> /* DIOCGDINFO */
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
/*
* Shows the size in bytes of a disk partition in OpenBSD.
@kernigh
kernigh / fifo-fail.diff
Last active October 11, 2017 21:37
prevent Ruby tests getting stuck in OpenBSD
Some of Ruby's tests get stuck in OpenBSD.
This is because of OpenBSD's bug. FIFO gets stuck.
This patch causes all FIFO tests to fail,
so I can run `make test-all` and `make test-spec` in OpenBSD.
Jeremy Evans (who knows OpenBSD better than me)
described the bug here: https://bugs.ruby-lang.org/issues/13875#note-7
diff --git a/spec/ruby/spec_helper.rb b/spec/ruby/spec_helper.rb
@kernigh
kernigh / ack-elf-fix.diff
Created January 17, 2017 02:01
ack: fix for ELF symbol table
diff --git a/util/amisc/aelflod.c b/util/amisc/aelflod.c
index d5a9c0d..dbaafc9 100644
--- a/util/amisc/aelflod.c
+++ b/util/amisc/aelflod.c
@@ -43,6 +43,7 @@ char* stringarea;
uint32_t ack_off_char;
int nstab = 0; /* S_STB symbol count */
int nsym = 0; /* other symbol count */
+int nlocal = 0; /* local symbols */
@kernigh
kernigh / ack-powerpc-ex.diff
Last active January 18, 2017 21:26
ack: PowerPC extended mnemonics, incomplete diff
diff --git a/mach/powerpc/as/mach2.c b/mach/powerpc/as/mach2.c
index 480c5fa..47ef18c 100644
--- a/mach/powerpc/as/mach2.c
+++ b/mach/powerpc/as/mach2.c
@@ -10,18 +10,32 @@
%token <y_word> C
%token <y_word> OP
+%token <y_word> OP_BDA
+%token <y_word> OP_BDL
@kernigh
kernigh / SetDemo.mod
Created December 10, 2016 17:25
test for Modula-2 set operations in Amsterdam Compiler Kit
MODULE SetDemo;
FROM InOut IMPORT WriteLn, WriteString;
PROCEDURE Puts(s: ARRAY OF CHAR);
BEGIN
WriteString(s);
WriteLn;
END Puts;
@kernigh
kernigh / benchrand.rb
Created May 9, 2016 02:35
benchmark for different random number generators
# Run benchmarks:
# $ ruby benchrand.rb
# Run benchmarks in parallel with sh and xterm:
# $ for i in 1 2; do xterm -hold -e ruby benchrand.rb& done
#
# Outputs the time to generate SIZE random bytes with several
# different random number generators:
# - Random::DEFAULT from Ruby
# - /dev/urandom
# - arc4random_buf() from libc
# This script compiles scramble.c and calculates the score.
# Before use, put scramble.c, $text, $pict in current directory.
text=pg100.txt
pict=filament.jpg
# Die if any command fails.
# Die if files are missing.
set -e
ls scramble.c $text $pict >/dev/null