-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding consts helper files back into repository.
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
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
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 | ||
*/ |
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
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 |