| 1 |
/* |
| 2 |
* Copyright (c) 2016-2019, NVIDIA CORPORATION. All rights reserved. |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 5 |
* copy of this software and associated documentation files (the "Software"), |
| 6 |
* to deal in the Software without restriction, including without limitation |
| 7 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 |
* and/or sell copies of the Software, and to permit persons to whom the |
| 9 |
* Software is furnished to do so, subject to the following conditions: |
| 10 |
* |
| 11 |
* The above copyright notice and this permission notice shall be included in |
| 12 |
* all copies or substantial portions of the Software. |
| 13 |
* |
| 14 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 18 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 19 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 20 |
* DEALINGS IN THE SOFTWARE. |
| 21 |
*/ |
| 22 |
|
| 23 |
#ifndef WAYLAND_THREAD_H |
| 24 |
#define WAYLAND_THREAD_H |
| 25 |
|
| 26 |
#include <wayland-client.h> |
| 27 |
#include <pthread.h> |
| 28 |
#include <stdbool.h> |
| 29 |
|
| 30 |
/* |
| 31 |
* wlExternalApiLock() |
| 32 |
* |
| 33 |
* Tries to acquire the external API lock. If the lock is already acquired by |
| 34 |
* another thread, it will block until the lock is released. |
| 35 |
* |
| 36 |
* Calling this function twice without calling wlExternalApiUnlock() in between |
| 37 |
* will fail. |
| 38 |
* |
| 39 |
* First call to wlExternalApiLock() will initialize the external API lock |
| 40 |
* resources. |
| 41 |
* |
| 42 |
* Returns 0 upon success; otherwise returns -1. |
| 43 |
*/ |
| 44 |
int wlExternalApiLock(void); |
| 45 |
|
| 46 |
/* |
| 47 |
* wlExternalApiUnlock() |
| 48 |
* |
| 49 |
* Releases the external API lock. |
| 50 |
* |
| 51 |
* Calling this function without a previous call to wlExternalApiLock() will |
| 52 |
* fail. |
| 53 |
* |
| 54 |
* Returns 0 upon success; otherwise returns -1. |
| 55 |
*/ |
| 56 |
int wlExternalApiUnlock(void); |
| 57 |
|
| 58 |
/* |
| 59 |
* wlExternalApiDestroyLock() |
| 60 |
* |
| 61 |
* Releases and frees the the external API lock resources. This call should only |
| 62 |
* be called as part of the global teardown. |
| 63 |
*/ |
| 64 |
void wlExternalApiDestroyLock(void); |
| 65 |
|
| 66 |
/* |
| 67 |
* wlEglInitializeMutex(pthread_mutex_t *mutex) |
| 68 |
* |
| 69 |
* Initialises the pthread mutex referenced by mutex. |
| 70 |
*/ |
| 71 |
bool wlEglInitializeMutex(pthread_mutex_t *mutex); |
| 72 |
|
| 73 |
/* |
| 74 |
* wlEglMutexDestroy(pthread_mutex_t *mutex) |
| 75 |
* |
| 76 |
* Destroys the pthread mutex referenced by mutex. |
| 77 |
*/ |
| 78 |
void wlEglMutexDestroy(pthread_mutex_t *mutex); |
| 79 |
|
| 80 |
#endif |