1 /+
2 +            Copyright 2022 – 2023 Aya Partridge
3 +          Copyright 2018 - 2022 Michael D. Parker
4 + Distributed under the Boost Software License, Version 1.0.
5 +     (See accompanying file LICENSE_1_0.txt or copy at
6 +           http://www.boost.org/LICENSE_1_0.txt)
7 +/
8 module sdl.cpuinfo;
9 
10 import bindbc.sdl.config;
11 import bindbc.sdl.codegen;
12 
13 import sdl.stdinc: SDL_bool;
14 
15 enum SDL_CACHELINE_SIZE = 128;
16 
17 mixin(joinFnBinds((){
18 	string[][] ret;
19 	ret ~= makeFnBinds([
20 		[q{int}, q{SDL_GetCPUCount}, q{}],
21 		[q{int}, q{SDL_GetCPUCacheLineSize}, q{}],
22 		[q{SDL_bool}, q{SDL_HasRDTSC}, q{}],
23 		[q{SDL_bool}, q{SDL_HasAltiVec}, q{}],
24 		[q{SDL_bool}, q{SDL_HasMMX}, q{}],
25 		[q{SDL_bool}, q{SDL_Has3DNow}, q{}],
26 		[q{SDL_bool}, q{SDL_HasSSE}, q{}],
27 		[q{SDL_bool}, q{SDL_HasSSE2}, q{}],
28 		[q{SDL_bool}, q{SDL_HasSSE3}, q{}],
29 		[q{SDL_bool}, q{SDL_HasSSE41}, q{}],
30 		[q{SDL_bool}, q{SDL_HasSSE42}, q{}],
31 	]);
32 	static if(sdlSupport >= SDLSupport.v2_0_1){
33 		ret ~= makeFnBinds([
34 			[q{int}, q{SDL_GetSystemRAM}, q{}],
35 		]);
36 	}
37 	static if(sdlSupport >= SDLSupport.v2_0_2){
38 		ret ~= makeFnBinds([
39 			[q{SDL_bool}, q{SDL_HasAVX}, q{}],
40 		]);
41 	}
42 	static if(sdlSupport >= SDLSupport.v2_0_4){
43 		ret ~= makeFnBinds([
44 			[q{SDL_bool}, q{SDL_HasAVX2}, q{}],
45 		]);
46 	}
47 	static if(sdlSupport >= SDLSupport.v2_0_6){
48 		ret ~= makeFnBinds([
49 			[q{SDL_bool}, q{SDL_HasNEON}, q{}],
50 		]);
51 	}
52 	static if(sdlSupport >= SDLSupport.v2_0_9){
53 		ret ~= makeFnBinds([
54 			[q{SDL_bool}, q{SDL_HasAVX512F}, q{}],
55 		]);
56 	}
57 	static if(sdlSupport >= SDLSupport.v2_0_10){
58 		ret ~= makeFnBinds([
59 			[q{size_t}, q{SDL_SIMDGetAlignment}, q{}],
60 			[q{void*}, q{SDL_SIMDAlloc}, q{const(size_t) len}],
61 			[q{void}, q{SDL_SIMDFree}, q{void*}],
62 		]);
63 	}
64 	static if(sdlSupport >= SDLSupport.v2_0_12){
65 		ret ~= makeFnBinds([
66 			[q{SDL_bool}, q{SDL_HasARMSIMD}, q{}],
67 		]);
68 	}
69 	static if(sdlSupport >= SDLSupport.v2_0_14){
70 		ret ~= makeFnBinds([
71 			[q{void*}, q{SDL_SIMDRealloc}, q{void* mem, const(size_t) len}],
72 		]);
73 	}
74 	static if(sdlSupport >= SDLSupport.v2_24){
75 		ret ~= makeFnBinds([
76 			[q{SDL_bool}, q{SDL_HasLSX}, q{}],
77 			[q{SDL_bool}, q{SDL_HasLASX}, q{}],
78 		]);
79 	}
80 	return ret;
81 }()));