Source

daybothreads / daybothreads.h

Full commit
  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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
/*
 Daybo Logic Threads Abstraction Library
 Copyright (C) 2001-2006 Daybo Logic.
 All rights reserved.

 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions
 are met:
 1. Redistributions of source code must retain the above copyright
    notice, this list of conditions and the following disclaimer.
 2. Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimer in the
    documentation and/or other materials provided with the distribution.
 3. Neither the name of the project nor the names of its contributors
    may be used to endorse or promote products derived from this software
    without specific prior written permission.

 THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 SUCH DAMAGE.

  Daybo Logic,
  Flat 2 Barker Court,
  Victoria Avenue,
  Redfield,
  Bristol
  England.
  UK
  BS5 9NW

  +44 117 954 2306
  David Duncan Ross Palmer <http://www.daybologic.co.uk/mailddrp/>
  http://www.daybologic.co.uk/dev/daybothreads
*/

/*
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %                   D a y b o T h r e a d s                 %
  %                   -----------------------                 %
  %                                                           %
  %      A portable threads abstraction wrapper library       %
  %                                                           %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  $Id: daybothreads.h,v 0.6.4 2011/02/27 09:38:37 palmer Exp $
*/

#ifndef INC_DAYBOTHREADS_H
#define INC_DAYBOTHREADS_H
/*-------------------------------------------------------------------------*/
/*
  C and C++ mixing macros.  For any function which is a C callable function
  existing in a C++ module, DAYBOTHREADS_C_IN_CPP must be placed _before_ the
  declaration.  In C++, void in a prototype is not expected, in C it is.
  Therefore if there are no paramters to a function,
  DAYBOTHREADS_PROTOTYPE_VOID must be placed in place of the parameter list.
  For example:
  DAYBOTHREADS_C_IN_CPP void Function(DAYBOTHREADS_PROTOTYPE_VOID);

  DAYBOTHREADS_C_IN_CPP is not presently used, as we are purely a C library,
  no parts of the library are C++ code.
*/
#ifdef __cplusplus /* C++ */

# define DAYBOTHREADS_C_IN_CPP extern "C"
# define DAYBOTHREADS_PROTOTYPE_VOID

#else /* C */

# define DAYBOTHREADS_C_IN_CPP
# define DAYBOTHREADS_PROTOTYPE_VOID void

#endif /*__cplusplus*/

#ifdef DAYBOTHREADS_AUTO_INCLUDE
  /* Pull-in static definition of which back-end the lib was built against */
# include "daybothreads-config.h"

# ifdef __cplusplus

#  include <cstdlib>
   /* nb. bool is an instrinstic type in C++ */
# else /* C */

#  ifdef HAVE_STDLIB_H
#   include <stdlib.h>
#  else
#   include "dlstdinc.h"
#  endif /*HAVE_STDLIB_H*/

#  ifdef HAVE_STDBOOL_H
#   include <stdbool.h>
#  else
#   include "dlstdinc.h"
#  endif /*HAVE_STDBOOL_H*/

# endif /*__cplusplus*/

  /* Include the back-end, otherwise ptlock_t etc will fail */
# if defined(DAYBOTHREADS_NT)
#  include <windows.h>
# elif defined(DAYBOTHREADS_PTH)
#  include <pth.h>
# elif defined(DAYBOTHREADS_PTHREAD)
#  include <pthread.h>
#  ifdef HAVE_ERRNO_H
#   ifdef __cplusplus
#    include <cerrno>
#   else /* C */
#    include <errno.h>
#   endif /*__cplusplus*/
#  endif /*HAVE_ERRNO_H*/
# endif

#endif /*DAYBOTHREADS_AUTO_INCLUDE*/

/*
  Export/import definition for easy library building.  Do not be confused
  by DAYBOTHREADS_AS_DLL.  DAYBOTHREADS_AS_DLL means we are being built as a
  shared lib _OR_ dynamic link library.
*/

/*
  Visual C++ does this automatically for us so I might as well make use of it
*/
#if ( defined(DAYBOTHREADS_EXPORTS) || defined(DAYBOTHREADS_IMPORTS) )
#  ifndef DAYBOTHREADS_AS_DLL
#    define DAYBOTHREADS_AS_DLL
#  endif
#endif

#if ( defined(DAYBOTHREADS_AS_DLL) && defined(DAYBOTHREADS_SOURCE) && defined(__WIN32__) )
#  define DAYBOTHREADS_API(ret) __declspec(dllexport) ##ret __stdcall
#elif ( defined(DAYBOTHREADS_AS_DLL) && !defined(DAYBOTHREADS_SOURCE) && defined(__WIN32__) )
#  define DAYBOTHREADS_API(ret) __declspec(dllimport) ##ret __stdcall
#else
#  define DAYBOTHREADS_API(ret) ret
#endif

/*
  Ensure all structure packing is aligned at DWORD boundries for compatibillity
  with VB and most other 32-bit applications.
*/
#if ( defined(DAYBOTHREADS_AS_DLL) && defined(__WIN32__) )
# include <pshpack4.h>
#endif


#ifdef __cplusplus
  extern "C" {
#endif

#ifdef DAYBOTHREADS_SOURCE
  /*
    The following functions are available for library functions only.
    They are not intended for users of the library and are not exported
    in Win32 dynamic link library builds.
  */
  
  /*
    Specific initialiser for portmutant
  */
  void daybothreads_oldportmutant_Start(
    DAYBOTHREADS_PROTOTYPE_VOID
  );
  /*
    Specific initialiser for portthread
  */
  void daybothreads_portthread_Start(
    DAYBOTHREADS_PROTOTYPE_VOID
  );

  /*
    Specific cleanup for portmutant
  */
  void daybothreads_oldportmutant_Stop(
    DAYBOTHREADS_PROTOTYPE_VOID
  );
  
  /*
    Specific cleanup for portthread
  */
  void daybothreads_portthread_Stop(
    DAYBOTHREADS_PROTOTYPE_VOID
  );
  
#endif /*DAYBOTHREADS_SOURCE*/

/*
  Initialise daybothreads.  This should be called once, before any other
  functions are used.  It will return nonzero on success.  On cleanup,
  daybothreads_Shutdown() should be called.
*/
DAYBOTHREADS_API(int) daybothreads_Startup(
  DAYBOTHREADS_PROTOTYPE_VOID
);

/*
  Shutdown daybothreads.  This should be called once, after you have
  finished using all functions.  No functions should be used after
  this function is used.  In certain thread libraries, calling this
  function could terminate your program, as your calling thread will also
  be destroyed.
*/
DAYBOTHREADS_API(void) daybothreads_Shutdown(
  DAYBOTHREADS_PROTOTYPE_VOID
);

/*
  Define a handle for using threads.  We provide a thread handle which
  is opaque to the user and can only be used via the DayboThreads library.
*/
typedef unsigned int DAYBOTHREADS_THREAD_HANDLE;

/*
  If a handle is not valid, we define a well known value for the handle
  which everybody realises represents an object which does not exist or
  is not initialised.  This value can be used via the mnemonic
  DAYBOTHREADS_INVALID_HANDLE
*/
#define DAYBOTHREADS_INVALID_HANDLE (0U)

/*
  Maximum filename length (used for source code debugging)
*/
#define DAYBOTHREADS_MAXFNLEN (255)

/*
  Maximum number of threads.  This is a thread-limiter.
*/
#define DAYBOTHREADS_MAXTHREADS (32)

/*
  Use the daybothreads_Version( ) function to discover the version
  number of the library which is being used.  Using the macros
  DAYBOTHREADS_VER_MAJOR, DAYBOTHREADS_VER_MINOR and
  DAYBOTHREADS_VER_PATCH directly will only tell you the version
  of the daybothreads.h you have included which is not _necessarily_
  the same thing.  daybothreads_Version( ) returns the major version
  number.
*/

#define DAYBOTHREADS_VER_MAJOR (0)
#define DAYBOTHREADS_VER_MINOR (4)
#define DAYBOTHREADS_VER_PATCH (2)

DAYBOTHREADS_API(unsigned int) daybothreads_Version(
  unsigned int *PMajor,
  unsigned int *PMinor,
  unsigned int *PPatch
);

/*
  The following structure details the capabilities of a built version
  of the library.  It should be used in place of macros in the client
  (user) program of this library.  This ensures that the library was
  built as you expect.  If you use the macros, you only know that the
  _header_ was says we support something, not the actual binary library.
  The size field, which is the first field in the structure must be
  set to the size of the structure.  The rest of the structure should
  be zeroed before the call to daybothreads_Caps() (the capability
  information function).
*/

enum daybothreadsRealLib {
  dtrlNT, /* DAYBOTHREADS_NT */
  dtrlPth, /* DAYBOTHREADS_PTH */
  dtrlPThread /* DAYBOTHREADS_PTHREAD */
};

struct daybothreadsCaps {
  size_t Size; /* Must be set before use */
  unsigned char Shared;
  struct {
    unsigned char Win32;
    unsigned char Unix;
  } PlatformCode;
  struct {
    unsigned char Threads;
  } Logging;
  unsigned char Debug;
  unsigned char BigEndian;
  unsigned int InvalidHandle;
  unsigned int MaxFNLength;
  unsigned int MaxThreads;
  enum daybothreadsRealLib RealLib;
  unsigned int ReservedInt0, ReservedInt1, ReservedInt2, ReservedInt3;
  unsigned char ReservedChar0, ReservedChar1, ReservedChar2, ReservedChar3;
};

DAYBOTHREADS_API(unsigned char) daybothreads_Caps(
  struct daybothreadsCaps *Capabilities
);

/*
  The following macros provide a macro mapping to the back-end thread
  library's mutex or critical section interface.  These are light-
  weight locking primatives
*/
#if defined(DAYBOTHREADS_NT)
# define dtlock_t                      CRITICAL_SECTION
# define daybothreads_CreateLock(p)    InitializeCriticalSection((p))
# define daybothreads_EnterLock(p)     EnterCriticalSection((p))
# define daybothreads_TryEnterLock(p)  TryEnterCriticalSection((p))
# define daybothreads_LeaveLock(p)     LeaveCriticalSection((p))
# define daybothreads_DestroyLock(p)   DeleteCriticalSection((p))
#elif defined(DAYBOTHREADS_PTH)
# define dtlock_t                      pth_mutex_t
# define daybothreads_CreateLock(p)    pth_mutex_init((p))
# define daybothreads_EnterLock(p)     pth_mutex_acquire((p), (int)false, NULL)
# define daybothreads_TryEnterLock(p)  pth_mutex_acquire((p), (int)true, NULL)
# define daybothreads_LeaveLock(p)     pth_mutex_release((p))
# define daybothreads_DestroyLock(p)   pth_mutex_init((p)) /* Not a mistake */
#elif defined(DAYBOTHREADS_PTHREAD)
# define dtlock_t                      pthread_mutex_t
# define daybothreads_CreateLock(p)    daybothreads_CreateRecursiveLock((p))
# define daybothreads_EnterLock(p)     pthread_mutex_lock((p))
# define daybothreads_TryEnterLock(p) \
    ( ( pthread_mutex_trylock((p)) == EBUSY ) ? false : true )
# define daybothreads_LeaveLock(p)     pthread_mutex_unlock((p))
# define daybothreads_DestroyLock(p)   pthread_mutex_destroy((p))
#else
  /*
    If you get this error, you must define one of the supported thread
    back-ends before compiling your source code.  You can do this in
    your configure script.  You should also compile DayboThreads to
    use the same library or results will be undefined.
  */
# error ("Must define:DAYBOTHREADS_NT,DAYBOTHREADS_PTH,DAYBOTHREADS_PTHREAD")
#endif

/*
  This function is a portable sleep.  Sleep functionality is
  difficult to find portably, so I recommend you use this version.
  It will call the appropriate operating system library sleep
  function.
*/
DAYBOTHREADS_API(void) daybothreads_Sleep(
  unsigned int Seconds
);

DAYBOTHREADS_API(void) daybothreads_SleepMS(
  unsigned int MilliSeconds
);

DAYBOTHREADS_API(bool) daybothreads_RunAsThread(
  void* (*Function)(void*)
);

DAYBOTHREADS_API(bool) daybothreads_WaitOnThreadTermination(
  void* (*Function)(void*)
);

/*
  This function is used by the macro daybothreads_CreateLock() and
  is only available when we are built with DAYBOTHREADS_PTHREAD
*/
#ifdef DAYBOTHREADS_PTHREAD
DAYBOTHREADS_API(void) daybothreads_CreateRecursiveLock(
  dtlock_t *PLock
);
#endif /*DAYBOTHREADS_PTHREAD*/

/*
  Yields control to another thread (gives up timeslice in pre-emptive
  scheduler
*/
DAYBOTHREADS_API(void) daybothreads_Yield(
  DAYBOTHREADS_PROTOTYPE_VOID
);

/*
  Returns the thread identifier of the thread which calls the function.
  DAYBOTHREADS_INVALID_HANDLE (zero) will be returned if the calling
  function does not exist within a thread or something wicked has happened
  looking up the thread.
*/
DAYBOTHREADS_API(DAYBOTHREADS_THREAD_HANDLE) daybothreads_WhoAmI(
  DAYBOTHREADS_PROTOTYPE_VOID
);

/*
  An atomic scalar is a very useful object which is a self-locking
  scalar type.  These are the scalar types it supports:
*/
enum daybothreads_scalarType {
  dtstUnknown,
  dtstIntSignedShort,
  dtstIntUnsignedShort,
  dtstIntSigned,
  dtstIntUnsigned,
  dtstIntSignedLong,
  dtstIntUnsignedLong,
  dtstChar,
  dtstSignedChar,
  dtstUnsignedChar
};

/*
  To use an atomic scalar, instantaniate one of these objects
  and then initialise it
*/
typedef struct daybothreads_scalar {
  /* private, treat as opaque */
  enum daybothreads_scalarType Type;
  union {
    signed short int ss;
    unsigned short int us;
    signed int si;
    unsigned int ui;
    signed long int sl;
    unsigned long int ul;
    char c;
    signed char sc;
    unsigned char uc;
  } Scalar;
  dtlock_t Lock;

  /*
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % Public - use these functions to manipulate %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  */
  /*
    Returns the type of integer
  */
  enum daybothreads_scalarType (*DetermineType)(
    struct daybothreads_scalar *PObject
  );
  /*
    Interlocked increment of the variable
  */
  void (*Increment)(
    struct daybothreads_scalar *PObject
  );
  /*
    Interlocked decrement of the variable
  */
  void (*Decrement)(
    struct daybothreads_scalar* PObject
  );
  /*
    Interlocked increment of the variable by a specifc amount
  */
  void (*IncrementBy)(
    struct daybothreads_scalar* PObject,
    const unsigned long Amount
  );
  /*
    Interlocked decrement of the variable by a specifc amount
  */
  void (*DecrementBy)(
    struct daybothreads_scalar *PObject,
    const unsigned long Amount
  );
  /*
    Interlocked integer setters/getters, return old value
  */
  signed short int (*SS)(
    struct daybothreads_scalar *PObject,
    const signed short int *PNew
  );
  unsigned short int (*US)(
    struct daybothreads_scalar *PObject,
    const unsigned short int *PNew
  );
  signed int (*SI)(
    struct daybothreads_scalar* PObject,
    const signed int* PNew
  );
  unsigned int (*UI)(
    struct daybothreads_scalar *PObject,
    const unsigned int *PNew
  );
  signed long int (*SL)(
    struct daybothreads_scalar *PObject,
    const signed long int *PNew
  );
  unsigned long int (*UL)(
    struct daybothreads_scalar *PObject,
    const unsigned long int *PNew
  );
  char (*C)(
    struct daybothreads_scalar *PObject,
    const char *PNew
  );
  signed char (*SC)(
    struct daybothreads_scalar *PObject,
    const signed char *PNew
  );
  unsigned char (*UC)(
    struct daybothreads_scalar *PObject,
    const unsigned char *PNew
  );
  /* Simpler getters... */
  signed short int (*GetSignedShort)(
    struct daybothreads_scalar *PObject
  );
  unsigned short int (*GetUnsignedShort)(
    struct daybothreads_scalar *PObject
  );
  signed int (*GetSignedInt)(
    struct daybothreads_scalar *PObject
  );
  unsigned int (*GetUnsignedInt)(
    struct daybothreads_scalar *PObject
  );
  signed long int (*GetSignedLong)(
    struct daybothreads_scalar *PObject
  );
  unsigned long int (*GetUnsignedLong)(
    struct daybothreads_scalar *PObject
  );
  char (*GetChar)(
    struct daybothreads_scalar *PObject
  );
  signed char (*GetSignedChar)(
    struct daybothreads_scalar *PObject
  );
  unsigned char (*GetUnsignedChar)(
    struct daybothreads_scalar *PObject
  );
  /* Simpler setters */
  signed short int (*SetSignedShort)(
    struct daybothreads_scalar *PObject,
    const signed short int New
  );
  unsigned short int (*SetUnsignedShort)(
    struct daybothreads_scalar *PObject,
    const unsigned short int New
  );
  signed int (*SetSignedInt)(
    struct daybothreads_scalar *PObject,
    const signed int New
  );
  unsigned int (*SetUnsignedInt)(
    struct daybothreads_scalar *PObject,
    const unsigned int New
  );
  signed long int (*SetSignedLong)(
    struct daybothreads_scalar *PObject,
    const signed long int New
  );
  unsigned long int (*SetUnsignedLong)(
    struct daybothreads_scalar *PObject,
    const unsigned long int New
  );
  char (*SetChar)(
    struct daybothreads_scalar *PObject,
    const char New
  );
  signed char (*SetSignedChar)(
    struct daybothreads_scalar *PObject,
    const signed char New
  );
  unsigned char (*SetUnsignedChar)(
    struct daybothreads_scalar *PObject,
    const unsigned char New
  );
} dtscalar_t;

/*
  The functions are mainly implemented in the object but before using them
  call daybothreads_CreateAtomicScalar() and after the object is finished
  with call daybothreads_DestroyAtomicScalar().
*/
DAYBOTHREADS_API(void) daybothreads_CreateAtomicScalar(
  struct daybothreads_scalar *PAtomicScalar
);

DAYBOTHREADS_API(void) daybothreads_DestroyAtomicScalar(
  struct daybothreads_scalar *PAtomicScalar
);

/*
  This function is of no use to normal end users
*/
DAYBOTHREADS_API(void) daybothreads_Unused(
  const void *const Arg,
  const unsigned char Recursed
);

/*
  The following macros are only available to the DayboThreads code,
  they allow use of much shorter names, to make the code more readable
*/
#ifdef DAYBOTHREADS_SOURCE
  /* Types */
# define THREAD_HANDLE DAYBOTHREADS_THREAD_HANDLE
# define INVALID_HANDLE DAYBOTHREADS_INVALID_HANDLE
# define MAXFNLEN DAYBOTHREADS_MAXFNLEN
# define MAXTHREADS DAYBOTHREADS_MAXTHREADS
# define VER_MAJOR DAYBOTHREADS_VER_MAJOR
# define VER_MINOR DAYBOTHREADS_VER_MINOR
# define VER_PATCH DAYBOTHREADS_VER_PATCH

  /* Functions */
# define Startup daybothreads_Startup
# define Shutdown daybothreads_Shutdown
# define Version daybothreads_Version
# define Caps daybothreads_Caps
# define RunAsThread daybothreads_RunAsThread
# define WaitOnThreadTermination daybothreads_WaitOnThreadTermination
# define WhoAmI daybothreads_WhoAmI
# define CreateAtomicScalar daybothreads_CreateAtomicScalar
# define DestroyAtomicScalar daybothreads_DestroyAtomicScalar
# define CreateLock daybothreads_CreateLock

# ifdef DAYBOTHREADS_PTHREAD
#  define CreateRecursiveLock daybothreads_CreateRecursiveLock
# endif /*DAYBOTHREADS_PTHREAD*/

# define DestroyLock daybothreads_DestroyLock
# define TryEnterLock daybothreads_TryEnterLock
# define EnterLock daybothreads_EnterLock
# define LeaveLock daybothreads_LeaveLock
# define Unused(p) daybothreads_Unused(((const void *const )(p)), '\x0')
  /*
    Note: Sleep related functions do not have short names,
    this could cause confusion, if they existed.  The functions which
    have no short names are:

    daybothreads_Sleep()
    daybothreads_SleepMS()
    daybothreads_SleepYield()
    daybothreads_Yield()
  */
#endif /*DAYBOTHREADS_SOURCE*/

#ifdef __cplusplus
  } /* extern "C" */
#endif /*__cplusplus*/

/*
  Restore alignment
*/
#if ( defined(DAYBOTHREADS_AS_DLL) && defined(__WIN32__) )
# include <poppack.h>
#endif
/*-------------------------------------------------------------------------*/
#endif /*!INC_DAYBOTHREADS_H*/