~ifolder-dev/simias/trunk-packaging

« back to all changes in this revision

Viewing changes to tools/gsoap/gsoap-linux-2.7/plugin/.svn/text-base/threads.h.svn-base

  • Committer: Jorge O. Castro
  • Date: 2007-12-03 06:56:46 UTC
  • Revision ID: jorge@ubuntu.com-20071203065646-mupcnjcwgm5mnhyt
* Remove a bunch of .svn directories we no longer need.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 
3
 
threads.h
4
 
 
5
 
gSOAP XML Web services tools
6
 
Copyright (C) 2000-2005, Robert van Engelen, Genivia Inc., All Rights Reserved.
7
 
This part of the software is released under one of the following licenses:
8
 
GPL, the gSOAP public license, or Genivia's license for commercial use.
9
 
--------------------------------------------------------------------------------
10
 
gSOAP public license.
11
 
 
12
 
The contents of this file are subject to the gSOAP Public License Version 1.3
13
 
(the "License"); you may not use this file except in compliance with the
14
 
License. You may obtain a copy of the License at
15
 
http://www.cs.fsu.edu/~engelen/soaplicense.html
16
 
Software distributed under the License is distributed on an "AS IS" basis,
17
 
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
18
 
for the specific language governing rights and limitations under the License.
19
 
 
20
 
The Initial Developer of the Original Code is Robert A. van Engelen.
21
 
Copyright (C) 2000-2005, Robert van Engelen, Genivia Inc., All Rights Reserved.
22
 
--------------------------------------------------------------------------------
23
 
GPL license.
24
 
 
25
 
This program is free software; you can redistribute it and/or modify it under
26
 
the terms of the GNU General Public License as published by the Free Software
27
 
Foundation; either version 2 of the License, or (at your option) any later
28
 
version.
29
 
 
30
 
This program is distributed in the hope that it will be useful, but WITHOUT ANY
31
 
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
32
 
PARTICULAR PURPOSE. See the GNU General Public License for more details.
33
 
 
34
 
You should have received a copy of the GNU General Public License along with
35
 
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
36
 
Place, Suite 330, Boston, MA 02111-1307 USA
37
 
 
38
 
Author contact information:
39
 
engelen@genivia.com / engelen@acm.org
40
 
--------------------------------------------------------------------------------
41
 
A commercial use license is available from Genivia, Inc., contact@genivia.com
42
 
--------------------------------------------------------------------------------
43
 
*/
44
 
 
45
 
#ifndef THREADS_H
46
 
#define THREADS_H
47
 
 
48
 
#ifndef WIN32
49
 
# include <unistd.h>    /* defines _POSIX_THREADS if pthreads are available */
50
 
#else
51
 
# define ssize_t int
52
 
# include <io.h>
53
 
# include <sys/types.h>
54
 
#endif
55
 
 
56
 
#ifdef _POSIX_THREADS
57
 
# include <pthread.h>
58
 
#endif
59
 
 
60
 
/******************************************************************************\
61
 
 *
62
 
 *      Threads
63
 
 *
64
 
\******************************************************************************/
65
 
 
66
 
#if defined(WIN32)
67
 
# define THREAD_TYPE            HANDLE
68
 
# define THREAD_ID              GetCurrentThreadId()
69
 
# define THREAD_CREATE(x,y,z)   *(x) = _beginthread((y), 8*4096, (z))
70
 
# define THREAD_DETACH(x)       
71
 
# define THREAD_JOIN(x)         WaitForSingleObject((x), INFINITE)
72
 
# define THREAD_EXIT            _endthread()
73
 
# define MUTEX_TYPE             HANDLE
74
 
# define MUTEX_SETUP(x)         (x) = CreateMutex(NULL, FALSE, NULL)
75
 
# define MUTEX_CLEANUP(x)       CloseHandle(x)
76
 
# define MUTEX_LOCK(x)          WaitForSingleObject((x), INFINITE)
77
 
# define MUTEX_UNLOCK(x)        ReleaseMutex(x)
78
 
# define COND_SETUP(x)          emulate_pthread_cond_init(&(x))
79
 
# define COND_CLEANUP(x)        emulate_pthread_cond_destroy(&(x))
80
 
# define COND_SIGNAL(x)         emulate_pthread_signal(&(x))
81
 
# define COND_WAIT(x,y)         emulate_pthread_wait(&(x), &(y))
82
 
typedef struct
83
 
{ u_int waiters_count_;
84
 
  CRITICAL_SECTION waiters_count_lock_;
85
 
  HANDLE signal_event_;
86
 
} COND_TYPE;
87
 
int emulate_pthread_cond_init(COND_TYPE*);
88
 
int emulate_pthread_cond_destroy(COND_TYPE*);
89
 
int emulate_pthread_signal(COND_TYPE*);
90
 
int emulate_pthread_wait(COND_TYPE*, MUTEX_TYPE*);
91
 
#elif defined(_POSIX_THREADS)
92
 
# define THREAD_TYPE            pthread_t
93
 
# define THREAD_ID              pthread_self()
94
 
# define THREAD_CREATE(x,y,z)   pthread_create((x), NULL, (y), (z))
95
 
# define THREAD_DETACH(x)       pthread_detach((x))
96
 
# define THREAD_JOIN(x)         pthread_join((x), NULL)
97
 
# define THREAD_EXIT            pthread_exit(NULL)
98
 
# define MUTEX_TYPE             pthread_mutex_t
99
 
# define MUTEX_SETUP(x)         pthread_mutex_init(&(x), NULL)
100
 
# define MUTEX_CLEANUP(x)       pthread_mutex_destroy(&(x))
101
 
# define MUTEX_LOCK(x)          pthread_mutex_lock(&(x))
102
 
# define MUTEX_UNLOCK(x)        pthread_mutex_unlock(&(x))
103
 
# define COND_TYPE              pthread_cond_t
104
 
# define COND_SETUP(x)          pthread_cond_init(&(x), NULL)
105
 
# define COND_CLEANUP(x)        pthread_cond_destroy(&(x))
106
 
# define COND_SIGNAL(x)         pthread_cond_signal(&(x))
107
 
# define COND_WAIT(x,y)         pthread_cond_wait(&(x), &(y))
108
 
#else
109
 
# error "No POSIX threads detected: we need thread and mutex operations. See for example OpenSSL /threads/th-lock.c on how to implement mutex on your platform"
110
 
#endif
111
 
 
112
 
#endif