1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * VMware VMCI Driver 4 * 5 * Copyright (C) 2012 VMware, Inc. All rights reserved. 6 */ 7 8 #ifndef _VMCI_HANDLE_ARRAY_H_ 9 #define _VMCI_HANDLE_ARRAY_H_ 10 11 #include <linux/vmw_vmci_defs.h> 12 #include <linux/types.h> 13 14 #define VMCI_HANDLE_ARRAY_DEFAULT_SIZE 4 15 #define VMCI_ARR_CAP_MULT 2 /* Array capacity multiplier */ 16 17 struct vmci_handle_arr { 18 size_t capacity; 19 size_t size; 20 struct vmci_handle entries[]; 21 }; 22 23 struct vmci_handle_arr *vmci_handle_arr_create(size_t capacity); 24 void vmci_handle_arr_destroy(struct vmci_handle_arr *array); 25 void vmci_handle_arr_append_entry(struct vmci_handle_arr **array_ptr, 26 struct vmci_handle handle); 27 struct vmci_handle vmci_handle_arr_remove_entry(struct vmci_handle_arr *array, 28 struct vmci_handle 29 entry_handle); 30 struct vmci_handle vmci_handle_arr_remove_tail(struct vmci_handle_arr *array); 31 struct vmci_handle 32 vmci_handle_arr_get_entry(const struct vmci_handle_arr *array, size_t index); 33 bool vmci_handle_arr_has_entry(const struct vmci_handle_arr *array, 34 struct vmci_handle entry_handle); 35 struct vmci_handle *vmci_handle_arr_get_handles(struct vmci_handle_arr *array); 36 37 static inline size_t vmci_handle_arr_get_size( 38 const struct vmci_handle_arr *array) 39 { 40 return array->size; 41 } 42 43 44 #endif /* _VMCI_HANDLE_ARRAY_H_ */ 45