1 #ifndef BEOS_BUILD_COMPATIBILITY_H 2 #define BEOS_BUILD_COMPATIBILITY_H 3 4 #if defined(HAIKU_HOST_PLATFORM_CYGWIN) 5 # ifndef __addr_t_defined 6 # define __addr_t_defined 7 # endif 8 #endif 9 10 #if defined(HAIKU_HOST_PLATFORM_CYGWIN) || defined(HAIKU_HOST_PLATFORM_SUNOS) 11 #ifndef DEFFILEMODE 12 #define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) 13 #endif 14 15 #ifndef S_IUMSK 16 #define S_IUMSK 07777 17 #endif 18 19 #include <ctype.h> 20 #endif 21 22 #ifdef HAIKU_HOST_PLATFORM_SUNOS 23 # include <limits.h> 24 # ifndef NAME_MAX 25 # define NAME_MAX MAXNAMELEN 26 # endif 27 #endif 28 29 typedef unsigned long haiku_build_addr_t; 30 #define addr_t haiku_build_addr_t 31 32 #include <Errors.h> 33 34 #include <fcntl.h> 35 #include <string.h> 36 #include <sys/types.h> 37 #include <sys/uio.h> 38 39 #ifdef __cplusplus 40 extern "C" { 41 #endif 42 43 // Is kernel-only under Linux. 44 extern size_t strlcpy(char* dest, const char* source, size_t length); 45 extern size_t strlcat(char* dest, const char* source, size_t length); 46 47 #if defined(HAIKU_HOST_PLATFORM_FREEBSD) || defined(HAIKU_HOST_PLATFORM_DARWIN) 48 extern size_t strnlen(const char* string, size_t length); 49 #endif 50 51 #if defined(HAIKU_HOST_PLATFORM_CYGWIN) || defined(HAIKU_HOST_PLATFORM_SUNOS) 52 extern char* stpcpy(char* dest, const char* src); 53 extern char* strcasestr(const char* s, const char* find); 54 #endif 55 56 // BeOS only 57 extern ssize_t read_pos(int fd, off_t pos, void* buffer, size_t count); 58 extern ssize_t write_pos(int fd, off_t pos, const void* buffer, size_t count); 59 extern ssize_t readv_pos(int fd, off_t pos, const struct iovec* vec, 60 size_t count); 61 extern ssize_t writev_pos(int fd, off_t pos, const struct iovec* vec, 62 size_t count); 63 64 65 // There's no O_NOTRAVERSE under Linux and FreeBSD -- we replace it with a flag 66 // that won't be used by our tools, preferrably a non-portable one; a fixed 67 // constant could always lead to trouble on the host. 68 // We can abuse this flag for our purposes as we filter it in libroot. 69 #ifndef O_NOTRAVERSE 70 # ifdef O_NOCTTY 71 # define O_NOTRAVERSE O_NOCTTY 72 # elif defined(O_RANDOM) 73 # define O_NOTRAVERSE O_RANDOM 74 # else 75 # error "Search for a proper replacement value for O_NOTRAVERSE" 76 # endif 77 #endif 78 79 #ifndef S_IUMSK 80 # define S_IUMSK ALLPERMS 81 #endif 82 83 84 // remap strerror() 85 extern char* _haiku_build_strerror(int errnum); 86 87 #ifndef BUILDING_HAIKU_ERROR_MAPPER 88 89 #undef strerror 90 #define strerror(errnum) _haiku_build_strerror(errnum) 91 92 #endif // BUILDING_HAIKU_ERROR_MAPPER 93 94 #ifdef __cplusplus 95 } // extern "C" 96 #endif 97 98 #endif // BEOS_BUILD_COMPATIBILITY_H 99 100