]> granicus.if.org Git - apache/blob - include/util_mutex.h
Save some bytes :)
[apache] / include / util_mutex.h
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2  * contributor license agreements.  See the NOTICE file distributed with
3  * this work for additional information regarding copyright ownership.
4  * The ASF licenses this file to You under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with
6  * the License.  You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /**
18  * @file  util_mutex.h
19  * @brief Apache Mutex support library
20  *
21  * @defgroup APACHE_CORE_MUTEX Mutex Library
22  * @ingroup  APACHE_CORE
23  * @{
24  */
25
26 #ifndef UTIL_MUTEX_H
27 #define UTIL_MUTEX_H
28
29 #include "httpd.h"
30 #include "apr_global_mutex.h"
31
32 #if APR_HAS_FLOCK_SERIALIZE
33 # define AP_LIST_FLOCK_SERIALIZE ", 'flock:/path/to/file'"
34 #else
35 # define AP_LIST_FLOCK_SERIALIZE
36 #endif
37 #if APR_HAS_FCNTL_SERIALIZE
38 # define AP_LIST_FCNTL_SERIALIZE ", 'fcntl:/path/to/file'"
39 #else
40 # define AP_LIST_FCNTL_SERIALIZE
41 #endif
42 #if APR_HAS_SYSVSEM_SERIALIZE
43 # define AP_LIST_SYSVSEM_SERIALIZE ", 'sysvsem'"
44 #else
45 # define AP_LIST_SYSVSEM_SERIALIZE
46 #endif
47 #if APR_HAS_POSIXSEM_SERIALIZE
48 # define AP_LIST_POSIXSEM_SERIALIZE ", 'posixsem'"
49 #else
50 # define AP_LIST_POSIXSEM_SERIALIZE
51 #endif
52 #if APR_HAS_PROC_PTHREAD_SERIALIZE
53 # define AP_LIST_PTHREAD_SERIALIZE ", 'pthread'"
54 #else
55 # define AP_LIST_PTHREAD_SERIALIZE
56 #endif
57 #if APR_HAS_FLOCK_SERIALIZE || APR_HAS_FCNTL_SERIALIZE
58 # define AP_LIST_FILE_SERIALIZE ", 'file:/path/to/file'"
59 #else
60 # define AP_LIST_FILE_SERIALIZE
61 #endif
62 #if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_POSIXSEM_SERIALIZE
63 # define AP_LIST_SEM_SERIALIZE ", 'sem'"
64 #else
65 # define AP_LIST_SEM_SERIALIZE
66 #endif
67
68 #define AP_ALL_AVAILABLE_MUTEXES_STRING                  \
69     "Mutex mechanisms are: 'none', 'default'"            \
70     AP_LIST_FLOCK_SERIALIZE   AP_LIST_FCNTL_SERIALIZE    \
71     AP_LIST_FILE_SERIALIZE    AP_LIST_PTHREAD_SERIALIZE  \
72     AP_LIST_SYSVSEM_SERIALIZE AP_LIST_POSIXSEM_SERIALIZE \
73     AP_LIST_SEM_SERIALIZE
74
75 #define AP_AVAILABLE_MUTEXES_STRING                      \
76     "Mutex mechanisms are: 'default'"                    \
77     AP_LIST_FLOCK_SERIALIZE   AP_LIST_FCNTL_SERIALIZE    \
78     AP_LIST_FILE_SERIALIZE    AP_LIST_PTHREAD_SERIALIZE  \
79     AP_LIST_SYSVSEM_SERIALIZE AP_LIST_POSIXSEM_SERIALIZE \
80     AP_LIST_SEM_SERIALIZE
81
82 #ifdef __cplusplus
83 extern "C" {
84 #endif
85
86 /**
87  * Get Mutex config data and parse it
88  * @param arg The mutex config string
89  * @param pool The allocation pool
90  * @param mutexmech The APR mutex locking mechanism
91  * @param mutexfile The lockfile to use as required
92  * @return APR status code
93  * @fn apr_status_t ap_parse_mutex(const char *arg, apr_pool_t *pool,
94                                         apr_lockmech_e *mutexmech,
95                                         const char **mutexfile)
96  */
97 AP_DECLARE(apr_status_t) ap_parse_mutex(const char *arg, apr_pool_t *pool,
98                                         apr_lockmech_e *mutexmech,
99                                         const char **mutexfile);
100
101
102 #ifdef __cplusplus
103 }
104 #endif
105
106 #endif /* UTIL_MUTEX_H */
107 /** @} */