Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
1feb1887
Commit
1feb1887
authored
Dec 14, 2006
by
tsmith/tim@siva.hindu.god
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
include/my_pthread.h: Fix botched merge - add struct timespec and set_timespec(), etc.
parent
e30dfac9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
2 deletions
+69
-2
include/my_pthread.h
include/my_pthread.h
+69
-2
No files found.
include/my_pthread.h
View file @
1feb1887
...
...
@@ -66,6 +66,34 @@ typedef int pthread_mutexattr_t;
#define pthread_handler_t EXTERNC void * __cdecl
typedef
void
*
(
__cdecl
*
pthread_handler
)(
void
*
);
/*
Struct and macros to be used in combination with the
windows implementation of pthread_cond_timedwait
*/
/*
Declare a union to make sure FILETIME is properly aligned
so it can be used directly as a 64 bit value. The value
stored is in 100ns units.
*/
union
ft64
{
FILETIME
ft
;
__int64
i64
;
};
struct
timespec
{
union
ft64
start
;
/* The max timeout value in millisecond for pthread_cond_timedwait */
long
timeout_msec
;
};
#define set_timespec(ABSTIME,SEC) { \
GetSystemTimeAsFileTime(&((ABSTIME).start.ft)); \
(ABSTIME).timeout_msec= (long)((SEC)*1000); \
}
#define set_timespec_nsec(ABSTIME,NSEC) { \
GetSystemTimeAsFileTime(&((ABSTIME).start.ft)); \
(ABSTIME).timeout_msec= (long)((NSEC)/1000000); \
}
void
win_pthread_init
(
void
);
int
win_pthread_setspecific
(
void
*
A
,
void
*
B
,
uint
length
);
int
pthread_create
(
pthread_t
*
,
pthread_attr_t
*
,
pthread_handler
,
void
*
);
...
...
@@ -141,8 +169,6 @@ void pthread_exit(void *a); /* was #define pthread_exit(A) ExitThread(A)*/
#define pthread_condattr_init(A)
#define pthread_condattr_destroy(A)
/*Irena: compiler does not like this: */
/*#define my_pthread_getprio(pthread_t thread_id) pthread_dummy(0) */
#define my_pthread_getprio(thread_id) pthread_dummy(0)
#else
/* Normal threads */
...
...
@@ -367,6 +393,47 @@ void my_pthread_attr_getstacksize(pthread_attr_t *attrib, size_t *size);
int
my_pthread_mutex_trylock
(
pthread_mutex_t
*
mutex
);
#endif
/*
The defines set_timespec and set_timespec_nsec should be used
for calculating an absolute time at which
pthread_cond_timedwait should timeout
*/
#ifdef HAVE_TIMESPEC_TS_SEC
#ifndef set_timespec
#define set_timespec(ABSTIME,SEC) \
{ \
(ABSTIME).ts_sec=time(0) + (time_t) (SEC); \
(ABSTIME).ts_nsec=0; \
}
#endif
/* !set_timespec */
#ifndef set_timespec_nsec
#define set_timespec_nsec(ABSTIME,NSEC) \
{ \
ulonglong now= my_getsystime() + (NSEC/100); \
(ABSTIME).ts_sec= (now / ULL(10000000)); \
(ABSTIME).ts_nsec= (now % ULL(10000000) * 100 + ((NSEC) % 100)); \
}
#endif
/* !set_timespec_nsec */
#else
#ifndef set_timespec
#define set_timespec(ABSTIME,SEC) \
{\
struct timeval tv;\
gettimeofday(&tv,0);\
(ABSTIME).tv_sec=tv.tv_sec+(time_t) (SEC);\
(ABSTIME).tv_nsec=tv.tv_usec*1000;\
}
#endif
/* !set_timespec */
#ifndef set_timespec_nsec
#define set_timespec_nsec(ABSTIME,NSEC) \
{\
ulonglong now= my_getsystime() + (NSEC/100); \
(ABSTIME).tv_sec= (time_t) (now / ULL(10000000)); \
(ABSTIME).tv_nsec= (long) (now % ULL(10000000) * 100 + ((NSEC) % 100)); \
}
#endif
/* !set_timespec_nsec */
#endif
/* HAVE_TIMESPEC_TS_SEC */
/* safe_mutex adds checking to mutex for easier debugging */
#if defined(__NETWARE__) && !defined(SAFE_MUTEX_DETECT_DESTROY)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment