George Zhang | b484b26 | 2013-01-08 15:54:39 -0800 | [diff] [blame] | 1 | /* |
| 2 | * VMware VMCI Driver |
| 3 | * |
| 4 | * Copyright (C) 2012 VMware, Inc. All rights reserved. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License as published by the |
| 8 | * Free Software Foundation version 2 and no later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 13 | * for more details. |
| 14 | */ |
| 15 | |
| 16 | #ifndef _VMCI_HANDLE_ARRAY_H_ |
| 17 | #define _VMCI_HANDLE_ARRAY_H_ |
| 18 | |
| 19 | #include <linux/vmw_vmci_defs.h> |
| 20 | #include <linux/types.h> |
| 21 | |
| 22 | #define VMCI_HANDLE_ARRAY_DEFAULT_SIZE 4 |
| 23 | #define VMCI_ARR_CAP_MULT 2 /* Array capacity multiplier */ |
| 24 | |
| 25 | struct vmci_handle_arr { |
| 26 | size_t capacity; |
| 27 | size_t size; |
| 28 | struct vmci_handle entries[]; |
| 29 | }; |
| 30 | |
| 31 | struct vmci_handle_arr *vmci_handle_arr_create(size_t capacity); |
| 32 | void vmci_handle_arr_destroy(struct vmci_handle_arr *array); |
| 33 | void vmci_handle_arr_append_entry(struct vmci_handle_arr **array_ptr, |
| 34 | struct vmci_handle handle); |
| 35 | struct vmci_handle vmci_handle_arr_remove_entry(struct vmci_handle_arr *array, |
| 36 | struct vmci_handle |
| 37 | entry_handle); |
| 38 | struct vmci_handle vmci_handle_arr_remove_tail(struct vmci_handle_arr *array); |
| 39 | struct vmci_handle |
| 40 | vmci_handle_arr_get_entry(const struct vmci_handle_arr *array, size_t index); |
| 41 | bool vmci_handle_arr_has_entry(const struct vmci_handle_arr *array, |
| 42 | struct vmci_handle entry_handle); |
| 43 | struct vmci_handle *vmci_handle_arr_get_handles(struct vmci_handle_arr *array); |
| 44 | |
| 45 | static inline size_t vmci_handle_arr_get_size( |
| 46 | const struct vmci_handle_arr *array) |
| 47 | { |
| 48 | return array->size; |
| 49 | } |
| 50 | |
| 51 | |
| 52 | #endif /* _VMCI_HANDLE_ARRAY_H_ */ |