summaryrefslogtreecommitdiff
path: root/PACE/pace/vxworks/pthread.h
blob: 260fe7a553d680150cee2383d79e1df6109806b8 (plain)
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
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/* $Id$

 * ============================================================================
 *
 * = LIBRARY
 *    pace
 *
 * = FILENAME
 *    pace/vxworks/pthread.h
 *
 * = AUTHOR
 *    Joe Hoffert. The *VAST* majority of the pthread code for VxWorks
 *    has been supplied by Hughes Network Systems via Braeton Taylor.
 *
 * ============================================================================ */

#ifndef PACE_PTHREAD_H_VXWORKS
#define PACE_PTHREAD_H_VXWORKS

#include <taskLib.h>
#include <taskHookLib.h>
#include <intLib.h>
#include <errnoLib.h>
#include "pace/sys/types.h"
#include "pace/signal.h"

#if defined (PACE_HAS_CPLUSPLUS)
extern "C" {
#endif /* PACE_HAS_CPLUSPLUS */

#define PACE_PTHREAD_CANCELED PTHREAD_CANCELED
#define PACE_PTHREAD_CANCEL_AYNCHRONOUS PTHREAD_CANCEL_ASYNCHRONOUS
#define PACE_PTHREAD_CANCEL_DEFERRED PTHREAD_CANCEL_DEFERRED
#define PACE_PTHREAD_CACEL_DISABLE PTHREAD_CANCEL_DISABLE
#define PACE_PTHREAD_CANCEL_ENABLE PTHREAD_CANCEL_ENABLE
#define PACE_PTHREAD_COND_INITIALIZER PTHREAD_COND_INITIALIZER
#define PACE_PTHREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED
#define PACE_PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE
#define PACE_PTHREAD_EXPLICIT_SCHED PTHREAD_EXPLICIT_SCHED
#define PACE_PTHREAD_INHERIT_SCHED PTHREAD_INHERIT_SCHED
#define PACE_PTHREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
#define PACE_PTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
#define PACE_PTHREAD_PRIO_INHERIT PTHREAD_PRIO_INHERIT
#define PACE_PTHREAD_PRIO_NONE PTHREAD_PRIO_NONE
#define PACE_PTHREAD_PRIO_PROTECT PTHREAD_PRIO_PROTECT
#define PACE_PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE
#define PACE_PTHREAD_PROCESS_SHARED PTHREAD_PROCESS_SHARED
#define PACE_PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS
#define PACE_PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM

#define PTHREAD_MUTEX_INITIALIZER 0
#define PTHREAD_COND_INITIALIZER 0

#ifndef PACE_SCHED_PARAM
#define PACE_SCHED_PARAM
  typedef struct sched_param pace_sched_param;
#endif /* PACE_SCHED_PARAM */

#if defined (PACE_HAS_CPLUSPLUS)
# ifndef PACE_ATFORK_PF
# define PACE_ATFORK_PF
  typedef void (*pace_atfork_pf) (void);
# endif /* PACE_ATFORK_PF */

# ifndef PACE_KEYCREATE_PF
# define PACE_KEYCREATE_PF
  typedef void (*pace_keycreate_pf) (void*);
# endif /* PACE_KEYCREATE_PF */

# ifndef PACE_ONCE_PF
# define PACE_ONCE_PF
  typedef void (*pace_once_pf) (void);
# endif /* PACE_ONCE_PF */

# ifndef PACE_CREATE_PF
# define PACE_CREATE_PF
  typedef void* (*pace_create_pf) (void*);
# endif /* PACE_CREATE_PF */

#endif /* PACE_HAS_CPLUPLUS */

  /*
   * VxWorks helper functions
   */
#if (PACE_HAS_POSIX_NONUOF_FUNCS)
  extern pace_pthread_attr_t pthread_attr_default;

  STATUS pacevx_vxworks_init();
  void pacevx_pthread_proc_exit(pace_pthread_t pthread, void *value_ptr);
  int pacevx_pthread_verify(pace_pthread_t pthread);
  void pacevx_pthread_run_cleanup (WIND_TCB *pTcb);
  int pacevx_pthread_queue_add(pace_pthread_t pthread);
  int pacevx_pthread_queue_remove(pace_pthread_t pthread);
  void pacevx_pthread_cleanup_popall(pace_pthread_t thread);
  void pacevx_pthread_destructor_thread(pace_pthread_t pthread);
  int pacevx_pthread_key_validate(pace_pthread_key_t key);
  void pacevx_pthread_destructor_key(pace_pthread_key_t key, void * arg);

  int pthread_cond_timedwait (pace_pthread_cond_t * cond,
                              pace_pthread_mutex_t * mutex,
                              const pace_timespec * abstime);
  int pthread_cond_wait (pace_pthread_cond_t * cond,
                         pace_pthread_mutex_t * mutex);
# if defined (PACE_HAS_CPLUSPLUS)
  int pthread_create (pace_pthread_t * thread,
                      const pace_pthread_attr_t * attr,
                      pace_create_pf start_routine,
                      void * arg);
  int pthread_key_create (pace_pthread_key_t * key,
                          pace_keycreate_pf destructor);
  int pthread_once (pace_pthread_once_t * once_control,
                    pace_once_pf init_routine);
# else /* ! PACE_HAS_CPLUSPLUS */
  int pthread_create (pace_pthread_t * thread,
                      const pace_pthread_attr_t * attr,
                      void * (*start_routine) (void*),
                      void * arg);
  int pthread_key_create (pace_pthread_key_t * key,
                          void (*destructor)(void*));
  int pthread_once (pace_pthread_once_t * once_control,
                    void (*init_routine) (void));
# endif /*! PACE_HAS_CPLUSPLUS */
  int pthread_detach (pace_pthread_t thread);
  int pthread_join (pace_pthread_t thread, void ** value_ptr);
  int pthread_key_delete (pace_pthread_key_t key);
  int pthread_attr_init (pace_pthread_attr_t * attr);
  int pthread_attr_setdetachstate (pace_pthread_attr_t * attr,
                                   int detachstate);
  int pthread_attr_setschedparam (pace_pthread_attr_t * attr,
                                  const pace_sched_param * param);
  int pthread_cancel (pace_pthread_t thread);
  int pthread_getschedparam (pace_pthread_t thread,
                             int * policy,
                             pace_sched_param * param);
  void * pthread_getspecific (pace_pthread_key_t key);
  int pthread_mutex_init (pace_pthread_mutex_t * mutex,
                          const pace_pthread_mutexattr_t * attr);
  int pthread_mutex_lock (pace_pthread_mutex_t * mutex);
  int pthread_mutex_trylock (pace_pthread_mutex_t * mutex);
  int pthread_mutex_unlock (pace_pthread_mutex_t * mutex);
  int pthread_mutexattr_setprotocol (pace_pthread_mutexattr_t * attr,
                                     int protocol);
  int pthread_mutexattr_init (pace_pthread_mutexattr_t * attr);
  int pthread_mutexattr_setpshared (pace_pthread_mutexattr_t * attr,
                                    int pshared);
  int pthread_setcancelstate (int state, int * oldstate);
  int pthread_setcanceltype (int type, int * oldtype);
  int pthread_setschedparam (pace_pthread_t thread,
                             int policy,
                             const pace_sched_param * param);
  int pthread_setspecific (pace_pthread_key_t key,
                           const void * value);
  int pthread_sigmask (int how,
                       const sigset_t * set,
                       sigset_t * oset);
  pace_pthread_t pthread_self ();
#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */

#if defined (PACE_HAS_CPLUSPLUS)
}
#endif /* PACE_HAS_CPLUSPLUS */

#endif /* PACE_PTHREAD_H_VXWORKS */