~ubuntu-branches/ubuntu/lucid/cmake/lucid

« back to all changes in this revision

Viewing changes to Utilities/cmxmlrpc/win32_pthreads.c

  • Committer: Bazaar Package Importer
  • Author(s): Artur Rona
  • Date: 2009-12-16 11:11:54 UTC
  • mfrom: (3.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20091216111154-6accvv6yq86h2hkc
Tags: 2.8.0-5ubuntu1
* Merge from debian testing (LP: #497349). Remaining changes:
  - Keep the Replaces: on cmake-data to cover the Kubuntu version from
    Jaunty in case someone decides to do an (unsupported) Jaunty->Lucid
    upgrade.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2001 by First Peer, Inc. All rights reserved.
2
 
**
3
 
** Redistribution and use in source and binary forms, with or without
4
 
** modification, are permitted provided that the following conditions
5
 
** are met:
6
 
** 1. Redistributions of source code must retain the above copyright
7
 
**    notice, this list of conditions and the following disclaimer.
8
 
** 2. Redistributions in binary form must reproduce the above copyright
9
 
**    notice, this list of conditions and the following disclaimer in the
10
 
**    documentation and/or other materials provided with the distribution.
11
 
** 3. The name of the author may not be used to endorse or promote products
12
 
**    derived from this software without specific prior written permission. 
13
 
**  
14
 
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15
 
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
 
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17
 
** ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18
 
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
 
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20
 
** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21
 
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22
 
** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23
 
** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24
 
** SUCH DAMAGE. */
25
 
 
26
 
#include "xmlrpc_config.h"
27
 
 
28
 
#ifdef _WIN32
29
 
 
30
 
#define HAVE_PTHREADS 1
31
 
#include "xmlrpc_pthreads.h"
32
 
 
33
 
#include <process.h>
34
 
 
35
 
#undef PACKAGE
36
 
#undef VERSION
37
 
 
38
 
#include "xmlrpc.h"
39
 
 
40
 
int pthread_create(pthread_t *new_thread_ID,
41
 
          const pthread_attr_t * attr,
42
 
          pthread_func start_func, void *arg)
43
 
{
44
 
        HANDLE hThread;
45
 
        unsigned dwThreadID;
46
 
 
47
 
        XMLRPC_ASSERT (attr == NULL); /* unimplemented. */
48
 
    XMLRPC_ASSERT_PTR_OK(new_thread_ID);
49
 
    XMLRPC_ASSERT_PTR_OK(start_func);
50
 
    XMLRPC_ASSERT_PTR_OK(arg);
51
 
 
52
 
        hThread = (HANDLE) _beginthreadex (NULL, 0, 
53
 
                start_func, (LPVOID)arg, CREATE_SUSPENDED, &dwThreadID);
54
 
 
55
 
        SetThreadPriority (hThread, THREAD_PRIORITY_NORMAL); 
56
 
        ResumeThread (hThread);
57
 
 
58
 
        *new_thread_ID = hThread;
59
 
 
60
 
        return hThread ? 0 : -1;
61
 
}
62
 
 
63
 
/* Just kill it. */
64
 
int pthread_cancel(pthread_t target_thread)
65
 
{
66
 
        CloseHandle (target_thread);
67
 
        return 0;
68
 
}
69
 
 
70
 
/* Waits for the thread to exit before continuing. */
71
 
int pthread_join(pthread_t target_thread, void **status)
72
 
{
73
 
        DWORD dwResult = WaitForSingleObject(target_thread, INFINITE);
74
 
        (*status) = (void *)dwResult;
75
 
        return 0;
76
 
}
77
 
 
78
 
/* Stubbed. Do nothing. */
79
 
int pthread_detach(pthread_t target_thread)
80
 
{
81
 
        return 0;
82
 
}
83
 
 
84
 
int pthread_mutex_init(pthread_mutex_t *mp,
85
 
                                        const pthread_mutexattr_t * attr)
86
 
{
87
 
        InitializeCriticalSection(mp);
88
 
        return 0;
89
 
}
90
 
 
91
 
int pthread_mutex_lock(pthread_mutex_t *mp)
92
 
{
93
 
        EnterCriticalSection(mp);
94
 
        return 0;
95
 
}
96
 
 
97
 
int pthread_mutex_unlock(pthread_mutex_t *mp)
98
 
{
99
 
        LeaveCriticalSection(mp);
100
 
        return 0;
101
 
}
102
 
 
103
 
int pthread_mutex_destroy(pthread_mutex_t *mp)
104
 
{
105
 
        DeleteCriticalSection(mp);
106
 
        return 0;
107
 
}
108
 
 
109
 
#endif