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
#! /usr/bin/env python | |
# encoding: utf-8 | |
# Joshua Simmons 2010 | |
def configure(conf): | |
pass | |
def build(bld): | |
pong = bld( | |
features = 'c cprogram', |
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
pub fn load_in_place<'a, T>(bytes: &'a [u8]) -> &'a T { | |
assert!(!bytes.is_empty()); | |
assert!(validate::<T>(bytes)); | |
unsafe { &*bytes.as_ptr().cast() } | |
} | |
#[cfg(test)] |
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 <stdint.h> | |
#include <X11/Xlib.h> | |
#include <X11/XKBlib.h> | |
#include <GL/glx.h> | |
#include <GL/gl.h> | |
#include <dlfcn.h> | |
#include <stdio.h> | |
#include <sys/syscall.h> | |
#include <time.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
#include <pthread.h> | |
#include <stdio.h> | |
#define PRODUCER_COUNT 4 | |
#define CONSUMER_COUNT 4 | |
#define THREAD_COUNT (PRODUCER_COUNT + CONSUMER_COUNT) | |
#define WORK_ITERS 10000 | |
#define WORK_COUNT 10000 | |
#define QUEUE_SIZE 64 |
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
// Attempting to find the link_map for an executable without | |
// actually using the relocations / symtab / etc so we can elide | |
// all that stuff from our ELF file. (for an executable packer) | |
// With a .got entry it should be not so difficult to do, | |
// since GOT[0] is always the link_map. (depending on what | |
// actually triggers this entry to be written by ld-linux.so.1) | |
// This code scans the aux vector for the address of the program's |
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
use std::{ | |
marker::PhantomData, | |
ops::Deref, | |
ptr::NonNull, | |
sync::atomic::{AtomicI32, Ordering}, | |
}; | |
struct Inner<T: ?Sized> { | |
// Number of strong references in addition to the current value. | |
// A negative value indicates a non-atomic reference count, counting up from i32::MIN |
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
/// Flexible Reference Kounting | |
use std::{ | |
marker::PhantomData, | |
ops::Deref, | |
ptr::NonNull, | |
sync::atomic::{AtomicI32, Ordering}, | |
}; | |
struct Inner<T: ?Sized> { | |
// Number of strong references in addition to the current value. |
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
mod rc; | |
use rc::{BoxArc, BoxRc}; | |
struct Widget { | |
value: i32, | |
} | |
impl Widget { | |
fn new(value: i32) -> Self { |
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 <pthread.h> | |
#include <stdio.h> | |
#define PRODUCER_COUNT 1 | |
#define CONSUMER_COUNT 1 | |
#define THREAD_COUNT (PRODUCER_COUNT + CONSUMER_COUNT) | |
#define QUEUE_SIZE 64 | |
// Let's go the easy way and keep a gap between head and tail when full. |
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 "ring-buffer.h" | |
#include <stdlib.h> | |
#include <string.h> | |
#include <assert.h> | |
RingBuffer *rb_new(size_t size) | |
{ | |
RingBuffer *buf = malloc(sizeof(*buf)); | |
assert(buf != NULL); |
NewerOlder