cbd4ee9f6504224d4a2b65dacfec4033152f5bc7
[alexxy/gromacs.git] / include / metacode.h
1 #ifndef _metacode_h
2 #define _metacode_h
3
4 #ifdef HAVE_CONFIG_H
5 #include <config.h>
6 #endif
7
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <stdarg.h>
11 #include <types/simple.h>
12
13 static char *SRCID_metacode_h = "";
14
15 #ifndef FALSE
16 #define FALSE 0
17 #endif
18 #ifndef TRUE
19 #define TRUE  1
20 #endif
21
22 #define FCON "     &" /* continuation line in f77 */
23 #define max(a,b) (((a) > (b)) ? (a) : (b))
24
25
26 /* Array referencing shortcut */
27 #define ARRAY(a,idx)          _array(#a,#idx)
28
29 typedef struct {
30   char typename[150];
31   char name[150];
32   bool breferenced;
33   bool bvector;
34   bool bconst;
35   char constval[50];
36 } decl_t;         /* Argument and variable buffer element */
37
38 extern int prec;  /* precision (4=single, 8=double) */
39 extern int IND;   /* current indentation */
40 extern char *codebuffer; /* buffer to which code is written */
41 extern char header[10000]; /* buffer for info and loop name */
42 extern FILE *output;  /* output file */
43 extern decl_t *decl_list; /* list with args and vars */
44 extern int ndecl; /* length of above list */
45 extern int nargs; /* first nargs are arguments, rest is vars */
46
47 extern bool bC;   
48
49 /* Concatenate a string to a buffer with plus sign between terms. */
50 void add_to_buffer(char *buffer,char *term);
51   
52 /* initiate output buffers */
53 void init_metacode(void);
54
55 /* write a function to file and empty buffers */
56 void flush_buffers(void);
57
58 /* Return the correct indentation as a string */
59 char *indent(void);
60
61 /* Print a line of code to the output file */
62 void code(char *fmt, ...);
63
64 void newline(void);
65
66 /* Add a comment */
67 void comment(char *s);
68
69 /* Define a new floating-point variable */
70 void declare_real(char *name);
71 void declare_real_vector(char *name);
72
73 void declare_const_real(char *name,double val);
74 void declare_const_int(char *name,int val);
75
76 void declare_int(char *name);
77 void declare_int_vector(char *name);
78 void declare_real4(char *name);
79 void declare_int4(char *name);
80 void declare_int8(char *name);
81 void declare_intreal(char *name);
82 void declare_other(char *typename,char *name);
83
84 /* Cray vector pragma */
85 void vector_pragma(void);
86
87
88 char *_array(char *a,char *idx, ...);
89
90 void _p_state(char *left,char *right,char *symb);
91
92 void file_error(char *fn);
93
94 void assign(char *left, char *right, ...);
95
96 void increment(char *left,char *right, ...);
97
98 void decrement(char *left,char *right, ...);
99
100 void add(char *left,char *r1,char *r2, ...);
101
102 void subtract(char *left,char *r1,char *r2, ...);
103
104 void multiply(char *left,char *r1,char *r2, ...);
105
106 void closeit(void);
107
108 void usage(int argc,char *argv[]);
109
110 int count_lines(char *fn);
111
112 void edit_warning(char *fn);
113
114 void start_loop(char *lvar,char *from,char *to);
115
116 void start_stride_loop(char *lvar,char *from,char *to, char *stride);
117
118 void end_loop(void);
119
120 void start_if(char *cond);
121 void do_else(void);
122 void end_if(void);
123
124 void close_func(void);
125
126 #endif
127