Full source code can be found here
- 2016-12-20
- New performance test - Paul Westcott (@manofstick) made me aware that SeqComposer has a more performant API. SeqComposer2 uses this API.
- 2016-12-23
/* | |
Preface: | |
I'm issuing this challenge as I've hit a major roadblock in the development process | |
of one of my personal side projects. I've spent the last 2 weeks exhaustively exploring | |
solutions to the following problem and I'm at my wits end. I've taken a number of approaches | |
using various tree data structures and clever algorithms with no success. | |
Full source code can be found here
// Credits: John Stewien | |
// From: http://code.cheesydesign.com/?p=572 | |
/* | |
Reading the Portable Executable (PE) header in C# | |
My job consists of writing fully custom applications for groups of people. The time pressure of these projects is quite high, so generally people start using the application while I’m still writing it, which means I write it modularly and add features as I go along. I also fix bugs as they are discovered. My clients are 2 tiered where expert users get a new build first, they test if for a while, and if they think it’s acceptable they then pass it on to others. | |
This method of distribution is quite ad-hoc so when a client rings me up and asks me to view their screen to look at something, it’s useful to know what build they are running. To facillitate this I print the link date in the main Window Title so I instantly have an idea about how old the version is that I am looking at. This date is calculated at run time. To do this requires reading in the Portable Executable (PE) header from th |
/* Compile with | |
* gcc -O2 -Wall -Wextra -pedantic -o test_bits test_bits.c | |
*/ | |
#define _GNU_SOURCE | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <fcntl.h> | |
#include <sched.h> | |
#include <stdint.h> |
Principles of Adult Behavior
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" > | |
<asmv3:application> | |
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings"> | |
<longPathAware>true</longPathAware> | |
</asmv3:windowsSettings> | |
</asmv3:application> | |
</assembly> |
// x86 SIMD string to uppercase | |
// See http://stackoverflow.com/questions/735204/convert-a-string-in-c-to-upper-case | |
#include <stdio.h> | |
#include <stdint.h> | |
#include <string.h> | |
#include <strings.h> // for ffs | |
#include <ctype.h> | |
#include <immintrin.h> |
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. |
unsafe void Main() | |
{ | |
var s = "hello world"; | |
Console.WriteLine($"String hash code: {s.GetHashCode()}"); | |
var hashCode = RuntimeHelpers.GetHashCode(s); | |
Console.WriteLine($"Object hash code: {hashCode}"); | |
Console.WriteLine("Poking string..."); | |
fixed (char* cs = s) |
// gcc -fno-inline -std=gnu99 -Wall -O3 -g -march=native l1d.c -o l1d | |
#include <sys/types.h> | |
#include <stdint.h> | |
#include <string.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <x86intrin.h> | |
#include <math.h> |