1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
|
/*
* Copyright (C) 2010 Red Hat, Inc.
*
* Author: Angus Salkeld <asalkeld@redhat.com>
*
* This file is part of libqb.
*
* libqb is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 2.1 of the License, or
* (at your option) any later version.
*
* libqb is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with libqb. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef QB_OS_BASE_H_DEFINED
#define QB_OS_BASE_H_DEFINED
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif /* HAVE_CONFIG_H */
#include <stdio.h>
#include <stdarg.h>
#include <limits.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif /* HAVE_SYS_TYPES_H */
#ifdef HAVE_SYS_UIO_H
#include <sys/uio.h>
#endif /* HAVE_SYS_UIO_H */
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif /* HAVE_STDINT_H */
#ifdef HAVE_STDDEF_H
#include <stddef.h>
#endif /* HAVE_STDDEF_H */
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#include <assert.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif /* HAVE_STDLIB_H */
#ifdef HAVE_STRING_H
#include <string.h>
#endif /* HAVE_STRING_H */
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif /* HAVE_STRINGS_H */
#ifndef S_SPLINT_S
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif /* HAVE_UNISTD_H */
#endif /* S_SPLINT_S */
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif /*HAVE_ERRNO_H*/
#ifdef HAVE_TIME_H
#include <time.h>
#endif /* HAVE_TIME_H */
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif /* HAVE_SYS_TIME_H */
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif /* HAVE_SYS_STAT_H */
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif /* HAVE_FCNTL_H */
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif /* HAVE_SYS_SOCKET_H */
#ifndef S_SPLINT_S
#ifdef HAVE_SYSLOG_H
#include <syslog.h>
#endif /* HAVE_SYSLOG_H */
#endif /* S_SPLINT_S */
#if defined HAVE_CLOCK_GETTIME && defined _POSIX_MONOTONIC_CLOCK && _POSIX_MONOTONIC_CLOCK >= 0
#define HAVE_MONOTONIC_CLOCK 1
#endif /* have monotonic clock */
#ifdef HAVE_EPOLL_CREATE1
#define HAVE_EPOLL 1
#endif /* HAVE_EPOLL_CREATE */
#if defined(__UCLIBC__)
#define DISABLE_POSIX_THREAD_PROCESS_SHARED 1
#endif
/* The pshared semaphore madness:
* To have a usable pshared semaphore we need the timed_wait api
* and pshared functionality.
*
* The order of choice is:
* 1) real posix sem -> HAVE_POSIX_PSHARED_SEMAPHORE
* 2) sysv sems (if we have semtimedop) -> HAVE_SYSV_PSHARED_SEMAPHORE
* 3) faked sems using pthread_cond_timedwait -> HAVE_RPL_PSHARED_SEMAPHORE
* 4) ENOTSUP
*/
#undef HAVE_POSIX_PSHARED_SEMAPHORE
#undef HAVE_SYSV_PSHARED_SEMAPHORE
#undef HAVE_RPL_PSHARED_SEMAPHORE
#if defined(DISABLE_POSIX_THREAD_PROCESS_SHARED)
#undef HAVE_PTHREAD_SHARED_SPIN_LOCK
#endif /* DISABLE_POSIX_THREAD_PROCESS_SHARED */
#if !defined(DISABLE_POSIX_THREAD_PROCESS_SHARED) && \
_POSIX_THREAD_PROCESS_SHARED > 0
#if defined(HAVE_PTHREAD_SPIN_LOCK)
#define HAVE_PTHREAD_SHARED_SPIN_LOCK 1
#endif /* HAVE_PTHREAD_SPIN_LOCK */
#if defined(HAVE_SEM_TIMEDWAIT)
#define HAVE_POSIX_PSHARED_SEMAPHORE 1
#else
#if defined(HAVE_PTHREAD_CONDATTR_SETPSHARED) && \
defined(HAVE_PTHREAD_MUTEXATTR_SETPSHARED)
#define HAVE_RPL_PSHARED_SEMAPHORE 1
#endif
#endif /* HAVE_SEM_TIMEDWAIT */
#endif /* posix pshared */
#ifdef HAVE_SEMTIMEDOP
#define HAVE_SYSV_PSHARED_SEMAPHORE 1
#endif /* HAVE_SEMTIMEDOP */
#if !defined(HAVE_SYSV_PSHARED_SEMAPHORE) && \
!defined(HAVE_POSIX_PSHARED_SEMAPHORE) && \
!defined(HAVE_RPL_PSHARED_SEMAPHORE)
#define DISABLE_IPC_SHM 1
#endif /* HAVE PSHARED SEMAPHORE */
#ifndef HAVE_STRCHRNUL
char *strchrnul (const char *s, int c_in);
#endif
#ifndef HAVE_STRLCPY
size_t strlcpy(char *dest, const char *src, size_t maxlen);
#endif
#ifndef HAVE_STRLCAT
size_t strlcat(char *dest, const char *src, size_t maxlen);
#endif
#ifndef PATH_MAX
#define PATH_MAX 4096
#endif
#ifndef NAME_MAX
#define NAME_MAX 255
#endif
#ifndef MSG_NOSIGNAL
#define MSG_NOSIGNAL 0
#endif
#endif /* QB_OS_BASE_H_DEFINED */
|