Skip to content

Commit 8073aa8

Browse files
committed
inc: winapi: Use clng() etc. instead of __LONG32 casts
Using clng() directly is probably cleaner; and as far as the fbfrog-based translation goes, expanding the __LONG32 macro allows fbfrog to parse the #defines easier. That in turn allowed the auto-translation of the 3 changed #defines in winerror.bi; the additional culng()'s are then added automatically around 32bit uint math operations (see also d26035a). (cherry picked from commit dec5df4)
1 parent c25c05c commit 8073aa8

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

inc/win/basetsd.bi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ type PDWORD32 as ulong ptr
169169
#define PtrToShort(p) cshort(cast(LONG_PTR, (p)))
170170
#define IntToPtr(i) cptr(VOID ptr, cast(INT_PTR, clng(i)))
171171
#define UIntToPtr(ui) cptr(VOID ptr, cast(UINT_PTR, culng(ui)))
172-
#define LongToPtr(l) cptr(VOID ptr, cast(LONG_PTR, cast(__LONG32, l)))
172+
#define LongToPtr(l) cptr(VOID ptr, cast(LONG_PTR, clng(l)))
173173
#define ULongToPtr(ul) cptr(VOID ptr, cast(ULONG_PTR, culng(ul)))
174174

175175
private function PtrToPtr64(byval p as const any ptr) as any ptr

inc/win/vfw.bi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ const MCIWNDF_NOOPEN = &h8000
10411041
#define MCIWndGetStart(hwnd) cast(LONG, MCIWndSM(hwnd, MCIWNDM_GETSTART, cast(WPARAM, 0), cast(LPARAM, 0)))
10421042
#define MCIWndGetLength(hwnd) cast(LONG, MCIWndSM(hwnd, MCIWNDM_GETLENGTH, cast(WPARAM, 0), cast(LPARAM, 0)))
10431043
#define MCIWndGetEnd(hwnd) cast(LONG, MCIWndSM(hwnd, MCIWNDM_GETEND, cast(WPARAM, 0), cast(LPARAM, 0)))
1044-
#define MCIWndStep(hwnd, n) cast(LONG, MCIWndSM(hwnd, MCI_STEP, cast(WPARAM, 0), cast(LPARAM, cast(__LONG32, (n)))))
1044+
#define MCIWndStep(hwnd, n) cast(LONG, MCIWndSM(hwnd, MCI_STEP, cast(WPARAM, 0), cast(LPARAM, clng((n)))))
10451045
#define MCIWndDestroy(hwnd) MCIWndSM(hwnd, WM_CLOSE, cast(WPARAM, 0), cast(LPARAM, 0))
10461046
#define MCIWndSetZoom(hwnd, iZoom) MCIWndSM(hwnd, MCIWNDM_SETZOOM, cast(WPARAM, 0), cast(LPARAM, cast(UINT, (iZoom))))
10471047
#define MCIWndGetZoom(hwnd) cast(UINT, MCIWndSM(hwnd, MCIWNDM_GETZOOM, cast(WPARAM, 0), cast(LPARAM, 0)))

inc/win/winerror.bi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1891,15 +1891,15 @@ const SEVERITY_SUCCESS = 0
18911891
const SEVERITY_ERROR = 1
18921892
#define SUCCEEDED(hr) (cast(HRESULT, (hr)) >= 0)
18931893
#define FAILED(hr) (cast(HRESULT, (hr)) < 0)
1894-
#define IS_ERROR(Status) ((culng(Status) shr 31) = SEVERITY_ERROR)
1894+
#define IS_ERROR(Status) (culng(culng((Status)) shr 31) = SEVERITY_ERROR)
18951895
#define HRESULT_CODE(hr) ((hr) and &hFFFF)
18961896
#define SCODE_CODE(sc) ((sc) and &hFFFF)
18971897
#define HRESULT_FACILITY(hr) (((hr) shr 16) and &h1fff)
18981898
#define SCODE_FACILITY(sc) (((sc) shr 16) and &h1fff)
18991899
#define HRESULT_SEVERITY(hr) (((hr) shr 31) and &h1)
19001900
#define SCODE_SEVERITY(sc) (((sc) shr 31) and &h1)
1901-
#define MAKE_HRESULT(sev, fac, code) cast(HRESULT, (culng(sev) shl 31) or (culng(fac) shl 16) or culng(code))
1902-
#define MAKE_SCODE(sev, fac, code) cast(SCODE , (culng(sev) shl 31) or (culng(fac) shl 16) or culng(code))
1901+
#define MAKE_HRESULT(sev, fac, code) cast(HRESULT, culng(culng(culng(culng((sev)) shl 31) or culng(culng((fac)) shl 16)) or culng((code))))
1902+
#define MAKE_SCODE(sev, fac, code) cast(SCODE, culng(culng(culng(culng((sev)) shl 31) or culng(culng((fac)) shl 16)) or culng((code))))
19031903
const FACILITY_NT_BIT = &h10000000
19041904
#define __HRESULT_FROM_WIN32(x) iif(cast(HRESULT, (x)) <= 0, cast(HRESULT, (x)), cast(HRESULT, (((x) and &h0000FFFF) or (FACILITY_WIN32 shl 16)) or &h80000000))
19051905
#define HRESULT_FROM_WIN32(x) __HRESULT_FROM_WIN32(x)

inc/win/winsock.bi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ const IOC_OUT = &h40000000
184184
const IOC_IN = &h80000000
185185
#define IOC_INOUT (IOC_IN or IOC_OUT)
186186
#define _IO(x, y) ((IOC_VOID or ((x) shl 8)) or (y))
187-
#define _IOR(x, y, t) (((IOC_OUT or ((cast(__LONG32, sizeof((t))) and IOCPARM_MASK) shl 16)) or ((x) shl 8)) or (y))
188-
#define _IOW(x, y, t) (((IOC_IN or ((cast(__LONG32, sizeof((t))) and IOCPARM_MASK) shl 16)) or ((x) shl 8)) or (y))
187+
#define _IOR(x, y, t) (((IOC_OUT or ((clng(sizeof((t))) and IOCPARM_MASK) shl 16)) or ((x) shl 8)) or (y))
188+
#define _IOW(x, y, t) (((IOC_IN or ((clng(sizeof((t))) and IOCPARM_MASK) shl 16)) or ((x) shl 8)) or (y))
189189
#define FIONREAD _IOR(asc("f"), 127, u_long)
190190
#define FIONBIO _IOW(asc("f"), 126, u_long)
191191
#define FIOASYNC _IOW(asc("f"), 125, u_long)
@@ -233,17 +233,17 @@ const IPPORT_RESERVED = 1024
233233
const IMPLINK_IP = 155
234234
const IMPLINK_LOWEXPER = 156
235235
const IMPLINK_HIGHEXPER = 158
236-
#define IN_CLASSA(i) ((cast(__LONG32, (i)) and &h80000000) = 0)
236+
#define IN_CLASSA(i) ((clng((i)) and &h80000000) = 0)
237237
const IN_CLASSA_NET = &hff000000
238238
const IN_CLASSA_NSHIFT = 24
239239
const IN_CLASSA_HOST = &h00ffffff
240240
const IN_CLASSA_MAX = 128
241-
#define IN_CLASSB(i) ((cast(__LONG32, (i)) and &hc0000000) = &h80000000)
241+
#define IN_CLASSB(i) ((clng((i)) and &hc0000000) = &h80000000)
242242
const IN_CLASSB_NET = &hffff0000
243243
const IN_CLASSB_NSHIFT = 16
244244
const IN_CLASSB_HOST = &h0000ffff
245245
const IN_CLASSB_MAX = 65536
246-
#define IN_CLASSC(i) ((cast(__LONG32, (i)) and &he0000000) = &hc0000000)
246+
#define IN_CLASSC(i) ((clng((i)) and &he0000000) = &hc0000000)
247247
const IN_CLASSC_NET = &hffffff00
248248
const IN_CLASSC_NSHIFT = 8
249249
const IN_CLASSC_HOST = &h000000ff

inc/win/winsock2.bi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ const IOC_OUT = &h40000000
181181
const IOC_IN = &h80000000
182182
#define IOC_INOUT (IOC_IN or IOC_OUT)
183183
#define _IO(x, y) ((IOC_VOID or ((x) shl 8)) or (y))
184-
#define _IOR(x, y, t) (((IOC_OUT or ((cast(__LONG32, sizeof((t))) and IOCPARM_MASK) shl 16)) or ((x) shl 8)) or (y))
185-
#define _IOW(x, y, t) (((IOC_IN or ((cast(__LONG32, sizeof((t))) and IOCPARM_MASK) shl 16)) or ((x) shl 8)) or (y))
184+
#define _IOR(x, y, t) (((IOC_OUT or ((clng(sizeof((t))) and IOCPARM_MASK) shl 16)) or ((x) shl 8)) or (y))
185+
#define _IOW(x, y, t) (((IOC_IN or ((clng(sizeof((t))) and IOCPARM_MASK) shl 16)) or ((x) shl 8)) or (y))
186186
#define FIONREAD _IOR(asc("f"), 127, u_long)
187187
#define FIONBIO _IOW(asc("f"), 126, u_long)
188188
#define FIOASYNC _IOW(asc("f"), 125, u_long)
@@ -241,21 +241,21 @@ const IPPORT_RESERVED = 1024
241241
const IMPLINK_IP = 155
242242
const IMPLINK_LOWEXPER = 156
243243
const IMPLINK_HIGHEXPER = 158
244-
#define IN_CLASSA(i) ((cast(__LONG32, (i)) and &h80000000) = 0)
244+
#define IN_CLASSA(i) ((clng((i)) and &h80000000) = 0)
245245
const IN_CLASSA_NET = &hff000000
246246
const IN_CLASSA_NSHIFT = 24
247247
const IN_CLASSA_HOST = &h00ffffff
248248
const IN_CLASSA_MAX = 128
249-
#define IN_CLASSB(i) ((cast(__LONG32, (i)) and &hc0000000) = &h80000000)
249+
#define IN_CLASSB(i) ((clng((i)) and &hc0000000) = &h80000000)
250250
const IN_CLASSB_NET = &hffff0000
251251
const IN_CLASSB_NSHIFT = 16
252252
const IN_CLASSB_HOST = &h0000ffff
253253
const IN_CLASSB_MAX = 65536
254-
#define IN_CLASSC(i) ((cast(__LONG32, (i)) and &he0000000) = &hc0000000)
254+
#define IN_CLASSC(i) ((clng((i)) and &he0000000) = &hc0000000)
255255
const IN_CLASSC_NET = &hffffff00
256256
const IN_CLASSC_NSHIFT = 8
257257
const IN_CLASSC_HOST = &h000000ff
258-
#define IN_CLASSD(i) ((cast(__LONG32, (i)) and &hf0000000) = &he0000000)
258+
#define IN_CLASSD(i) ((clng((i)) and &hf0000000) = &he0000000)
259259
const IN_CLASSD_NET = &hf0000000
260260
const IN_CLASSD_NSHIFT = 28
261261
const IN_CLASSD_HOST = &h0fffffff

0 commit comments

Comments
 (0)