@@ -79,7 +79,7 @@ fn fill_charp_buf(f: fn(*mut c_char, size_t) -> bool)
79
79
}
80
80
}
81
81
82
- #[ cfg( target_os = "win32" ) ]
82
+ #[ cfg( windows ) ]
83
83
mod win32 {
84
84
import dword = libc : : types:: os:: arch:: extra:: DWORD ;
85
85
@@ -200,9 +200,7 @@ mod global_env {
200
200
201
201
mod impl {
202
202
203
- #[ cfg( target_os = "linux") ]
204
- #[ cfg( target_os = "macos") ]
205
- #[ cfg( target_os = "freebsd") ]
203
+ #[ cfg( unix) ]
206
204
fn getenv( n: str ) -> option<str > unsafe {
207
205
let s = str :: as_c_str( n, libc:: getenv) ;
208
206
ret if unsafe :: reinterpret_cast( s) == 0 {
@@ -213,7 +211,7 @@ mod global_env {
213
211
} ;
214
212
}
215
213
216
- #[ cfg( target_os = "win32" ) ]
214
+ #[ cfg( windows ) ]
217
215
fn getenv( n: str ) -> option<str > unsafe {
218
216
import libc:: types:: os:: arch:: extra:: * ;
219
217
import libc:: funcs:: extra:: kernel32:: * ;
@@ -226,9 +224,7 @@ mod global_env {
226
224
}
227
225
228
226
229
- #[ cfg( target_os = "linux") ]
230
- #[ cfg( target_os = "macos") ]
231
- #[ cfg( target_os = "freebsd") ]
227
+ #[ cfg( unix) ]
232
228
fn setenv( n: str , v: str ) {
233
229
234
230
// FIXME: remove this when export globs work properly.
@@ -241,7 +237,7 @@ mod global_env {
241
237
}
242
238
243
239
244
- #[ cfg( target_os = "win32" ) ]
240
+ #[ cfg( windows ) ]
245
241
fn setenv( n: str , v: str ) {
246
242
// FIXME: remove imports when export globs work properly.
247
243
import libc:: funcs:: extra:: kernel32:: * ;
@@ -265,7 +261,7 @@ fn fdopen(fd: c_int) -> *FILE {
265
261
266
262
// fsync related
267
263
268
- #[ cfg( target_os = "win32" ) ]
264
+ #[ cfg( windows ) ]
269
265
fn fsync_fd( fd: c_int, _level: io:: fsync:: level) -> c_int {
270
266
import libc:: funcs:: extra:: msvcrt:: * ;
271
267
ret commit( fd) ;
@@ -305,14 +301,12 @@ fn fsync_fd(fd: c_int, _l: io::fsync::level) -> c_int {
305
301
}
306
302
307
303
308
- #[ cfg( target_os = "win32" ) ]
304
+ #[ cfg( windows ) ]
309
305
fn waitpid( pid: pid_t) -> c_int {
310
306
ret rustrt:: rust_process_wait( pid) ;
311
307
}
312
308
313
- #[ cfg( target_os = "linux") ]
314
- #[ cfg( target_os = "freebsd") ]
315
- #[ cfg( target_os = "macos") ]
309
+ #[ cfg( unix) ]
316
310
fn waitpid( pid: pid_t) -> c_int {
317
311
import libc:: funcs:: posix01:: wait:: * ;
318
312
let status = 0 as c_int;
@@ -323,9 +317,7 @@ fn waitpid(pid: pid_t) -> c_int {
323
317
}
324
318
325
319
326
- #[ cfg( target_os = "linux") ]
327
- #[ cfg( target_os = "freebsd") ]
328
- #[ cfg( target_os = "macos") ]
320
+ #[ cfg( unix) ]
329
321
fn pipe( ) -> { in : c_int, out: c_int} {
330
322
let fds = { mut in: 0 as c_int ,
331
323
mut out: 0 as c_int } ;
@@ -335,7 +327,7 @@ fn pipe() -> {in: c_int, out: c_int} {
335
327
336
328
337
329
338
- #[ cfg( target_os = "win32" ) ]
330
+ #[ cfg( windows ) ]
339
331
fn pipe ( ) -> { in: c_int, out: c_int} {
340
332
// FIXME: remove this when export globs work properly.
341
333
import libc:: consts:: os:: extra:: * ;
@@ -359,12 +351,10 @@ fn pipe() -> {in: c_int, out: c_int} {
359
351
fn dll_filename ( base : str ) -> str {
360
352
ret pre ( ) + base + dll_suffix ( ) ;
361
353
362
- #[ cfg( target_os = "macos" ) ]
363
- #[ cfg( target_os = "linux" ) ]
364
- #[ cfg( target_os = "freebsd" ) ]
354
+ #[ cfg( unix) ]
365
355
fn pre ( ) -> str { "lib" }
366
356
367
- #[ cfg( target_os = "win32" ) ]
357
+ #[ cfg( windows ) ]
368
358
fn pre ( ) -> str { "" }
369
359
}
370
360
@@ -405,7 +395,7 @@ fn self_exe_path() -> option<path> {
405
395
}
406
396
}
407
397
408
- #[ cfg( target_os = "win32" ) ]
398
+ #[ cfg( windows ) ]
409
399
fn load_self ( ) -> option < path > unsafe {
410
400
// FIXME: remove imports when export globs work properly.
411
401
import libc:: types:: os:: arch:: extra:: * ;
@@ -449,14 +439,12 @@ fn homedir() -> option<path> {
449
439
}
450
440
} ;
451
441
452
- #[ cfg( target_os = "linux" ) ]
453
- #[ cfg( target_os = "macos" ) ]
454
- #[ cfg( target_os = "freebsd" ) ]
442
+ #[ cfg( unix) ]
455
443
fn secondary ( ) -> option < path > {
456
444
none
457
445
}
458
446
459
- #[ cfg( target_os = "win32" ) ]
447
+ #[ cfg( windows ) ]
460
448
fn secondary ( ) -> option < path > {
461
449
option:: chain ( getenv ( "USERPROFILE" ) ) { |p|
462
450
if !str:: is_empty ( p) {
@@ -536,7 +524,7 @@ fn make_absolute(p: path) -> path {
536
524
fn make_dir ( p : path , mode : c_int ) -> bool {
537
525
ret mkdir ( p, mode) ;
538
526
539
- #[ cfg( target_os = "win32" ) ]
527
+ #[ cfg( windows ) ]
540
528
fn mkdir ( p : path , _mode : c_int ) -> bool unsafe {
541
529
// FIXME: remove imports when export globs work properly.
542
530
import libc:: types:: os:: arch:: extra:: * ;
@@ -549,9 +537,7 @@ fn make_dir(p: path, mode: c_int) -> bool {
549
537
}
550
538
}
551
539
552
- #[ cfg( target_os = "linux" ) ]
553
- #[ cfg( target_os = "macos" ) ]
554
- #[ cfg( target_os = "freebsd" ) ]
540
+ #[ cfg( unix) ]
555
541
fn mkdir ( p : path , mode : c_int ) -> bool {
556
542
as_c_charp ( p) { |c|
557
543
libc:: mkdir ( c, mode as mode_t ) == ( 0 as c_int )
@@ -562,12 +548,10 @@ fn make_dir(p: path, mode: c_int) -> bool {
562
548
#[ doc = "Lists the contents of a directory" ]
563
549
fn list_dir ( p : path ) -> [ str ] {
564
550
565
- #[ cfg( target_os = "linux" ) ]
566
- #[ cfg( target_os = "macos" ) ]
567
- #[ cfg( target_os = "freebsd" ) ]
551
+ #[ cfg( unix) ]
568
552
fn star ( p : str ) -> str { p }
569
553
570
- #[ cfg( target_os = "win32" ) ]
554
+ #[ cfg( windows ) ]
571
555
fn star ( p : str ) -> str {
572
556
let pl = str:: len ( p) ;
573
557
if pl == 0 u || ( p[ pl - 1 u] as char != path:: consts:: path_sep
@@ -602,7 +586,7 @@ fn list_dir_path(p: path) -> [str] {
602
586
fn remove_dir ( p : path ) -> bool {
603
587
ret rmdir ( p) ;
604
588
605
- #[ cfg( target_os = "win32" ) ]
589
+ #[ cfg( windows ) ]
606
590
fn rmdir ( p : path ) -> bool {
607
591
// FIXME: remove imports when export globs work properly.
608
592
import libc:: funcs:: extra:: kernel32:: * ;
@@ -613,9 +597,7 @@ fn remove_dir(p: path) -> bool {
613
597
} ;
614
598
}
615
599
616
- #[ cfg( target_os = "linux" ) ]
617
- #[ cfg( target_os = "macos" ) ]
618
- #[ cfg( target_os = "freebsd" ) ]
600
+ #[ cfg( unix) ]
619
601
fn rmdir ( p : path ) -> bool {
620
602
ret as_c_charp ( p) { |buf|
621
603
libc:: rmdir ( buf) == ( 0 as c_int )
@@ -626,7 +608,7 @@ fn remove_dir(p: path) -> bool {
626
608
fn change_dir ( p : path ) -> bool {
627
609
ret chdir ( p) ;
628
610
629
- #[ cfg( target_os = "win32" ) ]
611
+ #[ cfg( windows ) ]
630
612
fn chdir ( p : path ) -> bool {
631
613
// FIXME: remove imports when export globs work properly.
632
614
import libc:: funcs:: extra:: kernel32:: * ;
@@ -637,9 +619,7 @@ fn change_dir(p: path) -> bool {
637
619
} ;
638
620
}
639
621
640
- #[ cfg( target_os = "linux" ) ]
641
- #[ cfg( target_os = "macos" ) ]
642
- #[ cfg( target_os = "freebsd" ) ]
622
+ #[ cfg( unix) ]
643
623
fn chdir ( p : path ) -> bool {
644
624
ret as_c_charp ( p) { |buf|
645
625
libc:: chdir ( buf) == ( 0 as c_int )
@@ -651,7 +631,7 @@ fn change_dir(p: path) -> bool {
651
631
fn copy_file ( from : path , to : path ) -> bool {
652
632
ret do_copy_file ( from, to) ;
653
633
654
- #[ cfg( target_os = "win32" ) ]
634
+ #[ cfg( windows ) ]
655
635
fn do_copy_file ( from : path , to : path ) -> bool {
656
636
// FIXME: remove imports when export globs work properly.
657
637
import libc:: funcs:: extra:: kernel32:: * ;
@@ -664,9 +644,7 @@ fn copy_file(from: path, to: path) -> bool {
664
644
}
665
645
}
666
646
667
- #[ cfg( target_os = "linux" ) ]
668
- #[ cfg( target_os = "macos" ) ]
669
- #[ cfg( target_os = "freebsd" ) ]
647
+ #[ cfg( unix) ]
670
648
fn do_copy_file ( from : path , to : path ) -> bool unsafe {
671
649
let istream = as_c_charp ( from) { |fromp|
672
650
as_c_charp ( "rb" ) { |modebuf|
@@ -716,7 +694,7 @@ fn copy_file(from: path, to: path) -> bool {
716
694
fn remove_file ( p : path ) -> bool {
717
695
ret unlink ( p) ;
718
696
719
- #[ cfg( target_os = "win32" ) ]
697
+ #[ cfg( windows ) ]
720
698
fn unlink ( p : path ) -> bool {
721
699
// FIXME: remove imports when export globs work properly.
722
700
// (similar to Issue #2006)
@@ -728,9 +706,7 @@ fn remove_file(p: path) -> bool {
728
706
} ;
729
707
}
730
708
731
- #[ cfg( target_os = "linux" ) ]
732
- #[ cfg( target_os = "macos" ) ]
733
- #[ cfg( target_os = "freebsd" ) ]
709
+ #[ cfg( unix) ]
734
710
fn unlink ( p : path ) -> bool {
735
711
ret as_c_charp ( p) { |buf|
736
712
libc:: unlink ( buf) == ( 0 as c_int )
@@ -755,12 +731,10 @@ fn set_exit_status(code: int) {
755
731
rustrt:: rust_set_exit_status ( code as libc:: intptr_t ) ;
756
732
}
757
733
758
- #[ cfg( target_os = "macos" ) ]
759
- #[ cfg( target_os = "linux" ) ]
760
- #[ cfg( target_os = "freebsd" ) ]
734
+ #[ cfg( unix) ]
761
735
fn family ( ) -> str { "unix" }
762
736
763
- #[ cfg( target_os = "win32" ) ]
737
+ #[ cfg( windows ) ]
764
738
fn family ( ) -> str { "windows" }
765
739
766
740
#[ cfg( target_os = "macos" ) ]
@@ -824,7 +798,8 @@ mod tests {
824
798
}
825
799
826
800
#[ test]
827
- #[ ignore( cgf( target_os = "win32" ) ) ]
801
+ #[ ignore( cfg( windows) ) ]
802
+ #[ ignore]
828
803
fn test_setenv_overwrite ( ) {
829
804
let n = make_rand_name ( ) ;
830
805
setenv ( n, "1" ) ;
@@ -837,7 +812,8 @@ mod tests {
837
812
// Windows GetEnvironmentVariable requires some extra work to make sure
838
813
// the buffer the variable is copied into is the right size
839
814
#[ test]
840
- #[ ignore( cgf( target_os = "win32" ) ) ]
815
+ #[ ignore( cfg( windows) ) ]
816
+ #[ ignore]
841
817
fn test_getenv_big ( ) {
842
818
let mut s = "" ;
843
819
let mut i = 0 ;
@@ -902,9 +878,7 @@ mod tests {
902
878
}
903
879
904
880
#[ test]
905
- #[ cfg( target_os = "linux" ) ]
906
- #[ cfg( target_os = "macos" ) ]
907
- #[ cfg( target_os = "freebsd" ) ]
881
+ #[ cfg( unix) ]
908
882
fn homedir ( ) {
909
883
let oldhome = getenv ( "HOME" ) ;
910
884
@@ -918,7 +892,7 @@ mod tests {
918
892
}
919
893
920
894
#[ test]
921
- #[ cfg( target_os = "win32" ) ]
895
+ #[ cfg( windows ) ]
922
896
fn homedir ( ) {
923
897
924
898
let oldhome = getenv ( "HOME" ) ;
0 commit comments