morsewinthread.h 2.71 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/**
 *
 * @copyright (c) 2009-2014 The University of Tennessee and The University 
 *                          of Tennessee Research Foundation. 
 *                          All rights reserved.
 * @copyright (c) 2012-2014 Inria. All rights reserved.
 * @copyright (c) 2012-2014 IPB. All rights reserved. 
 *
 **/

/**
 *
 * @file morsewinthread.h
 *
 *  MORSE thread routines
 *  MORSE is a software package provided by Univ. of Tennessee,
 *  Univ. of California Berkeley and Univ. of Colorado Denver
 *
19
 * @version 0.9.0
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
 * @author Piotr Luszczek
 * @author Cedric Castagnede
 * @date 2012-09-15
 *
 **/

#ifndef MORSEWINTHREAD_H
#define MORSEWINTHREAD_H

#include <windows.h>

/*
typedef struct pthread_s {
  HANDLE Hth;
  unsigned IDth;
  void *(*Fth) (void *);
} pthread_t;
*/
typedef struct pthread_s {
  HANDLE hThread;
  unsigned int uThId;
} pthread_t;

typedef HANDLE pthread_mutex_t;
typedef int pthread_mutexattr_t;
typedef int pthread_attr_t;
typedef int pthread_condattr_t;

typedef struct pthread_cond_s {
  HANDLE hSem;
  HANDLE hEvt;
  CRITICAL_SECTION cs;
  int waitCount; /* waiting thread counter */
} pthread_cond_t;

typedef int pthread_attr_t;

#define PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t) -1)

#define PTHREAD_SCOPE_SYSTEM 1

#define MORSE_DLLPORT
#define MORSE_CDECL __cdecl

MORSE_DLLPORT pthread_t MORSE_CDECL pthread_self(void);
MORSE_DLLPORT int MORSE_CDECL pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t * attr);
MORSE_DLLPORT int MORSE_CDECL pthread_mutex_destroy(pthread_mutex_t *mutex);
MORSE_DLLPORT int MORSE_CDECL pthread_mutex_lock(pthread_mutex_t *mutex);
MORSE_DLLPORT int MORSE_CDECL pthread_mutex_trylock(pthread_mutex_t *mutex);
MORSE_DLLPORT int MORSE_CDECL pthread_mutex_unlock(pthread_mutex_t *mutex);
MORSE_DLLPORT int MORSE_CDECL pthread_attr_init(pthread_attr_t *attr);
MORSE_DLLPORT int MORSE_CDECL pthread_attr_destroy(pthread_attr_t *attr);
MORSE_DLLPORT int MORSE_CDECL pthread_attr_setscope(pthread_attr_t *attr, int scope);
MORSE_DLLPORT int MORSE_CDECL pthread_create(pthread_t *tid, const pthread_attr_t *attr, void *(*start) (void *), void *arg);
MORSE_DLLPORT int MORSE_CDECL pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr);
MORSE_DLLPORT int MORSE_CDECL pthread_cond_destroy(pthread_cond_t *cond);
MORSE_DLLPORT int MORSE_CDECL pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex);
MORSE_DLLPORT int MORSE_CDECL pthread_cond_broadcast(pthread_cond_t *cond);
MORSE_DLLPORT int MORSE_CDECL pthread_join(pthread_t thread, void **value_ptr);
MORSE_DLLPORT int MORSE_CDECL pthread_equal(pthread_t thread1, pthread_t thread2);

MORSE_DLLPORT int MORSE_CDECL pthread_setconcurrency (int);

MORSE_DLLPORT unsigned int MORSE_CDECL pthread_self_id(void);

#endif