1
by brian
clean slate |
1 |
/* Copyright (C) 2000 MySQL AB
|
2 |
||
3 |
This program is free software; you can redistribute it and/or modify
|
|
4 |
it under the terms of the GNU General Public License as published by
|
|
5 |
the Free Software Foundation; version 2 of the License.
|
|
6 |
||
7 |
This program is distributed in the hope that it will be useful,
|
|
8 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
10 |
GNU General Public License for more details.
|
|
11 |
||
12 |
You should have received a copy of the GNU General Public License
|
|
13 |
along with this program; if not, write to the Free Software
|
|
1802.10.2
by Monty Taylor
Update all of the copyright headers to include the correct address. |
14 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
1
by brian
clean slate |
15 |
|
16 |
/* Defines to make different thread packages compatible */
|
|
17 |
||
2234
by Brian Aker
Mass removal of ifdef/endif in favor of pragma once. |
18 |
#pragma once
|
1
by brian
clean slate |
19 |
|
549
by Monty Taylor
Took gettext.h out of header files. |
20 |
#include <unistd.h> |
1878.10.1
by Billy Earney
removed my_micro_time, my_micro_time_and_time, along with my_getsystime and replaced with boost:date_time for compatibility between OS. |
21 |
#include <boost/date_time.hpp> |
22 |
||
1
by brian
clean slate |
23 |
#ifndef ETIME
|
24 |
#define ETIME ETIMEDOUT /* For FreeBSD */ |
|
25 |
#endif
|
|
26 |
||
27 |
#include <pthread.h> |
|
28 |
#ifndef _REENTRANT
|
|
29 |
#define _REENTRANT
|
|
30 |
#endif
|
|
31 |
#ifdef HAVE_SCHED_H
|
|
32 |
#include <sched.h> |
|
33 |
#endif
|
|
34 |
#ifdef HAVE_SYNCH_H
|
|
35 |
#include <synch.h> |
|
36 |
#endif
|
|
37 |
||
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
38 |
#include <drizzled/visibility.h> |
2119.4.1
by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by |
39 |
|
2385.3.8
by Olaf van der Spek
Refactor |
40 |
namespace drizzled { |
41 |
namespace internal { |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
42 |
|
1
by brian
clean slate |
43 |
#if !defined(HAVE_PTHREAD_YIELD_ONE_ARG) && !defined(HAVE_PTHREAD_YIELD_ZERO_ARG)
|
44 |
/* no pthread_yield() available */
|
|
45 |
#ifdef HAVE_SCHED_YIELD
|
|
46 |
#define pthread_yield() sched_yield()
|
|
47 |
#elif defined(HAVE_PTHREAD_YIELD_NP) /* can be Mac OS X */ |
|
48 |
#define pthread_yield() pthread_yield_np()
|
|
49 |
#endif
|
|
50 |
#endif
|
|
51 |
||
52 |
/*
|
|
53 |
The defines set_timespec and set_timespec_nsec should be used
|
|
54 |
for calculating an absolute time at which
|
|
55 |
pthread_cond_timedwait should timeout
|
|
56 |
*/
|
|
57 |
#ifndef set_timespec
|
|
58 |
#define set_timespec(ABSTIME,SEC) \
|
|
59 |
{\
|
|
60 |
struct timeval tv;\
|
|
61 |
gettimeofday(&tv,0);\
|
|
62 |
(ABSTIME).tv_sec=tv.tv_sec+(time_t) (SEC);\
|
|
63 |
(ABSTIME).tv_nsec=tv.tv_usec*1000;\
|
|
64 |
}
|
|
65 |
#endif /* !set_timespec */ |
|
66 |
#ifndef set_timespec_nsec
|
|
67 |
#define set_timespec_nsec(ABSTIME,NSEC) \
|
|
68 |
{\
|
|
1878.10.1
by Billy Earney
removed my_micro_time, my_micro_time_and_time, along with my_getsystime and replaced with boost:date_time for compatibility between OS. |
69 |
boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::local_time());\
|
70 |
boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));\
|
|
71 |
uint64_t t_mark= (mytime-epoch).total_microseconds();\
|
|
72 |
uint64_t now= t_mark + (NSEC/100); \
|
|
398.1.8
by Monty Taylor
Enabled -Wlong-long. |
73 |
(ABSTIME).tv_sec= (time_t) (now / 10000000UL); \
|
74 |
(ABSTIME).tv_nsec= (long) (now % 10000000UL * 100 + ((NSEC) % 100)); \
|
|
1
by brian
clean slate |
75 |
}
|
76 |
#endif /* !set_timespec_nsec */ |
|
77 |
||
78 |
/* Wrappers if safe mutex is actually used */
|
|
79 |
#define safe_mutex_assert_owner(mp)
|
|
80 |
#define safe_mutex_assert_not_owner(mp)
|
|
81 |
||
82 |
/* READ-WRITE thread locking */
|
|
83 |
||
84 |
#if !defined(HAVE_PTHREAD_ATTR_SETSTACKSIZE) && ! defined(pthread_attr_setstacksize)
|
|
85 |
#define pthread_attr_setstacksize(A,B) pthread_dummy(0)
|
|
86 |
#endif
|
|
87 |
||
88 |
/* Define mutex types, see my_thr_init.c */
|
|
970.1.4
by Brian Aker
Removed dependency on internal_lock for session to lookup global table value |
89 |
#ifdef THREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
|
1
by brian
clean slate |
90 |
extern pthread_mutexattr_t my_fast_mutexattr; |
91 |
#define MY_MUTEX_INIT_FAST &my_fast_mutexattr
|
|
92 |
#else
|
|
93 |
#define MY_MUTEX_INIT_FAST NULL
|
|
94 |
#endif
|
|
95 |
||
96 |
#ifndef ESRCH
|
|
97 |
/* Define it to something */
|
|
98 |
#define ESRCH 1
|
|
99 |
#endif
|
|
100 |
||
2281.4.5
by Olaf van der Spek
Prune & refactor |
101 |
DRIZZLED_API void my_thread_init(); |
1
by brian
clean slate |
102 |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
103 |
} /* namespace internal */ |
104 |
} /* namespace drizzled */ |
|
105 |