@@ -1385,48 +1385,30 @@ pub mod funcs {
13851385 use libc:: types:: common:: posix88:: { DIR , dirent_t} ;
13861386 use libc:: types:: os:: arch:: c95:: { c_char, c_int, c_long} ;
13871387
1388- pub extern {
1389- // default bindings for opendir and readdir in
1390- // non-macos unix
1391- #[ cfg( target_os = "linux" ) ]
1392- #[ cfg( target_os = "android" ) ]
1393- #[ cfg( target_os = "freebsd" ) ]
1394- unsafe fn opendir ( dirname : * c_char ) -> * DIR ;
1395- #[ cfg( target_os = "linux" ) ]
1396- #[ cfg( target_os = "android" ) ]
1397- #[ cfg( target_os = "freebsd" ) ]
1398- unsafe fn readdir ( dirp : * DIR ) -> * dirent_t ;
1388+ // NOTE: On OS X opendir and readdir have two versions,
1389+ // one for 32-bit kernelspace and one for 64.
1390+ // We should be linking to the 64-bit ones, called
1391+ // opendir$INODE64, etc. but for some reason rustc
1392+ // doesn't link it correctly on i686, so we're going
1393+ // through a C function that mysteriously does work.
1394+ pub unsafe fn opendir ( dirname : * c_char ) -> * DIR {
1395+ rust_opendir ( dirname)
1396+ }
1397+ pub unsafe fn readdir ( dirp : * DIR ) -> * dirent_t {
1398+ rust_readdir ( dirp)
1399+ }
1400+
1401+ extern {
1402+ unsafe fn rust_opendir ( dirname : * c_char ) -> * DIR ;
1403+ unsafe fn rust_readdir ( dirp : * DIR ) -> * dirent_t ;
1404+ }
13991405
1406+ pub extern {
14001407 unsafe fn closedir ( dirp : * DIR ) -> c_int ;
14011408 unsafe fn rewinddir ( dirp : * DIR ) ;
14021409 unsafe fn seekdir ( dirp : * DIR , loc : c_long ) ;
14031410 unsafe fn telldir ( dirp : * DIR ) -> c_long ;
14041411 }
1405-
1406- #[ cfg( target_word_size = "64" ) ]
1407- pub extern {
1408- // on OSX (particularly when running with a
1409- // 64bit kernel), we have an issue where there
1410- // are separate bindings for opendir and readdir,
1411- // which we have to explicitly link, as below.
1412- #[ cfg( target_os = "macos" ) ]
1413- #[ link_name = "opendir$INODE64" ]
1414- unsafe fn opendir ( dirname : * c_char ) -> * DIR ;
1415- #[ cfg( target_os = "macos" ) ]
1416- #[ link_name = "readdir$INODE64" ]
1417- unsafe fn readdir ( dirp : * DIR ) -> * dirent_t ;
1418- }
1419- #[ cfg( target_word_size = "32" ) ]
1420- pub extern {
1421- // on OSX (particularly when running with a
1422- // 64bit kernel), we have an issue where there
1423- // are separate bindings for opendir and readdir,
1424- // which we have to explicitly link, as below.
1425- #[ cfg( target_os = "macos" ) ]
1426- unsafe fn opendir ( dirname : * c_char ) -> * DIR ;
1427- #[ cfg( target_os = "macos" ) ]
1428- unsafe fn readdir ( dirp : * DIR ) -> * dirent_t ;
1429- }
14301412 }
14311413
14321414 #[ nolink]
0 commit comments