Apache Portable Runtime
apr_portable.h
Go to the documentation of this file.
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/* This header file is where you should put ANY platform specific information.
18 * This should be the only header file that programs need to include that
19 * actually has platform dependent code which refers to the .
20 */
21#ifndef APR_PORTABLE_H
22#define APR_PORTABLE_H
23/**
24 * @file apr_portable.h
25 * @brief APR Portability Routines
26 */
27
28#include "apr.h"
29#include "apr_pools.h"
30#include "apr_thread_proc.h"
31#include "apr_file_io.h"
32#include "apr_network_io.h"
33#include "apr_errno.h"
34#include "apr_global_mutex.h"
35#include "apr_proc_mutex.h"
36#include "apr_time.h"
37#include "apr_dso.h"
38#include "apr_shm.h"
39
40#if APR_HAVE_DIRENT_H
41#include <dirent.h>
42#endif
43#if APR_HAVE_FCNTL_H
44#include <fcntl.h>
45#endif
46#if APR_HAVE_PTHREAD_H
47#include <pthread.h>
48#endif
49#if APR_HAVE_SEMAPHORE_H
50#include <semaphore.h>
51#endif
52
53#ifdef __cplusplus
54extern "C" {
55#endif /* __cplusplus */
56
57/**
58 * @defgroup apr_portabile Portability Routines
59 * @ingroup APR
60 * @{
61 */
62
63#ifdef WIN32
64/* The primitives for Windows types */
65typedef HANDLE apr_os_file_t;
66typedef HANDLE apr_os_dir_t;
67typedef SOCKET apr_os_sock_t;
68typedef HANDLE apr_os_proc_mutex_t;
69typedef HANDLE apr_os_thread_t;
70typedef HANDLE apr_os_proc_t;
71typedef DWORD apr_os_threadkey_t;
72typedef FILETIME apr_os_imp_time_t;
73typedef SYSTEMTIME apr_os_exp_time_t;
74typedef HANDLE apr_os_dso_handle_t;
75typedef HANDLE apr_os_shm_t;
76
77#elif defined(OS2)
78typedef HFILE apr_os_file_t;
79typedef HDIR apr_os_dir_t;
80typedef int apr_os_sock_t;
81typedef HMTX apr_os_proc_mutex_t;
82typedef TID apr_os_thread_t;
83typedef PID apr_os_proc_t;
84typedef PULONG apr_os_threadkey_t;
85typedef struct timeval apr_os_imp_time_t;
86typedef struct tm apr_os_exp_time_t;
87typedef HMODULE apr_os_dso_handle_t;
88typedef void* apr_os_shm_t;
89
90#elif defined(__BEOS__)
91#include <kernel/OS.h>
92#include <kernel/image.h>
93
95 sem_id sem;
96 int32 ben;
97};
98
99typedef int apr_os_file_t;
100typedef DIR apr_os_dir_t;
101typedef int apr_os_sock_t;
103typedef thread_id apr_os_thread_t;
104typedef thread_id apr_os_proc_t;
105typedef int apr_os_threadkey_t;
106typedef struct timeval apr_os_imp_time_t;
107typedef struct tm apr_os_exp_time_t;
108typedef image_id apr_os_dso_handle_t;
109typedef void* apr_os_shm_t;
110
111#elif defined(NETWARE)
112typedef int apr_os_file_t;
113typedef DIR apr_os_dir_t;
114typedef int apr_os_sock_t;
115typedef NXMutex_t apr_os_proc_mutex_t;
116typedef NXThreadId_t apr_os_thread_t;
117typedef long apr_os_proc_t;
118typedef NXKey_t apr_os_threadkey_t;
119typedef struct timeval apr_os_imp_time_t;
120typedef struct tm apr_os_exp_time_t;
121typedef void * apr_os_dso_handle_t;
122typedef void* apr_os_shm_t;
123
124#else
125/* Any other OS should go above this one. This is the lowest common
126 * denominator typedefs for all UNIX-like systems. :)
127 */
128
129/** Basic OS process mutex structure. */
131#if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE || APR_HAS_FLOCK_SERIALIZE
132 /** Value used for SYS V Semaphore, FCNTL and FLOCK serialization */
133 int crossproc;
134#endif
135#if APR_HAS_PROC_PTHREAD_SERIALIZE
136 /** Value used for PTHREAD serialization */
137 pthread_mutex_t *pthread_interproc;
138#endif
139#if APR_HAS_THREADS
140 /* If no threads, no need for thread locks */
141#if APR_USE_PTHREAD_SERIALIZE
142 /** This value is currently unused within APR and Apache */
143 pthread_mutex_t *intraproc;
144#endif
145#endif
146#if APR_HAS_POSIXSEM_SERIALIZE
147 /** Value used for POSIX semaphores serialization */
148 sem_t *psem_interproc;
149#endif
150};
151
152typedef int apr_os_file_t; /**< native file */
153typedef DIR apr_os_dir_t; /**< native dir */
154typedef int apr_os_sock_t; /**< native dir */
155typedef struct apr_os_proc_mutex_t apr_os_proc_mutex_t; /**< native process
156 * mutex
157 */
158#if APR_HAS_THREADS && APR_HAVE_PTHREAD_H
159typedef pthread_t apr_os_thread_t; /**< native thread */
160typedef pthread_key_t apr_os_threadkey_t; /**< native thread address
161 * space */
162#endif
163typedef pid_t apr_os_proc_t; /**< native pid */
164typedef struct timeval apr_os_imp_time_t; /**< native timeval */
165typedef struct tm apr_os_exp_time_t; /**< native tm */
166/** @var apr_os_dso_handle_t
167 * native dso types
168 */
169#if defined(HPUX) || defined(HPUX10) || defined(HPUX11)
170#include <dl.h>
171typedef shl_t apr_os_dso_handle_t;
172#elif defined(DARWIN)
173#include <mach-o/dyld.h>
174typedef NSModule apr_os_dso_handle_t;
175#else
176typedef void * apr_os_dso_handle_t;
177#endif
178typedef void* apr_os_shm_t; /**< native SHM */
179
180#endif
181