Skip to content

Instantly share code, notes, and snippets.

@JohanEngelen
JohanEngelen / format_timetrace.d
Created February 24, 2023 20:37
ASCII output of --ftime-trace
// Run using: ldc2 --run format_timetrace.d <your .time-trace file>
// Outputs timetrace.txt in current dir
import std.stdio;
import std.file;
import std.json;
import std.range;
import std.conv;
import std.algorithm;
@JohanEngelen
JohanEngelen / test_bitfield.d
Created August 7, 2022 21:01
Generates random struct with bitfields in C and D code and tests whether D compiler correctly compiles C bitfields
// Test importC bitfields.
// Generates random bitfield structure type, generates the C code and header file, generates D file that tests reading/writing from bitfields in C-land and D-land.
/+
struct Test {
{<empty>|some __alignment...} {<empty>|signed|unsigned} {int|char|long|size_t|float|...} member1 {<empty>|:<some number 0..bitwidth of the storage type};
... repeat for member2, member3, random number of members
}
void resetMember1_C(Test* t)
#!/bin/bash
set -e
# Grab CE's GCC 6.3.0 for its binutils (which is what the site uses to link currently)
mkdir -p /opt/compiler-explorer
pushd /opt/compiler-explorer
curl -sL https://s3.amazonaws.com/compiler-explorer/opt/gcc-6.3.0.tar.xz | tar Jxf -
popd