/simpletypesystem/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk

« back to all changes in this revision

Viewing changes to libssts/Thread.h

  • Committer: Gustav Hartvigsson
  • Date: 2016-02-02 21:10:28 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20160202211028-nmyi59c53qlncztp
* Removed blasted #pragma message s from Thread.h
* replaced external/[threads.h,threads_posix.h,threads_win32.h] with
  the more standard tinycthread "library".
* renamed miss-named thrd_timeout -> thred_timedout
* added mapping for the mutex flags.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
#include "config.h"
12
12
 
13
13
#if  !__STDC_NO_ATOMICS__
14
 
#pragma message ("We have _Atomic")
15
14
#include <stdatomic.h>
16
15
#else
17
 
#pragma message ("We don't have standard _Atomic. includeing external .h file.")
18
16
#include "external/stdatomic.h"
19
17
#endif
20
18
 
21
19
#if !__STDC_NO_THREADS__
22
 
#pragma message ("We have threads.h")
23
20
#include <threads.h>
24
21
#else
25
 
#pragma message ("We don't have standard threads.h. includeing external .h file.")
26
 
#include "external/threads.h"
 
22
#include "external/tinycthread.h"
27
23
#endif
28
24
 
29
25
 
48
44
 * offten used as return values for different fuctions.
49
45
 */
50
46
typedef enum {
51
 
  S_THREAD_STATUS_SUCCESS    = thrd_success, /*< Succes*/
52
 
  S_THREAD_STATUS_TIMEOUT    = thrd_timeout, /*< Timeout*/
53
 
  S_THREAD_STATUS_ERROR      = thrd_error,   /*< Error */
54
 
  S_THREAD_STATUS_BUSY       = thrd_busy,    /*< Busy */
55
 
  S_THREAD_STATUS_NO_MEM     = thrd_nomem,   /*< No memory*/
56
 
  S_THREAD_STATUS_LAST                       /*< Not used */
 
47
  S_THREAD_STATUS_SUCCESS    = thrd_success,  /*< Succes*/
 
48
  S_THREAD_STATUS_TIMEOUT    = thrd_timedout, /*< Timedout*/
 
49
  S_THREAD_STATUS_ERROR      = thrd_error,    /*< Error */
 
50
  S_THREAD_STATUS_BUSY       = thrd_busy,     /*< Busy */
 
51
  S_THREAD_STATUS_NO_MEM     = thrd_nomem,    /*< No memory*/
 
52
  S_THREAD_STATUS_LAST                        /*< Not used */
57
53
} SThreadStatus;
58
54
 
59
55
/**
62
58
S_UNUSED static
63
59
schar * SThreadStatusName[] = {
64
60
  "Succes",
65
 
  "Timeout",
 
61
  "Timedout",
66
62
  "Error",
67
63
  "Busy",
68
64
  "No Momory",
83
79
char *
84
80
s_thread_status_get_name (SThreadStatus status);
85
81
 
 
82
/**
 
83
 * The flags used when creating threads.
 
84
 * These map 1:1 to the C11 flags.
 
85
 */
 
86
typedef enum {
 
87
 S_MUTEX_FLAG_PLAIN = mtx_plain, /**< Plain mutex */
 
88
 S_MUTEX_FLAG_TIMED = mtx_timed, /**< Timed mutex */
 
89
 S_MUTEX_FLAG_RECURSIVE = mtx_recursive, /**< Recursive mutex */
 
90
 S_MUTEX_FLAG_LAST
 
91
} SMutexFlag;
 
92
 
 
93
/**
 
94
 * @see SMutexFlag
 
95
 */
 
96
S_UNUSED static
 
97
schar * SMutexFlagName[] = {
 
98
  "Plain",
 
99
  "Timed",
 
100
  "Recursive",
 
101
  "INVALID"
 
102
  0x0,
 
103
  0x0
 
104
};
 
105
 
 
106
/** @brief
 
107
 * Get the name of the mutex flag.
 
108
 *
 
109
 * For use in bindings.
 
110
 */
 
111
schar *
 
112
s_mutex_flag_get_name (SMutexFlag flag);
 
113
 
86
114
/* ****************************************************************************
87
115
 ********************************** SMutex ************************************
88
116
 **************************************************************************** */