Cleanup darwin build system some more.
* Convert fs_darwin.cpp and fs_freebsd.cpp to C. * Convert extern C calls to __BEGIN_DECLS and __END_DECLS macros * Link rm_attrs with dynamic libroot
This commit is contained in:
@@ -1,16 +1,12 @@
|
||||
#ifndef _HAIKU_BUILD_COMPATIBILITY_DARWIN_DIRENT
|
||||
#define _HAIKU_BUILD_COMPATIBILITY_DARWIN_DIRENT
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include_next <dirent.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
DIR* fdopendir(int fd);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
__END_DECLS
|
||||
|
||||
#endif // _HAIKU_BUILD_COMPATIBILITY_DARWIN_DIRENT
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#ifndef _HAIKU_BUILD_COMPATIBILITY_DARWIN_FCNTL
|
||||
#define _HAIKU_BUILD_COMPATIBILITY_DARWIN_FCNTL
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include_next <fcntl.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
@@ -24,11 +20,11 @@ extern "C" {
|
||||
#define AT_SYMLINK_FOLLOW 0x400 /* linkat() */
|
||||
#define AT_REMOVEDIR 0x800 /* unlinkat() */
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
int unlinkat(int fd, const char *path, int flag);
|
||||
int futimesat(int fd, const char *path, const struct timeval times[2]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
__END_DECLS
|
||||
|
||||
#endif // _HAIKU_BUILD_COMPATIBILITY_DARWIN_FCNTL
|
||||
|
||||
@@ -3,14 +3,10 @@
|
||||
|
||||
// Include the darwin port of gnuregex
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include </opt/local/include/gnuregex.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
__END_DECLS
|
||||
|
||||
#endif // _HAIKU_BUILD_COMPATIBILITY_DARWIN_REGEX
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
#ifndef _HAIKU_BUILD_COMPATIBILITY_DARWIN_STDIO
|
||||
#define _HAIKU_BUILD_COMPATIBILITY_DARWIN_STDIO
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include_next <stdio.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
int renameat(int oldFD, const char* oldPath, int newFD, const char* newPath);
|
||||
int symlinkat(const char *oldPath, int fd, const char *newPath);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
__END_DECLS
|
||||
|
||||
#endif // _HAIKU_BUILD_COMPATIBILITY_DARWIN_STDIO
|
||||
|
||||
@@ -25,10 +25,14 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
int fchmodat(int fd, const char* path, mode_t mode, int flag);
|
||||
int fstatat(int fd, const char *path, struct stat *st, int flag);
|
||||
int mkdirat(int fd, const char *path, mode_t mode);
|
||||
int mkfifoat(int fd, const char *path, mode_t mode);
|
||||
int mknodat(int fd, const char *name, mode_t mode, dev_t dev);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _HAIKU_BUILD_COMPATIBILITY_DARWIN_SYS_STAT */
|
||||
|
||||
@@ -1,20 +1,16 @@
|
||||
#ifndef _HAIKU_BUILD_COMPATIBILITY_DARWIN_UNISTD
|
||||
#define _HAIKU_BUILD_COMPATIBILITY_DARWIN_UNISTD
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include_next <unistd.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
int faccessat(int fd, const char* path, int accessMode, int flag);
|
||||
int fchownat(int fd, const char* path, uid_t owner, gid_t group, int flag);
|
||||
ssize_t readlinkat(int fd, const char *path, char *buffer, size_t bufferSize);
|
||||
int linkat(int oldFD, const char *oldPath, int newFD, const char *newPath,
|
||||
int flag);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
__END_DECLS
|
||||
|
||||
#endif // _HAIKU_BUILD_COMPATIBILITY_DARWIN_UNISTD
|
||||
|
||||
@@ -47,11 +47,11 @@ if $(HOST_PLATFORM) = cygwin || $(HOST_PLATFORM) = sunos {
|
||||
|
||||
local hostPlatformSources ;
|
||||
if $(HOST_PLATFORM) = freebsd {
|
||||
hostPlatformSources = fs_freebsd.cpp ;
|
||||
hostPlatformSources = fs_freebsd.c ;
|
||||
}
|
||||
|
||||
if $(HOST_PLATFORM) = darwin {
|
||||
hostPlatformSources = fs_darwin.cpp ;
|
||||
hostPlatformSources = fs_darwin.c ;
|
||||
}
|
||||
|
||||
local librootSources =
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
@@ -116,7 +115,7 @@ faccessat(int fd, const char* path, int accessMode, int flag)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (fd == AT_FDCWD || path != NULL && path[0] == '/') {
|
||||
if (fd == AT_FDCWD || (path != NULL && path[0] == '/')) {
|
||||
// call access() ignoring fd
|
||||
return (flag & AT_EACCESS) != 0 ? eaccess(path, accessMode)
|
||||
: access(path, accessMode);
|
||||
@@ -146,7 +145,7 @@ fchmodat(int fd, const char* path, mode_t mode, int flag)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (fd == AT_FDCWD || path != NULL && path[0] == '/') {
|
||||
if (fd == AT_FDCWD || (path != NULL && path[0] == '/')) {
|
||||
// call chmod() ignoring fd
|
||||
if ((flag & AT_SYMLINK_NOFOLLOW) != 0) {
|
||||
// fake lchmod() with open() and fchmod()
|
||||
@@ -190,7 +189,7 @@ fchownat(int fd, const char* path, uid_t owner, gid_t group, int flag)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (fd == AT_FDCWD || path != NULL && path[0] == '/') {
|
||||
if (fd == AT_FDCWD || (path != NULL && path[0] == '/')) {
|
||||
// call chown() ignoring fd
|
||||
return (flag & AT_SYMLINK_NOFOLLOW) != 0 ? lchown(path, owner, group)
|
||||
: chown(path, owner, group);
|
||||
@@ -244,7 +243,7 @@ fstatat(int fd, const char *path, struct stat *st, int flag)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (fd == AT_FDCWD || path != NULL && path[0] == '/') {
|
||||
if (fd == AT_FDCWD || (path != NULL && path[0] == '/')) {
|
||||
// call stat() or lstat() ignoring fd
|
||||
return (flag & AT_SYMLINK_NOFOLLOW) != 0 ? lstat(path, st)
|
||||
: stat(path, st);
|
||||
@@ -268,7 +267,7 @@ fstatat(int fd, const char *path, struct stat *st, int flag)
|
||||
int
|
||||
mkdirat(int fd, const char *path, mode_t mode)
|
||||
{
|
||||
if (fd == AT_FDCWD || path != NULL && path[0] == '/') {
|
||||
if (fd == AT_FDCWD || (path != NULL && path[0] == '/')) {
|
||||
// call mkdir() ignoring fd
|
||||
return mkdir(path, mode);
|
||||
}
|
||||
@@ -290,7 +289,7 @@ mkdirat(int fd, const char *path, mode_t mode)
|
||||
int
|
||||
mkfifoat(int fd, const char *path, mode_t mode)
|
||||
{
|
||||
if (fd == AT_FDCWD || path != NULL && path[0] == '/') {
|
||||
if (fd == AT_FDCWD || (path != NULL && path[0] == '/')) {
|
||||
// call mkfifo() ignoring fd
|
||||
return mkfifo(path, mode);
|
||||
}
|
||||
@@ -312,7 +311,7 @@ mkfifoat(int fd, const char *path, mode_t mode)
|
||||
int
|
||||
mknodat(int fd, const char *path, mode_t mode, dev_t dev)
|
||||
{
|
||||
if (fd == AT_FDCWD || path != NULL && path[0] == '/') {
|
||||
if (fd == AT_FDCWD || (path != NULL && path[0] == '/')) {
|
||||
// call mknod() ignoring fd
|
||||
return mknod(path, mode, dev);
|
||||
}
|
||||
@@ -334,14 +333,14 @@ mknodat(int fd, const char *path, mode_t mode, dev_t dev)
|
||||
int
|
||||
renameat(int oldFD, const char* oldPath, int newFD, const char* newPath)
|
||||
{
|
||||
bool ignoreOldFD = false;
|
||||
bool ignoreNewFD = false;
|
||||
int ignoreOldFD = 0;
|
||||
int ignoreNewFD = 0;
|
||||
|
||||
if (oldFD == AT_FDCWD || oldPath != NULL && oldPath[0] == '/')
|
||||
ignoreOldFD = true;
|
||||
if (oldFD == AT_FDCWD || (oldPath != NULL && oldPath[0] == '/'))
|
||||
ignoreOldFD = 1;
|
||||
|
||||
if (newFD == AT_FDCWD || newPath != NULL && newPath[0] == '/')
|
||||
ignoreNewFD = true;
|
||||
if (newFD == AT_FDCWD || (newPath != NULL && newPath[0] == '/'))
|
||||
ignoreNewFD = 1;
|
||||
|
||||
if (ignoreOldFD && ignoreNewFD) {
|
||||
// call rename() ignoring the fd's
|
||||
@@ -380,7 +379,7 @@ renameat(int oldFD, const char* oldPath, int newFD, const char* newPath)
|
||||
ssize_t
|
||||
readlinkat(int fd, const char *path, char *buffer, size_t bufferSize)
|
||||
{
|
||||
if (fd == AT_FDCWD || path != NULL && path[0] == '/') {
|
||||
if (fd == AT_FDCWD || (path != NULL && path[0] == '/')) {
|
||||
// call readlink() ignoring fd
|
||||
return readlink(path, buffer, bufferSize);
|
||||
}
|
||||
@@ -402,7 +401,7 @@ readlinkat(int fd, const char *path, char *buffer, size_t bufferSize)
|
||||
int
|
||||
symlinkat(const char *oldPath, int fd, const char *newPath)
|
||||
{
|
||||
if (fd == AT_FDCWD || newPath != NULL && newPath[0] == '/') {
|
||||
if (fd == AT_FDCWD || (newPath != NULL && newPath[0] == '/')) {
|
||||
// call symlink() ignoring fd
|
||||
return symlink(oldPath, newPath);
|
||||
}
|
||||
@@ -431,7 +430,7 @@ unlinkat(int fd, const char *path, int flag)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (fd == AT_FDCWD || path != NULL && path[0] == '/') {
|
||||
if (fd == AT_FDCWD || (path != NULL && path[0] == '/')) {
|
||||
// call rmdir() or unlink() ignoring fd
|
||||
return (flag & AT_REMOVEDIR) != 0 ? rmdir(path) : unlink(path);
|
||||
}
|
||||
@@ -465,14 +464,14 @@ linkat(int oldFD, const char *oldPath, int newFD, const char *newPath,
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool ignoreOldFD = false;
|
||||
bool ignoreNewFD = false;
|
||||
int ignoreOldFD = 0;
|
||||
int ignoreNewFD = 0;
|
||||
|
||||
if (oldFD == AT_FDCWD || oldPath != NULL && oldPath[0] == '/')
|
||||
ignoreOldFD = true;
|
||||
ignoreOldFD = 1;
|
||||
|
||||
if (newFD == AT_FDCWD || newPath != NULL && newPath[0] == '/')
|
||||
ignoreNewFD = true;
|
||||
ignoreNewFD = 1;
|
||||
|
||||
if (ignoreOldFD && ignoreNewFD) {
|
||||
// call link() ignoring the fd's
|
||||
@@ -511,7 +510,7 @@ linkat(int oldFD, const char *oldPath, int newFD, const char *newPath,
|
||||
int
|
||||
futimesat(int fd, const char *path, const struct timeval times[2])
|
||||
{
|
||||
if (fd == AT_FDCWD || path != NULL && path[0] == '/') {
|
||||
if (fd == AT_FDCWD || (path != NULL && path[0] == '/')) {
|
||||
// call utimes() ignoring fd
|
||||
return utimes(path, times);
|
||||
}
|
||||
@@ -40,11 +40,10 @@ haiku_freebsd_read(int fd, void *buf, size_t nbytes)
|
||||
|
||||
off_t seekDiff = (sectorSize - (cur % sectorSize)) % sectorSize;
|
||||
off_t nbytesDiff = (nbytes - seekDiff) % sectorSize;
|
||||
|
||||
|
||||
if (seekDiff == 0 && nbytesDiff == 0) {
|
||||
// Not needed but this saves malloc and free operations
|
||||
return read(fd, buf, nbytes);
|
||||
|
||||
} else if (cur % sectorSize + nbytes <= sectorSize) {
|
||||
// Read complete in only a block
|
||||
char* tmpBlock = (char*)malloc(sectorSize);
|
||||
@@ -63,9 +62,8 @@ haiku_freebsd_read(int fd, void *buf, size_t nbytes)
|
||||
}
|
||||
|
||||
free(tmpBlock);
|
||||
|
||||
return nbytes;
|
||||
|
||||
return nbytes;
|
||||
} else {
|
||||
// Needs to write more than a block
|
||||
|
||||
@@ -88,13 +86,14 @@ haiku_freebsd_read(int fd, void *buf, size_t nbytes)
|
||||
|
||||
// Blocks between
|
||||
if ((nbytes - seekDiff) >= sectorSize) {
|
||||
if (read(fd, ((char*)buf) + seekDiff, nbytes - seekDiff - nbytesDiff) == -1)
|
||||
if (read(fd, ((char*)buf) + seekDiff, nbytes - seekDiff
|
||||
- nbytesDiff) == -1) {
|
||||
perror("read between");
|
||||
}
|
||||
}
|
||||
|
||||
// Last block if overflow
|
||||
if (nbytesDiff > 0 ) {
|
||||
|
||||
off_t sdCur = lseek(fd, 0, SEEK_CUR);
|
||||
if (sdCur == -1)
|
||||
perror("lseek last");
|
||||
@@ -107,10 +106,9 @@ haiku_freebsd_read(int fd, void *buf, size_t nbytes)
|
||||
}
|
||||
|
||||
free(tmpBlock);
|
||||
|
||||
|
||||
return nbytes;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -157,9 +155,8 @@ haiku_freebsd_write(int fd, const void *buf, size_t nbytes)
|
||||
perror("lseek2 oneblock");
|
||||
|
||||
free(tmpBlock);
|
||||
|
||||
return nbytes;
|
||||
|
||||
return nbytes;
|
||||
} else {
|
||||
// Needs to write more than a block
|
||||
|
||||
@@ -179,7 +176,6 @@ haiku_freebsd_write(int fd, const void *buf, size_t nbytes)
|
||||
memcpy(tmpBlock + (sectorSize - seekDiff), buf, seekDiff);
|
||||
if (write(fd, tmpBlock, sectorSize)==-1)
|
||||
perror("write seekDiff");
|
||||
|
||||
}
|
||||
|
||||
// Blocks between
|
||||
@@ -187,28 +183,29 @@ haiku_freebsd_write(int fd, const void *buf, size_t nbytes)
|
||||
if (write(fd, ((char*)buf) + seekDiff, nbytes - seekDiff - nbytesDiff) == -1)
|
||||
perror("write between");
|
||||
}
|
||||
|
||||
|
||||
// Last block if overflow
|
||||
if (nbytesDiff > 0) {
|
||||
|
||||
off_t sdCur = lseek(fd, 0, SEEK_CUR);
|
||||
if (sdCur == -1)
|
||||
perror("lseek last");
|
||||
|
||||
if (pread(fd, tmpBlock, sectorSize, sdCur) == -1)
|
||||
perror("pread last");
|
||||
|
||||
memcpy(tmpBlock, ((char*)buf) + nbytes - nbytesDiff, nbytesDiff);
|
||||
if (write(fd, tmpBlock, sectorSize) == -1)
|
||||
perror("write last");
|
||||
|
||||
// repos at byte offset of latest wrote block
|
||||
if (lseek(fd, -(sectorSize - nbytesDiff), SEEK_CUR) == -1)
|
||||
perror("lseek2 last");
|
||||
}
|
||||
|
||||
free(tmpBlock);
|
||||
|
||||
|
||||
return nbytes;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#ifndef FS_FREEBSD_H
|
||||
#define FS_FREEBSD_H
|
||||
|
||||
|
||||
#include <sys/uio.h>
|
||||
|
||||
|
||||
@@ -13,5 +14,4 @@ ssize_t haiku_freebsd_write(int fd, const void *buf, size_t nbytes);
|
||||
ssize_t haiku_freebsd_readv(int fd, const iovec *vecs, size_t count);
|
||||
ssize_t haiku_freebsd_writev(int fd, const struct iovec *vecs, size_t count);
|
||||
|
||||
|
||||
#endif // FS_FREEBSD_H
|
||||
#endif /* FS_FREEBSD_H */
|
||||
|
||||
@@ -86,8 +86,6 @@ if $(HOST_PLATFORM_BEOS_COMPATIBLE) {
|
||||
|
||||
BuildPlatformMain <build>mkindex : mkindex.cpp : $(HOST_LIBBE) ;
|
||||
|
||||
# We want rm_attrs to be self-contained, so we link against the static libroot.
|
||||
HOST_LIBROOT on <build>rm_attrs_tmp = $(HOST_STATIC_LIBROOT) ;
|
||||
BuildPlatformMain <build>rm_attrs_tmp : rm_attrs.cpp
|
||||
: $(HOST_LIBSUPC++) $(HOST_LIBSTDC++) ;
|
||||
MakeLocateDebug <build>rm_attrs ;
|
||||
@@ -146,4 +144,3 @@ SubInclude HAIKU_TOP src tools unzip ;
|
||||
SubInclude HAIKU_TOP src tools vmdkimage ;
|
||||
SubInclude HAIKU_TOP src tools unflatten ;
|
||||
SubInclude HAIKU_TOP src tools zip ;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user