HAMMER 60I/Many: Mirroring
[dragonfly.git] / lib / libsys / genhooks / defs.h
blob5d1e738e25db995048f6675fa28c307cf7113bd7
1 /*
2 * DEFS.H
4 * $DragonFly: src/lib/libsys/genhooks/defs.h,v 1.2 2005/12/05 16:48:22 dillon Exp $
5 */
7 #include <sys/types.h>
8 #include <sys/stat.h>
9 #include <sys/mman.h>
10 #include <assert.h>
11 #include <stdarg.h>
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <string.h>
15 #include <unistd.h>
16 #include <fcntl.h>
17 #include <err.h>
19 #define TOK_SEMI ';'
20 #define TOK_COMMA ','
21 #define TOK_OBRACE '{'
22 #define TOK_CBRACE '}'
23 #define TOK_OPAREN '('
24 #define TOK_CPAREN ')'
25 #define TOK_EOF 0x00000100
26 #define TOK_UNKNOWN 0x00000101
27 #define TOK_INTEGER 0x00000102
28 #define TOK_BASE 0x00000103
29 #define TOK_SYMBOL 0x04000000
31 #define TOK_ADD (TOK_SYMBOL|0x00000001)
32 #define TOK_FUNCTION (TOK_SYMBOL|0x00000002)
33 #define TOK_IMPLEMENTATION (TOK_SYMBOL|0x00000003)
34 #define TOK_DIRECT (TOK_SYMBOL|0x00000004)
35 #define TOK_SIMULATED (TOK_SYMBOL|0x00000005)
37 typedef struct lex_token {
38 struct lex_info *info;
39 int type;
40 int index;
41 int len;
42 const char *sym;
43 int value;
44 } lex_token;
46 typedef struct lex_info {
47 char *path;
48 int fd;
49 const char *base;
50 int size;
51 int cache_line; /* cached line number for index */
52 int cache_index; /* index to base of cached line */
53 int cache_len; /* size of cached line, including newline */
54 } lex_info;
56 typedef struct sys_type {
57 char *type_name;
58 char *var_name;
59 } sys_type;
61 typedef struct sys_info {
62 struct sys_type *func_ret;
63 struct sys_type **func_args;
64 int nargs; /* 0 if takes void */
65 int sysno; /* syscall number */
66 } sys_info;
68 extern struct sys_info **sys_array;
69 extern int sys_count;
70 extern char *sys_sectname;
72 void *zalloc(int bytes);
74 void lex_open(const char *path, lex_token *tok);
75 void lex_close(lex_token *tok);
76 int lex_gettoken(lex_token *tok);
77 int lex_skip_token(lex_token *tok, int type);
78 void lex_error(lex_token *tok, const char *ctl, ...);
79 const char *lex_string_quick(lex_token *tok);
80 char *lex_string(lex_token *tok);
82 void parse_file(const char *path);
84 void output_user(FILE *fo);
85 void output_lib(FILE *fo);
86 void output_standalone(FILE *fo, const char *list_prefix);