1 | /* $Id: VBoxMPSa.h 82968 2020-02-04 10:35:17Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | * Sorted array API
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2014-2020 Oracle Corporation
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | */
|
---|
18 | #ifndef GA_INCLUDED_SRC_WINNT_Graphics_Video_mp_wddm_VBoxMPSa_h
|
---|
19 | #define GA_INCLUDED_SRC_WINNT_Graphics_Video_mp_wddm_VBoxMPSa_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | #include <iprt/types.h>
|
---|
25 | #include <iprt/assert.h>
|
---|
26 |
|
---|
27 | typedef struct CR_SORTARRAY
|
---|
28 | {
|
---|
29 | uint32_t cBufferSize;
|
---|
30 | uint32_t cSize;
|
---|
31 | uint64_t *pElements;
|
---|
32 | } CR_SORTARRAY;
|
---|
33 |
|
---|
34 |
|
---|
35 | #ifndef IN_RING0
|
---|
36 | # define VBOXSADECL(_type) DECLEXPORT(_type)
|
---|
37 | #else
|
---|
38 | # define VBOXSADECL(_type) RTDECL(_type)
|
---|
39 | #endif
|
---|
40 |
|
---|
41 |
|
---|
42 | DECLINLINE(uint32_t) CrSaGetSize(const CR_SORTARRAY *pArray)
|
---|
43 | {
|
---|
44 | return pArray->cSize;
|
---|
45 | }
|
---|
46 |
|
---|
47 | DECLINLINE(uint64_t) CrSaGetVal(const CR_SORTARRAY *pArray, uint32_t i)
|
---|
48 | {
|
---|
49 | Assert(i < pArray->cSize);
|
---|
50 | return pArray->pElements[i];
|
---|
51 | }
|
---|
52 |
|
---|
53 | DECLINLINE(const uint64_t*) CrSaGetElements(const CR_SORTARRAY *pArray)
|
---|
54 | {
|
---|
55 | return pArray->pElements;
|
---|
56 | }
|
---|
57 |
|
---|
58 | DECLINLINE(void) CrSaClear(CR_SORTARRAY *pArray)
|
---|
59 | {
|
---|
60 | pArray->cSize = 0;
|
---|
61 | }
|
---|
62 |
|
---|
63 | VBOXSADECL(int) CrSaInit(CR_SORTARRAY *pArray, uint32_t cInitBuffer);
|
---|
64 | VBOXSADECL(void) CrSaCleanup(CR_SORTARRAY *pArray);
|
---|
65 | /*
|
---|
66 | * @return true if element is found */
|
---|
67 | VBOXSADECL(bool) CrSaContains(const CR_SORTARRAY *pArray, uint64_t element);
|
---|
68 |
|
---|
69 | /*
|
---|
70 | * @return VINF_SUCCESS if element is added
|
---|
71 | * VINF_ALREADY_INITIALIZED if element was in array already
|
---|
72 | * VERR_NO_MEMORY - no memory
|
---|
73 | * */
|
---|
74 | VBOXSADECL(int) CrSaAdd(CR_SORTARRAY *pArray, uint64_t element);
|
---|
75 |
|
---|
76 | /*
|
---|
77 | * @return VINF_SUCCESS if element is removed
|
---|
78 | * VINF_ALREADY_INITIALIZED if element was NOT in array
|
---|
79 | * */
|
---|
80 | VBOXSADECL(int) CrSaRemove(CR_SORTARRAY *pArray, uint64_t element);
|
---|
81 |
|
---|
82 | /*
|
---|
83 | * @return VINF_SUCCESS on success
|
---|
84 | * VERR_NO_MEMORY - no memory
|
---|
85 | * */
|
---|
86 | VBOXSADECL(void) CrSaIntersect(CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2);
|
---|
87 | VBOXSADECL(int) CrSaIntersected(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2, CR_SORTARRAY *pResult);
|
---|
88 |
|
---|
89 | /*
|
---|
90 | * @return VINF_SUCCESS on success
|
---|
91 | * VERR_NO_MEMORY - no memory
|
---|
92 | * */
|
---|
93 | VBOXSADECL(int) CrSaUnited(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2, CR_SORTARRAY *pResult);
|
---|
94 |
|
---|
95 | /*
|
---|
96 | * @return VINF_SUCCESS on success
|
---|
97 | * VERR_NO_MEMORY - no memory
|
---|
98 | * */
|
---|
99 | VBOXSADECL(int) CrSaClone(const CR_SORTARRAY *pArray1, CR_SORTARRAY *pResult);
|
---|
100 |
|
---|
101 | VBOXSADECL(int) CrSaCmp(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2);
|
---|
102 |
|
---|
103 | VBOXSADECL(bool) CrSaCovers(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2);
|
---|
104 |
|
---|
105 | #endif /* !GA_INCLUDED_SRC_WINNT_Graphics_Video_mp_wddm_VBoxMPSa_h */
|
---|