Skip to content

Commit

Permalink
Adding consts helper files back into repository.
Browse files Browse the repository at this point in the history
  • Loading branch information
niemeyer committed Apr 18, 2012
1 parent f168d56 commit 080c6b2
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
53 changes: 53 additions & 0 deletions consts.c.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include <sys/mman.h>
#include <stdio.h>

#define pcomment(COMMENT) printf("// %s\n", COMMENT)
#define ppackage(NAME) printf("package %s\n", NAME)
#define ptype(NAME, TYPE) printf("\ntype %s %s\n", #NAME, #TYPE)
#define pconstblock(EXPS) { printf("\nconst (\n"); {EXPS} printf(")\n"); }
#define pconst(NAME, TYPE) printf("\t%-15s %s = 0x%x\n", #NAME, #TYPE, NAME)

int main(int argc, char *argvc[]) {
pcomment("** This file is automatically generated from consts.c.txt **\n");
ppackage("gommap");
ptype(ProtFlags, uint);
pconstblock(
pconst(PROT_NONE, ProtFlags);
pconst(PROT_READ, ProtFlags);
pconst(PROT_WRITE, ProtFlags);
pconst(PROT_EXEC, ProtFlags);
)
ptype(MapFlags, uint);
pconstblock(
pconst(MAP_SHARED, MapFlags);
pconst(MAP_PRIVATE, MapFlags);
pconst(MAP_FIXED, MapFlags);
pconst(MAP_ANONYMOUS, MapFlags);
pconst(MAP_GROWSDOWN, MapFlags);
pconst(MAP_LOCKED, MapFlags);
pconst(MAP_NONBLOCK, MapFlags);
pconst(MAP_NORESERVE, MapFlags);
pconst(MAP_POPULATE, MapFlags);
)
ptype(SyncFlags, uint);
pconstblock(
pconst(MS_SYNC, SyncFlags);
pconst(MS_ASYNC, SyncFlags);
pconst(MS_INVALIDATE, SyncFlags);
)
ptype(AdviseFlags, uint);
pconstblock(
pconst(MADV_NORMAL, AdviseFlags);
pconst(MADV_RANDOM, AdviseFlags);
pconst(MADV_SEQUENTIAL, AdviseFlags);
pconst(MADV_WILLNEED, AdviseFlags);
pconst(MADV_DONTNEED, AdviseFlags);
pconst(MADV_REMOVE, AdviseFlags);
pconst(MADV_DONTFORK, AdviseFlags);
pconst(MADV_DOFORK, AdviseFlags);
)
return 0;
}

/* vim:ft=c
*/
4 changes: 4 additions & 0 deletions consts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
gcc -xc -Wall -pedantic consts.c.txt -o _consts.out
./_consts.out > consts.go
rm ./_consts.out

0 comments on commit 080c6b2

Please sign in to comment.