xref: /xnu-10002.1.13/EXTERNAL_HEADERS/CoreEntitlements/Index.h (revision 1031c584a5e37aff177559b9f69dbd3c8c3fd30a)
1*1031c584SApple OSS Distributions //
2*1031c584SApple OSS Distributions //  Index.h
3*1031c584SApple OSS Distributions //  CoreEntitlements
4*1031c584SApple OSS Distributions //
5*1031c584SApple OSS Distributions //
6*1031c584SApple OSS Distributions 
7*1031c584SApple OSS Distributions #ifndef CORE_ENTITLEMENTS_INDEX_H
8*1031c584SApple OSS Distributions #define CORE_ENTITLEMENTS_INDEX_H
9*1031c584SApple OSS Distributions 
10*1031c584SApple OSS Distributions #ifndef _CE_INDIRECT
11*1031c584SApple OSS Distributions #error "Please include <CoreEntitlements/CoreEntitlements.h> instead of this file"
12*1031c584SApple OSS Distributions #endif
13*1031c584SApple OSS Distributions 
14*1031c584SApple OSS Distributions #include <CoreEntitlements/Result.h>
15*1031c584SApple OSS Distributions 
16*1031c584SApple OSS Distributions /*
17*1031c584SApple OSS Distributions  The kernel always supports acceleration
18*1031c584SApple OSS Distributions  */
19*1031c584SApple OSS Distributions #define CE_ACCELERATION_SUPPORTED 1
20*1031c584SApple OSS Distributions 
21*1031c584SApple OSS Distributions 
22*1031c584SApple OSS Distributions /*!
23*1031c584SApple OSS Distributions  @typedef CEAccelerationElement_t
24*1031c584SApple OSS Distributions 
25*1031c584SApple OSS Distributions  A single element of the acceleration structure, the contents of this struct are an implementation detail
26*1031c584SApple OSS Distributions  and are subject to change.
27*1031c584SApple OSS Distributions  */
28*1031c584SApple OSS Distributions typedef struct CEAccelerationElement {
29*1031c584SApple OSS Distributions     uint32_t key_offset;
30*1031c584SApple OSS Distributions     uint32_t key_length;
31*1031c584SApple OSS Distributions } CEAccelerationElement_t;
32*1031c584SApple OSS Distributions 
33*1031c584SApple OSS Distributions /*!
34*1031c584SApple OSS Distributions  @struct CEAccelerationContext
35*1031c584SApple OSS Distributions 
36*1031c584SApple OSS Distributions  Contains data required to accelerate queries, the contents of this struct are an implementation detail
37*1031c584SApple OSS Distributions  and are subject to change.
38*1031c584SApple OSS Distributions  */
39*1031c584SApple OSS Distributions struct CEAccelerationContext {
40*1031c584SApple OSS Distributions     CEAccelerationElement_t * __counted_by(index_count) index;
41*1031c584SApple OSS Distributions     size_t index_count;
42*1031c584SApple OSS Distributions };
43*1031c584SApple OSS Distributions 
44*1031c584SApple OSS Distributions /*!
45*1031c584SApple OSS Distributions  @function CEIndexSizeForContext
46*1031c584SApple OSS Distributions  Computes an upper bound of memory needed to construct an acceleration index for a particular query context.
47*1031c584SApple OSS Distributions 
48*1031c584SApple OSS Distributions  @param context
49*1031c584SApple OSS Distributions  The context for which the calculation should be made
50*1031c584SApple OSS Distributions 
51*1031c584SApple OSS Distributions  @param size
52*1031c584SApple OSS Distributions  Contains the required size, in bytes.
53*1031c584SApple OSS Distributions 
54*1031c584SApple OSS Distributions  @returns an error if the context cannot be accelerated, success otherwise
55*1031c584SApple OSS Distributions  */
56*1031c584SApple OSS Distributions CEError_t CEIndexSizeForContext(CEQueryContext_t context, size_t* size);
57*1031c584SApple OSS Distributions 
58*1031c584SApple OSS Distributions /*!
59*1031c584SApple OSS Distributions  @function CEBuildIndexForContext
60*1031c584SApple OSS Distributions  Computes and stores and acceleration index into the passed in context.
61*1031c584SApple OSS Distributions  Building an index requires runtime support.
62*1031c584SApple OSS Distributions 
63*1031c584SApple OSS Distributions  @param context
64*1031c584SApple OSS Distributions  The context for which the index should be computed.
65*1031c584SApple OSS Distributions  */
66*1031c584SApple OSS Distributions CEError_t CEBuildIndexForContext(CEQueryContext_t context);
67*1031c584SApple OSS Distributions 
68*1031c584SApple OSS Distributions /*!
69*1031c584SApple OSS Distributions  @function CEFreeIndexForContext
70*1031c584SApple OSS Distributions  Frees an index associated with a query context
71*1031c584SApple OSS Distributions 
72*1031c584SApple OSS Distributions  @param context
73*1031c584SApple OSS Distributions  The context for which the index should be freed.
74*1031c584SApple OSS Distributions  */
75*1031c584SApple OSS Distributions CEError_t CEFreeIndexForContext(CEQueryContext_t context);
76*1031c584SApple OSS Distributions 
77*1031c584SApple OSS Distributions /*!
78*1031c584SApple OSS Distributions  @function CEContextIsAccelerated
79*1031c584SApple OSS Distributions  Checks if the passed in context supports query acceleration
80*1031c584SApple OSS Distributions 
81*1031c584SApple OSS Distributions  @param context
82*1031c584SApple OSS Distributions  The context to check.
83*1031c584SApple OSS Distributions  */
84*1031c584SApple OSS Distributions bool CEContextIsAccelerated(CEQueryContext_t context);
85*1031c584SApple OSS Distributions 
86*1031c584SApple OSS Distributions #endif /* CORE_ENTITLEMENTS_INDEX_H */
87