Skip to content

Instantly share code, notes, and snippets.

View nickdesaulniers's full-sized avatar
Paternity Leave

Nick Desaulniers (paternity leave) nickdesaulniers

Paternity Leave
View GitHub Profile
pushd /image/usr/src/linux-5.13.12
make ARCH=x86_64 mrproper
make ARCH=x86_64 INSTALL_HDR_PATH=/image/usr headers_install
mkdir -p /image/var/tmp/build/compiler-rt-12.0.1
pushd /image/var/tmp/build/compiler-rt-12.0.1
cmake -D CMAKE_BUILD_TYPE=Release \
-D CMAKE_C_COMPILER_TARGET=x86_64-unknown-linux-musl \
nico /
Last active July 25, 2023 18:43
C vs C++ inline function semantics, and ODR vs /arch:

The semantics of inline are one of the areas where C and C++ are pretty different. This post is about the C++ semantics, but the history is interesting, so here's a short summary of it.

The meaning of "inline" is intuitively easy to understand: It gives the compiler a hint that it'd be nice if a function could be inlined. It gets a bit complicated because of two issues:

  1. If the function ends up not being inlined, where should the definition of the function be emitted?
  2. If the inline function contains a static local variable, should that be inlined? Should there be several copies of the static local, or just one?
PixelSergey /
Last active May 25, 2024 11:41
Dump games with godmode9

Dumping games with Godmode9

Dumping games is the act of taking a game from your system or gamecart and copying it into a readable format onto your SD card. Dumping is perfectly legal if you keep the dumps to yourself, however sharing these dumps is piracy and is illegal.

This guide will tell you how to dump games from various formats and for various purposes. Dumping 3DS cartriges as .cia files is good if you want to install them to your system. Dumping them as .3ds files is good for emulators. Installed titles cannot be dumped as .3ds files. NDS cartiges can only be dumped as .nds files and cannot be installed (however, you can play them with emulators or flashcarts).

Dumping the RomFS of a game is primarily for romhacking purposess.

shafik /
Last active May 28, 2024 00:06
What is Strict Aliasing and Why do we Care?

What is the Strict Aliasing Rule and Why do we care?

(OR Type Punning, Undefined Behavior and Alignment, Oh My!)

What is strict aliasing? First we will describe what is aliasing and then we can learn what being strict about it means.

In C and C++ aliasing has to do with what expression types we are allowed to access stored values through. In both C and C++ the standard specifies which expression types are allowed to alias which types. The compiler and optimizer are allowed to assume we follow the aliasing rules strictly, hence the term strict aliasing rule. If we attempt to access a value using a type not allowed it is classified as undefined behavior(UB). Once we have undefined behavior all bets are off, the results of our program are no longer reliable.

Unfortunately with strict aliasing violations, we will often obtain the results we expect, leaving the possibility the a future version of a compiler with a new optimization will break code we th

rygorous / gist:e0f055bfb74e3d5f0af20690759de5a7
Created May 8, 2016 06:54
A bit of background on compilers exploiting signed overflow
Why do compilers even bother with exploiting undefinedness signed overflow? And what are those
mysterious cases where it helps?
A lot of people (myself included) are against transforms that aggressively exploit undefined behavior, but
I think it's useful to know what compiler writers are accomplishing by this.
TL;DR: C doesn't work very well if int!=register width, but (for backwards compat) int is 32-bit on all
major 64-bit targets, and this causes quite hairy problems for code generation and optimization in some
fairly common cases. The signed overflow UB exploitation is an attempt to work around this.
paragonie-scott /
Last active April 21, 2024 23:48
An Open Letter to Developers Everywhere (About Cryptography)
sergnechaev / sdl2_opengl.cpp
Last active September 26, 2022 02:34 — forked from exavolt/sdl2_opengl.c
Very basic SDL2 OpenGL application (C++1y)
#include <iostream>
#include <cmath>
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
constexpr int SCREEN_WIDTH = 800;
constexpr int SCREEN_HEIGHT = 600;
anonymous / joshVR.xml
Created August 24, 2015 11:39
joshVR snapshot
<!-- VR X-Wing by David Bryant ( -->
<!-- X-Wing = all parts grouped together -->
<group scaleX="1.0" scaleY="1.0" scaleZ="1.0"
rotateX="0.0" rotateY="0.0" rotateZ="0.0"
translateX="0.0" translateY="0.0" translateZ="0.0">
<!-- Fuselage -->
<!-- Main body -->