Skip to content

Instantly share code, notes, and snippets.

David Zmick dpzmick

Block or report user

Report or block dpzmick

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View rs-cpp.org

Understanding Pin for C and C++ developers

My initial impression of Pin was that it said “hey there’s something sitting at this memory location. Feel free to use it, even though, in this context, the compiler can’t lexically prove that it is actually still there.” My understanding of Pin was roughly that it was a backdoor through the lifetime system.

Opening up the documentation, the page starts with a discussion about Unpin. Unpin is weird. Basically, Unpin says “yeah I know this

@dpzmick
dpzmick / rb_move_semantics.cpp
Created Nov 10, 2019
possibly incorrect ring buffer move semantics explanation
View rb_move_semantics.cpp
#include <array>
#include <iostream>
#include <stdexcept>
template <typename T, size_t N>
struct ring_buffer {
std::array<T, N+1> entries;
T* head = entries.data(); // pop from here
T* tail = head+1; // push to here, one past the end
@dpzmick
dpzmick / 0_test.c
Last active Oct 10, 2019
get wrecked clang
View 0_test.c
#include <stdlib.h>
int test() {
int *x = NULL;
int y = rand();
int z = rand();
int v = 4;
if (z == 8) x = &v;
View quadtree.c
#include <assert.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <x86intrin.h>
/*
@dpzmick
dpzmick / topsort.cpp
Last active Oct 6, 2017
fragile topological sort in c++ templates
View topsort.cpp
#include <cstddef>
#include <iostream>
#include <sstream>
#include <type_traits>
struct nil { };
template <typename H, class T>
struct cons
{
View views.cpp
#include <cstddef>
#include <iostream>
#include <type_traits>
struct nil { };
template <typename H, class T>
struct cons
{
using head = H;
View apply.cpp
#include <tuple>
#include <iostream>
class LoudCopy
{
public:
LoudCopy() { }
LoudCopy(const LoudCopy&) = delete;
LoudCopy(LoudCopy&&) {}
};
View test.cpp
#include "benchmark/benchmark.h"
#include <cstdlib>
#include <random>
#define LIMIT 5*1024*1024
enum class Variant { eA, eB };
struct Wrapper {
View rt_annotations.cpp
#include "typestring.hh"
#include <memory>
#include <thread>
#include <type_traits>
#include <iostream>
// by default nothing is realtime
template <typename T>
struct RTSaftey
View rt_annotations.cpp
#include "typestring.hh"
#include <memory>
#include <thread>
#include <type_traits>
#include <iostream>
// by default nothing is realtime
template <typename T>
struct RTSaftey
You can’t perform that action at this time.