xref: /haiku/src/libs/zydis/Zydis/Zydis.c (revision 1003e004e6c97eb60657a98928dd334e141c59ee)
1*1003e004SJérôme Duval /***************************************************************************************************
2*1003e004SJérôme Duval 
3*1003e004SJérôme Duval   Zyan Disassembler Library (Zydis)
4*1003e004SJérôme Duval 
5*1003e004SJérôme Duval   Original Author : Florian Bernd
6*1003e004SJérôme Duval 
7*1003e004SJérôme Duval  * Permission is hereby granted, free of charge, to any person obtaining a copy
8*1003e004SJérôme Duval  * of this software and associated documentation files (the "Software"), to deal
9*1003e004SJérôme Duval  * in the Software without restriction, including without limitation the rights
10*1003e004SJérôme Duval  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11*1003e004SJérôme Duval  * copies of the Software, and to permit persons to whom the Software is
12*1003e004SJérôme Duval  * furnished to do so, subject to the following conditions:
13*1003e004SJérôme Duval  *
14*1003e004SJérôme Duval  * The above copyright notice and this permission notice shall be included in all
15*1003e004SJérôme Duval  * copies or substantial portions of the Software.
16*1003e004SJérôme Duval  *
17*1003e004SJérôme Duval  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18*1003e004SJérôme Duval  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19*1003e004SJérôme Duval  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20*1003e004SJérôme Duval  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21*1003e004SJérôme Duval  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22*1003e004SJérôme Duval  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23*1003e004SJérôme Duval  * SOFTWARE.
24*1003e004SJérôme Duval 
25*1003e004SJérôme Duval ***************************************************************************************************/
26*1003e004SJérôme Duval 
27*1003e004SJérôme Duval #include <Zydis/Zydis.h>
28*1003e004SJérôme Duval 
29*1003e004SJérôme Duval /* ============================================================================================== */
30*1003e004SJérôme Duval /* Exported functions                                                                             */
31*1003e004SJérôme Duval /* ============================================================================================== */
32*1003e004SJérôme Duval 
ZydisGetVersion(void)33*1003e004SJérôme Duval ZyanU64 ZydisGetVersion(void)
34*1003e004SJérôme Duval {
35*1003e004SJérôme Duval     return ZYDIS_VERSION;
36*1003e004SJérôme Duval }
37*1003e004SJérôme Duval 
ZydisIsFeatureEnabled(ZydisFeature feature)38*1003e004SJérôme Duval ZyanStatus ZydisIsFeatureEnabled(ZydisFeature feature)
39*1003e004SJérôme Duval {
40*1003e004SJérôme Duval     switch (feature)
41*1003e004SJérôme Duval     {
42*1003e004SJérôme Duval     case ZYDIS_FEATURE_DECODER:
43*1003e004SJérôme Duval #ifndef ZYDIS_DISABLE_DECODER
44*1003e004SJérôme Duval         return ZYAN_STATUS_TRUE;
45*1003e004SJérôme Duval #else
46*1003e004SJérôme Duval         return ZYAN_STATUS_FALSE;
47*1003e004SJérôme Duval #endif
48*1003e004SJérôme Duval     case ZYDIS_FEATURE_ENCODER:
49*1003e004SJérôme Duval #ifndef ZYDIS_DISABLE_ENCODER
50*1003e004SJérôme Duval         return ZYAN_STATUS_TRUE;
51*1003e004SJérôme Duval #else
52*1003e004SJérôme Duval         return ZYAN_STATUS_FALSE;
53*1003e004SJérôme Duval #endif
54*1003e004SJérôme Duval     case ZYDIS_FEATURE_FORMATTER:
55*1003e004SJérôme Duval #ifndef ZYDIS_DISABLE_FORMATTER
56*1003e004SJérôme Duval         return ZYAN_STATUS_TRUE;
57*1003e004SJérôme Duval #else
58*1003e004SJérôme Duval         return ZYAN_STATUS_FALSE;
59*1003e004SJérôme Duval #endif
60*1003e004SJérôme Duval     case ZYDIS_FEATURE_AVX512:
61*1003e004SJérôme Duval #ifndef ZYDIS_DISABLE_AVX512
62*1003e004SJérôme Duval         return ZYAN_STATUS_TRUE;
63*1003e004SJérôme Duval #else
64*1003e004SJérôme Duval         return ZYAN_STATUS_FALSE;
65*1003e004SJérôme Duval #endif
66*1003e004SJérôme Duval 
67*1003e004SJérôme Duval     case ZYDIS_FEATURE_KNC:
68*1003e004SJérôme Duval #ifndef ZYDIS_DISABLE_KNC
69*1003e004SJérôme Duval         return ZYAN_STATUS_TRUE;
70*1003e004SJérôme Duval #else
71*1003e004SJérôme Duval         return ZYAN_STATUS_FALSE;
72*1003e004SJérôme Duval #endif
73*1003e004SJérôme Duval 
74*1003e004SJérôme Duval     case ZYDIS_FEATURE_SEGMENT:
75*1003e004SJérôme Duval #ifndef ZYDIS_DISABLE_SEGMENT
76*1003e004SJérôme Duval         return ZYAN_STATUS_TRUE;
77*1003e004SJérôme Duval #else
78*1003e004SJérôme Duval         return ZYAN_STATUS_FALSE;
79*1003e004SJérôme Duval #endif
80*1003e004SJérôme Duval 
81*1003e004SJérôme Duval     default:
82*1003e004SJérôme Duval         return ZYAN_STATUS_INVALID_ARGUMENT;
83*1003e004SJérôme Duval     }
84*1003e004SJérôme Duval }
85*1003e004SJérôme Duval 
86*1003e004SJérôme Duval /* ============================================================================================== */
87