Ticket #7938: vxworks.hpp.diff
File vxworks.hpp.diff, 4.0 KB (added by , 10 years ago) |
---|
-
C:/Daten/Libraries/Boost/boost/config/platform/vxworks.hpp
73 73 // Generally available functionality: 74 74 #define BOOST_HAS_THREADS 75 75 #define BOOST_HAS_NANOSLEEP 76 #define BOOST_HAS_GETTIMEOFDAY 76 77 #define BOOST_HAS_CLOCK_GETTIME 77 78 #define BOOST_HAS_MACRO_USE_FACET 78 79 … … 88 89 89 90 // Functionality available for RTPs only: 90 91 #ifdef __RTP__ 91 //# define BOOST_HAS_GETTIMEOFDAY92 92 # define BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE 93 93 # define BOOST_HAS_LOG1P 94 94 # define BOOST_HAS_EXPM1 … … 122 122 // miserably fails to #include the required <sysLib.h> to make 123 123 // sysClkRateGet() available! So we manually include it here. 124 124 #ifdef __RTP__ 125 # include <time.h> 125 126 # include <sysLib.h> 126 127 #endif 127 128 … … 151 152 // #include Libraries required for the following function adaption 152 153 #include <ioLib.h> 153 154 #include <tickLib.h> 155 #include <sys/time.h> 154 156 155 157 // Use C-linkage for the following helper functions 156 158 extern "C" { … … 203 205 return -1; 204 206 } 205 207 208 // vxWorks claims to implement gettimeofday in sys/time.h 209 // but nevertheless does not provide it! See 210 // https://support.windriver.com/olsPortal/faces/maintenance/techtipDetail_noHeader.jspx?docId=16442&contentId=WR_TECHTIP_006256 211 // We implement a surrogate version here via clock_gettime: 212 inline int gettimeofday(struct timeval *tv, void * /*tzv*/) { 213 struct timespec ts; 214 clock_gettime(CLOCK_MONOTONIC, &ts); 215 tv->tv_sec = ts.tv_sec; 216 tv->tv_usec = ts.tv_nsec / 1000; 217 return 0; 218 } 219 206 220 // vxWorks does provide neither struct tms nor function times()! 207 221 // We implement an empty dummy-function, simply setting the user 208 222 // and system time to the half of thew actual system ticks-value … … 221 235 }; 222 236 223 237 inline clock_t times(struct tms *t){ 224 clock_t ticks = static_cast<clock_t>(tickGet()); 238 struct timespec ts; 239 clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts); 240 clock_t ticks(static_cast<clock_t>(static_cast<double>(ts.tv_sec) * CLOCKS_PER_SEC + 241 static_cast<double>(ts.tv_nsec) * CLOCKS_PER_SEC / 1000000.0)); 225 242 t->tms_utime = ticks/2U; 226 243 t->tms_stime = ticks/2U; 227 t->tms_cutime = 0; 228 t->tms_cstime = 0; 244 t->tms_cutime = 0; // vxWorks is lacking the concept of a child process! 245 t->tms_cstime = 0; // -> Set the wait times for childs to 0 229 246 return ticks; 230 247 } 231 248 … … 241 258 using ::symlink; 242 259 using ::readlink; 243 260 using ::times; 261 using ::gettimeofday; 244 262 } 245 263 246 264 // Some more macro-magic: 247 265 // vxWorks-around: Some functions are not present or broken in vxWorks 248 266 // but may be patched to life via helper macros... 249 267 250 // Include signal.h which containsa typo to be corrected here268 // Include signal.h which might contain a typo to be corrected here 251 269 #include <signal.h> 252 270 253 271 #define getpagesize() sysconf(_SC_PAGESIZE) // getpagesize is deprecated anyway! … … 259 277 # define FPE_FLTINV (FPE_FLTSUB+1) // vxWorks has no FPE_FLTINV, so define one as a dummy 260 278 #endif 261 279 #if !defined(BUS_ADRALN) && defined(BUS_ADRALNR) 262 # define BUS_ADRALN BUS_ADRALNR // Correct a supposed typo in vxWorks' <signal.h> ?280 # define BUS_ADRALN BUS_ADRALNR // Correct a supposed typo in vxWorks' <signal.h> 263 281 #endif 264 282 //typedef int locale_t; // locale_t is a POSIX-extension, currently unpresent in vxWorks! 265 283 … … 268 286 269 287 // vxWorks lies about XSI conformance, there is no nl_types.h: 270 288 #undef BOOST_HAS_NL_TYPES_H 271 272 // vxWorks blatantly lies about implementing gettimeofday:273 // Though it even declares a prototype in sys/time.h, linking it fails!274 #undef BOOST_HAS_GETTIMEOFDAY275 Kein Zeilenumbruch am Ende der Datei