~ubuntu-branches/ubuntu/natty/xmlrpc-c/natty

« back to all changes in this revision

Viewing changes to lib/util/pthreadx_win32.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2011-01-06 18:56:02 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20110106185602-09og2x3suqlzbf6s
Tags: 1.16.32-0ubuntu1
* New upstream version (stable release). LP: #659591.
  - No unresolved symbols in the shared libraries. LP: #690779.
  - Builds with --no-add-needed and --as-needed.
* Rename shared library packages.
* Add symbols files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
#include "xmlrpc_config.h"
27
27
 
28
 
#if WIN32
 
28
#ifdef WIN32
29
29
 
30
30
#include "pthreadx.h"
31
31
 
34
34
#undef PACKAGE
35
35
#undef VERSION
36
36
 
37
 
int pthread_create(pthread_t *new_thread_ID,
38
 
                   const pthread_attr_t * attr,
39
 
                   pthread_func start_func, void *arg)
40
 
{
 
37
int
 
38
pthread_create(pthread_t *            const new_thread_ID,
 
39
               const pthread_attr_t * const attr,
 
40
               pthread_func *               func,
 
41
               void *                 const arg) {
 
42
 
41
43
    HANDLE hThread;
42
44
    DWORD dwThreadID;
43
45
 
44
46
    hThread = (HANDLE) _beginthreadex (
45
 
        NULL, 0, start_func, (LPVOID)arg, CREATE_SUSPENDED, &dwThreadID);
 
47
        NULL, 0, func, (LPVOID)arg, CREATE_SUSPENDED, &dwThreadID);
46
48
 
47
49
    SetThreadPriority (hThread, THREAD_PRIORITY_NORMAL); 
48
50
    ResumeThread (hThread);
52
54
    return hThread ? 0 : -1;
53
55
}
54
56
 
 
57
 
 
58
 
55
59
/* Just kill it. */
56
 
int pthread_cancel(pthread_t target_thread)
57
 
{
58
 
    CloseHandle (target_thread);
 
60
int
 
61
pthread_cancel(pthread_t const target_thread) {
 
62
 
 
63
    CloseHandle(target_thread);
59
64
    return 0;
60
65
}
61
66
 
 
67
 
 
68
 
62
69
/* Waits for the thread to exit before continuing. */
63
 
int pthread_join(pthread_t target_thread, void **status)
64
 
{
 
70
int
 
71
pthread_join(pthread_t const target_thread,
 
72
             void **   const statusP) {
 
73
 
65
74
    DWORD dwResult = WaitForSingleObject(target_thread, INFINITE);
66
 
    (*status) = (void *)dwResult;
67
 
    return 0;
68
 
}
69
 
 
70
 
/* Stubbed. Do nothing. */
71
 
int pthread_detach(pthread_t target_thread)
72
 
{
73
 
    return 0;
74
 
}
75
 
 
76
 
int pthread_mutex_init(pthread_mutex_t *mp,
77
 
                       const pthread_mutexattr_t * attr)
78
 
{
 
75
    *statusP = (void *)dwResult;
 
76
    return 0;
 
77
}
 
78
 
 
79
 
 
80
 
 
81
int
 
82
pthread_detach(pthread_t const target_thread) {
 
83
    return 0;
 
84
}
 
85
 
 
86
 
 
87
 
 
88
int
 
89
pthread_mutex_init(pthread_mutex_t *           const mp,
 
90
                   const pthread_mutexattr_t * const attr) {
 
91
 
79
92
    InitializeCriticalSection(mp);
80
93
    return 0;
81
94
}
82
95
 
83
 
int pthread_mutex_lock(pthread_mutex_t *mp)
84
 
{
 
96
 
 
97
 
 
98
int
 
99
pthread_mutex_lock(pthread_mutex_t * const mp) {
 
100
 
85
101
    EnterCriticalSection(mp);
86
102
    return 0;
87
103
}
88
104
 
89
 
int pthread_mutex_unlock(pthread_mutex_t *mp)
90
 
{
 
105
 
 
106
 
 
107
int
 
108
pthread_mutex_unlock(pthread_mutex_t * const mp) {
 
109
 
91
110
    LeaveCriticalSection(mp);
92
111
    return 0;
93
112
}
94
113
 
95
 
int pthread_mutex_destroy(pthread_mutex_t *mp)
96
 
{
 
114
 
 
115
 
 
116
int
 
117
pthread_mutex_destroy(pthread_mutex_t * const mp) {
 
118
 
97
119
    DeleteCriticalSection(mp);
98
120
    return 0;
99
121
}