Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita1a1c6a

Browse files
committed
Remove DWORD
1 parent7d18991 commita1a1c6a

File tree

15 files changed

+90
-105
lines changed

15 files changed

+90
-105
lines changed

‎std/src/process/tests.rs‎

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -385,29 +385,25 @@ fn test_interior_nul_in_env_value_is_error() {
385385
#[cfg(windows)]
386386
fntest_creation_flags(){
387387
usecrate::os::windows::process::CommandExt;
388-
usecrate::sys::c::{BOOL,DWORD,INFINITE};
388+
usecrate::sys::c::{BOOL,INFINITE};
389389
#[repr(C)]
390390
structDEBUG_EVENT{
391-
pubevent_code:DWORD,
392-
pubprocess_id:DWORD,
393-
pubthread_id:DWORD,
391+
pubevent_code:u32,
392+
pubprocess_id:u32,
393+
pubthread_id:u32,
394394
// This is a union in the real struct, but we don't
395395
// need this data for the purposes of this test.
396396
pub_junk:[u8;164],
397397
}
398398

399399
extern"system"{
400-
fnWaitForDebugEvent(lpDebugEvent:*mutDEBUG_EVENT,dwMilliseconds:DWORD) ->BOOL;
401-
fnContinueDebugEvent(
402-
dwProcessId:DWORD,
403-
dwThreadId:DWORD,
404-
dwContinueStatus:DWORD,
405-
) ->BOOL;
400+
fnWaitForDebugEvent(lpDebugEvent:*mutDEBUG_EVENT,dwMilliseconds:u32) ->BOOL;
401+
fnContinueDebugEvent(dwProcessId:u32,dwThreadId:u32,dwContinueStatus:u32) ->BOOL;
406402
}
407403

408-
constDEBUG_PROCESS:DWORD =1;
409-
constEXIT_PROCESS_DEBUG_EVENT:DWORD =5;
410-
constDBG_EXCEPTION_NOT_HANDLED:DWORD =0x80010001;
404+
constDEBUG_PROCESS:u32 =1;
405+
constEXIT_PROCESS_DEBUG_EVENT:u32 =5;
406+
constDBG_EXCEPTION_NOT_HANDLED:u32 =0x80010001;
411407

412408
letmut child =
413409
Command::new("cmd").creation_flags(DEBUG_PROCESS).stdin(Stdio::piped()).spawn().unwrap();

‎std/src/sys/pal/windows/alloc.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ mod tests;
1515
// See https://docs.microsoft.com/windows/win32/api/heapapi/
1616

1717
// Flag to indicate that the memory returned by `HeapAlloc` should be zeroed.
18-
constHEAP_ZERO_MEMORY:c::DWORD =0x00000008;
18+
constHEAP_ZERO_MEMORY:u32 =0x00000008;
1919

2020
// Get a handle to the default heap of the current process, or null if the operation fails.
2121
//
@@ -113,7 +113,7 @@ fn init_or_get_process_heap() -> c::HANDLE {
113113
#[cold]
114114
extern"C"fnprocess_heap_init_and_alloc(
115115
_heap:MaybeUninit<c::HANDLE>,// We pass this argument to match the ABI of `HeapAlloc`
116-
flags:c::DWORD,
116+
flags:u32,
117117
dwBytes:usize,
118118
) ->*mutc_void{
119119
let heap =init_or_get_process_heap();
@@ -127,7 +127,7 @@ extern "C" fn process_heap_init_and_alloc(
127127
#[inline(never)]
128128
fnprocess_heap_alloc(
129129
_heap:MaybeUninit<c::HANDLE>,// We pass this argument to match the ABI of `HeapAlloc`,
130-
flags:c::DWORD,
130+
flags:u32,
131131
dwBytes:usize,
132132
) ->*mutc_void{
133133
let heap =HEAP.load(Ordering::Relaxed);

‎std/src/sys/pal/windows/c.rs‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ pub(super) mod windows_targets;
1717
mod windows_sys;
1818
pubuse windows_sys::*;
1919

20-
pubtypeDWORD =c_ulong;
2120
pubtypeWCHAR =u16;
2221

2322
pubtypesocklen_t =c_int;
@@ -316,13 +315,13 @@ compat_fn_with_fallback! {
316315
// >= Win10 1607
317316
// https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setthreaddescription
318317
pubfnSetThreadDescription(hthread:HANDLE, lpthreaddescription:PCWSTR) ->HRESULT{
319-
SetLastError(ERROR_CALL_NOT_IMPLEMENTEDasDWORD);E_NOTIMPL
318+
SetLastError(ERROR_CALL_NOT_IMPLEMENTEDasu32);E_NOTIMPL
320319
}
321320

322321
// >= Win10 1607
323322
// https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getthreaddescription
324323
pubfnGetThreadDescription(hthread:HANDLE, lpthreaddescription:*mutPWSTR) ->HRESULT{
325-
SetLastError(ERROR_CALL_NOT_IMPLEMENTEDasDWORD);E_NOTIMPL
324+
SetLastError(ERROR_CALL_NOT_IMPLEMENTEDasu32);E_NOTIMPL
326325
}
327326

328327
// >= Win8 / Server 2012
@@ -383,9 +382,9 @@ compat_fn_with_fallback! {
383382
#[cfg(target_vendor ="win7")]
384383
pubfnNtCreateKeyedEvent(
385384
KeyedEventHandle:*mutHANDLE,
386-
DesiredAccess:DWORD,
385+
DesiredAccess:u32,
387386
ObjectAttributes:*mut c_void,
388-
Flags:ULONG
387+
Flags:u32
389388
) ->NTSTATUS{
390389
panic!("keyed events not available")
391390
}
@@ -433,9 +432,9 @@ compat_fn_with_fallback! {
433432
apccontext:*mut c_void,
434433
iostatusblock:&mutIO_STATUS_BLOCK,
435434
buffer:*mutcrate::mem::MaybeUninit<u8>,
436-
length:ULONG,
435+
length:u32,
437436
byteoffset:Option<&i64>,
438-
key:Option<&ULONG>
437+
key:Option<&u32>
439438
) ->NTSTATUS{
440439
STATUS_NOT_IMPLEMENTED
441440
}
@@ -447,9 +446,9 @@ compat_fn_with_fallback! {
447446
apccontext:*mut c_void,
448447
iostatusblock:&mutIO_STATUS_BLOCK,
449448
buffer:*constu8,
450-
length:ULONG,
449+
length:u32,
451450
byteoffset:Option<&i64>,
452-
key:Option<&ULONG>
451+
key:Option<&u32>
453452
) ->NTSTATUS{
454453
STATUS_NOT_IMPLEMENTED
455454
}

‎std/src/sys/pal/windows/fs.rs‎

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,21 @@ pub struct File {
2828

2929
#[derive(Clone)]
3030
pubstructFileAttr{
31-
attributes:c::DWORD,
31+
attributes:u32,
3232
creation_time: c::FILETIME,
3333
last_access_time: c::FILETIME,
3434
last_write_time: c::FILETIME,
3535
file_size:u64,
36-
reparse_tag:c::DWORD,
36+
reparse_tag:u32,
3737
volume_serial_number:Option<u32>,
3838
number_of_links:Option<u32>,
3939
file_index:Option<u64>,
4040
}
4141

4242
#[derive(Copy,Clone,PartialEq,Eq,Hash,Debug)]
4343
pubstructFileType{
44-
attributes:c::DWORD,
45-
reparse_tag:c::DWORD,
44+
attributes:u32,
45+
reparse_tag:u32,
4646
}
4747

4848
pubstructReadDir{
@@ -75,16 +75,16 @@ pub struct OpenOptions {
7575
create_new:bool,
7676
// system-specific
7777
custom_flags:u32,
78-
access_mode:Option<c::DWORD>,
79-
attributes:c::DWORD,
80-
share_mode:c::DWORD,
81-
security_qos_flags:c::DWORD,
78+
access_mode:Option<u32>,
79+
attributes:u32,
80+
share_mode:u32,
81+
security_qos_flags:u32,
8282
security_attributes:*mut c::SECURITY_ATTRIBUTES,
8383
}
8484

8585
#[derive(Clone,PartialEq,Eq,Debug)]
8686
pubstructFilePermissions{
87-
attrs:c::DWORD,
87+
attrs:u32,
8888
}
8989

9090
#[derive(Copy,Clone,Debug,Default)]
@@ -245,7 +245,7 @@ impl OpenOptions {
245245
self.security_attributes = attrs;
246246
}
247247

248-
fnget_access_mode(&self) -> io::Result<c::DWORD>{
248+
fnget_access_mode(&self) -> io::Result<u32>{
249249
match(self.read,self.write,self.append,self.access_mode){
250250
(..,Some(mode)) =>Ok(mode),
251251
(true,false,false,None) =>Ok(c::GENERIC_READ),
@@ -261,7 +261,7 @@ impl OpenOptions {
261261
}
262262
}
263263

264-
fnget_creation_mode(&self) -> io::Result<c::DWORD>{
264+
fnget_creation_mode(&self) -> io::Result<u32>{
265265
match(self.write,self.append){
266266
(true,false) =>{}
267267
(false,false) =>{
@@ -287,7 +287,7 @@ impl OpenOptions {
287287
})
288288
}
289289

290-
fnget_flags_and_attributes(&self) ->c::DWORD{
290+
fnget_flags_and_attributes(&self) ->u32{
291291
self.custom_flags
292292
|self.attributes
293293
|self.security_qos_flags
@@ -397,21 +397,21 @@ impl File {
397397
self.handle.as_raw_handle(),
398398
c::FileBasicInfo,
399399
core::ptr::addr_of_mut!(info)as*mutc_void,
400-
sizeasc::DWORD,
400+
sizeasu32,
401401
))?;
402402
letmut attr =FileAttr{
403403
attributes: info.FileAttributes,
404404
creation_time: c::FILETIME{
405-
dwLowDateTime: info.CreationTimeasc::DWORD,
406-
dwHighDateTime:(info.CreationTime >>32)asc::DWORD,
405+
dwLowDateTime: info.CreationTimeasu32,
406+
dwHighDateTime:(info.CreationTime >>32)asu32,
407407
},
408408
last_access_time: c::FILETIME{
409-
dwLowDateTime: info.LastAccessTimeasc::DWORD,
410-
dwHighDateTime:(info.LastAccessTime >>32)asc::DWORD,
409+
dwLowDateTime: info.LastAccessTimeasu32,
410+
dwHighDateTime:(info.LastAccessTime >>32)asu32,
411411
},
412412
last_write_time: c::FILETIME{
413-
dwLowDateTime: info.LastWriteTimeasc::DWORD,
414-
dwHighDateTime:(info.LastWriteTime >>32)asc::DWORD,
413+
dwLowDateTime: info.LastWriteTimeasu32,
414+
dwHighDateTime:(info.LastWriteTime >>32)asu32,
415415
},
416416
file_size:0,
417417
reparse_tag:0,
@@ -425,7 +425,7 @@ impl File {
425425
self.handle.as_raw_handle(),
426426
c::FileStandardInfo,
427427
core::ptr::addr_of_mut!(info)as*mutc_void,
428-
sizeasc::DWORD,
428+
sizeasu32,
429429
))?;
430430
attr.file_size = info.AllocationSizeasu64;
431431
attr.number_of_links =Some(info.NumberOfLinks);
@@ -511,7 +511,7 @@ impl File {
511511
fnreparse_point(
512512
&self,
513513
space:&mutAlign8<[MaybeUninit<u8>]>,
514-
) -> io::Result<(c::DWORD,*mut c::REPARSE_DATA_BUFFER)>{
514+
) -> io::Result<(u32,*mut c::REPARSE_DATA_BUFFER)>{
515515
unsafe{
516516
letmut bytes =0;
517517
cvt({
@@ -524,7 +524,7 @@ impl File {
524524
ptr::null_mut(),
525525
0,
526526
space.0.as_mut_ptr().cast(),
527-
lenasc::DWORD,
527+
lenasu32,
528528
&mut bytes,
529529
ptr::null_mut(),
530530
)
@@ -609,8 +609,7 @@ impl File {
609609
"Cannot set file timestamp to 0",
610610
));
611611
}
612-
let is_max =
613-
|t: c::FILETIME| t.dwLowDateTime == c::DWORD::MAX && t.dwHighDateTime == c::DWORD::MAX;
612+
let is_max = |t: c::FILETIME| t.dwLowDateTime == u32::MAX && t.dwHighDateTime == u32::MAX;
614613
if times.accessed.map_or(false, is_max)
615614
|| times.modified.map_or(false, is_max)
616615
|| times.created.map_or(false, is_max)
@@ -641,7 +640,7 @@ impl File {
641640
self.handle.as_raw_handle(),
642641
c::FileBasicInfo,
643642
core::ptr::addr_of_mut!(info)as*mutc_void,
644-
sizeasc::DWORD,
643+
sizeasu32,
645644
))?;
646645
Ok(info)
647646
}
@@ -1020,7 +1019,7 @@ impl FileTimes {
10201019
}
10211020

10221021
implFileType{
1023-
fnnew(attrs:c::DWORD,reparse_tag:c::DWORD) ->FileType{
1022+
fnnew(attrs:u32,reparse_tag:u32) ->FileType{
10241023
FileType{attributes: attrs, reparse_tag}
10251024
}
10261025
pubfnis_dir(&self) ->bool{
@@ -1421,12 +1420,12 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
14211420
_TotalBytesTransferred:i64,
14221421
_StreamSize:i64,
14231422
StreamBytesTransferred:i64,
1424-
dwStreamNumber:c::DWORD,
1425-
_dwCallbackReason:c::DWORD,
1423+
dwStreamNumber:u32,
1424+
_dwCallbackReason:u32,
14261425
_hSourceFile: c::HANDLE,
14271426
_hDestinationFile: c::HANDLE,
14281427
lpData:*constc_void,
1429-
) ->c::DWORD{
1428+
) ->u32{
14301429
if dwStreamNumber ==1{
14311430
*(lpDataas*muti64) =StreamBytesTransferred;
14321431
}

‎std/src/sys/pal/windows/handle.rs‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl Handle {
141141
buf:&mut[u8],
142142
overlapped:*mut c::OVERLAPPED,
143143
) -> io::Result<Option<usize>>{
144-
let len = cmp::min(buf.len(),<c::DWORD>::MAXasusize)asc::DWORD;
144+
let len = cmp::min(buf.len(),u32::MAXasusize)asu32;
145145
letmut amt =0;
146146
let res =
147147
cvt(c::ReadFile(self.as_raw_handle(), buf.as_mut_ptr(), len,&mut amt, overlapped));
@@ -209,12 +209,7 @@ impl Handle {
209209
Ok(Self(self.0.try_clone()?))
210210
}
211211

212-
pubfnduplicate(
213-
&self,
214-
access: c::DWORD,
215-
inherit:bool,
216-
options: c::DWORD,
217-
) -> io::Result<Self>{
212+
pubfnduplicate(&self,access:u32,inherit:bool,options:u32) -> io::Result<Self>{
218213
Ok(Self(self.0.as_handle().duplicate(access, inherit, options)?))
219214
}
220215

@@ -233,7 +228,7 @@ impl Handle {
233228
letmut io_status = c::IO_STATUS_BLOCK::PENDING;
234229

235230
// The length is clamped at u32::MAX.
236-
let len = cmp::min(len,c::DWORD::MAXasusize)asc::DWORD;
231+
let len = cmp::min(len,u32::MAXasusize)asu32;
237232
let status = c::NtReadFile(
238233
self.as_handle(),
239234
ptr::null_mut(),
@@ -281,7 +276,7 @@ impl Handle {
281276
letmut io_status = c::IO_STATUS_BLOCK::PENDING;
282277

283278
// The length is clamped at u32::MAX.
284-
let len = cmp::min(buf.len(),c::DWORD::MAXasusize)asc::DWORD;
279+
let len = cmp::min(buf.len(),u32::MAXasusize)asu32;
285280
let status =unsafe{
286281
c::NtWriteFile(
287282
self.as_handle(),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp