// (C) Copyright Dustin Spicuzza 2009. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // See http://www.boost.org for most recent version. // Since WRS does not yet properly support Boost under VxWorks // and this file was badly outdated, but I was keen on using it, // I patched boost myself to make it work. This has been tested and // adapted for vxWorks 6.9 only, there's no proper version checking! // This would need some knowledge about older versions (which I am // lacking). The only thing I know for sure is that very old versions // of vxWorks (namely everything below 6.x) is absolutely unable to // use Boost. This is mainly due to the absolutely outdated libraries // and ancient compiler (GCC 2.96 or worse). Do not even think of // getting this working, a miserable failure is guaranteed! // TODO: Versions below vxWorks 6.x need to be blocked out, // raising a compiler error. // vxWorks specific config options: #define BOOST_PLATFORM "vxWorks" // Special behaviour for the DKM (Kernel-Mode): #ifdef _WRS_KERNEL // The DKM does not have the -header, // but apparently it does have an intrinsic wchar_t meanwhile! # define BOOST_NO_CWCHAR // Lots of wide-functions and -headers are unavailable for DKM as well: # define BOOST_NO_CWCTYPE # define BOOST_NO_SWPRINTF # define BOOST_NO_STD_WSTRING # define BOOST_NO_STD_WSTREAMBUF #endif // Generally available headers: #define BOOST_HAS_UNISTD_H #define BOOST_HAS_STDINT_H #define BOOST_HAS_DIRENT_H #define BOOST_HAS_SLIST // vxWorks does not have installed an iconv-library by default! // So, instead it is suggested to switch to ICU, as this seems to be // the most complete and portable option... #define BOOST_LOCALE_WITH_ICU // Generally available functionality: #define BOOST_HAS_THREADS #define BOOST_HAS_NANOSLEEP #define BOOST_HAS_CLOCK_GETTIME #define BOOST_HAS_MACRO_USE_FACET // Generally unavailable functioality: //#define BOOST_NO_DEDUCED_TYPENAME // Commented out, the test gives an errorneous result! #define BOOST_NO_CXX11_EXTERN_TEMPLATE #define BOOST_NO_CXX11_VARIADIC_MACROS // Generally available threading API's: #define BOOST_HAS_PTHREADS #define BOOST_HAS_SCHED_YIELD #define BOOST_HAS_SIGACTION // Functionality available for RTP only: #ifdef __RTP__ # define BOOST_HAS_GETTIMEOFDAY # define BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE # define BOOST_HAS_LOG1P # define BOOST_HAS_EXPM1 #endif // Functionality available for DKM only: #ifdef _WRS_KERNEL // Luckily, at the moment there seems to be none! #endif // These #defines allow posix_features to work, since vxWorks doesn't // define them itself if for DKM (In RTP on the contrary it does): #ifdef _WRS_KERNEL # define _POSIX_TIMERS 1 # define _POSIX_THREADS 1 #endif // vxWorks doesn't work with asio serial ports: #define BOOST_ASIO_DISABLE_SERIAL_PORT // TODO: The problem here seems to bee that vxWorks uses its own, very specific // ways to handle serial ports, incompatible with POSIX or anything... // Maybe a specific implementation would be possible, but until the // straight need arises... This implementation would presumably consist // of some vxWOrks specific ioctl-calls, etc. // vxWorks-around: defines CLOCKS_PER_SEC as sysClkRateGet() but // miserably fails to #include the required to make // sysClkRateGet() available! So we manually include it here. #ifdef __RTP__ # include #endif // vxWorks-around: In the macros INT32_C(), UINT32_C(), INT64_C() and // UINT64_C() are defined errorneously, yielding not an signed/ // unsigned long/long long type, but a signed/unsigned int/long // type. Eventually this leads to compile errors in ratio_fwd.hpp, // when trying to define several constants which do not fit into a // long type! We correct them here by redefining. #ifdef __cplusplus # include #else # include #endif // Some macro-magic #define VX_JOIN(X, Y) VX_DO_JOIN(X, Y) #define VX_DO_JOIN(X, Y) VX_DO_JOIN2(X, Y) #define VX_DO_JOIN2(X, Y) X##Y // Correctly setup the macros #undef INT32_C #undef UINT32_C #undef INT64_C #undef UINT64_C #define INT32_C(x) VX_JOIN(x, L) #define UINT32_C(x) VX_JOIN(x, UL) #define INT64_C(x) VX_JOIN(x, LL) #define UINT64_C(x) VX_JOIN(x, ULL) // include Libraries required for the following function adaption #include #include #ifdef __cplusplus extern "C" { #endif // vxWorks-around: The required functions getrlimit() and getrlimit() are missing. // But we have the similar functions getprlimit() and setprlimit(), // which may serve the purpose. // Problem: The vxWorks-documentation regarding these functions // doesn't deserve its name! It isn't documented what the first two // parameters idtype and id mean, so we fall back to an educated // guess - null... :-/ // TODO: getprlimit() and setprlimit() do exist in RTP only, for whatever reason. // Thus for DKM there would have to be another implementation. #ifdef __RTP__ inline int getrlimit(int resource, struct rlimit *rlp){ return getprlimit(0, 0, resource, rlp); } inline int setrlimit(int resource, const struct rlimit *rlp){ # ifdef __cplusplus return setprlimit(0, 0, resource, const_cast(rlp)); # else return setprlimit(0, 0, resource, (struct rlimit*)rlp); # endif } #endif // vxWorks only has ftruncate(), so we simulate truncate(): inline int truncate(const char *p, off_t l){ int fd = open(p, O_WRONLY); if (fd == -1){ errno = EACCES; return -1; } if (ftruncate(fd, l) == -1){ close(fd); errno = EACCES; return -1; } return close(fd); } // vxWorks has no symlinks -> always return an error! #ifdef __cplusplus inline int symlink(const char*, const char*){ #else inline int symlink(const char *t, const char *f){ #endif errno = EACCES; return -1; } // vxWorks has no symlinks -> always return an error! #ifdef __cplusplus inline ssize_t readlink(const char*, char*, size_t){ #else inline ssize_t readlink(const char *p, char *b, size_t s){ #endif errno = EACCES; return -1; } // vxWorks does provide neither struct tms nor function times! // We implement an empty dummy-function, simply setting everything // to the actual system ticks-value (better than setting to 0). struct tms{ clock_t tms_utime; // User CPU time clock_t tms_stime; // System CPU time clock_t tms_cutime; // User CPU time of terminated child processes clock_t tms_cstime; // System CPU time of terminated child processes }; inline clock_t times(struct tms *t){ clock_t ticks = (clock_t)tickGet(); t->tms_utime = t->tms_stime = t->tms_cutime = t->tms_cstime = ticks; return ticks; } // Put the selfmade functions into the std-namespace #ifdef __cplusplus } // extern "C" namespace std { # ifdef __RTP__ using ::getrlimit; using ::setrlimit; # endif using ::truncate; using ::symlink; using ::readlink; using ::times; } #endif // Some more macro-magic // vxWorks-around: Some functions are not present in vxWorks but may be patched // via a helper macro... #define getpagesize() sysconf(_SC_PAGESIZE) // getpagesize is deprecated anyway! #ifndef S_ISSOCK # define S_ISSOCK(mode) ((mode & S_IFMT) == S_IFSOCK) // Is file a socket? #endif #define lstat(p, b) stat(p, b) // lstat == stat, as vxWorks has no symlinks! #ifndef FPE_FLTINV # define FPE_FLTINV (FPE_FLTSUB+1) // vxWorks has no FPE_FLTINV, so define one as a dummy #endif #ifndef BUS_ADRALN # define BUS_ADRALN BUS_ADRALNR // Correct a supposed typo in vxWorks' ? #endif //typedef int locale_t; // locale_t is a POSIX-extension, currently unpresent in vxWorks! // boilerplate code: #include // vxWorks lies about XSI conformance, there is no nl_types.h: #undef BOOST_HAS_NL_TYPES_H