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 _GNU_SOURCE | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <sys/mman.h> | |
#include <unistd.h> | |
#include <fcntl.h> | |
#include <signal.h> | |
#include <ucontext.h> |
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
struct real_gc_base { | |
virtual ~real_gc_base() {} | |
}; | |
struct gc : virtual real_gc_base { | |
}; | |
struct b1 : gc { | |
}; |
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
//http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0009r4.html | |
#include <utility> | |
#include <array> | |
#include <algorithm> | |
#include <functional> | |
#include <type_traits> | |
#include <memory> | |
#include <exception> |
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
__pragma(optimize("", off)) | |
__pragma(runtime_checks("", off)) | |
__pragma(check_stack(off)) | |
__pragma(strict_gs_check(push, off)) | |
// anonymous namespace to ensure that the function names are not exported, | |
// and hence that I can take their address without suffering indirections | |
namespace { | |
__pragma(code_seg(push, "thunks")) |
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 <variant> | |
#include <string_view> | |
#include <vector> | |
#include <unordered_map> | |
#include <utility> | |
namespace json { | |
struct Value; | |
using Null = std::nullptr_t; | |
using Bool = bool; |
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
Intel(R) Core(TM) i7-7900X CPU @ 3.30GHz | |
Maximum frequency: 3301 MHz (as reported to/by Windows, which seems in fact to be the base frequency at P0) | |
rdtsc ticks at 3311999074 ticks per second | |
measurement overhead in ticks: 11 | |
\ core-to-core ping time/ns | |
\ destination | |
source \ 0| 1| 2| 3| 4| 5| 6| 7| 8| 9| 10| 11| 12| 13| 14| 15| 16| 17| 18| 19| | |
__________\_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____| | |
0 | -| 16| 91| 91| 98| 99| 98| 96| 84| 87| 104| 93| 96| 97| 91| 97| 97| 90| 82| 81| | |
1 | 20| -| 93| 93| 100| 100| 99| 97| 87| 89| 106| 94| 98| 98| 92| 99| 98| 92| 84| 83| |
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
template<typename T> // fuck anyone who writes 'class T' | |
struct alignas(T) speculative_buffer { | |
static_assert(std::is_default_constructible_v<T>, "T must be DefaultConstructible"); | |
static_assert(std::is_trivially_copyable_v<T>, "T must be TriviallyCopyable"); | |
speculative_buffer(T* src) { | |
unsafe_read(src); | |
} | |
void unsafe_read(T* src) { // nb: can read from any pointer, does not need to be atomic etc. |
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
#pragma once | |
// Copyright(c) 2017 Peter Bright | |
// | |
// This software is provided 'as-is', without any express or implied | |
// warranty. In no event will the authors be held liable for any damages | |
// arising from the use of this software. | |
// | |
// Permission is granted to anyone to use this software for any purpose, | |
// including commercial applications, and to alter it and redistribute it |
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 <SDKDDKVer.h> | |
#pragma warning(disable: 4710) // warning C4710: '%s': function not inlined | |
#pragma warning(disable: 4668) // warning C4668: '%s' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif' | |
#pragma warning(disable: 4820) // warning C4820: '%s': '%d' bytes padding added after data member '%s' | |
#define STRICT | |
#define NOMINMAX | |
#include <Windows.h> |
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
// positive rotations go left, negative go right | |
void rotate(int arr[], const ptrdiff_t len, const ptrdiff_t m) { | |
if(0 == m || m >= len) { | |
return; | |
} | |
ptrdiff_t dst = 0; | |
ptrdiff_t first_in_cycle = 0; | |
int tmp = arr[first_in_cycle]; | |
for(ptrdiff_t i = 0; i < len; ++i) { |
NewerOlder