1 
2 //          Copyright Michael D. Parker 2018.
3 // Distributed under the Boost Software License, Version 1.0.
4 //    (See accompanying file LICENSE_1_0.txt or copy at
5 //          http://www.boost.org/LICENSE_1_0.txt)
6 
7 module bindbc.sdl.bind.sdlcpuinfo;
8 
9 import bindbc.sdl.config;
10 import bindbc.sdl.bind.sdlstdinc : SDL_bool;
11 
12 enum  SDL_CACHELINE_SIZE = 128;
13 
14 version(BindSDL_Static) {
15     extern(C) @nogc nothrow {
16         int SDL_GetCPUCount();
17         int SDL_GetCPUCacheLineSize();
18         SDL_bool SDL_HasRDTSC();
19         SDL_bool SDL_HasAltiVec();
20         SDL_bool SDL_HasMMX();
21         SDL_bool SDL_Has3DNow();
22         SDL_bool SDL_HasSSE();
23         SDL_bool SDL_HasSSE2();
24         SDL_bool SDL_HasSSE3();
25         SDL_bool SDL_HasSSE41();
26         SDL_bool SDL_HasSSE42();
27 
28         static if(sdlSupport >= SDLSupport.sdl201) {
29             int SDL_GetSystemRAM();
30         }
31         static if(sdlSupport >= SDLSupport.sdl202) {
32             SDL_bool SDL_HasAVX();
33         }
34         static if(sdlSupport >= SDLSupport.sdl204) {
35             SDL_bool SDL_HasAVX2();
36         }
37         static if(sdlSupport >= SDLSupport.sdl206) {
38             SDL_bool SDL_HasNEON();
39         }
40         static if(sdlSupport >= SDLSupport.sdl209) {
41             SDL_bool SDL_HasAVX512F();
42         }
43         static if(sdlSupport >= SDLSupport.sdl2010) {
44             size_t SDL_SIMDGetAlignment();
45             void* SDL_SIMDAlloc(const(size_t));
46             void SDL_SIMDFree(void*);
47         }
48     }
49 }
50 else {
51     extern(C) @nogc nothrow {
52         alias pSDL_GetCPUCount = int function();
53         alias pSDL_GetCPUCacheLineSize = int function();
54         alias pSDL_HasRDTSC = SDL_bool function();
55         alias pSDL_HasAltiVec = SDL_bool function();
56         alias pSDL_HasMMX = SDL_bool function();
57         alias pSDL_Has3DNow = SDL_bool function();
58         alias pSDL_HasSSE = SDL_bool function();
59         alias pSDL_HasSSE2 = SDL_bool function();
60         alias pSDL_HasSSE3 = SDL_bool function();
61         alias pSDL_HasSSE41 = SDL_bool function();
62         alias pSDL_HasSSE42 = SDL_bool function();
63     }
64 
65     __gshared {
66         pSDL_GetCPUCount SDL_GetCPUCount;
67         pSDL_GetCPUCacheLineSize SDL_GetCPUCacheLineSize;
68         pSDL_HasRDTSC SDL_HasRDTSC;
69         pSDL_HasAltiVec SDL_HasAltiVec;
70         pSDL_HasMMX SDL_HasMMX;
71         pSDL_Has3DNow SDL_Has3DNow;
72         pSDL_HasSSE SDL_HasSSE;
73         pSDL_HasSSE2 SDL_HasSSE2;
74         pSDL_HasSSE3 SDL_HasSSE3;
75         pSDL_HasSSE41 SDL_HasSSE41;
76         pSDL_HasSSE42 SDL_HasSSE42;
77     }
78     static if(sdlSupport >= SDLSupport.sdl201) {
79         extern(C) @nogc nothrow {
80             alias pSDL_GetSystemRAM = int function();
81         }
82         __gshared {
83             pSDL_GetSystemRAM SDL_GetSystemRAM;
84         }
85     }
86     static if(sdlSupport >= SDLSupport.sdl202) {
87         extern(C) @nogc nothrow {
88             alias pSDL_HasAVX = SDL_bool function();
89         }
90         __gshared {
91             pSDL_HasAVX SDL_HasAVX;
92         }
93     }
94     static if(sdlSupport >= SDLSupport.sdl204) {
95         extern(C) @nogc nothrow {
96             alias pSDL_HasAVX2 = SDL_bool function();
97         }
98         __gshared {
99             pSDL_HasAVX2 SDL_HasAVX2;
100         }
101     }
102     static if(sdlSupport >= SDLSupport.sdl206) {
103         extern(C) @nogc nothrow {
104             alias pSDL_HasNEON = SDL_bool function();
105         }
106         __gshared {
107             pSDL_HasNEON SDL_HasNEON;
108         }
109     }
110     static if(sdlSupport >= SDLSupport.sdl209) {
111         extern(C) @nogc nothrow {
112             alias pSDL_HasAVX512F = SDL_bool function();
113         }
114         __gshared {
115             pSDL_HasAVX512F SDL_HasAVX512F;
116         }
117     }
118     static if(sdlSupport >= SDLSupport.sdl2010) {
119         extern(C) @nogc nothrow {
120             alias pSDL_SIMDGetAlignment = size_t function();
121             alias pSDL_SIMDAlloc = void* function(const(size_t));
122             alias pSDL_SIMDFree = void function(void*);
123         }
124         __gshared {
125             pSDL_SIMDGetAlignment SDL_SIMDGetAlignment;
126             pSDL_SIMDAlloc SDL_SIMDAlloc;
127             pSDL_SIMDFree SDL_SIMDFree;
128         }
129     }
130 }