This file contains hidden or 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 hidden or 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 hidden or 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
/* cube_vbo.c - demo of drawing a cube in GL using VBOs. | |
* | |
* PUBLIC DOMAIN - Jon Mayo - April 24, 2015 | |
* | |
* Requires SDL2 | |
* | |
* To build: | |
* gcc -Wall -W -o cube_vbo cube_vbo.c `pkg-config --libs --cflags sdl2 gl` | |
* | |
*/ |
This file contains hidden or 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
Program = _ (DeclareVar | Function { printf("good\n"); } | |
| . { printf("bad\n"); exit(1); } | |
)* | |
| !. { printf("done\n"); exit(0); } | |
DeclareVar = type VarInit ( "," _ VarInit )* ";" _ | |
VarInit = identifier ( "=" _ Expression )? | |
Function = t:type i:identifier "(" _ Parameters? ")" _ Compound { | |
printf("Function:\n"); | |
value_print(t); |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
/* This software is public domain. No copyright is claimed. | |
* Jon Mayo April 2011 | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
/* Load an .ini format file | |
* filename - path to a file | |
* report - callback can return non-zero to stop, the callback error code is |
This file contains hidden or 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; |