@@ -129,7 +129,7 @@ libc_bitflags!{
129
129
#[ cfg( any( target_os = "dragonfly" , target_os = "freebsd" , target_os = "netbsd" , target_os = "openbsd" ) ) ]
130
130
MAP_HASSEMAPHORE ;
131
131
/// Region grows down, like a stack.
132
- #[ cfg( any( target_os = "android" , target_os = "dragonfly" , target_os = "freebsd" , target_os = "linux" ) ) ]
132
+ #[ cfg( any( target_os = "android" , target_os = "dragonfly" , target_os = "freebsd" , target_os = "linux" , target_os = "openbsd" ) ) ]
133
133
MAP_STACK ;
134
134
/// Pages in this mapping are not retained in the kernel's memory cache.
135
135
#[ cfg( any( target_os = "ios" , target_os = "macos" ) ) ]
@@ -139,14 +139,22 @@ libc_bitflags!{
139
139
}
140
140
}
141
141
142
- #[ cfg( target_os = "linux" ) ]
142
+ #[ cfg( any ( target_os = "linux" , target_os = "netbsd" ) ) ]
143
143
libc_bitflags ! {
144
144
/// Options for `mremap()`.
145
145
pub struct MRemapFlags : c_int {
146
146
/// Permit the kernel to relocate the mapping to a new virtual address, if necessary.
147
+ #[ cfg( target_os = "linux" ) ]
147
148
MREMAP_MAYMOVE ;
148
149
/// Place the mapping at exactly the address specified in `new_address`.
150
+ #[ cfg( target_os = "linux" ) ]
149
151
MREMAP_FIXED ;
152
+ /// Permits to use the old and new address as hints to relocate the mapping.
153
+ #[ cfg( target_os = "netbsd" ) ]
154
+ MAP_FIXED ;
155
+ /// Allows to duplicate the mapping to be able to apply different flags on the copy.
156
+ #[ cfg( target_os = "netbsd" ) ]
157
+ MAP_REMAPDUP ;
150
158
}
151
159
}
152
160
@@ -334,15 +342,24 @@ pub unsafe fn mmap(addr: *mut c_void, length: size_t, prot: ProtFlags, flags: Ma
334
342
///
335
343
/// See the `mremap(2)` [man page](https://man7.org/linux/man-pages/man2/mremap.2.html) for
336
344
/// detailed requirements.
337
- #[ cfg( target_os = "linux" ) ]
345
+ #[ cfg( any ( target_os = "linux" , target_os = "netbsd" ) ) ]
338
346
pub unsafe fn mremap (
339
347
addr : * mut c_void ,
340
348
old_size : size_t ,
341
349
new_size : size_t ,
342
350
flags : MRemapFlags ,
343
351
new_address : Option < * mut c_void > ,
344
352
) -> Result < * mut c_void > {
353
+ #[ cfg( target_os = "linux" ) ]
345
354
let ret = libc:: mremap ( addr, old_size, new_size, flags. bits ( ) , new_address. unwrap_or ( std:: ptr:: null_mut ( ) ) ) ;
355
+ #[ cfg( target_os = "netbsd" ) ]
356
+ let ret = libc:: mremap (
357
+ addr,
358
+ old_size,
359
+ new_address. unwrap_or ( std:: ptr:: null_mut ( ) ) ,
360
+ new_size,
361
+ flags. bits ( ) ,
362
+ ) ;
346
363
347
364
if ret == libc:: MAP_FAILED {
348
365
Err ( Error :: from ( Errno :: last ( ) ) )
0 commit comments