Is there a prime number whose…

Is there a prime number whose binary representation looks like a giraffe?

Yes!

like another prime number?

Yes!

like a prime number of giraffes?

YES!

like Squidward Tentacles?

Heck Yeah!

You’ve probably understood the mechanism by now. Converting a binary image into a number, its nearest upper prime generally only differ in the lesser significant bits, hence most of the image pattern stays the same. So finding a prime number whose binary representation looks like a specific image is relatively easy. I say relatively, because in a computer sens it is quite really complex.

I just wrote a program to do just that. It is written in C and uses GMP. It is around 1k SLOC. It could probably have been much shorter, and even less so in another language. But I wanted something that went a little further than just of simple proof of concept.

I must admit, it’s pretty useless. But still there it is. And there is still much room for improvement. So patches are welcome on GitHub.

Linuxulator ist kaputt

Since a few weeks I’m running RELEASE on a custom kernel to use a patch that I made for a missing feature in the IPv6 stack (namely icmp_may_rst).

But a few minutes ago I had the surprise to find that the Linuxulator was no longer working. Trying to run a Linux binary failed with the following error:

ELF binary type "0" not known.
exec: test: Exec format error

Actually looking at kldstat, the Linux kernel module wasn’t even loaded. Trying to load it manually gave me the following error:

link_elf_obj: symbol kern_sched_setscheduler undefined
linker_load_file: Unsupported file type

OK so what is this sched_setscheduler you are talking about? Well there you go!
Now the Linuxulator depends on that syscall, but for some reason the necessary option disappeared from my custom kernel configuration. All I had to do was to add it again and recompile:

options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions

And now I can run Linux binaries again!