@@ -79,7 +79,7 @@ fn fill_charp_buf(f: fn(*mut c_char, size_t) -> bool)
7979 }
8080}
8181
82- #[ cfg( target_os = "win32" ) ]
82+ #[ cfg( windows ) ]
8383mod win32 {
8484 import dword = libc : : types:: os:: arch:: extra:: DWORD ;
8585
@@ -200,9 +200,7 @@ mod global_env {
200200
201201 mod impl {
202202
203- #[ cfg( target_os = "linux") ]
204- #[ cfg( target_os = "macos") ]
205- #[ cfg( target_os = "freebsd") ]
203+ #[ cfg( unix) ]
206204 fn getenv( n: str ) -> option<str > unsafe {
207205 let s = str :: as_c_str( n, libc:: getenv) ;
208206 ret if unsafe :: reinterpret_cast( s) == 0 {
@@ -213,7 +211,7 @@ mod global_env {
213211 } ;
214212 }
215213
216- #[ cfg( target_os = "win32" ) ]
214+ #[ cfg( windows ) ]
217215 fn getenv( n: str ) -> option<str > unsafe {
218216 import libc:: types:: os:: arch:: extra:: * ;
219217 import libc:: funcs:: extra:: kernel32:: * ;
@@ -226,9 +224,7 @@ mod global_env {
226224 }
227225
228226
229- #[ cfg( target_os = "linux") ]
230- #[ cfg( target_os = "macos") ]
231- #[ cfg( target_os = "freebsd") ]
227+ #[ cfg( unix) ]
232228 fn setenv( n: str , v: str ) {
233229
234230 // FIXME: remove this when export globs work properly.
@@ -241,7 +237,7 @@ mod global_env {
241237 }
242238
243239
244- #[ cfg( target_os = "win32" ) ]
240+ #[ cfg( windows ) ]
245241 fn setenv( n: str , v: str ) {
246242 // FIXME: remove imports when export globs work properly.
247243 import libc:: funcs:: extra:: kernel32:: * ;
@@ -265,7 +261,7 @@ fn fdopen(fd: c_int) -> *FILE {
265261
266262// fsync related
267263
268- #[ cfg( target_os = "win32" ) ]
264+ #[ cfg( windows ) ]
269265fn fsync_fd( fd: c_int, _level: io:: fsync:: level) -> c_int {
270266 import libc:: funcs:: extra:: msvcrt:: * ;
271267 ret commit( fd) ;
@@ -305,14 +301,12 @@ fn fsync_fd(fd: c_int, _l: io::fsync::level) -> c_int {
305301}
306302
307303
308- #[ cfg( target_os = "win32" ) ]
304+ #[ cfg( windows ) ]
309305fn waitpid( pid: pid_t) -> c_int {
310306 ret rustrt:: rust_process_wait( pid) ;
311307}
312308
313- #[ cfg( target_os = "linux") ]
314- #[ cfg( target_os = "freebsd") ]
315- #[ cfg( target_os = "macos") ]
309+ #[ cfg( unix) ]
316310fn waitpid( pid: pid_t) -> c_int {
317311 import libc:: funcs:: posix01:: wait:: * ;
318312 let status = 0 as c_int;
@@ -323,9 +317,7 @@ fn waitpid(pid: pid_t) -> c_int {
323317}
324318
325319
326- #[ cfg( target_os = "linux") ]
327- #[ cfg( target_os = "freebsd") ]
328- #[ cfg( target_os = "macos") ]
320+ #[ cfg( unix) ]
329321fn pipe( ) -> { in : c_int, out: c_int} {
330322 let fds = { mut in: 0 as c_int ,
331323 mut out: 0 as c_int } ;
@@ -335,7 +327,7 @@ fn pipe() -> {in: c_int, out: c_int} {
335327
336328
337329
338- #[ cfg( target_os = "win32" ) ]
330+ #[ cfg( windows ) ]
339331fn pipe ( ) -> { in: c_int, out: c_int} {
340332 // FIXME: remove this when export globs work properly.
341333 import libc:: consts:: os:: extra:: * ;
@@ -359,12 +351,10 @@ fn pipe() -> {in: c_int, out: c_int} {
359351fn dll_filename ( base : str ) -> str {
360352 ret pre ( ) + base + dll_suffix ( ) ;
361353
362- #[ cfg( target_os = "macos" ) ]
363- #[ cfg( target_os = "linux" ) ]
364- #[ cfg( target_os = "freebsd" ) ]
354+ #[ cfg( unix) ]
365355 fn pre ( ) -> str { "lib" }
366356
367- #[ cfg( target_os = "win32" ) ]
357+ #[ cfg( windows ) ]
368358 fn pre ( ) -> str { "" }
369359}
370360
@@ -405,7 +395,7 @@ fn self_exe_path() -> option<path> {
405395 }
406396 }
407397
408- #[ cfg( target_os = "win32" ) ]
398+ #[ cfg( windows ) ]
409399 fn load_self ( ) -> option < path > unsafe {
410400 // FIXME: remove imports when export globs work properly.
411401 import libc:: types:: os:: arch:: extra:: * ;
@@ -449,14 +439,12 @@ fn homedir() -> option<path> {
449439 }
450440 } ;
451441
452- #[ cfg( target_os = "linux" ) ]
453- #[ cfg( target_os = "macos" ) ]
454- #[ cfg( target_os = "freebsd" ) ]
442+ #[ cfg( unix) ]
455443 fn secondary ( ) -> option < path > {
456444 none
457445 }
458446
459- #[ cfg( target_os = "win32" ) ]
447+ #[ cfg( windows ) ]
460448 fn secondary ( ) -> option < path > {
461449 option:: chain ( getenv ( "USERPROFILE" ) ) { |p|
462450 if !str:: is_empty ( p) {
@@ -536,7 +524,7 @@ fn make_absolute(p: path) -> path {
536524fn make_dir ( p : path , mode : c_int ) -> bool {
537525 ret mkdir ( p, mode) ;
538526
539- #[ cfg( target_os = "win32" ) ]
527+ #[ cfg( windows ) ]
540528 fn mkdir ( p : path , _mode : c_int ) -> bool unsafe {
541529 // FIXME: remove imports when export globs work properly.
542530 import libc:: types:: os:: arch:: extra:: * ;
@@ -549,9 +537,7 @@ fn make_dir(p: path, mode: c_int) -> bool {
549537 }
550538 }
551539
552- #[ cfg( target_os = "linux" ) ]
553- #[ cfg( target_os = "macos" ) ]
554- #[ cfg( target_os = "freebsd" ) ]
540+ #[ cfg( unix) ]
555541 fn mkdir ( p : path , mode : c_int ) -> bool {
556542 as_c_charp ( p) { |c|
557543 libc:: mkdir ( c, mode as mode_t ) == ( 0 as c_int )
@@ -562,12 +548,10 @@ fn make_dir(p: path, mode: c_int) -> bool {
562548#[ doc = "Lists the contents of a directory" ]
563549fn list_dir ( p : path ) -> [ str ] {
564550
565- #[ cfg( target_os = "linux" ) ]
566- #[ cfg( target_os = "macos" ) ]
567- #[ cfg( target_os = "freebsd" ) ]
551+ #[ cfg( unix) ]
568552 fn star ( p : str ) -> str { p }
569553
570- #[ cfg( target_os = "win32" ) ]
554+ #[ cfg( windows ) ]
571555 fn star ( p : str ) -> str {
572556 let pl = str:: len ( p) ;
573557 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] {
602586fn remove_dir ( p : path ) -> bool {
603587 ret rmdir ( p) ;
604588
605- #[ cfg( target_os = "win32" ) ]
589+ #[ cfg( windows ) ]
606590 fn rmdir ( p : path ) -> bool {
607591 // FIXME: remove imports when export globs work properly.
608592 import libc:: funcs:: extra:: kernel32:: * ;
@@ -613,9 +597,7 @@ fn remove_dir(p: path) -> bool {
613597 } ;
614598 }
615599
616- #[ cfg( target_os = "linux" ) ]
617- #[ cfg( target_os = "macos" ) ]
618- #[ cfg( target_os = "freebsd" ) ]
600+ #[ cfg( unix) ]
619601 fn rmdir ( p : path ) -> bool {
620602 ret as_c_charp ( p) { |buf|
621603 libc:: rmdir ( buf) == ( 0 as c_int )
@@ -626,7 +608,7 @@ fn remove_dir(p: path) -> bool {
626608fn change_dir ( p : path ) -> bool {
627609 ret chdir ( p) ;
628610
629- #[ cfg( target_os = "win32" ) ]
611+ #[ cfg( windows ) ]
630612 fn chdir ( p : path ) -> bool {
631613 // FIXME: remove imports when export globs work properly.
632614 import libc:: funcs:: extra:: kernel32:: * ;
@@ -637,9 +619,7 @@ fn change_dir(p: path) -> bool {
637619 } ;
638620 }
639621
640- #[ cfg( target_os = "linux" ) ]
641- #[ cfg( target_os = "macos" ) ]
642- #[ cfg( target_os = "freebsd" ) ]
622+ #[ cfg( unix) ]
643623 fn chdir ( p : path ) -> bool {
644624 ret as_c_charp ( p) { |buf|
645625 libc:: chdir ( buf) == ( 0 as c_int )
@@ -651,7 +631,7 @@ fn change_dir(p: path) -> bool {
651631fn copy_file ( from : path , to : path ) -> bool {
652632 ret do_copy_file ( from, to) ;
653633
654- #[ cfg( target_os = "win32" ) ]
634+ #[ cfg( windows ) ]
655635 fn do_copy_file ( from : path , to : path ) -> bool {
656636 // FIXME: remove imports when export globs work properly.
657637 import libc:: funcs:: extra:: kernel32:: * ;
@@ -664,9 +644,7 @@ fn copy_file(from: path, to: path) -> bool {
664644 }
665645 }
666646
667- #[ cfg( target_os = "linux" ) ]
668- #[ cfg( target_os = "macos" ) ]
669- #[ cfg( target_os = "freebsd" ) ]
647+ #[ cfg( unix) ]
670648 fn do_copy_file ( from : path , to : path ) -> bool unsafe {
671649 let istream = as_c_charp ( from) { |fromp|
672650 as_c_charp ( "rb" ) { |modebuf|
@@ -716,7 +694,7 @@ fn copy_file(from: path, to: path) -> bool {
716694fn remove_file ( p : path ) -> bool {
717695 ret unlink ( p) ;
718696
719- #[ cfg( target_os = "win32" ) ]
697+ #[ cfg( windows ) ]
720698 fn unlink ( p : path ) -> bool {
721699 // FIXME: remove imports when export globs work properly.
722700 // (similar to Issue #2006)
@@ -728,9 +706,7 @@ fn remove_file(p: path) -> bool {
728706 } ;
729707 }
730708
731- #[ cfg( target_os = "linux" ) ]
732- #[ cfg( target_os = "macos" ) ]
733- #[ cfg( target_os = "freebsd" ) ]
709+ #[ cfg( unix) ]
734710 fn unlink ( p : path ) -> bool {
735711 ret as_c_charp ( p) { |buf|
736712 libc:: unlink ( buf) == ( 0 as c_int )
@@ -755,12 +731,10 @@ fn set_exit_status(code: int) {
755731 rustrt:: rust_set_exit_status ( code as libc:: intptr_t ) ;
756732}
757733
758- #[ cfg( target_os = "macos" ) ]
759- #[ cfg( target_os = "linux" ) ]
760- #[ cfg( target_os = "freebsd" ) ]
734+ #[ cfg( unix) ]
761735fn family ( ) -> str { "unix" }
762736
763- #[ cfg( target_os = "win32" ) ]
737+ #[ cfg( windows ) ]
764738fn family ( ) -> str { "windows" }
765739
766740#[ cfg( target_os = "macos" ) ]
@@ -824,7 +798,8 @@ mod tests {
824798 }
825799
826800 #[ test]
827- #[ ignore( cgf( target_os = "win32" ) ) ]
801+ #[ ignore( cfg( windows) ) ]
802+ #[ ignore]
828803 fn test_setenv_overwrite ( ) {
829804 let n = make_rand_name ( ) ;
830805 setenv ( n, "1" ) ;
@@ -837,7 +812,8 @@ mod tests {
837812 // Windows GetEnvironmentVariable requires some extra work to make sure
838813 // the buffer the variable is copied into is the right size
839814 #[ test]
840- #[ ignore( cgf( target_os = "win32" ) ) ]
815+ #[ ignore( cfg( windows) ) ]
816+ #[ ignore]
841817 fn test_getenv_big ( ) {
842818 let mut s = "" ;
843819 let mut i = 0 ;
@@ -902,9 +878,7 @@ mod tests {
902878 }
903879
904880 #[ test]
905- #[ cfg( target_os = "linux" ) ]
906- #[ cfg( target_os = "macos" ) ]
907- #[ cfg( target_os = "freebsd" ) ]
881+ #[ cfg( unix) ]
908882 fn homedir ( ) {
909883 let oldhome = getenv ( "HOME" ) ;
910884
@@ -918,7 +892,7 @@ mod tests {
918892 }
919893
920894 #[ test]
921- #[ cfg( target_os = "win32" ) ]
895+ #[ cfg( windows ) ]
922896 fn homedir ( ) {
923897
924898 let oldhome = getenv ( "HOME" ) ;
0 commit comments