Skip to content

Instantly share code, notes, and snippets.

#ifndef CARRAYMACROS_H
#define CARRAYMACROS_H 1
#include <inttypes.h>
#include <stdio.h>
#define ARRAY_SIZE(array) array ## _num
#define ARRAY_MAX(array) array ## _max
#define ARRAY_CDECL(array, type) \
# This is a comment
# Plain constant:
Dummystring = "foobar"
# Parameters to be injected from outside (CLI or another processor) and their respective types:
Parameters {
target_file: string,
integration_time: uint32
}
ins NOP()
{
/* Empty */
}
ins END()
{
goto end_eval;
}
<?php
public function getService($service)
{
if(isset($this->_instances[$service]))
{
return $this->_instances[$service];
}
if( ! isset($this->_loaders[$service]))
<?php
namespace React\EventLoop;
use libev\EventLoop;
use libev\IOEvent;
class LibevLoop
{
protected $loop = null;
<?php
/**
* Creates a HTTP response to be sent as the response.
*
* @param resource The socket connection stream
* @param array array(response_code, array(header_title => header_content), content)
* @return string
*/
protected function httpResponse($conn, array $response)
{
@m4rw3r
m4rw3r / gist:2775309
Created May 23, 2012 13:45
InjectStack middleware for ChunkedEncoding
<?php
/*
* Created by Martin Wernståhl on 2011-04-25.
* Copyright (c) 2011 Martin Wernståhl.
* All rights reserved.
*/
namespace Inject\Stack\Middleware;
use \Inject\Stack\MiddlewareInterface;
/* Function to calcuate the n first fibonacci numbers */
Frame *fib_frame = malloc(sizeof(Frame));
Frame_init(fib_frame);
uint32_t prevfr = Frame_allocVariable(fib_frame);
/* No continuations called here, so we can get away with not allocating space for return values */
uint32_t varsum = Frame_allocVariable(fib_frame);
uint32_t varn = Frame_allocVariable(fib_frame);
uint32_t vara = Frame_allocVariable(fib_frame);
uint32_t varb = Frame_allocVariable(fib_frame);
@m4rw3r
m4rw3r / gist:3070816
Created July 8, 2012 12:53
Test interpreter with function-pointers
#include <inttypes.h>
#include <stdio.h>
#define Util_StaticAssert_CONCAT_(a, b) a##b
#define Util_StaticAssert_CONCAT(a, b) Util_StaticAssert_CONCAT_(a, b)
#define Util_StaticAssert(e, msg) \
enum { Util_StaticAssert_CONCAT(assert_line_, __LINE__) = 1/(!!(e)) }
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include <assert.h>
#include <sys/mman.h>
typedef uint8_t Register;
#define Register_lowBits(r) (r & 0x7)