File: thread.h

package info (click to toggle)
glpk 4.61-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 11,520 kB
  • ctags: 7,131
  • sloc: ansic: 78,819; sh: 11,184; makefile: 197; sql: 142; cs: 83
file content (49 lines) | stat: -rw-r--r-- 1,864 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* thread.h (pthread emulation for Windows) */

/***********************************************************************
*  This code is part of GLPK (GNU Linear Programming Kit).
*
*  Copyright (C) 2011-2017, Heinrich Schuchardt <xypron.glpk@gmx.de>
*
*  Permission to use, copy, modify, and/or distribute this software for
*  any purpose with or without fee is hereby granted.
*
*  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
*  WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
*  WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
*  AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
*  DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
*  OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
*  TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
*  PERFORMANCE OF THIS SOFTWARE.
***********************************************************************/

#ifndef THREAD_H

#define THREAD_H 1

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif // HAVE_CONFIG_H

#ifdef __WOE__
#include <windows.h>
typedef CRITICAL_SECTION pthread_mutex_t;
typedef HANDLE pthread_t;
// @todo The return type of routine C is "DWORD" for Windows and
//       "void *" for Posix.
#define pthread_create(A,B,C,D) \
  (int)((*A = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)&C,D,0,NULL))==NULL)
#define pthread_exit(A)          ExitThread(0)
#define pthread_mutex_destroy(A) DeleteCriticalSection(A)
#define pthread_mutex_init(A,B)  (InitializeCriticalSection(A),0)
#define pthread_mutex_lock(A)    (EnterCriticalSection(A),0)
#define pthread_mutex_unlock(A)  (LeaveCriticalSection(A),0)
#define pthread_self()           GetCurrentThreadId()
#define pthread_join(A, B) \
  (WaitForSingleObject(A, INFINITE),CloseHandle(A),0)
#else
#include <pthread.h>
#endif

#endif // THREAD_H