Bug 935962: [OS.File] create a special type for stat.st_size and deal with NetBSD libc symbol names. r=yoric

This commit is contained in:
Martin Husemann 2013-11-09 08:36:19 +01:00
Родитель 2bb5fe2c42
Коммит 867a2bd662
2 изменённых файлов: 57 добавлений и 5 удалений

Просмотреть файл

@ -92,6 +92,15 @@
Type.gid_t =
Type.intn_t(Const.OSFILE_SIZEOF_GID_T).withName("gid_t");
/**
* A file size (st_size in struct stat)
*/
if (OS.Constants.Sys.Name == "NetBSD") {
Type.stat_size_t = Type.off_t.withName("stat_size_t");
} else {
Type.stat_size_t = Type.size_t.withName("stat_size_t");
}
/**
* Type |time_t|
*/
@ -165,7 +174,7 @@
}
stat.add_field_at(Const.OSFILE_OFFSETOF_STAT_ST_SIZE,
"st_size", Type.size_t.implementation);
"st_size", Type.stat_size_t.implementation);
Type.stat = stat.getType();
}
@ -398,9 +407,15 @@
/*oflags*/Type.int,
/*mode*/ Type.int);
declareLazyFFI(SysFile, "opendir", libc, "opendir", ctypes.default_abi,
if (OS.Constants.Sys.Name == "NetBSD") {
declareLazyFFI(SysFile, "opendir", libc, "__opendir30", ctypes.default_abi,
/*return*/ Type.null_or_DIR_ptr,
/*path*/ Type.path);
} else {
declareLazyFFI(SysFile, "opendir", libc, "opendir", ctypes.default_abi,
/*return*/ Type.null_or_DIR_ptr,
/*path*/ Type.path);
}
declareLazyFFI(SysFile, "pread", libc, "pread", ctypes.default_abi,
/*return*/ Type.negativeone_or_ssize_t,
@ -437,6 +452,10 @@
declareLazyFFI(SysFile, "readdir", libc, "readdir$INODE64", ctypes.default_abi,
/*return*/Type.null_or_dirent_ptr,
/*dir*/ Type.DIR.in_ptr); // For MacOS X
} else if (OS.Constants.Sys.Name == "NetBSD") {
declareLazyFFI(SysFile, "readdir", libc, "__readdir30", ctypes.default_abi,
/*return*/Type.null_or_dirent_ptr,
/*dir*/ Type.DIR.in_ptr); // Other Unices
} else {
declareLazyFFI(SysFile, "readdir", libc, "readdir", ctypes.default_abi,
/*return*/Type.null_or_dirent_ptr,
@ -547,6 +566,23 @@
SysFile.fstat = function fstat(fd, buf) {
return Stat.fxstat(ver, fd, buf);
};
} else if (OS.Constants.Sys.Name == "NetBSD") {
// NetBSD 5.0 and newer
declareLazyFFI(SysFile, "stat", libc, "__stat50", ctypes.default_abi,
/*return*/ Type.negativeone_or_nothing,
/*path*/ Type.path,
/*buf*/ Type.stat.out_ptr
);
declareLazyFFI(SysFile, "lstat", libc, "__lstat50", ctypes.default_abi,
/*return*/ Type.negativeone_or_nothing,
/*path*/ Type.path,
/*buf*/ Type.stat.out_ptr
);
declareLazyFFI(SysFile, "fstat", libc, "__fstat50", ctypes.default_abi,
/*return*/ Type.negativeone_or_nothing,
/*fd*/ Type.fd,
/*buf*/ Type.stat.out_ptr
);
} else {
// Mac OS X 32-bits, other Unix
declareLazyFFI(SysFile, "stat", libc, "stat", ctypes.default_abi,
@ -589,16 +625,32 @@
return result;
};
declareLazyFFI(SysFile, "utimes", libc, "utimes", ctypes.default_abi,
if (OS.Constants.Sys.Name == "NetBSD") {
declareLazyFFI(SysFile, "utimes", libc, "__utimes50", ctypes.default_abi,
/*return*/ Type.negativeone_or_nothing,
/*path*/ Type.path,
/*timeval[2]*/ Type.timevals.out_ptr
);
declareLazyFFI(SysFile, "futimes", libc, "futimes", ctypes.default_abi,
} else {
declareLazyFFI(SysFile, "utimes", libc, "utimes", ctypes.default_abi,
/*return*/ Type.negativeone_or_nothing,
/*path*/ Type.path,
/*timeval[2]*/ Type.timevals.out_ptr
);
}
if (OS.Constants.Sys.Name == "NetBSD") {
declareLazyFFI(SysFile, "futimes", libc, "__futimes50", ctypes.default_abi,
/*return*/ Type.negativeone_or_nothing,
/*fd*/ Type.fd,
/*timeval[2]*/ Type.timevals.out_ptr
);
} else {
declareLazyFFI(SysFile, "futimes", libc, "futimes", ctypes.default_abi,
/*return*/ Type.negativeone_or_nothing,
/*fd*/ Type.fd,
/*timeval[2]*/ Type.timevals.out_ptr
);
}
};
exports.OS.Unix = {

Просмотреть файл

@ -789,7 +789,7 @@
File.Info = function Info(stat) {
let isDir = (stat.st_mode & Const.S_IFMT) == Const.S_IFDIR;
let isSymLink = (stat.st_mode & Const.S_IFMT) == Const.S_IFLNK;
let size = Type.size_t.importFromC(stat.st_size);
let size = Type.stat_size_t.importFromC(stat.st_size);
let lastAccessDate = new Date(stat.st_atime * 1000);
let lastModificationDate = new Date(stat.st_mtime * 1000);