Line data Source code
1 : /* Copyright 2024 Wikimedia Foundation
2 : *
3 : * Licensed under the Apache License, Version 2.0 (the "License");
4 : * you may not use this file except in compliance with the License.
5 : * You may obtain a copy of the License at
6 : *
7 : * http://www.apache.org/licenses/LICENSE-2.0
8 : *
9 : * Unless required by applicable law or agreed to in writing, software
10 : * distributed under the License is distributed on an "AS IS" BASIS,
11 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : * See the License for the specific language governing permissions and
13 : * limitations under the License.
14 : */
15 :
16 : #include "excimer_mutex.h"
17 : #include "php.h"
18 :
19 44 : void excimer_mutex_init(pthread_mutex_t *mutex)
20 : {
21 44 : int result = pthread_mutex_init(mutex, NULL);
22 44 : if (result != 0) {
23 0 : zend_error_noreturn(E_ERROR, "pthread_mutex_init(): %s", strerror(result));
24 : }
25 44 : }
26 :
27 311 : void excimer_mutex_lock(pthread_mutex_t *mutex)
28 : {
29 311 : int result = pthread_mutex_lock(mutex);
30 311 : if (result != 0) {
31 0 : fprintf(stderr, "pthread_mutex_lock(): %s", strerror(result));
32 0 : abort();
33 : }
34 311 : }
35 :
36 311 : void excimer_mutex_unlock(pthread_mutex_t *mutex)
37 : {
38 311 : int result = pthread_mutex_unlock(mutex);
39 311 : if (result != 0) {
40 0 : fprintf(stderr, "pthread_mutex_unlock(): %s", strerror(result));
41 0 : abort();
42 : }
43 311 : }
44 :
45 44 : void excimer_mutex_destroy(pthread_mutex_t *mutex)
46 : {
47 44 : int result = pthread_mutex_destroy(mutex);
48 44 : if (result != 0) {
49 0 : zend_error_noreturn(E_ERROR, "pthread_mutex_destroy(): %s", strerror(result));
50 : }
51 44 : }
|