]> git.ipfire.org Git - thirdparty/cups.git/blame - cups/thread-private.h
Fix source file header text duplication text duplication.
[thirdparty/cups.git] / cups / thread-private.h
CommitLineData
c7017ecc 1/*
7e86f2f6 2 * Private threading definitions for CUPS.
c7017ecc 3 *
ad7daa25 4 * Copyright 2009-2016 by Apple Inc.
c7017ecc 5 *
7e86f2f6
MS
6 * These coded instructions, statements, and computer programs are the
7 * property of Apple Inc. and are protected by Federal copyright
8 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
9 * which should have been included with this file. If this file is
57b7b66b 10 * missing or damaged, see the license at "http://www.cups.org/".
6539a0af
MS
11 *
12 * This file is subject to the Apple OS-Developed Software exception.
c7017ecc
MS
13 */
14
15#ifndef _CUPS_THREAD_PRIVATE_H_
16# define _CUPS_THREAD_PRIVATE_H_
17
18/*
19 * Include necessary headers...
20 */
21
22# include "config.h"
23
24
25/*
26 * C++ magic...
27 */
28
29# ifdef __cplusplus
30extern "C" {
31# endif /* __cplusplus */
32
33
ad7daa25 34# ifdef HAVE_PTHREAD_H /* POSIX threading */
c7017ecc
MS
35# include <pthread.h>
36typedef void *(*_cups_thread_func_t)(void *arg);
ad7daa25
MS
37typedef pthread_t _cups_thread_t;
38typedef pthread_cond_t _cups_cond_t;
c7017ecc 39typedef pthread_mutex_t _cups_mutex_t;
1106b00e 40typedef pthread_rwlock_t _cups_rwlock_t;
c7017ecc 41typedef pthread_key_t _cups_threadkey_t;
ad7daa25 42# define _CUPS_COND_INITIALIZER PTHREAD_COND_INITIALIZER
c7017ecc 43# define _CUPS_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
1106b00e 44# define _CUPS_RWLOCK_INITIALIZER PTHREAD_RWLOCK_INITIALIZER
7e86f2f6 45# define _CUPS_THREADKEY_INITIALIZER 0
c7017ecc
MS
46# define _cupsThreadGetData(k) pthread_getspecific(k)
47# define _cupsThreadSetData(k,p) pthread_setspecific(k,p)
48
ad7daa25 49# elif defined(WIN32) /* Windows threading */
c7017ecc
MS
50# include <winsock2.h>
51# include <windows.h>
52typedef void *(__stdcall *_cups_thread_func_t)(void *arg);
ad7daa25
MS
53typedef int _cups_thread_t;
54typedef char _cups_cond_t; /* TODO: Implement Win32 conditional */
c7017ecc
MS
55typedef struct _cups_mutex_s
56{
f3c17241 57 int m_init; /* Flag for on-demand initialization */
c7017ecc
MS
58 CRITICAL_SECTION m_criticalSection;
59 /* Win32 Critical Section */
60} _cups_mutex_t;
1106b00e 61typedef _cups_mutex_t _cups_rwlock_t; /* TODO: Implement Win32 reader/writer lock */
c7017ecc 62typedef DWORD _cups_threadkey_t;
ad7daa25 63# define _CUPS_COND_INITIALIZER 0
c7017ecc 64# define _CUPS_MUTEX_INITIALIZER { 0, 0 }
1106b00e 65# define _CUPS_RWLOCK_INITIALIZER { 0, 0 }
c7017ecc
MS
66# define _CUPS_THREADKEY_INITIALIZER 0
67# define _cupsThreadGetData(k) TlsGetValue(k)
68# define _cupsThreadSetData(k,p) TlsSetValue(k,p)
69
ad7daa25 70# else /* No threading */
f3c17241 71typedef void *(*_cups_thread_func_t)(void *arg);
ad7daa25
MS
72typedef int _cups_thread_t;
73typedef char _cups_cond_t;
c7017ecc 74typedef char _cups_mutex_t;
1106b00e 75typedef char _cups_rwlock_t;
c7017ecc 76typedef void *_cups_threadkey_t;
ad7daa25 77# define _CUPS_COND_INITIALIZER 0
c7017ecc 78# define _CUPS_MUTEX_INITIALIZER 0
1106b00e 79# define _CUPS_RWLOCK_INITIALIZER 0
c7017ecc
MS
80# define _CUPS_THREADKEY_INITIALIZER (void *)0
81# define _cupsThreadGetData(k) k
82# define _cupsThreadSetData(k,p) k=p
83# endif /* HAVE_PTHREAD_H */
84
85
86/*
87 * Functions...
88 */
89
ad7daa25
MS
90extern void _cupsCondBroadcast(_cups_cond_t *cond);
91extern void _cupsCondInit(_cups_cond_t *cond);
92extern void _cupsCondWait(_cups_cond_t *cond, _cups_mutex_t *mutex, double timeout);
1106b00e 93extern void _cupsMutexInit(_cups_mutex_t *mutex);
c7017ecc
MS
94extern void _cupsMutexLock(_cups_mutex_t *mutex);
95extern void _cupsMutexUnlock(_cups_mutex_t *mutex);
1106b00e
MS
96extern void _cupsRWInit(_cups_rwlock_t *rwlock);
97extern void _cupsRWLockRead(_cups_rwlock_t *rwlock);
98extern void _cupsRWLockWrite(_cups_rwlock_t *rwlock);
99extern void _cupsRWUnlock(_cups_rwlock_t *rwlock);
ad7daa25
MS
100extern void _cupsThreadCancel(_cups_thread_t thread);
101extern _cups_thread_t _cupsThreadCreate(_cups_thread_func_t func, void *arg);
102extern void *_cupsThreadWait(_cups_thread_t thread);
c7017ecc
MS
103
104# ifdef __cplusplus
105}
106# endif /* __cplusplus */
107#endif /* !_CUPS_THREAD_PRIVATE_H_ */