2005-11-07 21:17:21 +03:00
|
|
|
#ifndef BEOS_BUILD_COMPATIBILITY_H
|
|
|
|
#define BEOS_BUILD_COMPATIBILITY_H
|
2005-11-04 17:48:35 +03:00
|
|
|
|
2020-05-03 20:24:26 +03:00
|
|
|
// DEFFILEMODE is not available on platforms with MUSL
|
2008-07-24 01:39:13 +04:00
|
|
|
#ifndef DEFFILEMODE
|
|
|
|
#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
|
|
|
|
#endif
|
|
|
|
|
2018-11-23 23:40:50 +03:00
|
|
|
// There's no ALLPERMS on platforms with MUSL
|
2018-04-29 09:38:10 +03:00
|
|
|
#ifndef ALLPERMS
|
|
|
|
# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)
|
|
|
|
#endif
|
|
|
|
|
2008-07-24 01:39:13 +04:00
|
|
|
#ifndef S_IUMSK
|
|
|
|
#define S_IUMSK 07777
|
|
|
|
#endif
|
|
|
|
|
* config/{HaikuConfig.h,types.h}:
- Added macro __HAIKU_ARCH_BITS specifying the architecture bitness (32/64)
(might be more convenient to use than __HAIKU_ARCH_{32,64}_BIT).
- Added macros __HAIKU_ARCH_PHYSICAL_BITS, __HAIKU_ARCH_PHYSICAL_{32,64}_BIT,
and the types __haiku_phys_[s]addr_t. The intention is to use separate
macros and types for virtual and physical addresses, since for some
architectures (e.g. x86 with PAE) those actually differ.
* sys/types.h, BeBuild.h, SupportDefs.h:
- Added types phys_[s]addr_t and respective printf() format macros.
- Added public macros B_HAIKU_BITS, B_HAIKU_PHYSICAL_BITS,
B_HAIKU_PHYSICAL_{32,64}_BIT.
Might break the build under older Haiku installations. Will test next.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36926 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-24 23:55:38 +04:00
|
|
|
typedef unsigned long haiku_build_addr_t;
|
|
|
|
#define addr_t haiku_build_addr_t
|
2005-11-04 17:48:35 +03:00
|
|
|
|
2020-05-03 20:24:26 +03:00
|
|
|
#if defined(HAIKU_HOST_PLATFORM_MSYS)
|
|
|
|
#define __addr_t_defined
|
|
|
|
#endif
|
|
|
|
|
2005-11-04 17:48:35 +03:00
|
|
|
#include <Errors.h>
|
2007-09-05 06:54:24 +04:00
|
|
|
|
|
|
|
#include <fcntl.h>
|
2011-06-30 21:17:17 +04:00
|
|
|
#include <stdio.h>
|
2005-11-04 17:48:35 +03:00
|
|
|
#include <string.h>
|
2011-06-30 21:17:17 +04:00
|
|
|
#include <sys/stat.h>
|
2007-09-05 06:54:24 +04:00
|
|
|
#include <sys/types.h>
|
2011-06-30 21:17:17 +04:00
|
|
|
#include <unistd.h>
|
2018-11-24 00:21:48 +03:00
|
|
|
#include <sys/uio.h>
|
|
|
|
|
2005-11-04 17:48:35 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Is kernel-only under Linux.
|
2013-12-17 20:48:03 +04:00
|
|
|
#ifndef strlcpy
|
2009-11-26 19:02:07 +03:00
|
|
|
extern size_t strlcpy(char* dest, const char* source, size_t length);
|
2013-12-17 20:48:03 +04:00
|
|
|
#endif
|
|
|
|
#ifndef strlcat
|
2009-11-26 19:02:07 +03:00
|
|
|
extern size_t strlcat(char* dest, const char* source, size_t length);
|
2013-12-17 20:48:03 +04:00
|
|
|
#endif
|
2005-11-04 17:48:35 +03:00
|
|
|
|
2007-05-18 19:59:04 +04:00
|
|
|
#if defined(HAIKU_HOST_PLATFORM_FREEBSD) || defined(HAIKU_HOST_PLATFORM_DARWIN)
|
2009-11-26 19:02:07 +03:00
|
|
|
extern size_t strnlen(const char* string, size_t length);
|
2006-02-03 15:24:15 +03:00
|
|
|
#endif
|
|
|
|
|
2005-11-04 17:48:35 +03:00
|
|
|
// BeOS only
|
2009-11-26 19:02:07 +03:00
|
|
|
extern ssize_t read_pos(int fd, off_t pos, void* buffer, size_t count);
|
|
|
|
extern ssize_t write_pos(int fd, off_t pos, const void* buffer, size_t count);
|
|
|
|
extern ssize_t readv_pos(int fd, off_t pos, const struct iovec* vec,
|
2007-04-27 16:11:30 +04:00
|
|
|
size_t count);
|
2009-11-26 19:02:07 +03:00
|
|
|
extern ssize_t writev_pos(int fd, off_t pos, const struct iovec* vec,
|
2007-04-27 16:11:30 +04:00
|
|
|
size_t count);
|
2005-11-04 17:48:35 +03:00
|
|
|
|
|
|
|
|
2009-11-26 19:02:07 +03:00
|
|
|
// There's no O_NOTRAVERSE under Linux and FreeBSD -- we replace it with a flag
|
|
|
|
// that won't be used by our tools, preferrably a non-portable one; a fixed
|
|
|
|
// constant could always lead to trouble on the host.
|
|
|
|
// We can abuse this flag for our purposes as we filter it in libroot.
|
2005-11-04 17:48:35 +03:00
|
|
|
#ifndef O_NOTRAVERSE
|
2009-11-26 19:02:07 +03:00
|
|
|
# ifdef O_NOCTTY
|
|
|
|
# define O_NOTRAVERSE O_NOCTTY
|
|
|
|
# elif defined(O_RANDOM)
|
|
|
|
# define O_NOTRAVERSE O_RANDOM
|
|
|
|
# else
|
|
|
|
# error "Search for a proper replacement value for O_NOTRAVERSE"
|
|
|
|
# endif
|
2005-11-04 17:48:35 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef S_IUMSK
|
2009-11-26 19:02:07 +03:00
|
|
|
# define S_IUMSK ALLPERMS
|
2005-11-04 17:48:35 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// remap strerror()
|
2009-11-26 19:02:07 +03:00
|
|
|
extern char* _haiku_build_strerror(int errnum);
|
2005-11-04 17:48:35 +03:00
|
|
|
|
|
|
|
#ifndef BUILDING_HAIKU_ERROR_MAPPER
|
|
|
|
|
|
|
|
#undef strerror
|
|
|
|
#define strerror(errnum) _haiku_build_strerror(errnum)
|
|
|
|
|
2009-11-26 19:02:07 +03:00
|
|
|
#endif // BUILDING_HAIKU_ERROR_MAPPER
|
2005-11-04 17:48:35 +03:00
|
|
|
|
2011-06-30 21:17:17 +04:00
|
|
|
|
|
|
|
// remap file descriptor functions
|
|
|
|
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);
|
|
|
|
int _haiku_build_fstatat(int fd, const char* path, struct stat* st,
|
|
|
|
int flag);
|
|
|
|
int _haiku_build_mkdirat(int fd, const char* path, mode_t mode);
|
|
|
|
int _haiku_build_mkfifoat(int fd, const char* path, mode_t mode);
|
|
|
|
int _haiku_build_utimensat(int fd, const char* path,
|
|
|
|
const struct timespec times[2], int flag);
|
|
|
|
int _haiku_build_futimens(int fd, const struct timespec times[2]);
|
|
|
|
int _haiku_build_faccessat(int fd, const char* path, int accessMode,
|
|
|
|
int flag);
|
|
|
|
int _haiku_build_fchdir(int fd);
|
|
|
|
int _haiku_build_close(int fd);
|
|
|
|
int _haiku_build_dup(int fd);
|
|
|
|
int _haiku_build_dup2(int fd1, int fd2);
|
|
|
|
int _haiku_build_linkat(int toFD, const char* toPath, int pathFD,
|
|
|
|
const char* path, int flag);
|
|
|
|
int _haiku_build_unlinkat(int fd, const char* path, int flag);
|
|
|
|
ssize_t _haiku_build_readlinkat(int fd, const char* path, char* buffer,
|
|
|
|
size_t bufferSize);
|
|
|
|
int _haiku_build_symlinkat(const char* toPath, int fd,
|
|
|
|
const char* symlinkPath);
|
|
|
|
int _haiku_build_ftruncate(int fd, off_t newSize);
|
|
|
|
int _haiku_build_fchown(int fd, uid_t owner, gid_t group);
|
|
|
|
int _haiku_build_fchownat(int fd, const char* path, uid_t owner,
|
|
|
|
gid_t group, int flag);
|
|
|
|
int _haiku_build_mknodat(int fd, const char* name, mode_t mode, dev_t dev);
|
|
|
|
int _haiku_build_creat(const char* path, mode_t mode);
|
|
|
|
#ifndef _HAIKU_BUILD_DONT_REMAP_FD_FUNCTIONS
|
|
|
|
int _haiku_build_open(const char* path, int openMode, ...);
|
|
|
|
int _haiku_build_openat(int fd, const char* path, int openMode, ...);
|
|
|
|
int _haiku_build_fcntl(int fd, int op, ...);
|
|
|
|
#else
|
|
|
|
int _haiku_build_open(const char* path, int openMode, mode_t permissions);
|
|
|
|
int _haiku_build_openat(int fd, const char* path, int openMode,
|
|
|
|
mode_t permissions);
|
|
|
|
int _haiku_build_fcntl(int fd, int op, int argument);
|
|
|
|
#endif
|
|
|
|
int _haiku_build_renameat(int fromFD, const char* from, int toFD,
|
|
|
|
const char* to);
|
|
|
|
|
|
|
|
#ifndef _HAIKU_BUILD_DONT_REMAP_FD_FUNCTIONS
|
|
|
|
# define fchmod(fd, mode) _haiku_build_fchmod(fd, mode)
|
|
|
|
# define fchmodat(fd, path, mode, flag) \
|
|
|
|
_haiku_build_fchmodat(fd, path, mode, flag)
|
|
|
|
# define fstat(fd, st) _haiku_build_fstat(fd, st)
|
|
|
|
# define fstatat(fd, path, st, flag) _haiku_build_fstatat(fd, path, st, flag)
|
|
|
|
# define mkdirat(fd, path, mode) _haiku_build_mkdirat(fd, path, mode)
|
|
|
|
# define mkfifoat(fd, path, mode) _haiku_build_mkfifoat(fd, path, mode)
|
|
|
|
# define utimensat(fd, path, times, flag) \
|
|
|
|
_haiku_build_utimensat(fd, path, times, flag)
|
|
|
|
# define futimens(fd, times) _haiku_build_futimens(fd, times)
|
|
|
|
# define faccessat(fd, path, accessMode, flag) \
|
|
|
|
_haiku_build_faccessat(fd, path, accessMode, flag)
|
|
|
|
# define fchdir(fd) _haiku_build_fchdir(fd)
|
|
|
|
# define close(fd) _haiku_build_close(fd)
|
|
|
|
# define dup(fd) _haiku_build_dup(fd)
|
|
|
|
# define dup2(fd1, fd2) _haiku_build_dup2(fd1, fd2)
|
|
|
|
# define linkat(toFD, toPath, pathFD, path, flag) \
|
|
|
|
_haiku_build_linkat(toFD, toPath, pathFD, path, flag)
|
|
|
|
# define unlinkat(fd, path, flag) _haiku_build_unlinkat(fd, path, flag)
|
|
|
|
# define readlinkat(fd, path, buffer, bufferSize) \
|
|
|
|
_haiku_build_readlinkat(fd, path, buffer, bufferSize)
|
|
|
|
# define symlinkat(toPath, fd, symlinkPath) \
|
|
|
|
_haiku_build_symlinkat(toPath, fd, symlinkPath)
|
|
|
|
# define ftruncate(fd, newSize) _haiku_build_ftruncate(fd, newSize)
|
|
|
|
# define fchown(fd, owner, group) _haiku_build_fchown(fd, owner, group)
|
|
|
|
# define fchownat(fd, path, owner, group, flag) \
|
|
|
|
_haiku_build_fchownat(fd, path, owner, group, flag)
|
|
|
|
# define mknodat(fd, name, mode, dev) \
|
|
|
|
_haiku_build_mknodat(fd, name, mode, dev)
|
|
|
|
# define creat(path, mode) _haiku_build_creat(path, mode)
|
|
|
|
# define open(path, openMode...) _haiku_build_open(path, openMode)
|
|
|
|
# define openat(fd, path, openMode...) \
|
|
|
|
_haiku_build_openat(fd, path, openMode)
|
|
|
|
# define fcntl(fd, op...) _haiku_build_fcntl(fd, op)
|
|
|
|
# define renameat(fromFD, from, toFD, to) \
|
|
|
|
_haiku_build_renameat(fromFD, from, toFD, to)
|
2018-04-15 06:59:18 +03:00
|
|
|
|
|
|
|
# if defined(HAIKU_HOST_USE_XATTR) && defined(HAIKU_HOST_PLATFORM_HAIKU)
|
|
|
|
# define fs_read_attr _haiku_build_fs_read_attr
|
|
|
|
# define fs_write_attr _haiku_build_fs_write_attr
|
|
|
|
# define fs_remove_attr _haiku_build_fs_remove_attr
|
|
|
|
# define fs_stat_attr _haiku_build_fs_stat_attr
|
|
|
|
# define fs_open_attr _haiku_build_fs_open_attr
|
|
|
|
# define fs_fopen_attr _haiku_build_fs_fopen_attr
|
|
|
|
# define fs_close_attr _haiku_build_fs_close_attr
|
|
|
|
# define fs_open_attr_dir _haiku_build_fs_open_attr_dir
|
|
|
|
# define fs_fopen_attr_dir _haiku_build_fs_fopen_attr_dir
|
|
|
|
# define fs_close_attr_dir _haiku_build_fs_close_attr_dir
|
|
|
|
# define fs_read_attr_dir _haiku_build_fs_read_attr_dir
|
|
|
|
# define fs_rewind_attr_dir _haiku_build_fs_rewind_attr_dir
|
|
|
|
# endif
|
|
|
|
|
2011-06-30 21:17:17 +04:00
|
|
|
#endif // _HAIKU_BUILD_DONT_REMAP_FD_FUNCTIONS
|
|
|
|
|
|
|
|
|
2005-11-04 17:48:35 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
} // extern "C"
|
|
|
|
#endif
|
|
|
|
|
2005-11-07 21:17:21 +03:00
|
|
|
#endif // BEOS_BUILD_COMPATIBILITY_H
|
2005-11-04 17:48:35 +03:00
|
|
|
|