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:
John Scipione
2012-08-12 20:33:46 -04:00
parent 7ad72ef6ea
commit e4e68917c3
11 changed files with 55 additions and 78 deletions
+3 -7
View File
@@ -1,16 +1,12 @@
#ifndef _HAIKU_BUILD_COMPATIBILITY_DARWIN_DIRENT #ifndef _HAIKU_BUILD_COMPATIBILITY_DARWIN_DIRENT
#define _HAIKU_BUILD_COMPATIBILITY_DARWIN_DIRENT #define _HAIKU_BUILD_COMPATIBILITY_DARWIN_DIRENT
#ifdef __cplusplus
extern "C" {
#endif
#include_next <dirent.h> #include_next <dirent.h>
__BEGIN_DECLS
DIR* fdopendir(int fd); DIR* fdopendir(int fd);
#ifdef __cplusplus __END_DECLS
}
#endif
#endif // _HAIKU_BUILD_COMPATIBILITY_DARWIN_DIRENT #endif // _HAIKU_BUILD_COMPATIBILITY_DARWIN_DIRENT
+3 -7
View File
@@ -1,10 +1,6 @@
#ifndef _HAIKU_BUILD_COMPATIBILITY_DARWIN_FCNTL #ifndef _HAIKU_BUILD_COMPATIBILITY_DARWIN_FCNTL
#define _HAIKU_BUILD_COMPATIBILITY_DARWIN_FCNTL #define _HAIKU_BUILD_COMPATIBILITY_DARWIN_FCNTL
#ifdef __cplusplus
extern "C" {
#endif
#include_next <fcntl.h> #include_next <fcntl.h>
#include <sys/time.h> #include <sys/time.h>
@@ -24,11 +20,11 @@ extern "C" {
#define AT_SYMLINK_FOLLOW 0x400 /* linkat() */ #define AT_SYMLINK_FOLLOW 0x400 /* linkat() */
#define AT_REMOVEDIR 0x800 /* unlinkat() */ #define AT_REMOVEDIR 0x800 /* unlinkat() */
__BEGIN_DECLS
int unlinkat(int fd, const char *path, int flag); int unlinkat(int fd, const char *path, int flag);
int futimesat(int fd, const char *path, const struct timeval times[2]); int futimesat(int fd, const char *path, const struct timeval times[2]);
#ifdef __cplusplus __END_DECLS
}
#endif
#endif // _HAIKU_BUILD_COMPATIBILITY_DARWIN_FCNTL #endif // _HAIKU_BUILD_COMPATIBILITY_DARWIN_FCNTL
+2 -6
View File
@@ -3,14 +3,10 @@
// Include the darwin port of gnuregex // Include the darwin port of gnuregex
#ifdef __cplusplus __BEGIN_DECLS
extern "C" {
#endif
#include </opt/local/include/gnuregex.h> #include </opt/local/include/gnuregex.h>
#ifdef __cplusplus __END_DECLS
}
#endif
#endif // _HAIKU_BUILD_COMPATIBILITY_DARWIN_REGEX #endif // _HAIKU_BUILD_COMPATIBILITY_DARWIN_REGEX
+3 -7
View File
@@ -1,17 +1,13 @@
#ifndef _HAIKU_BUILD_COMPATIBILITY_DARWIN_STDIO #ifndef _HAIKU_BUILD_COMPATIBILITY_DARWIN_STDIO
#define _HAIKU_BUILD_COMPATIBILITY_DARWIN_STDIO #define _HAIKU_BUILD_COMPATIBILITY_DARWIN_STDIO
#ifdef __cplusplus
extern "C" {
#endif
#include_next <stdio.h> #include_next <stdio.h>
__BEGIN_DECLS
int renameat(int oldFD, const char* oldPath, int newFD, const char* newPath); int renameat(int oldFD, const char* oldPath, int newFD, const char* newPath);
int symlinkat(const char *oldPath, int fd, const char *newPath); int symlinkat(const char *oldPath, int fd, const char *newPath);
#ifdef __cplusplus __END_DECLS
}
#endif
#endif // _HAIKU_BUILD_COMPATIBILITY_DARWIN_STDIO #endif // _HAIKU_BUILD_COMPATIBILITY_DARWIN_STDIO
+4
View File
@@ -25,10 +25,14 @@
# endif # endif
#endif #endif
__BEGIN_DECLS
int fchmodat(int fd, const char* path, mode_t mode, int flag); 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 fstatat(int fd, const char *path, struct stat *st, int flag);
int mkdirat(int fd, const char *path, mode_t mode); int mkdirat(int fd, const char *path, mode_t mode);
int mkfifoat(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); int mknodat(int fd, const char *name, mode_t mode, dev_t dev);
__END_DECLS
#endif /* _HAIKU_BUILD_COMPATIBILITY_DARWIN_SYS_STAT */ #endif /* _HAIKU_BUILD_COMPATIBILITY_DARWIN_SYS_STAT */
+3 -7
View File
@@ -1,20 +1,16 @@
#ifndef _HAIKU_BUILD_COMPATIBILITY_DARWIN_UNISTD #ifndef _HAIKU_BUILD_COMPATIBILITY_DARWIN_UNISTD
#define _HAIKU_BUILD_COMPATIBILITY_DARWIN_UNISTD #define _HAIKU_BUILD_COMPATIBILITY_DARWIN_UNISTD
#ifdef __cplusplus
extern "C" {
#endif
#include_next <unistd.h> #include_next <unistd.h>
__BEGIN_DECLS
int faccessat(int fd, const char* path, int accessMode, int flag); 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); 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); 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 linkat(int oldFD, const char *oldPath, int newFD, const char *newPath,
int flag); int flag);
#ifdef __cplusplus __END_DECLS
}
#endif
#endif // _HAIKU_BUILD_COMPATIBILITY_DARWIN_UNISTD #endif // _HAIKU_BUILD_COMPATIBILITY_DARWIN_UNISTD
+2 -2
View File
@@ -47,11 +47,11 @@ if $(HOST_PLATFORM) = cygwin || $(HOST_PLATFORM) = sunos {
local hostPlatformSources ; local hostPlatformSources ;
if $(HOST_PLATFORM) = freebsd { if $(HOST_PLATFORM) = freebsd {
hostPlatformSources = fs_freebsd.cpp ; hostPlatformSources = fs_freebsd.c ;
} }
if $(HOST_PLATFORM) = darwin { if $(HOST_PLATFORM) = darwin {
hostPlatformSources = fs_darwin.cpp ; hostPlatformSources = fs_darwin.c ;
} }
local librootSources = local librootSources =
@@ -4,7 +4,6 @@
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#include <dirent.h> #include <dirent.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
@@ -116,7 +115,7 @@ faccessat(int fd, const char* path, int accessMode, int flag)
return -1; return -1;
} }
if (fd == AT_FDCWD || path != NULL && path[0] == '/') { if (fd == AT_FDCWD || (path != NULL && path[0] == '/')) {
// call access() ignoring fd // call access() ignoring fd
return (flag & AT_EACCESS) != 0 ? eaccess(path, accessMode) return (flag & AT_EACCESS) != 0 ? eaccess(path, accessMode)
: access(path, accessMode); : access(path, accessMode);
@@ -146,7 +145,7 @@ fchmodat(int fd, const char* path, mode_t mode, int flag)
return -1; return -1;
} }
if (fd == AT_FDCWD || path != NULL && path[0] == '/') { if (fd == AT_FDCWD || (path != NULL && path[0] == '/')) {
// call chmod() ignoring fd // call chmod() ignoring fd
if ((flag & AT_SYMLINK_NOFOLLOW) != 0) { if ((flag & AT_SYMLINK_NOFOLLOW) != 0) {
// fake lchmod() with open() and fchmod() // 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; return -1;
} }
if (fd == AT_FDCWD || path != NULL && path[0] == '/') { if (fd == AT_FDCWD || (path != NULL && path[0] == '/')) {
// call chown() ignoring fd // call chown() ignoring fd
return (flag & AT_SYMLINK_NOFOLLOW) != 0 ? lchown(path, owner, group) return (flag & AT_SYMLINK_NOFOLLOW) != 0 ? lchown(path, owner, group)
: chown(path, owner, group); : chown(path, owner, group);
@@ -244,7 +243,7 @@ fstatat(int fd, const char *path, struct stat *st, int flag)
return -1; return -1;
} }
if (fd == AT_FDCWD || path != NULL && path[0] == '/') { if (fd == AT_FDCWD || (path != NULL && path[0] == '/')) {
// call stat() or lstat() ignoring fd // call stat() or lstat() ignoring fd
return (flag & AT_SYMLINK_NOFOLLOW) != 0 ? lstat(path, st) return (flag & AT_SYMLINK_NOFOLLOW) != 0 ? lstat(path, st)
: stat(path, st); : stat(path, st);
@@ -268,7 +267,7 @@ fstatat(int fd, const char *path, struct stat *st, int flag)
int int
mkdirat(int fd, const char *path, mode_t mode) 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 // call mkdir() ignoring fd
return mkdir(path, mode); return mkdir(path, mode);
} }
@@ -290,7 +289,7 @@ mkdirat(int fd, const char *path, mode_t mode)
int int
mkfifoat(int fd, const char *path, mode_t mode) 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 // call mkfifo() ignoring fd
return mkfifo(path, mode); return mkfifo(path, mode);
} }
@@ -312,7 +311,7 @@ mkfifoat(int fd, const char *path, mode_t mode)
int int
mknodat(int fd, const char *path, mode_t mode, dev_t dev) 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 // call mknod() ignoring fd
return mknod(path, mode, dev); return mknod(path, mode, dev);
} }
@@ -334,14 +333,14 @@ mknodat(int fd, const char *path, mode_t mode, dev_t dev)
int int
renameat(int oldFD, const char* oldPath, int newFD, const char* newPath) renameat(int oldFD, const char* oldPath, int newFD, const char* newPath)
{ {
bool ignoreOldFD = false; int ignoreOldFD = 0;
bool ignoreNewFD = false; int ignoreNewFD = 0;
if (oldFD == AT_FDCWD || oldPath != NULL && oldPath[0] == '/') if (oldFD == AT_FDCWD || (oldPath != NULL && oldPath[0] == '/'))
ignoreOldFD = true; ignoreOldFD = 1;
if (newFD == AT_FDCWD || newPath != NULL && newPath[0] == '/') if (newFD == AT_FDCWD || (newPath != NULL && newPath[0] == '/'))
ignoreNewFD = true; ignoreNewFD = 1;
if (ignoreOldFD && ignoreNewFD) { if (ignoreOldFD && ignoreNewFD) {
// call rename() ignoring the fd's // call rename() ignoring the fd's
@@ -380,7 +379,7 @@ renameat(int oldFD, const char* oldPath, int newFD, const char* newPath)
ssize_t ssize_t
readlinkat(int fd, const char *path, char *buffer, size_t bufferSize) 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 // call readlink() ignoring fd
return readlink(path, buffer, bufferSize); return readlink(path, buffer, bufferSize);
} }
@@ -402,7 +401,7 @@ readlinkat(int fd, const char *path, char *buffer, size_t bufferSize)
int int
symlinkat(const char *oldPath, int fd, const char *newPath) 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 // call symlink() ignoring fd
return symlink(oldPath, newPath); return symlink(oldPath, newPath);
} }
@@ -431,7 +430,7 @@ unlinkat(int fd, const char *path, int flag)
return -1; return -1;
} }
if (fd == AT_FDCWD || path != NULL && path[0] == '/') { if (fd == AT_FDCWD || (path != NULL && path[0] == '/')) {
// call rmdir() or unlink() ignoring fd // call rmdir() or unlink() ignoring fd
return (flag & AT_REMOVEDIR) != 0 ? rmdir(path) : unlink(path); 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; return -1;
} }
bool ignoreOldFD = false; int ignoreOldFD = 0;
bool ignoreNewFD = false; int ignoreNewFD = 0;
if (oldFD == AT_FDCWD || oldPath != NULL && oldPath[0] == '/') if (oldFD == AT_FDCWD || oldPath != NULL && oldPath[0] == '/')
ignoreOldFD = true; ignoreOldFD = 1;
if (newFD == AT_FDCWD || newPath != NULL && newPath[0] == '/') if (newFD == AT_FDCWD || newPath != NULL && newPath[0] == '/')
ignoreNewFD = true; ignoreNewFD = 1;
if (ignoreOldFD && ignoreNewFD) { if (ignoreOldFD && ignoreNewFD) {
// call link() ignoring the fd's // call link() ignoring the fd's
@@ -511,7 +510,7 @@ linkat(int oldFD, const char *oldPath, int newFD, const char *newPath,
int int
futimesat(int fd, const char *path, const struct timeval times[2]) 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 // call utimes() ignoring fd
return utimes(path, times); return utimes(path, times);
} }
@@ -44,7 +44,6 @@ haiku_freebsd_read(int fd, void *buf, size_t nbytes)
if (seekDiff == 0 && nbytesDiff == 0) { if (seekDiff == 0 && nbytesDiff == 0) {
// Not needed but this saves malloc and free operations // Not needed but this saves malloc and free operations
return read(fd, buf, nbytes); return read(fd, buf, nbytes);
} else if (cur % sectorSize + nbytes <= sectorSize) { } else if (cur % sectorSize + nbytes <= sectorSize) {
// Read complete in only a block // Read complete in only a block
char* tmpBlock = (char*)malloc(sectorSize); char* tmpBlock = (char*)malloc(sectorSize);
@@ -65,7 +64,6 @@ haiku_freebsd_read(int fd, void *buf, size_t nbytes)
free(tmpBlock); free(tmpBlock);
return nbytes; return nbytes;
} else { } else {
// Needs to write more than a block // Needs to write more than a block
@@ -88,13 +86,14 @@ haiku_freebsd_read(int fd, void *buf, size_t nbytes)
// Blocks between // Blocks between
if ((nbytes - seekDiff) >= sectorSize) { 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"); perror("read between");
} }
}
// Last block if overflow // Last block if overflow
if (nbytesDiff > 0 ) { if (nbytesDiff > 0 ) {
off_t sdCur = lseek(fd, 0, SEEK_CUR); off_t sdCur = lseek(fd, 0, SEEK_CUR);
if (sdCur == -1) if (sdCur == -1)
perror("lseek last"); perror("lseek last");
@@ -110,7 +109,6 @@ haiku_freebsd_read(int fd, void *buf, size_t nbytes)
return nbytes; return nbytes;
} }
} }
@@ -159,7 +157,6 @@ haiku_freebsd_write(int fd, const void *buf, size_t nbytes)
free(tmpBlock); free(tmpBlock);
return nbytes; return nbytes;
} else { } else {
// Needs to write more than a block // 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); memcpy(tmpBlock + (sectorSize - seekDiff), buf, seekDiff);
if (write(fd, tmpBlock, sectorSize)==-1) if (write(fd, tmpBlock, sectorSize)==-1)
perror("write seekDiff"); perror("write seekDiff");
} }
// Blocks between // Blocks between
@@ -190,15 +186,17 @@ haiku_freebsd_write(int fd, const void *buf, size_t nbytes)
// Last block if overflow // Last block if overflow
if (nbytesDiff > 0) { if (nbytesDiff > 0) {
off_t sdCur = lseek(fd, 0, SEEK_CUR); off_t sdCur = lseek(fd, 0, SEEK_CUR);
if (sdCur == -1) if (sdCur == -1)
perror("lseek last"); perror("lseek last");
if (pread(fd, tmpBlock, sectorSize, sdCur) == -1) if (pread(fd, tmpBlock, sectorSize, sdCur) == -1)
perror("pread last"); perror("pread last");
memcpy(tmpBlock, ((char*)buf) + nbytes - nbytesDiff, nbytesDiff); memcpy(tmpBlock, ((char*)buf) + nbytes - nbytesDiff, nbytesDiff);
if (write(fd, tmpBlock, sectorSize) == -1) if (write(fd, tmpBlock, sectorSize) == -1)
perror("write last"); perror("write last");
// repos at byte offset of latest wrote block // repos at byte offset of latest wrote block
if (lseek(fd, -(sectorSize - nbytesDiff), SEEK_CUR) == -1) if (lseek(fd, -(sectorSize - nbytesDiff), SEEK_CUR) == -1)
perror("lseek2 last"); perror("lseek2 last");
@@ -208,7 +206,6 @@ haiku_freebsd_write(int fd, const void *buf, size_t nbytes)
return nbytes; return nbytes;
} }
} }
+2 -2
View File
@@ -5,6 +5,7 @@
#ifndef FS_FREEBSD_H #ifndef FS_FREEBSD_H
#define FS_FREEBSD_H #define FS_FREEBSD_H
#include <sys/uio.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_readv(int fd, const iovec *vecs, size_t count);
ssize_t haiku_freebsd_writev(int fd, const struct 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
-3
View File
@@ -86,8 +86,6 @@ if $(HOST_PLATFORM_BEOS_COMPATIBLE) {
BuildPlatformMain <build>mkindex : mkindex.cpp : $(HOST_LIBBE) ; 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 BuildPlatformMain <build>rm_attrs_tmp : rm_attrs.cpp
: $(HOST_LIBSUPC++) $(HOST_LIBSTDC++) ; : $(HOST_LIBSUPC++) $(HOST_LIBSTDC++) ;
MakeLocateDebug <build>rm_attrs ; 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 vmdkimage ;
SubInclude HAIKU_TOP src tools unflatten ; SubInclude HAIKU_TOP src tools unflatten ;
SubInclude HAIKU_TOP src tools zip ; SubInclude HAIKU_TOP src tools zip ;