diff --git a/build/jam/BuildSetup b/build/jam/BuildSetup index 06c59a91d9..fbed8d1ecf 100644 --- a/build/jam/BuildSetup +++ b/build/jam/BuildSetup @@ -294,7 +294,7 @@ HOST_UNARFLAGS ?= x ; # check the host platform compatibility SetPlatformCompatibilityFlagVariables HOST_PLATFORM : HOST : host : linux freebsd ; -if $(HOST_PLATFORM) = linux { +if $(HOST_PLATFORM) = linux || $(HOST_PLATFORM) = freebsd { # don't use lex: otherwise rc will not work correctly if $(LEX) = lex { LEX = flex ; @@ -422,6 +422,11 @@ if $(HOST_PLATFORM_BEOS_COMPATIBLE) { HOST_LIBSUPC++ = supc++ ; } + # Unlike glibc FreeBSD's libc doesn't have built-in regex support. + if $(HOST_PLATFORM) = freebsd { + HOST_LIBROOT += /usr/lib/libgnuregex.so ; + } + # The BeOS compilers define __INTEL__ respectively __POWERPC__. On the # build platform we need to make sure, this is also defined. if $(HOST_CPU) = x86 { @@ -449,7 +454,7 @@ if $(METROWERKS) { HOST_BE_API_HEADERS = ; HOST_BE_API_CCFLAGS = ; HOST_BE_API_C++FLAGS = ; - + if ! $(HOST_PLATFORM_BEOS_COMPATIBLE) { HOST_BE_API_HEADERS = [ FDirName $(HAIKU_TOP) headers build ] @@ -465,6 +470,10 @@ if ! $(HOST_PLATFORM_BEOS_COMPATIBLE) { HOST_BE_API_C++FLAGS = $(HOST_BE_API_CCFLAGS) ; } +# Add directory with system headers we need when building something for the host +# platform, e.g. containing missing POSIX/GNU headers. +HOST_HDRS += [ FDirName $(HAIKU_TOP) headers build host $(HOST_PLATFORM) ] ; + #pragma mark - @@ -655,7 +664,7 @@ CC = bad-cc ; C++ = bad-c++ ; LINK = bad-link ; -# Allow compiling unit tests on Zeta. Instead of fixing the PostMessage() +# Allow compiling unit tests on Zeta. Instead of fixing the PostMessage() # issues, they deprecated that nice function. This will enable it again: C++FLAGS += -D_ZETA_USING_DEPRECATED_API_=1 ; # Same for buggy find_directory threadsafety fixes diff --git a/headers/build/BeOSBuildCompatibility.h b/headers/build/BeOSBuildCompatibility.h index 7dda8b56e2..928781604d 100644 --- a/headers/build/BeOSBuildCompatibility.h +++ b/headers/build/BeOSBuildCompatibility.h @@ -25,7 +25,7 @@ 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); -// There's no O_NOTRAVERSE under Linux, but there's a O_NOFOLLOW, which +// There's no O_NOTRAVERSE under Linux and FreeBSD, but there's a O_NOFOLLOW, which // means something different (open() fails when the file is a symlink), but // we can abuse this flag for our purposes (we filter it in libroot). #ifndef O_NOTRAVERSE diff --git a/headers/build/host/freebsd/endian.h b/headers/build/host/freebsd/endian.h new file mode 100644 index 0000000000..5a6b5c66c6 --- /dev/null +++ b/headers/build/host/freebsd/endian.h @@ -0,0 +1,14 @@ +#ifndef _HAIKU_BUILD_COMPATIBILITY_FREEBSD_ENDIAN +#define _HAIKU_BUILD_COMPATIBILITY_FREEBSD_ENDIAN + +// There's no in FreeBSD, but . And the macro naming +// differs. + +#include + +#define __LITTLE_ENDIAN _LITTLE_ENDIAN +#define __BIG_ENDIAN _BIG_ENDIAN +#define __PDP_ENDIAN _PDP_ENDIAN +#define BYTE_ORDER _BYTE_ORDER + +#endif // _HAIKU_BUILD_COMPATIBILITY_FREEBSD_ENDIAN diff --git a/headers/build/host/freebsd/regex.h b/headers/build/host/freebsd/regex.h new file mode 100644 index 0000000000..8d42abfbe0 --- /dev/null +++ b/headers/build/host/freebsd/regex.h @@ -0,0 +1,8 @@ +#ifndef _HAIKU_BUILD_COMPATIBILITY_FREEBSD_REGEX +#define _HAIKU_BUILD_COMPATIBILITY_FREEBSD_REGEX + +// There's no in FreeBSD, but . + +#include + +#endif // _HAIKU_BUILD_COMPATIBILITY_FREEBSD_REGEX diff --git a/src/build/libroot/errors.cpp b/src/build/libroot/errors.cpp index e3c1a957c5..2ebea8c6dd 100644 --- a/src/build/libroot/errors.cpp +++ b/src/build/libroot/errors.cpp @@ -1,158 +1,166 @@ - - -#define BUILDING_HAIKU_ERROR_MAPPER 1 -#include - -#include -#include - -#include - -using namespace std; - -static map sToHaikuErrorMap; -static map sToHostErrorMap; -static bool sErrorMapsInitialized = false; - -// init_error_map -static void -init_error_map() -{ - if (sErrorMapsInitialized) - return; - - #define ADD_ERROR(error) \ - sToHaikuErrorMap[error] = HAIKU_##error; \ - sToHostErrorMap[HAIKU_##error] = error; - - ADD_ERROR(E2BIG); - ADD_ERROR(ECHILD); - ADD_ERROR(EDEADLK); - ADD_ERROR(EFBIG); - ADD_ERROR(EMLINK); - ADD_ERROR(ENFILE); - ADD_ERROR(ENODEV); - ADD_ERROR(ENOLCK); - ADD_ERROR(ENOSYS); - ADD_ERROR(ENOTTY); - ADD_ERROR(ENXIO); - ADD_ERROR(ESPIPE); - ADD_ERROR(ESRCH); - #ifdef EFPOS - ADD_ERROR(EFPOS); - #endif - #ifdef ESIGPARM - ADD_ERROR(ESIGPARM); - #endif - ADD_ERROR(EDOM); - ADD_ERROR(ERANGE); - ADD_ERROR(EPROTOTYPE); - ADD_ERROR(EPROTONOSUPPORT); - ADD_ERROR(EPFNOSUPPORT); - ADD_ERROR(EAFNOSUPPORT); - ADD_ERROR(EADDRINUSE); - ADD_ERROR(EADDRNOTAVAIL); - ADD_ERROR(ENETDOWN); - ADD_ERROR(ENETUNREACH); - ADD_ERROR(ENETRESET); - ADD_ERROR(ECONNABORTED); - ADD_ERROR(ECONNRESET); - ADD_ERROR(EISCONN); - ADD_ERROR(ENOTCONN); - ADD_ERROR(ESHUTDOWN); - ADD_ERROR(ECONNREFUSED); - ADD_ERROR(EHOSTUNREACH); - ADD_ERROR(ENOPROTOOPT); - ADD_ERROR(ENOBUFS); - ADD_ERROR(EINPROGRESS); - ADD_ERROR(EALREADY); - ADD_ERROR(EILSEQ); - ADD_ERROR(ENOMSG); - ADD_ERROR(ESTALE); - ADD_ERROR(EOVERFLOW); - ADD_ERROR(EMSGSIZE); - ADD_ERROR(EOPNOTSUPP); - ADD_ERROR(ENOTSOCK); - ADD_ERROR(EHOSTDOWN); - ADD_ERROR(EBADMSG); - ADD_ERROR(ECANCELED); - ADD_ERROR(EDESTADDRREQ); - ADD_ERROR(EDQUOT); - ADD_ERROR(EIDRM); - ADD_ERROR(EMULTIHOP); - ADD_ERROR(ENODATA); - ADD_ERROR(ENOLINK); - ADD_ERROR(ENOSR); - ADD_ERROR(ENOSTR); - ADD_ERROR(ENOTSUP); - ADD_ERROR(EPROTO); - ADD_ERROR(ETIME); - ADD_ERROR(ETXTBSY); - ADD_ERROR(ENOMEM); - ADD_ERROR(EACCES); - ADD_ERROR(EINTR); - ADD_ERROR(EIO); - ADD_ERROR(EBUSY); - ADD_ERROR(EFAULT); - ADD_ERROR(ETIMEDOUT); - ADD_ERROR(EAGAIN); - ADD_ERROR(EWOULDBLOCK); - ADD_ERROR(EBADF); - ADD_ERROR(EEXIST); - ADD_ERROR(EINVAL); - ADD_ERROR(ENAMETOOLONG); - ADD_ERROR(ENOENT); - ADD_ERROR(EPERM); - ADD_ERROR(ENOTDIR); - ADD_ERROR(EISDIR); - ADD_ERROR(ENOTEMPTY); - ADD_ERROR(ENOSPC); - ADD_ERROR(EROFS); - ADD_ERROR(EMFILE); - ADD_ERROR(EXDEV); - ADD_ERROR(ELOOP); - ADD_ERROR(ENOEXEC); - ADD_ERROR(EPIPE); - - sErrorMapsInitialized = true; -} - -// to_host_error -static int -to_host_error(int error) -{ - init_error_map(); - - map::iterator it = sToHostErrorMap.find(error); - return (it != sToHostErrorMap.end() ? it->second : error); -} - -// to_haiku_error -static int -to_haiku_error(int error) -{ - init_error_map(); - - map::iterator it = sToHaikuErrorMap.find(error); - if (it != sToHaikuErrorMap.end()) - return it->second; - - return (error > 0 ? -error : error); -} - -// _haiku_build_strerror -char * -_haiku_build_strerror(int errnum) -{ - return strerror(to_host_error(errnum)); -} - -// _haiku_build_errno -int * -_haiku_build_errno() -{ - static int localErrno = 0; - localErrno = to_haiku_error(errno); - return &localErrno; -} - + + +#define BUILDING_HAIKU_ERROR_MAPPER 1 +#include + +#include +#include + +#include + +using namespace std; + +static map sToHaikuErrorMap; +static map sToHostErrorMap; +static bool sErrorMapsInitialized = false; + +// init_error_map +static void +init_error_map() +{ + if (sErrorMapsInitialized) + return; + + #define ADD_ERROR(error) \ + sToHaikuErrorMap[error] = HAIKU_##error; \ + sToHostErrorMap[HAIKU_##error] = error; + + ADD_ERROR(E2BIG); + ADD_ERROR(ECHILD); + ADD_ERROR(EDEADLK); + ADD_ERROR(EFBIG); + ADD_ERROR(EMLINK); + ADD_ERROR(ENFILE); + ADD_ERROR(ENODEV); + ADD_ERROR(ENOLCK); + ADD_ERROR(ENOSYS); + ADD_ERROR(ENOTTY); + ADD_ERROR(ENXIO); + ADD_ERROR(ESPIPE); + ADD_ERROR(ESRCH); + #ifdef EFPOS + ADD_ERROR(EFPOS); + #endif + #ifdef ESIGPARM + ADD_ERROR(ESIGPARM); + #endif + ADD_ERROR(EDOM); + ADD_ERROR(ERANGE); + ADD_ERROR(EPROTOTYPE); + ADD_ERROR(EPROTONOSUPPORT); + ADD_ERROR(EPFNOSUPPORT); + ADD_ERROR(EAFNOSUPPORT); + ADD_ERROR(EADDRINUSE); + ADD_ERROR(EADDRNOTAVAIL); + ADD_ERROR(ENETDOWN); + ADD_ERROR(ENETUNREACH); + ADD_ERROR(ENETRESET); + ADD_ERROR(ECONNABORTED); + ADD_ERROR(ECONNRESET); + ADD_ERROR(EISCONN); + ADD_ERROR(ENOTCONN); + ADD_ERROR(ESHUTDOWN); + ADD_ERROR(ECONNREFUSED); + ADD_ERROR(EHOSTUNREACH); + ADD_ERROR(ENOPROTOOPT); + ADD_ERROR(ENOBUFS); + ADD_ERROR(EINPROGRESS); + ADD_ERROR(EALREADY); + ADD_ERROR(EILSEQ); + ADD_ERROR(ENOMSG); + ADD_ERROR(ESTALE); + ADD_ERROR(EOVERFLOW); + ADD_ERROR(EMSGSIZE); + ADD_ERROR(EOPNOTSUPP); + ADD_ERROR(ENOTSOCK); + ADD_ERROR(EHOSTDOWN); + ADD_ERROR(EBADMSG); + ADD_ERROR(ECANCELED); + ADD_ERROR(EDESTADDRREQ); + ADD_ERROR(EDQUOT); + ADD_ERROR(EIDRM); + ADD_ERROR(EMULTIHOP); + #ifdef ENODATA + ADD_ERROR(ENODATA); + #endif + ADD_ERROR(ENOLINK); + #ifdef ENOSR + ADD_ERROR(ENOSR); + #endif + #ifdef ENOSTR + ADD_ERROR(ENOSTR); + #endif + ADD_ERROR(ENOTSUP); + ADD_ERROR(EPROTO); + #ifdef ETIME + ADD_ERROR(ETIME); + #endif + ADD_ERROR(ETXTBSY); + ADD_ERROR(ENOMEM); + ADD_ERROR(EACCES); + ADD_ERROR(EINTR); + ADD_ERROR(EIO); + ADD_ERROR(EBUSY); + ADD_ERROR(EFAULT); + ADD_ERROR(ETIMEDOUT); + ADD_ERROR(EAGAIN); + ADD_ERROR(EWOULDBLOCK); + ADD_ERROR(EBADF); + ADD_ERROR(EEXIST); + ADD_ERROR(EINVAL); + ADD_ERROR(ENAMETOOLONG); + ADD_ERROR(ENOENT); + ADD_ERROR(EPERM); + ADD_ERROR(ENOTDIR); + ADD_ERROR(EISDIR); + ADD_ERROR(ENOTEMPTY); + ADD_ERROR(ENOSPC); + ADD_ERROR(EROFS); + ADD_ERROR(EMFILE); + ADD_ERROR(EXDEV); + ADD_ERROR(ELOOP); + ADD_ERROR(ENOEXEC); + ADD_ERROR(EPIPE); + + sErrorMapsInitialized = true; +} + +// to_host_error +static int +to_host_error(int error) +{ + init_error_map(); + + map::iterator it = sToHostErrorMap.find(error); + return (it != sToHostErrorMap.end() ? it->second : error); +} + +// to_haiku_error +static int +to_haiku_error(int error) +{ + init_error_map(); + + map::iterator it = sToHaikuErrorMap.find(error); + if (it != sToHaikuErrorMap.end()) + return it->second; + + return (error > 0 ? -error : error); +} + +// _haiku_build_strerror +char * +_haiku_build_strerror(int errnum) +{ + return strerror(to_host_error(errnum)); +} + +// _haiku_build_errno +int * +_haiku_build_errno() +{ + static int localErrno = 0; + localErrno = to_haiku_error(errno); + return &localErrno; +} + diff --git a/src/preferences/devices/Jamfile b/src/preferences/devices/Jamfile index 43c5bfba33..890c116409 100644 --- a/src/preferences/devices/Jamfile +++ b/src/preferences/devices/Jamfile @@ -15,7 +15,7 @@ rule ISAPnPHeaderGen actions ISAPnPHeaderGen1 { - grep '^PNP[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]] ' $(2[1]) | awk -f $(2[2]) > $(1) ; + grep '^PNP[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]] ' $(2[1]) | gawk -f $(2[2]) > $(1) ; } ISAPnPHeaderGen [ FGristFiles isapnpids.h ] : isapnp_devids.txt : devlist2h.awk ; @@ -33,7 +33,7 @@ rule USBHeaderGen actions USBHeaderGen1 { - awk -v HEADERFILE=$(1[1]) -v DATAFILE=$(1[2]) -f $(2[2]) $(2[1]) + gawk -v HEADERFILE=$(1[1]) -v DATAFILE=$(1[2]) -f $(2[2]) $(2[1]) } USBHeaderGen [ FGristFiles usbdevs.h usbdevs_data.h ] : usbdevs : usb_devlist2h.awk ; @@ -51,7 +51,7 @@ rule PCIHeaderGen actions PCIHeaderGen1 { - awk -v HEADERFILE=$(1) -f $(2[2]) $(2[1]) + gawk -v HEADERFILE=$(1) -f $(2[2]) $(2[1]) } PCIHeaderGen [ FGristFiles pcihdr.h ] : pci.ids : pci-header.awk ; diff --git a/src/tests/add-ons/kernel/file_systems/fs_shell/compat.h b/src/tests/add-ons/kernel/file_systems/fs_shell/compat.h index 9f9521b99c..2aad7f753c 100644 --- a/src/tests/add-ons/kernel/file_systems/fs_shell/compat.h +++ b/src/tests/add-ons/kernel/file_systems/fs_shell/compat.h @@ -6,7 +6,7 @@ and some versions of Unix). To further avoid complications I've also hidden the stat and dirent structs since those vary even more widely. - THIS CODE COPYRIGHT DOMINIC GIAMPAOLO. NO WARRANTY IS EXPRESSED + THIS CODE COPYRIGHT DOMINIC GIAMPAOLO. NO WARRANTY IS EXPRESSED OR IMPLIED. YOU MAY USE THIS CODE AND FREELY DISTRIBUTE IT FOR NON-COMMERCIAL USE AS LONG AS THIS NOTICE REMAINS ATTACHED. @@ -14,8 +14,8 @@ Dominic Giampaolo dbg@be.com -*/ - +*/ + #ifndef _COMPAT_H #define _COMPAT_H @@ -51,6 +51,19 @@ typedef struct iovec iovec; # include /* for a few typedefs */ # include /* for various ioctl structs, etc */ # include /* because we're boneheads sometimes */ +#elif HAIKU_HOST_PLATFORM_FREEBSD +/* BSD Compilant stat.h */ +# define __BSD_VISIBLE 1 +#undef __XSI_VISIBLE +# define __XSI_VISIBLE 1 + /* for mknod */ +# define __POSIX_VISIBLE 200112 + /* for S_ISLNK, S_ISSOCK and lstat */ +# include +# include +# include /* for a few typedefs */ +# include /* for various ioctl structs, etc */ +typedef unsigned long ulong; #else # include # include /* for a few typedefs */ diff --git a/src/tests/add-ons/kernel/file_systems/fs_shell/errors.cpp b/src/tests/add-ons/kernel/file_systems/fs_shell/errors.cpp index aba4b0cce3..a62259a34e 100644 --- a/src/tests/add-ons/kernel/file_systems/fs_shell/errors.cpp +++ b/src/tests/add-ons/kernel/file_systems/fs_shell/errors.cpp @@ -55,8 +55,12 @@ static error_entry sErrors[] = { { FS_ENXIO, ENXIO }, { FS_ESPIPE, ESPIPE }, { FS_ESRCH, ESRCH }, -// { FS_EFPOS, EFPOS }, -// { FS_ESIGPARM, ESIGPARM }, + #ifdef EFPOS + { FS_EFPOS, EFPOS }, + #endif + #ifdef ESIGPARM + { FS_ESIGPARM, ESIGPARM }, + #endif { FS_EDOM, EDOM }, { FS_ERANGE, ERANGE }, { FS_EPROTOTYPE, EPROTOTYPE }, @@ -93,13 +97,21 @@ static error_entry sErrors[] = { { FS_EDQUOT, EDQUOT }, { FS_EIDRM, EIDRM }, { FS_EMULTIHOP, EMULTIHOP }, - { FS_ENODATA, ENODATA }, + #ifdef ENODATA + { FS_ENODATA, ENODATA }, + #endif { FS_ENOLINK, ENOLINK }, - { FS_ENOSR, ENOSR }, - { FS_ENOSTR, ENOSTR }, + #ifdef ENOSR + { FS_ENOSR, ENOSR }, + #endif + #ifdef ENOSTR + { FS_ENOSTR, ENOSTR }, + #endif { FS_ENOTSUP, ENOTSUP }, { FS_EPROTO, EPROTO }, - { FS_ETIME, ETIME }, + #ifdef ETIME + { FS_ETIME, ETIME }, + #endif { FS_ETXTBSY, ETXTBSY }, { FS_ENOMEM, ENOMEM }, diff --git a/src/tests/add-ons/kernel/file_systems/fs_shell/external_commands_unix.cpp b/src/tests/add-ons/kernel/file_systems/fs_shell/external_commands_unix.cpp index 8958266796..ec8f7a5ccb 100644 --- a/src/tests/add-ons/kernel/file_systems/fs_shell/external_commands_unix.cpp +++ b/src/tests/add-ons/kernel/file_systems/fs_shell/external_commands_unix.cpp @@ -121,7 +121,8 @@ get_external_command(const char *prompt, char *input, int len) } // get the len of the command - int commandLen = strnlen(message.command, sizeof(message.command)) + 1; + message.command[sizeof(message.command) - 1] = '\0'; + int commandLen = strlen(message.command) + 1; if (commandLen <= 1) { fprintf(stderr, "No command given.\n"); continue; diff --git a/src/tools/makebootable/platform/bios_ia32/Jamfile b/src/tools/makebootable/platform/bios_ia32/Jamfile index 504651fb3f..a87008487d 100644 --- a/src/tools/makebootable/platform/bios_ia32/Jamfile +++ b/src/tools/makebootable/platform/bios_ia32/Jamfile @@ -8,7 +8,7 @@ SEARCH_SOURCE USES_BE_API on makebootable = true ; local hostPlatformSources ; -if $(HOST_PLATFORM) = linux { +if $(HOST_PLATFORM) = linux || $(HOST_PLATFORM) = freebsd { hostPlatformSources = PartitionMap.cpp PartitionMapParser.cpp ; SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons kernel