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
local concat, coroutine, insert, loadstring, open, pcall, setfenv, setmetatable = | |
table.concat, coroutine, table.insert, loadstring, io.open, pcall, setfenv, setmetatable | |
module 'spin.template' | |
function parse_file(path, env) | |
local file, err = open(path, 'r') | |
if not file then return nil, err end | |
local source = file:read('*a') |
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
local function print_table(tab, level, done) | |
level = level or 1 | |
done = done or {} | |
assert(type(tab) == 'table') | |
for k, v in pairs(tab) do | |
if done[v] then | |
print(('\t'):rep(level) .. ('\t'):rep(level) .. '[' .. tostring(k) .. '] already printed!') | |
else | |
local t = type(v) | |
if t == 'table' then |
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); |
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
local parser = require 'parser' | |
-- | |
-- Generation options. | |
-- | |
local SPEC_PATH = './specs/' | |
local TM_PATH = SPEC_PATH .. 'gl.tm' | |
local ENUM_PATH = 'enum.spec' | |
local ENUMEXT_PATH = SPEC_PATH .. 'enumext.spec' |
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
local ffi = require 'ffi' | |
ffi.cdef [[ | |
enum SDL_INIT_FLAGS { | |
SDL_INIT_TIMER = 0x00000001, | |
SDL_INIT_AUDIO = 0x00000010, | |
SDL_INIT_VIDEO = 0x00000020, | |
SDL_INIT_JOYSTICK = 0x00000200, | |
SDL_INIT_HAPTIC = 0x00001000, | |
SDL_INIT_NOPARACHUTE = 0x00100000, |
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 SGL_EVENT_H | |
#define SGL_EVENT_H | |
#include <stdint.h> | |
#include "button.h" | |
struct _SWindow; | |
typedef enum |
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
local ffi = require 'ffi' | |
local sgl = require 'sgl' | |
local gl = require 'opengl' | |
local shader = require 'shader' | |
local C = ffi.C; | |
local window = sgl.window { | |
screen_width = 1440; |
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 "sg_tpool.h" | |
#include <pthread.h> | |
#include <semaphore.h> | |
#include <stdbool.h> | |
#include <stdlib.h> | |
typedef struct | |
{ | |
STaskID id; |
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 <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 |