This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Unigine C++ School 2 | |
// Homework 1 | |
// | |
// by griff | |
// | |
#include <fstream> | |
#include <iostream> | |
#include <iterator> | |
#include <sstream> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum EventTest { | |
// + brain dead simple | |
// - need to manually unsubscribe | |
class Event<Args> { | |
typealias CallbackType = (Args) -> Void | |
private var id: UInt64 = 0 | |
private var callbacks = [UInt64: CallbackType]() | |
func subscribe(_ callback: @escaping CallbackType) -> UInt64 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Reverse char string in place | |
// | |
// Build: | |
// clang -O2 -DTEST -mavx2 -Wall -Wpedantic -Wextra str_reverse.c -o str_reverse | |
// or | |
// clang -O2 -DTEST -mssse3 -Wall -Wpedantic -Wextra str_reverse.c -o str_reverse | |
// | |
#include <stdint.h> // uint64_t uint32_t | |
#include <stdlib.h> // abort() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/sysctl.h> // sysctlbyname | |
i64 cache_line_size() { | |
i64 ret = 0; | |
u64 size = sizeof ret; | |
if (sysctlbyname("hw.cachelinesize", &ret, &size, NULL, 0) == -1) { | |
return -1; | |
} | |
return ret; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef __aarch64__ | |
#error Arches other than arm64 are not supported | |
#endif // #ifndef __aarch64__ | |
#define FORCE_INLINE inline __attribute__((always_inline)) | |
typedef unsigned long u64; | |
static FORCE_INLINE u64 rdtsc(void) { | |
u64 val; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// disable optimisations | |
#ifdef _MSC_VER | |
#pragma optimize("", off) | |
inline void bench_opt_off(const void*) {} | |
#pragma optimize("", on) | |
#define ESCAPE(p) bench_opt_off(p) | |
#define CLOBBER(p) bench_opt_off(p) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef __aarch64__ | |
#error Architectures other than arm64 are not supported | |
#endif // #ifndef __aarch64__ | |
#include <arm_neon.h> | |
#include <stdio.h> // printf | |
typedef int i32; | |
typedef unsigned int u32; | |
typedef long i64; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define ISB(option) __asm__ volatile ("isb " #option : : : "memory") | |
#define DSB(option) __asm__ volatile ("dsb " #option : : : "memory") | |
#define DMB(option) __asm__ volatile ("dmb " #option : : : "memory") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Chrome: disable swipe navigation | |
defaults write com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool false | |
# Finder: show full path in the title | |
defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES | |
# Xcode: show build times | |
defaults write com.apple.dt.Xcode ShowBuildOperationDuration YES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// string view | |
struct sv { | |
const char *begin; | |
const char *end; | |
}; | |
const char *s_dot = "."; | |
// Custom basename returning string view | |
struct sv basename(const char *path) { |
OlderNewer