kconfig/expr.h
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Jul 13 10:32:38 2008 +0000 (2008-07-13)
changeset 645 8e58024f8e37
child 943 1cca90ce0481
permissions -rw-r--r--
Ioannis E. VENETIS <venetis@mail.capsl.udel.edu> pointed out that GMP and MPFR were not used by gcc.
Turned out that none could use GMP and MPFR as the config option changed its name, but the change was not propagated to all users.

/trunk/scripts/build/binutils.sh | 2 1 1 0 +-
/trunk/scripts/build/debug/300-gdb.sh | 2 1 1 0 +-
/trunk/scripts/build/cc_gcc.sh | 6 3 3 0 +++---
3 files changed, 5 insertions(+), 5 deletions(-)
yann@1
     1
/*
yann@1
     2
 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
yann@1
     3
 * Released under the terms of the GNU GPL v2.0.
yann@1
     4
 */
yann@1
     5
yann@1
     6
#ifndef EXPR_H
yann@1
     7
#define EXPR_H
yann@1
     8
yann@1
     9
#ifdef __cplusplus
yann@1
    10
extern "C" {
yann@1
    11
#endif
yann@1
    12
yann@1
    13
#include <stdio.h>
yann@1
    14
#ifndef __cplusplus
yann@1
    15
#include <stdbool.h>
yann@1
    16
#endif
yann@1
    17
yann@1
    18
struct file {
yann@1
    19
	struct file *next;
yann@1
    20
	struct file *parent;
yann@1
    21
	char *name;
yann@1
    22
	int lineno;
yann@1
    23
	int flags;
yann@1
    24
};
yann@1
    25
yann@1
    26
#define FILE_BUSY		0x0001
yann@1
    27
#define FILE_SCANNED		0x0002
yann@1
    28
#define FILE_PRINTED		0x0004
yann@1
    29
yann@1
    30
typedef enum tristate {
yann@1
    31
	no, mod, yes
yann@1
    32
} tristate;
yann@1
    33
yann@1
    34
enum expr_type {
yann@1
    35
	E_NONE, E_OR, E_AND, E_NOT, E_EQUAL, E_UNEQUAL, E_CHOICE, E_SYMBOL, E_RANGE
yann@1
    36
};
yann@1
    37
yann@1
    38
union expr_data {
yann@1
    39
	struct expr *expr;
yann@1
    40
	struct symbol *sym;
yann@1
    41
};
yann@1
    42
yann@1
    43
struct expr {
yann@1
    44
	enum expr_type type;
yann@1
    45
	union expr_data left, right;
yann@1
    46
};
yann@1
    47
yann@1
    48
#define E_OR(dep1, dep2)	(((dep1)>(dep2))?(dep1):(dep2))
yann@1
    49
#define E_AND(dep1, dep2)	(((dep1)<(dep2))?(dep1):(dep2))
yann@1
    50
#define E_NOT(dep)		(2-(dep))
yann@1
    51
yann@1
    52
struct expr_value {
yann@1
    53
	struct expr *expr;
yann@1
    54
	tristate tri;
yann@1
    55
};
yann@1
    56
yann@1
    57
struct symbol_value {
yann@1
    58
	void *val;
yann@1
    59
	tristate tri;
yann@1
    60
};
yann@1
    61
yann@1
    62
enum symbol_type {
yann@1
    63
	S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_OTHER
yann@1
    64
};
yann@1
    65
yann@1
    66
enum {
yann@1
    67
	S_DEF_USER,		/* main user value */
yann@1
    68
	S_DEF_AUTO,
yann@1
    69
};
yann@1
    70
yann@1
    71
struct symbol {
yann@1
    72
	struct symbol *next;
yann@1
    73
	char *name;
yann@1
    74
	char *help;
yann@1
    75
	enum symbol_type type;
yann@1
    76
	struct symbol_value curr;
yann@1
    77
	struct symbol_value def[4];
yann@1
    78
	tristate visible;
yann@1
    79
	int flags;
yann@1
    80
	struct property *prop;
yann@1
    81
	struct expr *dep, *dep2;
yann@1
    82
	struct expr_value rev_dep;
yann@1
    83
};
yann@1
    84
yann@1
    85
#define for_all_symbols(i, sym) for (i = 0; i < 257; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER)
yann@1
    86
yann@1
    87
#define SYMBOL_CONST		0x0001
yann@1
    88
#define SYMBOL_CHECK		0x0008
yann@1
    89
#define SYMBOL_CHOICE		0x0010
yann@1
    90
#define SYMBOL_CHOICEVAL	0x0020
yann@1
    91
#define SYMBOL_PRINTED		0x0040
yann@1
    92
#define SYMBOL_VALID		0x0080
yann@1
    93
#define SYMBOL_OPTIONAL		0x0100
yann@1
    94
#define SYMBOL_WRITE		0x0200
yann@1
    95
#define SYMBOL_CHANGED		0x0400
yann@1
    96
#define SYMBOL_AUTO		0x1000
yann@1
    97
#define SYMBOL_CHECKED		0x2000
yann@1
    98
#define SYMBOL_WARNED		0x8000
yann@1
    99
#define SYMBOL_DEF		0x10000
yann@1
   100
#define SYMBOL_DEF_USER		0x10000
yann@1
   101
#define SYMBOL_DEF_AUTO		0x20000
yann@1
   102
#define SYMBOL_DEF3		0x40000
yann@1
   103
#define SYMBOL_DEF4		0x80000
yann@1
   104
yann@1
   105
#define SYMBOL_MAXLENGTH	256
yann@1
   106
#define SYMBOL_HASHSIZE		257
yann@1
   107
#define SYMBOL_HASHMASK		0xff
yann@1
   108
yann@1
   109
enum prop_type {
yann@1
   110
	P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_DEFAULT, P_CHOICE, P_SELECT, P_RANGE
yann@1
   111
};
yann@1
   112
yann@1
   113
struct property {
yann@1
   114
	struct property *next;
yann@1
   115
	struct symbol *sym;
yann@1
   116
	enum prop_type type;
yann@1
   117
	const char *text;
yann@1
   118
	struct expr_value visible;
yann@1
   119
	struct expr *expr;
yann@1
   120
	struct menu *menu;
yann@1
   121
	struct file *file;
yann@1
   122
	int lineno;
yann@1
   123
};
yann@1
   124
yann@1
   125
#define for_all_properties(sym, st, tok) \
yann@1
   126
	for (st = sym->prop; st; st = st->next) \
yann@1
   127
		if (st->type == (tok))
yann@1
   128
#define for_all_defaults(sym, st) for_all_properties(sym, st, P_DEFAULT)
yann@1
   129
#define for_all_choices(sym, st) for_all_properties(sym, st, P_CHOICE)
yann@1
   130
#define for_all_prompts(sym, st) \
yann@1
   131
	for (st = sym->prop; st; st = st->next) \
yann@1
   132
		if (st->text)
yann@1
   133
yann@1
   134
struct menu {
yann@1
   135
	struct menu *next;
yann@1
   136
	struct menu *parent;
yann@1
   137
	struct menu *list;
yann@1
   138
	struct symbol *sym;
yann@1
   139
	struct property *prompt;
yann@1
   140
	struct expr *dep;
yann@1
   141
	unsigned int flags;
yann@1
   142
	//char *help;
yann@1
   143
	struct file *file;
yann@1
   144
	int lineno;
yann@1
   145
	void *data;
yann@1
   146
};
yann@1
   147
yann@1
   148
#define MENU_CHANGED		0x0001
yann@1
   149
#define MENU_ROOT		0x0002
yann@1
   150
yann@1
   151
#ifndef SWIG
yann@1
   152
yann@1
   153
extern struct file *file_list;
yann@1
   154
extern struct file *current_file;
yann@1
   155
struct file *lookup_file(const char *name);
yann@1
   156
yann@1
   157
extern struct symbol symbol_yes, symbol_no, symbol_mod;
yann@1
   158
extern struct symbol *modules_sym;
yann@1
   159
extern struct symbol *sym_defconfig_list;
yann@1
   160
extern int cdebug;
yann@1
   161
struct expr *expr_alloc_symbol(struct symbol *sym);
yann@1
   162
struct expr *expr_alloc_one(enum expr_type type, struct expr *ce);
yann@1
   163
struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2);
yann@1
   164
struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2);
yann@1
   165
struct expr *expr_alloc_and(struct expr *e1, struct expr *e2);
yann@1
   166
struct expr *expr_alloc_or(struct expr *e1, struct expr *e2);
yann@1
   167
struct expr *expr_copy(struct expr *org);
yann@1
   168
void expr_free(struct expr *e);
yann@1
   169
int expr_eq(struct expr *e1, struct expr *e2);
yann@1
   170
void expr_eliminate_eq(struct expr **ep1, struct expr **ep2);
yann@1
   171
tristate expr_calc_value(struct expr *e);
yann@1
   172
struct expr *expr_eliminate_yn(struct expr *e);
yann@1
   173
struct expr *expr_trans_bool(struct expr *e);
yann@1
   174
struct expr *expr_eliminate_dups(struct expr *e);
yann@1
   175
struct expr *expr_transform(struct expr *e);
yann@1
   176
int expr_contains_symbol(struct expr *dep, struct symbol *sym);
yann@1
   177
bool expr_depends_symbol(struct expr *dep, struct symbol *sym);
yann@1
   178
struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2);
yann@1
   179
struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2);
yann@1
   180
void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2);
yann@1
   181
struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym);
yann@1
   182
yann@1
   183
void expr_fprint(struct expr *e, FILE *out);
yann@1
   184
struct gstr; /* forward */
yann@1
   185
void expr_gstr_print(struct expr *e, struct gstr *gs);
yann@1
   186
yann@1
   187
static inline int expr_is_yes(struct expr *e)
yann@1
   188
{
yann@1
   189
	return !e || (e->type == E_SYMBOL && e->left.sym == &symbol_yes);
yann@1
   190
}
yann@1
   191
yann@1
   192
static inline int expr_is_no(struct expr *e)
yann@1
   193
{
yann@1
   194
	return e && (e->type == E_SYMBOL && e->left.sym == &symbol_no);
yann@1
   195
}
yann@1
   196
#endif
yann@1
   197
yann@1
   198
#ifdef __cplusplus
yann@1
   199
}
yann@1
   200
#endif
yann@1
   201
yann@1
   202
#endif /* EXPR_H */