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
/* showif.c : PUBLIC DOMAIN - Jon Mayo - August 22, 2006 | |
* - You may remove any comments you wish, modify this code any way you wish, | |
* and distribute any way you wish.*/ | |
/* finds all network interfaces and shows a little information about them. | |
* some operating systems list interfaces multiple times because of different | |
* flags, modes, etc. if you want to use this code you should be aware that | |
* duplicate interfaces is a possibility */ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.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
/* 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
/* 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 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
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 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` | |
* | |
*/ |
OlderNewer