used ircons_t.h now
[libfirm] / ir / ident / ident_t.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/common/ident_t.h
4  * Purpose:     Hash table to store names -- private header.
5  * Author:      Goetz Lindenmaier
6  * Modified by:
7  * Created:
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 1999-2003 Universität Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12
13 # ifndef _IDENT_T_H_
14 # define _IDENT_T_H_
15
16 # include "ident.h"
17 # include "set.h"
18
19 void id_init (int initial_n_idents);
20 void id_finish (void);
21
22 #define ID_HASH(str, len) \
23   (((  ((unsigned char *)(str))[0] * 33 \
24      + ((unsigned char *)(str))[(len)>>1]) * 31 \
25     + ((unsigned char *)(str))[(len)-1]) * 9 \
26    + (len))
27
28
29 /* ------------------------ *
30  * inline functions         *
31  * ------------------------ */
32 extern set *__id_set;
33
34 static INLINE ident *
35 __id_from_str(const char *str, int len)
36 {
37   assert(len > 0);
38   return set_hinsert0(__id_set, str, len, ID_HASH(str, len));
39 }
40
41 static INLINE const char * __get_id_str(ident *id) { return (const char *)id->dptr; }
42
43 static INLINE int __get_id_strlen(ident *id) { return id->size; }
44
45
46 #define id_from_str(str, len)    __id_from_str(str, len)
47 #define get_id_str(id)           __get_id_str(id)
48 #define get_id_strlen(id)        __get_id_strlen(id)
49
50 # endif /* _IDENT_T_H_ */