os: Use Entersyscall when reading directories.
authorIan Lance Taylor <ian@gcc.gnu.org>
Wed, 13 Jun 2012 04:47:25 +0000 (04:47 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Wed, 13 Jun 2012 04:47:25 +0000 (04:47 +0000)
From-SVN: r188494

libgo/go/os/dir.go

index c693aebf3775861334f170c879a62e727ee99df5..02b21e6f7dad87fb24c3d18526ed78214c5b777f 100644 (file)
@@ -42,7 +42,11 @@ func (file *File) readdirnames(n int) (names []string, err error) {
        if file.dirinfo == nil {
                file.dirinfo = new(dirInfo)
                file.dirinfo.buf = make([]byte, elen)
-               file.dirinfo.dir = libc_opendir(syscall.StringBytePtr(file.name))
+               p := syscall.StringBytePtr(file.name)
+               syscall.Entersyscall()
+               r := libc_opendir(p)
+               syscall.Exitsyscall()
+               file.dirinfo.dir = r
        }
 
        entry_dirent := unsafe.Pointer(&file.dirinfo.buf[0]).(*syscall.Dirent)
@@ -62,7 +66,10 @@ func (file *File) readdirnames(n int) (names []string, err error) {
 
        for n != 0 {
                var result *syscall.Dirent
-               i := libc_readdir_r(dir, entry_dirent, &result)
+               pr := &result
+               syscall.Entersyscall()
+               i := libc_readdir_r(dir, entry_dirent, pr)
+               syscall.Exitsyscall()
                if i != 0 {
                        return names, NewSyscallError("readdir_r", i)
                }