git-svn-id: http://svn.openzap.org/svn/openzap/trunk@15 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
Anthony Minessale committed 2007-05-17 16:57:26 +00:00
1 parent 719bc15057
commit de432ce258
10 files changed
+145 -50

No files matched your search

+8 -3
View File
@@ -2,6 +2,11 @@
#ifndef __HASHTABLE_CWC22_H__
#define __HASHTABLE_CWC22_H__
#ifdef _MSC_VER
#ifndef __inline__
#define __inline__ __inline
#endif
#endif
struct hashtable;
@@ -73,8 +78,8 @@ struct hashtable;
struct hashtable *
create_hashtable(unsigned int minsize,
unsigned int (*hashfunction) (const void*),
int (*key_eq_fn) (const void*,const void*));
unsigned int (*hashfunction) (void*),
int (*key_eq_fn) (void*,void*));
/*****************************************************************************
* hashtable_insert
@@ -114,7 +119,7 @@ int fnname (struct hashtable *h, keytype *k, valuetype *v) \
*/
void *
hashtable_search(struct hashtable *h, const void *k);
hashtable_search(struct hashtable *h, void *k);
#define DEFINE_HASHTABLE_SEARCH(fnname, keytype, valuetype) \
valuetype * fnname (struct hashtable *h, keytype *k) \
+10 -2
View File
@@ -28,12 +28,20 @@ hashtable_iterator(struct hashtable *h);
/* hashtable_iterator_key
* - return the value of the (key,value) pair at the current position */
#define hashtable_iterator_key(i) (void *)i->e->k
extern __inline__ void *
hashtable_iterator_key(struct hashtable_itr *i)
{
return i->e->k;
}
/*****************************************************************************/
/* value - return the value of the (key,value) pair at the current position */
#define hashtable_iterator_value (void *)i->e->v
extern __inline__ void *
hashtable_iterator_value(struct hashtable_itr *i)
{
return i->e->v;
}
/*****************************************************************************/
/* advance - advance the iterator to the next element
+8 -4
View File
@@ -5,6 +5,7 @@
#include "hashtable.h"
/*****************************************************************************/
struct entry
{
@@ -19,17 +20,20 @@ struct hashtable {
unsigned int entrycount;
unsigned int loadlimit;
unsigned int primeindex;
unsigned int (*hashfn) (const void *k);
int (*eqfn) (const void *k1, const void *k2);
unsigned int (*hashfn) (void *k);
int (*eqfn) (void *k1, void *k2);
};
/*****************************************************************************/
unsigned int
hash(struct hashtable *h, const void *k);
hash(struct hashtable *h, void *k);
/*****************************************************************************/
/* indexFor */
#define indexFor(hashvalue, tablelength) (unsigned int)(hashvalue % tablelength)
static __inline__ unsigned int
indexFor(unsigned int tablelength, unsigned int hashvalue) {
return (hashvalue % tablelength);
}
/* Only works if tablelength == 2^N */
/*static inline unsigned int
+20 -11
View File
@@ -209,18 +209,27 @@ typedef zap_status_t (*zint_write_t) ZINT_WRITE_ARGS ;
#define ZINT_WRITE_MUZZLE assert(zchan != NULL); assert(data != NULL); assert(datalen != NULL)
#define ZAP_PRE __FILE__, __FUNCTION__, __LINE__
#define ZAP_LOG_DEBUG ZAP_PRE, 7
#define ZAP_LOG_INFO ZAP_PRE, 6
#define ZAP_LOG_NOTICE ZAP_PRE, 5
#define ZAP_LOG_WARNING ZAP_PRE, 4
#define ZAP_LOG_ERROR ZAP_PRE, 3
#define ZAP_LOG_CRIT ZAP_PRE, 2
#define ZAP_LOG_ALERT ZAP_PRE, 1
#define ZAP_LOG_EMERG ZAP_PRE, 0
#define ZAP_LOG_LEVEL_DEBUG 7
#define ZAP_LOG_LEVEL_INFO 6
#define ZAP_LOG_LEVEL_NOTICE 5
#define ZAP_LOG_LEVEL_WARNING 4
#define ZAP_LOG_LEVEL_ERROR 3
#define ZAP_LOG_LEVEL_CRIT 2
#define ZAP_LOG_LEVEL_ALERT 1
#define ZAP_LOG_LEVEL_EMERG 0
#define ZAP_LOG_DEBUG ZAP_PRE, ZAP_LOG_LEVEL_DEBUG
#define ZAP_LOG_INFO ZAP_PRE, ZAP_LOG_LEVEL_INFO
#define ZAP_LOG_NOTICE ZAP_PRE, ZAP_LOG_LEVEL_NOTICE
#define ZAP_LOG_WARNING ZAP_PRE, ZAP_LOG_LEVEL_WARNING
#define ZAP_LOG_ERROR ZAP_PRE, ZAP_LOG_LEVEL_ERROR
#define ZAP_LOG_CRIT ZAP_PRE, ZAP_LOG_LEVEL_CRIT
#define ZAP_LOG_ALERT ZAP_PRE, ZAP_LOG_LEVEL_ALERT
#define ZAP_LOG_EMERG ZAP_PRE, ZAP_LOG_LEVEL_EMERG
typedef void (*zap_logger_t)(char *file, const char *func, int line, int level, char *fmt, ...);
extern zap_logger_t global_logger;
#define zap_log global_logger;
extern zap_logger_t zap_log;
struct zap_software_interface {
const char *name;
@@ -252,7 +261,7 @@ zap_status_t zap_channel_write(zap_channel_t *zchan, void *data, zap_size_t *dat
zap_status_t zap_global_init(void);
zap_status_t zap_global_destroy(void);
void zap_global_set_logger(zap_logger_t logger);
void zap_global_set_default_logger(void);
void zap_global_set_default_logger(int level);
typedef struct hashtable zap_hash_t;