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
Quick Reference for SDL2 | |
======================== | |
Includes both prototypes and short examples of using the call. | |
int SDL_Init(Uint32 flags) | |
SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO); | |
void SDL_Quit(void) | |
atexit(SDL_Quit); | |
const char* SDL_GetHint(const char* name) |
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
/* Montgomery's Ladder Technique | |
* http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.5.4956&rep=rep1&type=pdf | |
*/ | |
#include <stdio.h> | |
#include <limits.h> | |
static unsigned long long ipow(unsigned g, unsigned k) | |
{ | |
unsigned long long r0, r1; | |
unsigned j; |
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 _XOPEN_SOURCE 700 | |
#include <sys/select.h> | |
static void copyfdset(fd_set *d, fd_set *s, unsigned fd_max) { | |
unsigned i; | |
unsigned n = (fd_max + 1 + __NFDBITS - 1) / __NFDBITS; | |
for(i = 0; i < n; i++) { | |
d->fds_bits[i] = s->fds_bits[i]; | |
} | |
} |
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
/* a complicated set of macros to support empty __VA_ARGS__ macros. | |
* example: | |
* pr_dbg("Check\n"); | |
* pr_dbg("Check %d\n", 12); | |
* pr_dbg("Check %d %s %d\n", 42, "Hello", 99); | |
* | |
* pr_info() and pr_err() macros don't use __func__ and __LINE__ | |
*/ | |
#ifndef DEBUG_H | |
#define DEBUG_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
/* otadd0.c : add without using +,++ or -,-- */ | |
/* clean: | |
int add(int a, int b) | |
{ | |
int r,n,c; | |
for(r=c=0,n=1;n;n<<=1) { | |
c = (a & b) ^ (c & (a ^ b)); | |
c <<= 1; | |
r |= (a ^ b ^ c) & n; | |
} |
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
/* bench.c : XOR pattern without any display/output to get a baseline benchmark */ | |
#include <stdio.h> | |
#include <stdint.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <sys/time.h> | |
#define BGRX8888(r, g, b) \ | |
((uint32_t)((unsigned char)(b)) << 24 | \ | |
(uint32_t)((unsigned char)(g)) << 16 | \ |
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
/* base.c : command-line utility to convert numbers to different formats. | |
* March 10, 2016 - PUBLIC DOMAIN */ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <errno.h> | |
#include <string.h> | |
#include <limits.h> | |
int main(int argc, char **argv) | |
{ |
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
/* vm.h - virtual machine */ | |
#ifndef VM_H | |
#define VM_H | |
/* Goals: | |
* - no allocations in library | |
* - multithread safe | |
* - easy opcode extensions | |
* - single file | |
*/ | |
#include <stddef.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
/* bitfield.h - bitfield macros */ | |
/* | |
* PUBLIC DOMAIN - NO COPYRIGHT CLAIMED - Jonathan Mayo - July 2005 | |
* | |
* Updated January 2010 | |
*/ | |
#ifndef BITFIELD_H | |
#define BITFIELD_H | |
#include <limits.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
#define _XOPEN_SOURCE 700 | |
#define _POSIX_C_SOURCE 200809L | |
#include <stdio.h> | |
#include <unistd.h> | |
int main() { | |
int s, fd[2]; | |
pipe(fd); | |
if (!fork()) { /* child */ | |
dup2(fd[0], STDIN_FILENO); |
OlderNewer