Split fs_darwin.h defines into various platform dependent headers.

This completes the final 1/3 of #8857. Changes again by nielx with
style fixes by me.

The one part that I couldn't figure out, and maybe Ingo can chime
in here. If headers/build/host/darwin/sys/stat.h is surrounded in

extern "C" {

}

guards then I get a link error complaining that the functions defined
here are duplicate symbols, once in fs.o and once in function_remapper.o.
For example:

ld: duplicate symbol _futimens in generated/objects/darwin/x86_64/release/build/libroot/libroot_build_function_remapper.a(function_remapper.o) and generated/objects/darwin/x86_64/release/build/libroot/libroot_build.a(fs.o) for architecture x86_64

I'm not sure why that is.
This commit is contained in:
John Scipione 2012-08-11 18:26:36 -04:00
parent 0de0cd6c47
commit a43b1ed6d8
9 changed files with 77 additions and 65 deletions

View File

@ -0,0 +1,34 @@
#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>
/*
* Magic value that specify the use of the current working directory
* to determine the target of relative file paths in the openat() and
* similar syscalls.
*/
#define AT_FDCWD -100 /* CWD FD for the *at() functions */
/*
* Miscellaneous flags for the *at() syscalls.
*/
#define AT_EACCESS 0x100 /* faccessat() */
#define AT_SYMLINK_NOFOLLOW 0x200 /* fstatat(), fchmodat(), fchownat(),
utimensat() */
#define AT_SYMLINK_FOLLOW 0x400 /* linkat() */
#define AT_REMOVEDIR 0x800 /* unlinkat() */
int unlinkat(int fd, const char *path, int flag);
int futimesat(int fd, const char *path, const struct timeval times[2]);
#ifdef __cplusplus
}
#endif
#endif // _HAIKU_BUILD_COMPATIBILITY_DARWIN_FCNTL

View File

@ -0,0 +1,17 @@
#ifndef _HAIKU_BUILD_COMPATIBILITY_DARWIN_STDIO
#define _HAIKU_BUILD_COMPATIBILITY_DARWIN_STDIO
#ifdef __cplusplus
extern "C" {
#endif
#include_next <stdio.h>
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
#endif // _HAIKU_BUILD_COMPATIBILITY_DARWIN_STDIO

View File

@ -1,12 +1,9 @@
#ifndef _HAIKU_BUILD_COMPATIBILITY_DARWIN_SYS_STAT
#define _HAIKU_BUILD_COMPATIBILITY_DARWIN_SYS_STAT
#include_next <sys/stat.h>
#include <sys/cdefs.h>
#ifndef UTIME_NOW
# define UTIME_NOW (-1)
# define UTIME_OMIT (-2)
@ -28,5 +25,10 @@
# endif
#endif
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);
#endif /* _HAIKU_BUILD_COMPATIBILITY_DARWIN_SYS_STAT */

View File

@ -0,0 +1,20 @@
#ifndef _HAIKU_BUILD_COMPATIBILITY_DARWIN_UNISTD
#define _HAIKU_BUILD_COMPATIBILITY_DARWIN_UNISTD
#ifdef __cplusplus
extern "C" {
#endif
#include_next <unistd.h>
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
#endif // _HAIKU_BUILD_COMPATIBILITY_DARWIN_UNISTD

View File

@ -1,12 +1,9 @@
#ifndef _HAIKU_BUILD_COMPATIBILITY_FREEBSD_SYS_STAT
#define _HAIKU_BUILD_COMPATIBILITY_FREEBSD_SYS_STAT
#include_next <sys/stat.h>
#include <sys/cdefs.h>
#ifndef UTIME_NOW
# define UTIME_NOW (-1)
# define UTIME_OMIT (-2)
@ -14,7 +11,7 @@
__BEGIN_DECLS
/* assume that futimens() and utimensat() aren't available */
int futimens(int fd, const struct timespec times[2]);
int futimens(int fd, const struct timespec times[2]);
int utimensat(int fd, const char* path, const struct timespec times[2],
int flag);
@ -28,5 +25,4 @@
# endif
#endif
#endif /* _HAIKU_BUILD_COMPATIBILITY_FREEBSD_SYS_STAT */

View File

@ -31,8 +31,6 @@
#if defined(HAIKU_HOST_PLATFORM_FREEBSD)
# include "fs_freebsd.h"
#elif defined(HAIKU_HOST_PLATFORM_DARWIN)
# include "fs_darwin.h"
#endif

View File

@ -5,8 +5,6 @@
*/
#include "fs_darwin.h"
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>

View File

@ -1,44 +0,0 @@
/*
* Copyright 2005-2011, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2012, John Scipione, jscipione@gmail.com.
* Distributed under the terms of the MIT License.
*/
#ifndef FS_DARWIN_H
#define FS_DARWIN_H
/*
* Magic value that specify the use of the current working directory
* to determine the target of relative file paths in the openat() and
* similar syscalls.
*/
#define AT_FDCWD -100 /* CWD FD for the *at() functions */
/*
* Miscellaneous flags for the *at() syscalls.
*/
#define AT_EACCESS 0x100 /* faccessat() */
#define AT_SYMLINK_NOFOLLOW 0x200 /* fstatat(), fchmodat(), fchownat(),
utimensat() */
#define AT_SYMLINK_FOLLOW 0x400 /* linkat() */
#define AT_REMOVEDIR 0x800 /* unlinkat() */
int faccessat(int fd, const char* path, int accessMode, int flag);
int fchmodat(int fd, const char* path, mode_t mode, int flag);
int fchownat(int fd, const char* path, uid_t owner, gid_t group, 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);
int renameat(int oldFD, const char* oldPath, int newFD, const char* newPath);
ssize_t readlinkat(int fd, const char *path, char *buffer, size_t bufferSize);
int symlinkat(const char *oldPath, int fd, const char *newPath);
int unlinkat(int fd, const char *path, int flag);
int linkat(int oldFD, const char *oldPath, int newFD, const char *newPath,
int flag);
int futimesat(int fd, const char *path, const struct timeval times[2]);
#endif // FS_DARWIN_H

View File

@ -5,18 +5,10 @@
#ifndef REMAPPED_FUNCTIONS_H
#define REMAPPED_FUNCTIONS_H
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>
#ifdef __cplusplus
extern "C" {
#endif
int _haiku_build_fchmod(int fd, mode_t mode);
int _haiku_build_fchmodat(int fd, const char* path, mode_t mode, int flag);
int _haiku_build_fstat(int fd, struct stat* st);
@ -53,7 +45,6 @@ int _haiku_build_fcntl(int fd, int op, int argument);
int _haiku_build_renameat(int fromFD, const char* from, int toFD,
const char* to);
#ifdef __cplusplus
} // extern "C"
#endif