~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/internal/my_pthread.h

  • Committer: Brian Aker
  • Date: 2010-08-12 17:21:13 UTC
  • mfrom: (1689.5.5 remove_pthread_calls)
  • Revision ID: brian@tangent.org-20100812172113-i0ox868kcbzjim2h
Merge in removal of pthread dead wrappers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
#define pthread_handler_t void *
45
45
typedef void *(* pthread_handler)(void *);
46
46
 
47
 
#ifndef my_pthread_attr_setprio
48
 
#ifdef HAVE_PTHREAD_ATTR_SETPRIO
49
 
#define my_pthread_attr_setprio(A,B) pthread_attr_setprio((A),(B))
50
 
#else
51
 
extern void my_pthread_attr_setprio(pthread_attr_t *attr, int priority);
52
 
#endif
53
 
#endif
54
 
 
55
47
#if !defined(HAVE_PTHREAD_YIELD_ONE_ARG) && !defined(HAVE_PTHREAD_YIELD_ZERO_ARG)
56
48
/* no pthread_yield() available */
57
49
#ifdef HAVE_SCHED_YIELD
84
76
}
85
77
#endif /* !set_timespec_nsec */
86
78
 
87
 
        /* safe_mutex adds checking to mutex for easier debugging */
88
 
 
89
 
typedef struct st_safe_mutex_t
90
 
{
91
 
  pthread_mutex_t global,mutex;
92
 
  const char *file;
93
 
  uint32_t line,count;
94
 
  pthread_t thread;
95
 
} safe_mutex_t;
96
 
 
97
 
int safe_mutex_init(safe_mutex_t *mp, const pthread_mutexattr_t *attr,
98
 
                    const char *file, uint32_t line);
99
 
int safe_mutex_lock(safe_mutex_t *mp, bool try_lock, const char *file, uint32_t line);
100
 
int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint32_t line);
101
 
int safe_mutex_destroy(safe_mutex_t *mp,const char *file, uint32_t line);
102
 
int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp,const char *file,
103
 
                   uint32_t line);
104
 
int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
105
 
                        struct timespec *abstime, const char *file, uint32_t line);
106
 
void safe_mutex_global_init(void);
107
 
void safe_mutex_end(void);
108
 
 
109
79
        /* Wrappers if safe mutex is actually used */
110
80
#define safe_mutex_assert_owner(mp)
111
81
#define safe_mutex_assert_not_owner(mp)
156
126
 
157
127
extern uint32_t thd_lib_detected;
158
128
 
159
 
/*
160
 
  thread_safe_xxx functions are for critical statistic or counters.
161
 
  The implementation is guaranteed to be thread safe, on all platforms.
162
 
  Note that the calling code should *not* assume the counter is protected
163
 
  by the mutex given, as the implementation of these helpers may change
164
 
  to use my_atomic operations instead.
165
 
*/
166
 
 
167
 
#ifndef thread_safe_increment
168
 
#define thread_safe_increment(V,L) \
169
 
        (pthread_mutex_lock((L)), (V)++, pthread_mutex_unlock((L)))
170
 
#define thread_safe_decrement(V,L) \
171
 
        (pthread_mutex_lock((L)), (V)--, pthread_mutex_unlock((L)))
172
 
#endif
173
 
 
174
 
#ifndef thread_safe_add
175
 
#define thread_safe_add(V,C,L) \
176
 
        (pthread_mutex_lock((L)), (V)+=(C), pthread_mutex_unlock((L)))
177
 
#define thread_safe_sub(V,C,L) \
178
 
        (pthread_mutex_lock((L)), (V)-=(C), pthread_mutex_unlock((L)))
179
 
#endif
180
 
 
181
129
} /* namespace internal */
182
130
} /* namespace drizzled */
183
131