00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #pragma once
00019
00020 #include <unistd.h>
00021 #include <boost/date_time.hpp>
00022
00023 #ifndef ETIME
00024 #define ETIME ETIMEDOUT
00025 #endif
00026
00027 #include <pthread.h>
00028 #ifndef _REENTRANT
00029 #define _REENTRANT
00030 #endif
00031 #ifdef HAVE_SCHED_H
00032 #include <sched.h>
00033 #endif
00034 #ifdef HAVE_SYNCH_H
00035 #include <synch.h>
00036 #endif
00037
00038 #include <drizzled/visibility.h>
00039
00040 namespace drizzled {
00041 namespace internal {
00042
00043 #if !defined(HAVE_PTHREAD_YIELD_ONE_ARG) && !defined(HAVE_PTHREAD_YIELD_ZERO_ARG)
00044
00045 #ifdef HAVE_SCHED_YIELD
00046 #define pthread_yield() sched_yield()
00047 #elif defined(HAVE_PTHREAD_YIELD_NP)
00048 #define pthread_yield() pthread_yield_np()
00049 #endif
00050 #endif
00051
00052
00053
00054
00055
00056
00057 #ifndef set_timespec
00058 #define set_timespec(ABSTIME,SEC) \
00059 {\
00060 struct timeval tv;\
00061 gettimeofday(&tv,0);\
00062 (ABSTIME).tv_sec=tv.tv_sec+(time_t) (SEC);\
00063 (ABSTIME).tv_nsec=tv.tv_usec*1000;\
00064 }
00065 #endif
00066 #ifndef set_timespec_nsec
00067 #define set_timespec_nsec(ABSTIME,NSEC) \
00068 {\
00069 boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::local_time());\
00070 boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));\
00071 uint64_t t_mark= (mytime-epoch).total_microseconds();\
00072 uint64_t now= t_mark + (NSEC/100); \
00073 (ABSTIME).tv_sec= (time_t) (now / 10000000UL); \
00074 (ABSTIME).tv_nsec= (long) (now % 10000000UL * 100 + ((NSEC) % 100)); \
00075 }
00076 #endif
00077
00078
00079 #define safe_mutex_assert_owner(mp)
00080 #define safe_mutex_assert_not_owner(mp)
00081
00082
00083
00084 #if !defined(HAVE_PTHREAD_ATTR_SETSTACKSIZE) && ! defined(pthread_attr_setstacksize)
00085 #define pthread_attr_setstacksize(A,B) pthread_dummy(0)
00086 #endif
00087
00088
00089 #ifdef THREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
00090 extern pthread_mutexattr_t my_fast_mutexattr;
00091 #define MY_MUTEX_INIT_FAST &my_fast_mutexattr
00092 #else
00093 #define MY_MUTEX_INIT_FAST NULL
00094 #endif
00095
00096 #ifndef ESRCH
00097
00098 #define ESRCH 1
00099 #endif
00100
00101 DRIZZLED_API void my_thread_init();
00102
00103 }
00104 }
00105