~ubuntu-branches/ubuntu/lucid/fpc/lucid-proposed

« back to all changes in this revision

Viewing changes to fpcsrc/packages/extra/gtk2/glib/gthread.inc

  • Committer: Bazaar Package Importer
  • Author(s): Mazen Neifer, Torsten Werner, Mazen Neifer
  • Date: 2008-10-09 23:29:00 UTC
  • mfrom: (4.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20081009232900-553f61m37jkp6upv
Tags: 2.2.2-4
[ Torsten Werner ]
* Update ABI version in fpc-depends automatically.
* Remove empty directories from binary package fpc-source.

[ Mazen Neifer ]
* Removed leading path when calling update-alternatives to remove a Linitian
  error.
* Fixed clean target.
* Improved description of packages. (Closes: #498882)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//{$ifndef __G_THREAD_H__}
2
 
//{$define __G_THREAD_H__}
3
 
 
4
 
//{$include gerror.inc}
5
 
// {$include gtypes.inc}
6
 
 
7
 
{* GLib Thread support *}
8
 
 
9
 
 
10
 
  function  g_thread_error_quark :  TGQuark; cdecl; external gthreadlib name 'g_thread_error_quark';
11
 
 
12
 
 
13
 
  function G_THREAD_ERROR: TGQuark;
14
 
 
15
 
 
16
 
 
17
 
 
18
 
  type
19
 
    PGThreadError = ^TGThreadError;
20
 
    TGThreadError = ( G_THREAD_ERROR_AGAIN  { Resource temporarily unavailable  });
21
 
 
22
 
    TGThreadFunc = function (data:gpointer):gpointer;cdecl;
23
 
 
24
 
    PGThreadPriority = ^TGThreadPriority;
25
 
    TGThreadPriority = (G_THREAD_PRIORITY_LOW,
26
 
                        G_THREAD_PRIORITY_NORMAL,
27
 
                        G_THREAD_PRIORITY_HIGH,
28
 
                        G_THREAD_PRIORITY_URGENT);
29
 
 
30
 
    PGThread = ^TGThread;
31
 
    TGThread = record
32
 
                 func : TGThreadFunc;
33
 
                 data : gpointer;
34
 
                 joinable : gboolean;
35
 
                 priority : TGThreadPriority;
36
 
               end;
37
 
 
38
 
    PPGMutex  = ^PGMutex;
39
 
    PGMutex   = pointer; //       GMutex;
40
 
    PGCond    = pointer; //       GCond;
41
 
    PGPrivate = pointer; //       GPrivate;
42
 
 
43
 
//    typedef struct _GMutex* GStaticMutex;
44
 
    PGStaticMutex = ^TGStaticMutex;
45
 
    TGStaticMutex = PGMutex;
46
 
 
47
 
    PGThreadFunctions = ^TGThreadFunctions;
48
 
    TGThreadFunctions = record
49
 
              mutex_new       : function :PGMutex; cdecl;
50
 
              mutex_lock      : procedure (mutex:PGMutex); cdecl;
51
 
              mutex_trylock   : function (mutex:PGMutex):gboolean; cdecl;
52
 
              mutex_unlock    : procedure (mutex:PGMutex); cdecl;
53
 
              mutex_free      : procedure (mutex:PGMutex); cdecl;
54
 
              cond_new        : function :PGCond; cdecl;
55
 
              cond_signal     : procedure (cond:PGCond); cdecl;
56
 
              cond_broadcast  : procedure (cond:PGCond); cdecl;
57
 
              cond_wait       : procedure (cond:PGCond; mutex:PGMutex); cdecl;
58
 
              cond_timed_wait : function (cond:PGCond; mutex:PGMutex; end_time:PGTimeVal):gboolean; cdecl;
59
 
              cond_free       : procedure (cond:PGCond); cdecl;
60
 
              private_new     : function (dest:TGDestroyNotify):PGPrivate; cdecl;
61
 
              private_get     : function (private_key:PGPrivate):gpointer; cdecl;
62
 
              private_set     : procedure (private_key:PGPrivate; data:gpointer); cdecl;
63
 
              thread_create   : procedure (func:TGThreadFunc; data:gpointer; stack_size:gulong; joinable:gboolean; bound:gboolean;
64
 
                                           priority:TGThreadPriority; thread:gpointer; error:PPGError); cdecl;
65
 
              thread_yield    : procedure ; cdecl;
66
 
              thread_join     : procedure (thread:gpointer); cdecl;
67
 
              thread_exit     : procedure ; cdecl;
68
 
              thread_set_priority : procedure (thread:gpointer; priority:TGThreadPriority); cdecl;
69
 
              thread_self         : procedure (thread:gpointer); cdecl;
70
 
              thread_equal        : function (thread1:gpointer; thread2:gpointer):gboolean; cdecl;
71
 
           end;
72
 
 
73
 
 
74
 
{$IFNDEF KYLIX}
75
 
  var
76
 
    {$IFDEF WIN32}
77
 
    g_thread_functions_for_glib_use : TGThreadFunctions; external gliblib name 'g_thread_functions_for_glib_use';
78
 
    g_thread_use_default_impl       : gboolean; external gliblib name 'g_thread_use_default_impl';
79
 
    g_threads_got_initialized       : gboolean; external gliblib name 'g_threads_got_initialized';
80
 
    {$ELSE}
81
 
    g_thread_functions_for_glib_use : TGThreadFunctions;cvar;external;      // ?????
82
 
    g_thread_use_default_impl       : gboolean;cvar;external;
83
 
    g_threads_got_initialized       : gboolean;cvar;external;
84
 
    {$ENDIF}
85
 
{$ENDIF}
86
 
 
87
 
 
88
 
{ initializes the mutex/cond/private implementation for glib, might
89
 
  only be called once, and must not be called directly or indirectly
90
 
  from another glib-function, e.g. as a callback.
91
 
}
92
 
 
93
 
  procedure g_thread_init(vtable:PGThreadFunctions);cdecl;external gthreadlib name 'g_thread_init';
94
 
 
95
 
{ Errorcheck mutexes. If you define G_ERRORCHECK_MUTEXES, then all
96
 
  mutexes will check for re-locking and re-unlocking  }
97
 
 
98
 
{ Initialize thread system with errorcheck mutexes. vtable must be
99
 
  NULL. Do not call directly. Use #define G_ERRORCHECK_MUTEXES
100
 
  instead.
101
 
}
102
 
  procedure g_thread_init_with_errorcheck_mutexes(vtable:PGThreadFunctions);cdecl;external gthreadlib name 'g_thread_init_with_errorcheck_mutexes';
103
 
 
104
 
{ A random number to recognize debug calls to g_mutex_...  }
105
 
 
106
 
  const
107
 
    G_MUTEX_DEBUG_MAGIC = $f8e18ad7;
108
 
 
109
 
 
110
 
{ internal function for fallback static mutex implementation  }
111
 
  function g_static_mutex_get_mutex_impl(mutex:PPGMutex):PGMutex;cdecl;external gthreadlib name 'g_static_mutex_get_mutex_impl';
112
 
 
113
 
 
114
 
{ shorthands for conditional and unconditional function calls  }
115
 
 
116
 
  function  g_thread_supported: gboolean;
117
 
 
118
 
  procedure g_mutex_lock     (mutex: PGMutex);
119
 
 
120
 
  function  g_mutex_trylock  (mutex: PGMutex):gboolean;
121
 
 
122
 
  procedure g_mutex_unlock   (mutex: PGMutex);
123
 
 
124
 
  procedure g_mutex_free     (mutex: PGMutex);
125
 
 
126
 
  procedure g_cond_wait      (cond: PGCond; mutex: PGMutex);
127
 
 
128
 
  function g_cond_timed_wait (cond: PGCond;
129
 
                              mutex: PGMutex;
130
 
                              end_time: PGTimeVal):gboolean;
131
 
 
132
 
  function  g_mutex_new : PGMutex;
133
 
  function  g_cond_new  : PGCond;
134
 
 
135
 
  procedure g_cond_signal    (cond: PGCond);
136
 
  procedure g_cond_broadcast (cond: PGCond);
137
 
  procedure g_cond_free      (cond: PGCond);
138
 
  function  g_private_new    (dest: TGDestroyNotify): PGPrivate;
139
 
  function  g_private_get    (private_key: PGPrivate): gpointer;
140
 
  procedure g_private_set    (var private_key: PGPrivate; data: gpointer);
141
 
 
142
 
  procedure g_thread_yield;
143
 
 
144
 
 
145
 
  function g_thread_create      (func: TGThreadFunc;
146
 
                                 data: gpointer;
147
 
                                 joinable: gboolean;
148
 
                                 error: PPGError): PGThread;
149
 
 
150
 
  function g_thread_create_full (func : TGThreadFunc;
151
 
                                 data : gpointer;
152
 
                                 stack_size: gulong;
153
 
                                 joinable, bound: gboolean;
154
 
                                 priority : TGThreadPriority;
155
 
                                 error    : ppGError): PGThread; cdecl; external gthreadlib name 'g_thread_create_full';
156
 
 
157
 
 
158
 
  function g_thread_self:PGThread;cdecl;external gthreadlib name 'g_thread_self';
159
 
 
160
 
  procedure g_thread_exit(retval:gpointer);cdecl;external gthreadlib name 'g_thread_exit';
161
 
 
162
 
  function g_thread_join(thread:PGThread):gpointer;cdecl;external gthreadlib name 'g_thread_join';
163
 
 
164
 
  procedure g_thread_set_priority(thread:PGThread; priority:TGThreadPriority);cdecl;external gthreadlib name 'g_thread_set_priority';
165
 
 
166
 
{ GStaticMutexes can be statically initialized with the value
167
 
  G_STATIC_MUTEX_INIT, and then they can directly be used, that is
168
 
  much easier, than having to explicitly allocate the mutex before
169
 
  use
170
 
}
171
 
 
172
 
  procedure g_static_mutex_lock   (mutex: PGStaticMutex);
173
 
 
174
 
  function  g_static_mutex_trylock (mutex: PGStaticMutex): gboolean;
175
 
 
176
 
  procedure g_static_mutex_unlock (mutex: PGStaticMutex);
177
 
 
178
 
 
179
 
  procedure g_static_mutex_free(mutex:PGStaticMutex);cdecl;external gthreadlib name 'g_static_mutex_free';
180
 
 
181
 
 
182
 
  type
183
 
    PGStaticPrivate = ^TGStaticPrivate;
184
 
    TGStaticPrivate = record
185
 
                        index : guint;
186
 
                      end;
187
 
 
188
 
  const
189
 
    nG_STATIC_PRIVATE_INIT = 0;       //renamed because of conflict with function_name
190
 
 
191
 
  procedure g_static_private_init(private_key:PGStaticPrivate);cdecl;external gthreadlib name 'g_static_private_init';
192
 
 
193
 
  function g_static_private_get(private_key:PGStaticPrivate):gpointer;cdecl;external gthreadlib name 'g_static_private_get';
194
 
 
195
 
  procedure g_static_private_set(private_key:PGStaticPrivate; data:gpointer; notify:TGDestroyNotify);cdecl;external gthreadlib name 'g_static_private_set';
196
 
 
197
 
  procedure g_static_private_free(private_key:PGStaticPrivate);cdecl;external gthreadlib name 'g_static_private_free';
198
 
 
199
 
  type
200
 
    PGStaticRecMutex = ^TGStaticRecMutex;
201
 
    TGStaticRecMutex = record
202
 
            mutex : TGStaticMutex;
203
 
            depth : guint;
204
 
            owner : TGSystemThread;      // defined in glibconfig.inc
205
 
         end;
206
 
 
207
 
  const
208
 
    nG_STATIC_MUTEX_INIT     = nil;      // from glibconfig.h
209
 
    nG_STATIC_REC_MUTEX_INIT = nG_STATIC_MUTEX_INIT;
210
 
 
211
 
 
212
 
  procedure g_static_rec_mutex_init(mutex:PGStaticRecMutex);cdecl;external gthreadlib name 'g_static_rec_mutex_init';
213
 
 
214
 
  procedure g_static_rec_mutex_lock(mutex:PGStaticRecMutex);cdecl;external gthreadlib name 'g_static_rec_mutex_lock';
215
 
 
216
 
  function g_static_rec_mutex_trylock(mutex:PGStaticRecMutex):gboolean;cdecl;external gthreadlib name 'g_static_rec_mutex_trylock';
217
 
 
218
 
  procedure g_static_rec_mutex_unlock(mutex:PGStaticRecMutex);cdecl;external gthreadlib name 'g_static_rec_mutex_unlock';
219
 
 
220
 
  procedure g_static_rec_mutex_lock_full(mutex:PGStaticRecMutex; depth:guint);cdecl;external gthreadlib name 'g_static_rec_mutex_lock_full';
221
 
 
222
 
  function g_static_rec_mutex_unlock_full(mutex:PGStaticRecMutex):guint;cdecl;external gthreadlib name 'g_static_rec_mutex_unlock_full';
223
 
 
224
 
  procedure g_static_rec_mutex_free(mutex:PGStaticRecMutex);cdecl;external gthreadlib name 'g_static_rec_mutex_free';
225
 
 
226
 
 
227
 
  type
228
 
     PGStaticRWLock = ^TGStaticRWLock;
229
 
     TGStaticRWLock = record
230
 
            mutex         : TGStaticMutex;
231
 
            read_cond     : PGCond;
232
 
            write_cond    : PGCond;
233
 
            read_counter  : guint;
234
 
            write         : gboolean;
235
 
            want_to_read  : guint;
236
 
            want_to_write : guint;
237
 
         end;
238
 
 
239
 
{* i can't translate this macro. any ideas???
240
 
 *
241
 
 * #define G_STATIC_RW_LOCK_INIT  G_STATIC_MUTEX_INIT, NULL, NULL, 0, FALSE, 0, 0
242
 
 *}
243
 
 
244
 
    procedure g_static_rw_lock_init(lock:PGStaticRWLock);cdecl;external gthreadlib name 'g_static_rw_lock_init';
245
 
 
246
 
    procedure g_static_rw_lock_reader_lock(lock:PGStaticRWLock);cdecl;external gthreadlib name 'g_static_rw_lock_reader_lock';
247
 
 
248
 
    function g_static_rw_lock_reader_trylock(lock:PGStaticRWLock):gboolean;cdecl;external gthreadlib name 'g_static_rw_lock_reader_trylock';
249
 
 
250
 
    procedure g_static_rw_lock_reader_unlock(lock:PGStaticRWLock);cdecl;external gthreadlib name 'g_static_rw_lock_reader_unlock';
251
 
 
252
 
    procedure g_static_rw_lock_writer_lock(lock:PGStaticRWLock);cdecl;external gthreadlib name 'g_static_rw_lock_writer_lock';
253
 
 
254
 
    function g_static_rw_lock_writer_trylock(lock:PGStaticRWLock):gboolean;cdecl;external gthreadlib name 'g_static_rw_lock_writer_trylock';
255
 
 
256
 
    procedure g_static_rw_lock_writer_unlock(lock:PGStaticRWLock);cdecl;external gthreadlib name 'g_static_rw_lock_writer_unlock';
257
 
 
258
 
    procedure g_static_rw_lock_free(lock:PGStaticRWLock);cdecl;external gthreadlib name 'g_static_rw_lock_free';
259
 
 
260
 
{ these are some convenience macros that expand to nothing if GLib
261
 
  was configured with --disable-threads. for using StaticMutexes,
262
 
  you define them with G_LOCK_DEFINE_STATIC (name) or G_LOCK_DEFINE (name)
263
 
  if you need to export the mutex. With G_LOCK_EXTERN (name) you can
264
 
  declare such an globally defined lock. name is a unique identifier
265
 
  for the protected varibale or code portion. locking, testing and
266
 
  unlocking of such mutexes can be done with G_LOCK(), G_UNLOCK() and
267
 
  G_TRYLOCK() respectively.
268
 
}
269
 
    procedure glib_dummy_decl;cdecl;external gthreadlib name 'glib_dummy_decl';
270
 
 
271
 
{ anyone an idea???
272
 
    #define G_LOCK_NAME(name)               g__ ## name ## _lock
273
 
    #define G_LOCK(name) g_static_mutex_lock       (&G_LOCK_NAME (name))
274
 
    #define G_UNLOCK(name) g_static_mutex_unlock   (&G_LOCK_NAME (name))
275
 
    #define G_TRYLOCK(name) g_static_mutex_trylock (&G_LOCK_NAME (name))
276
 
}
277
 
 
278
 
//{$endif}