Include stddef.h for size_t.
[libfirm] / include / libfirm / adt / pset.h
index 6c6e4c0..773d276 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
+ * Copyright (C) 1995-2011 University of Karlsruhe.  All right reserved.
  *
  * This file is part of libFirm.
  *
 #include "hashptr.h"
 #include "iterator.h"
 
+#include "../begin.h"
+
 /**
  * The default comparison function for pointers.
  * @param x A pointer.
  * @param y A pointer.
  * @return 0 if @p x and @p y are equal. Some value != 0 otherwise.
  */
-int pset_default_ptr_cmp(const void *x, const void *y);
+FIRM_API int pset_default_ptr_cmp(const void *x, const void *y);
 
 /**
  * The abstract type of a pset (Set of pointers).
@@ -83,13 +85,13 @@ typedef int (*pset_cmp_fun) (const void *elt, const void *key);
  * Creates a new pset.
  *
  * @param func    The compare function of this pset.
- * @param slots   Initial number of collision chains.  I.e., #slots
+ * @param slots   Initial number of collision chains.  I.e., \#slots
  *                different keys can be hashed without collisions.
  *
  * @returns
  *    created pset
  */
-pset *new_pset (pset_cmp_fun func, int slots);
+FIRM_API pset *new_pset(pset_cmp_fun func, size_t slots);
 
 /**
  * Deletes a pset.
@@ -99,14 +101,14 @@ pset *new_pset (pset_cmp_fun func, int slots);
  * @note
  *    This does NOT delete the elements of this pset, just it's pointers!
  */
-void del_pset (pset *pset);
+FIRM_API void del_pset(pset *pset);
 
 /**
  * Returns the number of elements in a pset.
  *
  * @param pset   the pset
  */
-int pset_count (pset *pset);
+FIRM_API size_t pset_count(pset *pset);
 
 /**
  * Searches an element pointer in a pset.
@@ -118,7 +120,7 @@ int pset_count (pset *pset);
  * @return
  *    the pointer of the found element in the pset or NULL if it was not found
  */
-void *pset_find (pset *pset, const void *key, unsigned hash);
+FIRM_API void *pset_find(pset *pset, const void *key, unsigned hash);
 
 /**
  * Inserts an element pointer into a pset.
@@ -135,7 +137,7 @@ void *pset_find (pset *pset, const void *key, unsigned hash);
  *    nothing but returning its already existing set_entry.
 
  */
-void *pset_insert (pset *pset, const void *key, unsigned hash);
+FIRM_API void *pset_insert(pset *pset, const void *key, unsigned hash);
 
 /**
  * Inserts an element pointer into a pset and returns its pset_entry.
@@ -151,7 +153,7 @@ void *pset_insert (pset *pset, const void *key, unsigned hash);
  *    that should be inserted is already in the pset, this functions does
  *    nothing but returning its pset_entry.
  */
-pset_entry *pset_hinsert (pset *pset, const void *key, unsigned hash);
+FIRM_API pset_entry *pset_hinsert(pset *pset, const void *key, unsigned hash);
 
 /**
  * Removes an element from a pset.
@@ -169,7 +171,7 @@ pset_entry *pset_hinsert (pset *pset, const void *key, unsigned hash);
  *    Further, it is allowed to remove elements during an iteration
  *    including the current one.
  */
-void *pset_remove (pset *pset, const void *key, unsigned hash);
+FIRM_API void *pset_remove(pset *pset, const void *key, unsigned hash);
 
 /**
  * Returns the first element of a pset.
@@ -178,7 +180,7 @@ void *pset_remove (pset *pset, const void *key, unsigned hash);
  *
  * @return a pointer to the element or NULL if the set is empty
  */
-void *pset_first (pset *pset);
+FIRM_API void *pset_first(pset *pset);
 
 /**
  * Returns the next element of a pset.
@@ -188,7 +190,7 @@ void *pset_first (pset *pset);
  * @return a pointer to the next element or NULL if the
  *         iteration is finished
  */
-void *pset_next (pset *pset);
+FIRM_API void *pset_next(pset *pset);
 
 /**
  * Breaks the iteration of a set. Must be called before
@@ -197,7 +199,7 @@ void *pset_next (pset *pset);
  *
  * @param pset  the pset
  */
-void pset_break (pset *pset);
+FIRM_API void pset_break(pset *pset);
 
 /**
  * Iterates oven an pset.
@@ -205,7 +207,7 @@ void pset_break (pset *pset);
  * @param pset   the pset
  * @param entry  the iterator
  */
-#define foreach_pset(pset, entry) for (entry = pset_first(pset); entry; entry = pset_next(pset))
+#define foreach_pset(pset, type, entry) for (entry = (type)pset_first(pset); entry; entry = (type)pset_next(pset))
 
 /**
  * Inserts all elements of the pointer set src into
@@ -214,9 +216,9 @@ void pset_break (pset *pset);
  * @param target  the target set, will contain the union
  * @param src     a set, will not be changed
  */
-void pset_insert_pset_ptr(pset *target, pset *src);
+FIRM_API void pset_insert_pset_ptr(pset *target, pset *src);
 
-#define new_pset(cmp, slots) (PSET_TRACE (new_pset) ((cmp), (slots)))
+#define new_pset(cmp, slots) ((new_pset) ((cmp), (slots)))
 #define pset_find(pset, key, hash) \
   _pset_search ((pset), (key), (hash), _pset_find)
 #define pset_insert(pset, key, hash) \
@@ -256,17 +258,8 @@ void pset_describe (pset *pset);
 
 typedef enum { _pset_find, _pset_insert, _pset_hinsert } _pset_action;
 
-void *_pset_search (pset *, const void *, unsigned, _pset_action);
-
-#if defined(DEBUG) && defined(HAVE_GNU_MALLOC)
-extern const char *pset_tag;
-# ifdef PSET_ID
-#   define PSET_TRACE pset_tag = SET_ID,
-# else
-#   define PSET_TRACE pset_tag = __FILE__,
-# endif
-#else /* !(DEBUG && HAVE_GNU_MALLOC) */
-#   define PSET_TRACE
-#endif /* !(DEBUG && HAVE_GNU_MALLOC) */
+FIRM_API void *_pset_search(pset *, const void *, unsigned, _pset_action);
+
+#include "../end.h"
 
 #endif