1 /*****************************************************************************/
2 /* Software Testing Automation Framework (STAF)                              */
3 /* (C) Copyright IBM Corp. 2001                                              */
4 /*                                                                           */
5 /* This software is licensed under the Eclipse Public License (EPL) V1.0.    */
6 /*****************************************************************************/
7 
8 #ifndef STAF_Thread
9 #define STAF_Thread
10 
11 #include "STAFError.h"
12 #include "STAFOSTypes.h"
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 typedef unsigned int (*STAFThreadFunc_t)(void *);
19 
20 /****************************************************************************/
21 /* STAFThreadStart - Starts a thread, passing in the specified data         */
22 /*                                                                          */
23 /* Accepts: (OUT) Pointer to thread identifier                              */
24 /*          (IN)  Pointer to function to start on the thread                */
25 /*          (IN)  The data to be passed to the thread                       */
26 /*          (IN)  Flags (currently, this should be set to 0)                */
27 /*          (OUT) Pointer operating system return code                      */
28 /*                                                                          */
29 /* Returns:  kSTAFOk, on success                                            */
30 /*           other on error                                                 */
31 /****************************************************************************/
32 STAFRC_t STAFThreadStart(STAFThreadID_t *threadID,
33     STAFThreadFunc_t theFunc, void *theData, unsigned int flags,
34     unsigned int *osRC);
35 
36 /****************************************************************************/
37 /* STAFThreadCurrentThreadID - Returns the current thread ID                */
38 /*                                                                          */
39 /* Accepts: Nothing                                                         */
40 /*                                                                          */
41 /* Returns:  The current thread ID                                          */
42 /****************************************************************************/
43 STAFThreadID_t STAFThreadCurrentThreadID();
44 
45 
46 /****************************************************************************/
47 /* STAFThreadSleepCurrentThread - Puts the current thread to sleep for a    */
48 /*                                specified amount of time                  */
49 /*                                                                          */
50 /* Accepts: (IN)  Sleep time (in milliseconds)                              */
51 /*          (OUT) Pointer operating system return code                      */
52 /*                                                                          */
53 /* Returns:  kSTAFOk, on success                                            */
54 /*           other on error                                                 */
55 /****************************************************************************/
56 STAFRC_t STAFThreadSleepCurrentThread(unsigned int milliseconds,
57                                       unsigned int *osRC);
58 
59 
60 /****************************************************************************/
61 /* STAFThreadSafeIncrement - Atomically increments a value                  */
62 /*                                                                          */
63 /* Accepts: Pointer to value to increment                                   */
64 /*                                                                          */
65 /* Returns: A negative value, if the new value is less than zero            */
66 /*          Zero, if the new value is zero                                  */
67 /*          A positive value, if the new value is greater than zero         */
68 /*                                                                          */
69 /* Note: This function does not guarantee that it well return the new value */
70 /*       of the variable                                                    */
71 /****************************************************************************/
72 STAFThreadSafeScalar_t STAFThreadSafeIncrement(STAFThreadSafeScalar_t *ptr);
73 
74 
75 /****************************************************************************/
76 /* STAFThreadSafeDecrement - Atomically decrements a value                  */
77 /*                                                                          */
78 /* Accepts: Pointer to value to decrement                                   */
79 /*                                                                          */
80 /* Returns: A negative value, if the new value is less than zero            */
81 /*          Zero, if the new value is zero                                  */
82 /*          A positive value, if the new value is greater than zero         */
83 /*                                                                          */
84 /* Note: This function does not guarantee that it well return the new value */
85 /*       of the variable                                                    */
86 /****************************************************************************/
87 STAFThreadSafeScalar_t STAFThreadSafeDecrement(STAFThreadSafeScalar_t *ptr);
88 
89 #ifdef __cplusplus
90 }
91 #endif
92 
93 #endif
94