Merged with tip.
[cacao.git] / src / toolbox / list.h
index 640eac38cbc82da73e41de3f0bcd99ce9aceffd5..f93cf1b076fa5721d39242cf7f95032f1db49996 100644 (file)
@@ -1,9 +1,7 @@
-/* src/toolbox/list.h - 
+/* src/toolbox/list.h - synchronized linked list
 
-   Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
-   R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
-   C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
-   Institut f. Computersprachen - TU Wien
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.
-
-   Contact: cacao@complang.tuwien.ac.at
-
-   Authors: Reinhard Grafl
-
-   Changes: Christian Thalinger
-
-   $Id: list.h 3449 2005-10-19 19:56:46Z twisti $
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
 
 */
 
 #ifndef _LIST_H
 #define _LIST_H
 
-typedef struct listnode {           /* structure for list element */
-       struct listnode *next;
-       struct listnode *prev;
-} listnode;
-
-
-typedef struct list {               /* structure for list head */
-       listnode *first;
-       listnode *last;
-       int nodeoffset;
-} list;
-
+#include "config.h"
 
-/* function prototypes */
+#ifdef __cplusplus
+extern "C" {
+#endif
 
-void list_init(list *l, int nodeoffset);
+#include <stdint.h>
 
-void list_addlast(list *l, void *element);
-void list_addfirst(list *l, void *element);
+#include "vm/global.h"
 
-void list_remove(list *l, void *element);
-void *list_first(list *l);
-void *list_last(list *l);
 
-void *list_next(list *l, void *element);
-void *list_prev(list *l, void *element);
-
-
-/*
----------------------- interface description -----------------------------
+/* ---------------------- interface description -----------------------------
 
 The list management with this module works like this:
        
@@ -123,6 +94,57 @@ distinct list).
 
 */
 
+/* listnode_t *****************************************************************/
+
+typedef struct listnode_t listnode_t;
+
+struct listnode_t {
+       listnode_t *next;
+       listnode_t *prev;
+};
+
+
+/* list_t *********************************************************************/
+
+typedef struct list_t list_t;
+
+struct list_t {
+#if defined(ENABLE_THREADS)
+       java_object_t      lock;            /* threads lock object                */
+#endif
+       listnode_t        *first;
+       listnode_t        *last;
+       int                nodeoffset;
+       int                size;            /* number of elements in the list     */
+};
+
+
+/* function prototypes ********************************************************/
+
+list_t *list_create(int nodeoffset);
+list_t *list_create_dump(int nodeoffset);
+
+void    list_free(list_t *l);
+
+void    list_lock(list_t *l);
+void    list_unlock(list_t *l);
+
+void    list_add_first(list_t *l, void *element);
+void    list_add_last(list_t *l, void *element);
+void    list_add_before(list_t *l, void *element, void *newelement);
+
+void    list_remove(list_t *l, void *element);
+
+void   *list_first(list_t *l);
+void   *list_last(list_t *l);
+
+void   *list_next(list_t *l, void *element);
+void   *list_prev(list_t *l, void *element);
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _LIST_H */