comparison fuhtark_test/include/winapi/stralign.h @ 1500:91c8c3b7cbf0

add: futhark tests for generating vulkan api
author sam <sam@basx.dev>
date Wed, 26 Nov 2025 21:36:48 +0700
parents
children
comparison
equal deleted inserted replaced
1499:1f58458b7ef7 1500:91c8c3b7cbf0
1 /**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the w64 mingw-runtime package.
4 * No warranty is given; refer to the file DISCLAIMER within this package.
5 */
6 #ifndef __STRALIGN_H_
7 #define __STRALIGN_H_
8
9 #ifndef _STRALIGN_USE_SECURE_CRT
10 #define _STRALIGN_USE_SECURE_CRT 0
11 #endif
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17 #if defined(I_X86_)
18 #define WSTR_ALIGNED(s) TRUE
19 #define ua_CharUpperW CharUpperW
20 #define ua_lstrcmpiW lstrcmpiW
21 #define ua_lstrcmpW lstrcmpW
22 #define ua_lstrlenW lstrlenW
23 #define ua_wcschr wcschr
24 #define ua_wcsicmp wcsicmp
25 #define ua_wcslen wcslen
26 #define ua_wcsrchr wcsrchr
27
28 PUWSTR ua_wcscpy(PUWSTR Destination,PCUWSTR Source);
29 #ifndef __CRT__NO_INLINE
30 __CRT_INLINE PUWSTR ua_wcscpy(PUWSTR Destination,PCUWSTR Source) { return wcscpy(Destination,Source); }
31 #else
32 #define ua_wcscpy wcscpy
33 #endif
34 #else
35 #define WSTR_ALIGNED(s) (((DWORD_PTR)(s) & (sizeof(WCHAR)-1))==0)
36
37 /* TODO: This method seems to be not present for amd64. */
38 LPUWSTR WINAPI uaw_CharUpperW(LPUWSTR String);
39 int WINAPI uaw_lstrcmpW(PCUWSTR String1,PCUWSTR String2);
40 int WINAPI uaw_lstrcmpiW(PCUWSTR String1,PCUWSTR String2);
41 int WINAPI uaw_lstrlenW(LPCUWSTR String);
42 PUWSTR __cdecl uaw_wcschr(PCUWSTR String,WCHAR Character);
43 PUWSTR __cdecl uaw_wcscpy(PUWSTR Destination,PCUWSTR Source);
44 int __cdecl uaw_wcsicmp(PCUWSTR String1,PCUWSTR String2);
45 size_t __cdecl uaw_wcslen(PCUWSTR String);
46 PUWSTR __cdecl uaw_wcsrchr(PCUWSTR String,WCHAR Character);
47 #ifdef CharUpper
48 LPUWSTR ua_CharUpperW(LPUWSTR String);
49 #ifndef __CRT__NO_INLINE
50 __CRT_INLINE LPUWSTR ua_CharUpperW(LPUWSTR String) {
51 if(WSTR_ALIGNED(String)) return CharUpperW((PWSTR)String);
52 return uaw_CharUpperW(String);
53 }
54 #endif /* !__CRT__NO_INLINE */
55 #endif
56
57 #ifdef lstrcmp
58 int ua_lstrcmpW(LPCUWSTR String1,LPCUWSTR String2);
59 #endif
60 #ifdef lstrcmpi
61 int ua_lstrcmpiW(LPCUWSTR String1,LPCUWSTR String2);
62 #endif
63 #ifdef lstrlen
64 int ua_lstrlenW(LPCUWSTR String);
65 #endif
66
67 #ifndef __CRT__NO_INLINE
68 #ifdef lstrcmp
69 __CRT_INLINE int ua_lstrcmpW(LPCUWSTR String1,LPCUWSTR String2) {
70 if(WSTR_ALIGNED(String1) && WSTR_ALIGNED(String2))
71 return lstrcmpW((LPCWSTR)String1,(LPCWSTR)String2);
72 return uaw_lstrcmpW(String1,String2);
73 }
74 #endif
75
76 #ifdef lstrcmpi
77 __CRT_INLINE int ua_lstrcmpiW(LPCUWSTR String1,LPCUWSTR String2) {
78 if(WSTR_ALIGNED(String1) && WSTR_ALIGNED(String2))
79 return lstrcmpiW((LPCWSTR)String1,(LPCWSTR)String2);
80 return uaw_lstrcmpiW(String1,String2);
81 }
82 #endif
83
84 #ifdef lstrlen
85 __CRT_INLINE int ua_lstrlenW(LPCUWSTR String) {
86 if(WSTR_ALIGNED(String)) return lstrlenW((PCWSTR)String);
87 return uaw_lstrlenW(String);
88 }
89 #endif
90 #endif /* !__CRT__NO_INLINE */
91
92 #if defined(_WSTRING_DEFINED)
93 #ifdef _WConst_return
94 typedef _WConst_return WCHAR UNALIGNED *PUWSTR_C;
95 #else
96 typedef WCHAR UNALIGNED *PUWSTR_C;
97 #endif
98
99 PUWSTR_C ua_wcschr(PCUWSTR String,WCHAR Character);
100 PUWSTR_C ua_wcsrchr(PCUWSTR String,WCHAR Character);
101 #if defined(__cplusplus) && defined(_WConst_Return)
102 PUWSTR ua_wcschr(PUWSTR String,WCHAR Character);
103 PUWSTR ua_wcsrchr(PUWSTR String,WCHAR Character);
104 #endif
105 PUWSTR ua_wcscpy(PUWSTR Destination,PCUWSTR Source);
106 size_t ua_wcslen(PCUWSTR String);
107
108 #ifndef __CRT__NO_INLINE
109 __CRT_INLINE PUWSTR_C ua_wcschr(PCUWSTR String,WCHAR Character) {
110 if(WSTR_ALIGNED(String)) return wcschr((PCWSTR)String,Character);
111 return (PUWSTR_C)uaw_wcschr(String,Character);
112 }
113 __CRT_INLINE PUWSTR_C ua_wcsrchr(PCUWSTR String,WCHAR Character) {
114 if(WSTR_ALIGNED(String)) return wcsrchr((PCWSTR)String,Character);
115 return (PUWSTR_C)uaw_wcsrchr(String,Character);
116 }
117 #if defined(__cplusplus) && defined(_WConst_Return)
118 __CRT_INLINE PUWSTR ua_wcschr(PUWSTR String,WCHAR Character) {
119 if(WSTR_ALIGNED(String)) return wcscpy((PWSTR)Destination,(PCWSTR)Source);
120 return uaw_wcscpy(Destination,Source);
121 }
122 __CRT_INLINE PUWSTR ua_wcsrchr(PUWSTR String,WCHAR Character) {
123 if(WSTR_ALIGNED(String)) return wcsrchr(String,Character);
124 return uaw_wcsrchr((PCUWSTR)String,Character);
125 }
126 #endif
127
128 __CRT_INLINE PUWSTR ua_wcscpy(PUWSTR Destination,PCUWSTR Source) {
129 if(WSTR_ALIGNED(Source) && WSTR_ALIGNED(Destination))
130 return wcscpy((PWSTR)Destination,(PCWSTR)Source);
131 return uaw_wcscpy(Destination,Source);
132 }
133 __CRT_INLINE size_t ua_wcslen(PCUWSTR String) {
134 if(WSTR_ALIGNED(String)) return wcslen((PCWSTR)String);
135 return uaw_wcslen(String);
136 }
137 #endif /* !__CRT__NO_INLINE */
138 #endif
139 int ua_wcsicmp(LPCUWSTR String1,LPCUWSTR String2);
140
141 #ifndef __CRT__NO_INLINE
142 __CRT_INLINE int ua_wcsicmp(LPCUWSTR String1,LPCUWSTR String2) {
143 if(WSTR_ALIGNED(String1) && WSTR_ALIGNED(String2))
144 return _wcsicmp((LPCWSTR)String1,(LPCWSTR)String2);
145 return uaw_wcsicmp(String1,String2);
146 }
147 #endif /* !__CRT__NO_INLINE */
148 #endif
149
150 #ifndef __UA_WCSLEN
151 #define __UA_WCSLEN ua_wcslen
152 #endif
153
154 #define __UA_WSTRSIZE(s) ((__UA_WCSLEN(s)+1)*sizeof(WCHAR))
155 #define __UA_STACKCOPY(p,s) memcpy(_alloca(s),p,s)
156
157 #ifdef I_X86_
158 #define WSTR_ALIGNED_STACK_COPY(d,s) (*(d) = (PCWSTR)(s))
159 #else
160 #define WSTR_ALIGNED_STACK_COPY(d,s) { PCUWSTR __ua_src; ULONG __ua_size; PWSTR __ua_dst; __ua_src = (s); if(WSTR_ALIGNED(__ua_src)) { __ua_dst = (PWSTR)__ua_src; } else { __ua_size = __UA_WSTRSIZE(__ua_src); __ua_dst = (PWSTR)_alloca(__ua_size); memcpy(__ua_dst,__ua_src,__ua_size); } *(d) = (PCWSTR)__ua_dst; }
161 #endif
162
163 #define ASTR_ALIGNED_STACK_COPY(d,s) (*(d) = (PCSTR)(s))
164
165 #ifndef I_X86_
166 #define __UA_STRUC_ALIGNED(t,s) (((DWORD_PTR)(s) & (TYPE_ALIGNMENT(t)-1))==0)
167 #define STRUC_ALIGNED_STACK_COPY(t,s) __UA_STRUC_ALIGNED(t,s) ? ((t const *)(s)) : ((t const *)__UA_STACKCOPY((s),sizeof(t)))
168 #else
169 #define STRUC_ALIGNED_STACK_COPY(t,s) ((CONST t *)(s))
170 #endif
171
172 #ifdef UNICODE
173 #define TSTR_ALIGNED_STACK_COPY(d,s) WSTR_ALIGNED_STACK_COPY(d,s)
174 #define TSTR_ALIGNED(x) WSTR_ALIGNED(x)
175 #define ua_CharUpper ua_CharUpperW
176 #define ua_lstrcmp ua_lstrcmpW
177 #define ua_lstrcmpi ua_lstrcmpiW
178 #define ua_lstrlen ua_lstrlenW
179 #define ua_tcscpy ua_wcscpy
180 #else
181 #define TSTR_ALIGNED_STACK_COPY(d,s) ASTR_ALIGNED_STACK_COPY(d,s)
182 #define TSTR_ALIGNED(x) TRUE
183 #define ua_CharUpper CharUpperA
184 #define ua_lstrcmp lstrcmpA
185 #define ua_lstrcmpi lstrcmpiA
186 #define ua_lstrlen lstrlenA
187 #define ua_tcscpy strcpy
188 #endif
189
190 #ifdef __cplusplus
191 }
192 #endif
193
194 #include <sec_api/stralign_s.h>
195 #endif