aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/hdr_histogram/src/hdr_thread.h
blob: da51b705073609027816fbdc090c59211e2c8735 (plain) (blame)
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
50
51
52
53
54
55
/** 
 * hdr_thread.h 
 * Written by Philip Orwig and released to the public domain, 
 * as explained at http://creativecommons.org/publicdomain/zero/1.0/ 
 */ 
 
#ifndef HDR_THREAD_H__ 
#define HDR_THREAD_H__ 
 
#include <stdint.h> 
 
#if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) 
 
 
#define HDR_ALIGN_PREFIX(alignment) __declspec( align(alignment) ) 
#define HDR_ALIGN_SUFFIX(alignment)  
 
typedef struct hdr_mutex 
{ 
    uint8_t _critical_section[40]; 
} hdr_mutex; 
 
#else 
 
#include <pthread.h> 
 
#define HDR_ALIGN_PREFIX(alignment)  
#define HDR_ALIGN_SUFFIX(alignment) __attribute__((aligned(alignment))) 
 
typedef struct hdr_mutex 
{ 
    pthread_mutex_t _mutex; 
} hdr_mutex; 
#endif 
 
#ifdef __cplusplus 
extern "C" { 
#endif 
 
struct hdr_mutex* hdr_mutex_alloc(void); 
void hdr_mutex_free(struct hdr_mutex*); 
 
int hdr_mutex_init(struct hdr_mutex* mutex); 
void hdr_mutex_destroy(struct hdr_mutex* mutex); 
 
void hdr_mutex_lock(struct hdr_mutex* mutex); 
void hdr_mutex_unlock(struct hdr_mutex* mutex); 
 
void hdr_yield(); 
int hdr_usleep(unsigned int useconds); 
 
#ifdef __cplusplus 
} 
#endif 
#endif