| 1 | /********************************************************************** |
|---|
| 2 | * Copyright (c) 2005-2008 David Carter <dcarter@arm4.org> and others. |
|---|
| 3 | * All rights reserved. This program and the accompanying materials |
|---|
| 4 | * are made available under the terms of the Eclipse Public License v1.0 |
|---|
| 5 | * which accompanies this distribution, and is available at |
|---|
| 6 | * http://www.eclipse.org/legal/epl-v10.html |
|---|
| 7 | * |
|---|
| 8 | * Contributors: |
|---|
| 9 | * David Carter - Initial API and implementation |
|---|
| 10 | **********************************************************************/ |
|---|
| 11 | |
|---|
| 12 | /* This is a specialized tree indexed using 64-bit handles */ |
|---|
| 13 | |
|---|
| 14 | #ifndef LIBARM4_TREE_H |
|---|
| 15 | #define LIBARM4_TREE_H 1 |
|---|
| 16 | |
|---|
| 17 | #include "arm4.h" |
|---|
| 18 | #include "libarm4_shm.h" |
|---|
| 19 | |
|---|
| 20 | typedef int (*tree_compare_t) (const void *key1_ptr, const void *key2_ptr); |
|---|
| 21 | typedef void * (*tree_clone_t) (const void *key_ptr); |
|---|
| 22 | |
|---|
| 23 | /* Tree record structures */ |
|---|
| 24 | typedef struct tree_record { |
|---|
| 25 | struct tree_record *left_ptr; |
|---|
| 26 | struct tree_record *right_ptr; |
|---|
| 27 | void *key_ptr; |
|---|
| 28 | void *data_ptr; |
|---|
| 29 | } tree_record_t; |
|---|
| 30 | |
|---|
| 31 | struct tree { |
|---|
| 32 | tree_record_t root; |
|---|
| 33 | tree_compare_t compare; |
|---|
| 34 | tree_clone_t clone; |
|---|
| 35 | pthread_mutex_t mutex; |
|---|
| 36 | }; |
|---|
| 37 | |
|---|
| 38 | typedef struct tree tree_t; |
|---|
| 39 | typedef struct tree tree_id_t; |
|---|
| 40 | |
|---|
| 41 | /* Functions */ |
|---|
| 42 | void __libarm4_tree_init (tree_t *tree_ptr); |
|---|
| 43 | void __libarm4_tree_insert (tree_t *tree_ptr, arm_int64_t key, void *data_ptr); |
|---|
| 44 | void *__libarm4_tree_find (tree_t *tree_ptr, arm_int64_t key); |
|---|
| 45 | void *__libarm4_tree_remove (tree_t *tree_ptr, arm_int64_t key); |
|---|
| 46 | void *__libarm4_tree_remove_next (tree_t *tree_ptr, arm_int64_t *key_ptr); |
|---|
| 47 | |
|---|
| 48 | void __libarm4_tree_id_init (tree_id_t *tree_ptr); |
|---|
| 49 | void __libarm4_tree_id_insert (tree_id_t *tree_ptr, const arm_id_t *key_ptr, void *data_ptr); |
|---|
| 50 | void *__libarm4_tree_id_find (tree_id_t *tree_ptr, const arm_id_t *key_ptr); |
|---|
| 51 | void *__libarm4_tree_id_remove (tree_id_t *tree_ptr, const arm_id_t *key_ptr); |
|---|
| 52 | void *__libarm4_tree_id_remove_next (tree_id_t *tree_ptr, arm_id_t *key_ptr); |
|---|
| 53 | |
|---|
| 54 | typedef struct application_instance_tree_record { |
|---|
| 55 | arm_id_t appl_id; |
|---|
| 56 | arm_boolean_t active; |
|---|
| 57 | tree_t transaction_tree; |
|---|
| 58 | |
|---|
| 59 | /* Need to save system address information when provided */ |
|---|
| 60 | arm_int16_t address_format; |
|---|
| 61 | arm_int16_t address_length; |
|---|
| 62 | arm_uint8_t *address; |
|---|
| 63 | } application_instance_tree_record_t; |
|---|
| 64 | |
|---|
| 65 | typedef struct alias_tree_record { |
|---|
| 66 | arm_id_t actual_id; |
|---|
| 67 | unsigned char digest [MD5_DIGEST_LENGTH]; |
|---|
| 68 | } alias_tree_record_t; |
|---|
| 69 | |
|---|
| 70 | #endif /* LIBARM4_TREE_H */ |
|---|