From 6236ae85702a77a03b8baca3f40eb684fdf9cfc2 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Wed, 25 Nov 2009 23:48:45 +0000 Subject: [PATCH] Also include HaikuBuildCompatibility.h on a Haiku host platform and conditionally define some of the new stuff there. That fixes the build under a r34172 Haiku, though it also causes some problems that needed working around. Haven't tested under newer Haiku revisions yet. Will do tomorrow. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34267 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- build/jam/BuildSetup | 8 ++ headers/build/HaikuBuildCompatibility.h | 137 +++++++++++++++++++++--- src/tools/gensyscalls/Jamfile | 2 + 3 files changed, 130 insertions(+), 17 deletions(-) diff --git a/build/jam/BuildSetup b/build/jam/BuildSetup index 43ea34f7dc..8ebd543f8c 100644 --- a/build/jam/BuildSetup +++ b/build/jam/BuildSetup @@ -677,6 +677,14 @@ if $(HOST_PLATFORM_BEOS_COMPATIBLE) { HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR = "export LIBRARY_PATH=$LIBRARY_PATH:$(HOST_BUILD_COMPATIBILITY_LIB_DIR)" ; HOST_LIBRARY_NAME_MAP_input_server = /system/servers/input_server ; HOST_DEFINES += __STDC_FORMAT_MACROS __STDC_LIMIT_MACROS ; + + local compatibilityHeader = -include [ FDirName $(HAIKU_TOP) headers build + HaikuBuildCompatibility.h ] ; + HOST_CCFLAGS += $(compatibilityHeader) ; + HOST_C++FLAGS += $(compatibilityHeader) ; + + # compatibility library + HOST_HAIKU_COMPATIBILITY_LIBS = libhaikucompat.a ; } else { HOST_LIBSTDC++ = stdc++ ; HOST_LIBROOT = libroot_build.so ; diff --git a/headers/build/HaikuBuildCompatibility.h b/headers/build/HaikuBuildCompatibility.h index 3f55e4179a..23a059fa50 100644 --- a/headers/build/HaikuBuildCompatibility.h +++ b/headers/build/HaikuBuildCompatibility.h @@ -3,8 +3,9 @@ /*! This header is automatically included in all Haiku applications - that are built for BeOS. - It will make BeOS a bit more Haiku compatible, and slightly more + that are built for BeOS or a Haiku host (which might not be compatible + with the current Haiku source anymore). + It will make BeOS/Haiku a bit more Haiku compatible, and slightly more POSIX compatible, too. It is supposed to keep the BeOS compatibility kludges in our source files at a minimum. */ @@ -22,14 +23,20 @@ # include #endif +#include #include #include +#include #include // no addr_t under standard BeOS -typedef unsigned long haiku_build_addr_t; -#define addr_t haiku_build_addr_t +#ifndef HAIKU_HOST_PLATFORM_HAIKU + typedef unsigned long haiku_build_addr_t; +# define addr_t haiku_build_addr_t +#endif + +#ifndef HAIKU_HOST_PLATFORM_HAIKU struct sockaddr_storage { uint8 ss_len; /* total length */ @@ -41,6 +48,8 @@ struct sockaddr_storage { typedef int socklen_t; +#endif // !HAIKU_HOST_PLATFORM_HAIKU + #ifndef DEFFILEMODE # define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) #endif @@ -65,12 +74,13 @@ typedef int socklen_t; # define B_SPINLOCK_INITIALIZER 0 #endif -#if __GNUC__ +#if defined(__GNUC__) && !defined(_PRINTFLIKE) # define _PRINTFLIKE(_format_, _args_) \ __attribute__((format(__printf__, _format_, _args_))) #endif -#ifdef HAIKU_TARGET_PLATFORM_LIBBE_TEST +#if defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) \ + && !defined(HAIKU_HOST_PLATFORM_HAIKU) // BeOS version of BeBuild.h defines this # define _IMPEXP_ROOT __declspec(dllimport) # define _IMPEXP_BE __declspec(dllimport) @@ -81,7 +91,7 @@ typedef int socklen_t; # define _IMPEXP_NET __declspec(dllimport) #endif -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(HAIKU_HOST_PLATFORM_HAIKU) class BBuffer; class BBufferConsumer; class BBufferGroup; @@ -128,7 +138,8 @@ extern float roundf(float value); #endif // These are R1-specific extensions -#ifndef HAIKU_TARGET_PLATFORM_LIBBE_TEST +#if !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) \ + && !defined(HAIKU_HOST_PLATFORM_HAIKU) # define B_TRANSLATION_MAKE_VERSION(major, minor, revision) \ ((major << 8) | ((minor << 4) & 0xf0) | (revision & 0x0f)) # define B_TRANSLATION_MAJOR_VERSION(v) (v >> 8) @@ -150,7 +161,7 @@ extern float roundf(float value); # define B_DOCUMENT_TEXT_COLOR B_MENU_ITEM_TEXT_COLOR #endif -#if !defined(HAIKU_TARGET_PLATFORM_HAIKU) && !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) +#if !defined(HAIKU_HOST_PLATFORM_HAIKU) && !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) # if !defined(B_NOT_SUPPORTED) && !defined(HAIKU_HOST_PLATFORM_DANO) # define B_NOT_SUPPORTED (B_ERROR) # endif @@ -174,15 +185,18 @@ extern float roundf(float value); # define INT64_MAX LONGLONG_MAX #endif -#define B_MPEG_2_AUDIO_LAYER_1 (enum mpeg_id)0x201 -#define B_MPEG_2_AUDIO_LAYER_2 (enum mpeg_id)0x202 -#define B_MPEG_2_AUDIO_LAYER_3 (enum mpeg_id)0x203 -#define B_MPEG_2_VIDEO (enum mpeg_id)0x211 -#define B_MPEG_2_5_AUDIO_LAYER_1 (enum mpeg_id)0x301 -#define B_MPEG_2_5_AUDIO_LAYER_2 (enum mpeg_id)0x302 -#define B_MPEG_2_5_AUDIO_LAYER_3 (enum mpeg_id)0x303 +#ifndef HAIKU_HOST_PLATFORM_HAIKU +# define B_MPEG_2_AUDIO_LAYER_1 (enum mpeg_id)0x201 +# define B_MPEG_2_AUDIO_LAYER_2 (enum mpeg_id)0x202 +# define B_MPEG_2_AUDIO_LAYER_3 (enum mpeg_id)0x203 +# define B_MPEG_2_VIDEO (enum mpeg_id)0x211 +# define B_MPEG_2_5_AUDIO_LAYER_1 (enum mpeg_id)0x301 +# define B_MPEG_2_5_AUDIO_LAYER_2 (enum mpeg_id)0x302 +# define B_MPEG_2_5_AUDIO_LAYER_3 (enum mpeg_id)0x303 +#endif // TODO: experimental API (keep in sync with Accelerant.h) +#ifndef HAIKU_HOST_PLATFORM_HAIKU typedef struct { uint32 version; char vendor[128]; @@ -201,7 +215,96 @@ typedef struct { uint32 max_vertical_frequency; uint32 max_pixel_clock; // in kHz } monitor_info; +#endif // !HAIKU_HOST_PLATFORM_HAIKU + + +#if !defined(B_HAIKU_32_BIT) && !defined(B_HAIKU_64_BIT) +# ifdef HAIKU_HOST_PLATFORM_64_BIT +# define B_HAIKU_64_BIT 1 +# else +# define B_HAIKU_32_BIT 1 +# endif +#endif + +#ifndef B_PRId8 +# define __HAIKU_PRI_PREFIX_32 "l" +# define __HAIKU_PRI_PREFIX_64 "ll" +# define __HAIKU_PRI_PREFIX_ADDR "l" + + /* printf()/scanf() format strings for [u]int* types */ +# define B_PRId8 "d" +# define B_PRIi8 "i" +# define B_PRId16 "d" +# define B_PRIi16 "i" +# define B_PRId32 __HAIKU_PRI_PREFIX_32 "d" +# define B_PRIi32 __HAIKU_PRI_PREFIX_32 "i" +# define B_PRId64 __HAIKU_PRI_PREFIX_64 "d" +# define B_PRIi64 __HAIKU_PRI_PREFIX_64 "i" +# define B_PRIu8 "u" +# define B_PRIo8 "o" +# define B_PRIx8 "x" +# define B_PRIX8 "X" +# define B_PRIu16 "u" +# define B_PRIo16 "o" +# define B_PRIx16 "x" +# define B_PRIX16 "X" +# define B_PRIu32 __HAIKU_PRI_PREFIX_32 "u" +# define B_PRIo32 __HAIKU_PRI_PREFIX_32 "o" +# define B_PRIx32 __HAIKU_PRI_PREFIX_32 "x" +# define B_PRIX32 __HAIKU_PRI_PREFIX_32 "X" +# define B_PRIu64 __HAIKU_PRI_PREFIX_64 "u" +# define B_PRIo64 __HAIKU_PRI_PREFIX_64 "o" +# define B_PRIx64 __HAIKU_PRI_PREFIX_64 "x" +# define B_PRIX64 __HAIKU_PRI_PREFIX_64 "X" + +# define B_SCNd8 "hhd" +# define B_SCNi8 "hhi" +# define B_SCNd16 "hd" +# define B_SCNi16 "hi" +# define B_SCNd32 __HAIKU_PRI_PREFIX_32 "d" +# define B_SCNi32 __HAIKU_PRI_PREFIX_32 "i" +# define B_SCNd64 __HAIKU_PRI_PREFIX_64 "d" +# define B_SCNi64 __HAIKU_PRI_PREFIX_64 "i" +# define B_SCNu8 "hhu" +# define B_SCNo8 "hho" +# define B_SCNx8 "hhx" +# define B_SCNu16 "hu" +# define B_SCNo16 "ho" +# define B_SCNx16 "hx" +# define B_SCNu32 __HAIKU_PRI_PREFIX_32 "u" +# define B_SCNo32 __HAIKU_PRI_PREFIX_32 "o" +# define B_SCNx32 __HAIKU_PRI_PREFIX_32 "x" +# define B_SCNu64 __HAIKU_PRI_PREFIX_64 "u" +# define B_SCNo64 __HAIKU_PRI_PREFIX_64 "o" +# define B_SCNx64 __HAIKU_PRI_PREFIX_64 "x" + + /* printf() format strings for some standard types */ + /* size_t */ +# define B_PRIuSIZE __HAIKU_PRI_PREFIX_ADDR "u" +# define B_PRIoSIZE __HAIKU_PRI_PREFIX_ADDR "o" +# define B_PRIxSIZE __HAIKU_PRI_PREFIX_ADDR "x" +# define B_PRIXSIZE __HAIKU_PRI_PREFIX_ADDR "X" + /* ssize_t */ +# define B_PRIdSSIZE __HAIKU_PRI_PREFIX_ADDR "d" +# define B_PRIiSSIZE __HAIKU_PRI_PREFIX_ADDR "i" + /* addr_t */ +# define B_PRIuADDR __HAIKU_PRI_PREFIX_ADDR "u" +# define B_PRIoADDR __HAIKU_PRI_PREFIX_ADDR "o" +# define B_PRIxADDR __HAIKU_PRI_PREFIX_ADDR "x" +# define B_PRIXADDR __HAIKU_PRI_PREFIX_ADDR "X" + /* off_t */ +# define B_PRIdOFF B_PRId64 +# define B_PRIiOFF B_PRIi64 + /* dev_t */ +# define B_PRIdDEV B_PRId32 +# define B_PRIiDEV B_PRIi32 + /* ino_t */ +# define B_PRIdINO B_PRId64 +# define B_PRIiINO B_PRIi64 + /* time_t */ +# define B_PRIdTIME B_PRId32 +# define B_PRIiTIME B_PRIi32 +#endif // !B_PRId8 #endif // HAIKU_BUILD_COMPATIBILITY_H - diff --git a/src/tools/gensyscalls/Jamfile b/src/tools/gensyscalls/Jamfile index 3029a7a7e2..51e3197f9b 100644 --- a/src/tools/gensyscalls/Jamfile +++ b/src/tools/gensyscalls/Jamfile @@ -87,6 +87,8 @@ SubDirHdrs [ FDirName $(SUBDIR) arch $(TARGET_ARCH) ] ; # build gensyscalls +ObjectDefines $(syscallInfos) : HAIKU_BUILD_COMPATIBILITY_H ; + # Prevent the inclusion of HaikuBuildCompatibility.h. TODO: Very hacky! BuildPlatformMain gensyscalls : gensyscalls.cpp $(syscallInfos) ; LinkAgainst gensyscalls : $(HOST_LIBSTDC++) $(HOST_LIBSUPC++) ;