Blame libarchive/archive_platform.h

Packit Service 1d0348
/*-
Packit Service 1d0348
 * Copyright (c) 2003-2007 Tim Kientzle
Packit Service 1d0348
 * All rights reserved.
Packit Service 1d0348
 *
Packit Service 1d0348
 * Redistribution and use in source and binary forms, with or without
Packit Service 1d0348
 * modification, are permitted provided that the following conditions
Packit Service 1d0348
 * are met:
Packit Service 1d0348
 * 1. Redistributions of source code must retain the above copyright
Packit Service 1d0348
 *    notice, this list of conditions and the following disclaimer.
Packit Service 1d0348
 * 2. Redistributions in binary form must reproduce the above copyright
Packit Service 1d0348
 *    notice, this list of conditions and the following disclaimer in the
Packit Service 1d0348
 *    documentation and/or other materials provided with the distribution.
Packit Service 1d0348
 *
Packit Service 1d0348
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
Packit Service 1d0348
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
Packit Service 1d0348
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
Packit Service 1d0348
 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
Packit Service 1d0348
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
Packit Service 1d0348
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
Packit Service 1d0348
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
Packit Service 1d0348
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Packit Service 1d0348
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
Packit Service 1d0348
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit Service 1d0348
 *
Packit Service 1d0348
 * $FreeBSD: head/lib/libarchive/archive_platform.h 201090 2009-12-28 02:22:04Z kientzle $
Packit Service 1d0348
 */
Packit Service 1d0348
Packit Service 1d0348
/* !!ONLY FOR USE INTERNALLY TO LIBARCHIVE!! */
Packit Service 1d0348
Packit Service 1d0348
/*
Packit Service 1d0348
 * This header is the first thing included in any of the libarchive
Packit Service 1d0348
 * source files.  As far as possible, platform-specific issues should
Packit Service 1d0348
 * be dealt with here and not within individual source files.  I'm
Packit Service 1d0348
 * actively trying to minimize #if blocks within the main source,
Packit Service 1d0348
 * since they obfuscate the code.
Packit Service 1d0348
 */
Packit Service 1d0348
Packit Service 1d0348
#ifndef ARCHIVE_PLATFORM_H_INCLUDED
Packit Service 1d0348
#define	ARCHIVE_PLATFORM_H_INCLUDED
Packit Service 1d0348
Packit Service 1d0348
/* archive.h and archive_entry.h require this. */
Packit Service 1d0348
#define	__LIBARCHIVE_BUILD 1
Packit Service 1d0348
Packit Service 1d0348
#if defined(PLATFORM_CONFIG_H)
Packit Service 1d0348
/* Use hand-built config.h in environments that need it. */
Packit Service 1d0348
#include PLATFORM_CONFIG_H
Packit Service 1d0348
#elif defined(HAVE_CONFIG_H)
Packit Service 1d0348
/* Most POSIX platforms use the 'configure' script to build config.h */
Packit Service 1d0348
#include "config.h"
Packit Service 1d0348
#else
Packit Service 1d0348
/* Warn if the library hasn't been (automatically or manually) configured. */
Packit Service 1d0348
#error Oops: No config.h and no pre-built configuration in archive_platform.h.
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
/* On macOS check for some symbols based on the deployment target version.  */
Packit Service 1d0348
#if defined(__APPLE__)
Packit Service 1d0348
# undef HAVE_FUTIMENS
Packit Service 1d0348
# undef HAVE_UTIMENSAT
Packit Service 1d0348
# include <AvailabilityMacros.h>
Packit Service 1d0348
# if MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
Packit Service 1d0348
#  define HAVE_FUTIMENS 1
Packit Service 1d0348
#  define HAVE_UTIMENSAT 1
Packit Service 1d0348
# endif
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
/* It should be possible to get rid of this by extending the feature-test
Packit Service 1d0348
 * macros to cover Windows API functions, probably along with non-trivial
Packit Service 1d0348
 * refactoring of code to find structures that sit more cleanly on top of
Packit Service 1d0348
 * either Windows or Posix APIs. */
Packit Service 1d0348
#if (defined(__WIN32__) || defined(_WIN32) || defined(__WIN32)) && !defined(__CYGWIN__)
Packit Service 1d0348
#include "archive_windows.h"
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
/*
Packit Service 1d0348
 * The config files define a lot of feature macros.  The following
Packit Service 1d0348
 * uses those macros to select/define replacements and include key
Packit Service 1d0348
 * headers as required.
Packit Service 1d0348
 */
Packit Service 1d0348
Packit Service 1d0348
/* Get a real definition for __FBSDID or __RCSID if we can */
Packit Service 1d0348
#if HAVE_SYS_CDEFS_H
Packit Service 1d0348
#include <sys/cdefs.h>
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
/* If not, define them so as to avoid dangling semicolons. */
Packit Service 1d0348
#ifndef __FBSDID
Packit Service 1d0348
#define	__FBSDID(a)     struct _undefined_hack
Packit Service 1d0348
#endif
Packit Service 1d0348
#ifndef __RCSID
Packit Service 1d0348
#define	__RCSID(a)     struct _undefined_hack
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
/* Try to get standard C99-style integer type definitions. */
Packit Service 1d0348
#if HAVE_INTTYPES_H
Packit Service 1d0348
#include <inttypes.h>
Packit Service 1d0348
#endif
Packit Service 1d0348
#if HAVE_STDINT_H
Packit Service 1d0348
#include <stdint.h>
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
/* Borland warns about its own constants!  */
Packit Service 1d0348
#if defined(__BORLANDC__)
Packit Service 1d0348
# if HAVE_DECL_UINT64_MAX
Packit Service 1d0348
#  undef	UINT64_MAX
Packit Service 1d0348
#  undef	HAVE_DECL_UINT64_MAX
Packit Service 1d0348
# endif
Packit Service 1d0348
# if HAVE_DECL_UINT64_MIN
Packit Service 1d0348
#  undef	UINT64_MIN
Packit Service 1d0348
#  undef	HAVE_DECL_UINT64_MIN
Packit Service 1d0348
# endif
Packit Service 1d0348
# if HAVE_DECL_INT64_MAX
Packit Service 1d0348
#  undef	INT64_MAX
Packit Service 1d0348
#  undef	HAVE_DECL_INT64_MAX
Packit Service 1d0348
# endif
Packit Service 1d0348
# if HAVE_DECL_INT64_MIN
Packit Service 1d0348
#  undef	INT64_MIN
Packit Service 1d0348
#  undef	HAVE_DECL_INT64_MIN
Packit Service 1d0348
# endif
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
/* Some platforms lack the standard *_MAX definitions. */
Packit Service 1d0348
#if !HAVE_DECL_SIZE_MAX
Packit Service 1d0348
#define	SIZE_MAX (~(size_t)0)
Packit Service 1d0348
#endif
Packit Service 1d0348
#if !HAVE_DECL_SSIZE_MAX
Packit Service 1d0348
#define	SSIZE_MAX ((ssize_t)(SIZE_MAX >> 1))
Packit Service 1d0348
#endif
Packit Service 1d0348
#if !HAVE_DECL_UINT32_MAX
Packit Service 1d0348
#define	UINT32_MAX (~(uint32_t)0)
Packit Service 1d0348
#endif
Packit Service 1d0348
#if !HAVE_DECL_INT32_MAX
Packit Service 1d0348
#define	INT32_MAX ((int32_t)(UINT32_MAX >> 1))
Packit Service 1d0348
#endif
Packit Service 1d0348
#if !HAVE_DECL_INT32_MIN
Packit Service 1d0348
#define	INT32_MIN ((int32_t)(~INT32_MAX))
Packit Service 1d0348
#endif
Packit Service 1d0348
#if !HAVE_DECL_UINT64_MAX
Packit Service 1d0348
#define	UINT64_MAX (~(uint64_t)0)
Packit Service 1d0348
#endif
Packit Service 1d0348
#if !HAVE_DECL_INT64_MAX
Packit Service 1d0348
#define	INT64_MAX ((int64_t)(UINT64_MAX >> 1))
Packit Service 1d0348
#endif
Packit Service 1d0348
#if !HAVE_DECL_INT64_MIN
Packit Service 1d0348
#define	INT64_MIN ((int64_t)(~INT64_MAX))
Packit Service 1d0348
#endif
Packit Service 1d0348
#if !HAVE_DECL_UINTMAX_MAX
Packit Service 1d0348
#define	UINTMAX_MAX (~(uintmax_t)0)
Packit Service 1d0348
#endif
Packit Service 1d0348
#if !HAVE_DECL_INTMAX_MAX
Packit Service 1d0348
#define	INTMAX_MAX ((intmax_t)(UINTMAX_MAX >> 1))
Packit Service 1d0348
#endif
Packit Service 1d0348
#if !HAVE_DECL_INTMAX_MIN
Packit Service 1d0348
#define	INTMAX_MIN ((intmax_t)(~INTMAX_MAX))
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
/*
Packit Service 1d0348
 * If we can't restore metadata using a file descriptor, then
Packit Service 1d0348
 * for compatibility's sake, close files before trying to restore metadata.
Packit Service 1d0348
 */
Packit Service 1d0348
#if defined(HAVE_FCHMOD) || defined(HAVE_FUTIMES) || defined(HAVE_ACL_SET_FD) || defined(HAVE_ACL_SET_FD_NP) || defined(HAVE_FCHOWN)
Packit Service 1d0348
#define	CAN_RESTORE_METADATA_FD
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
/*
Packit Service 1d0348
 * glibc 2.24 deprecates readdir_r
Packit Service 1d0348
 */
Packit Service 1d0348
#if defined(HAVE_READDIR_R) && (!defined(__GLIBC__) || !defined(__GLIBC_MINOR__) || __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 24))
Packit Service 1d0348
#define	USE_READDIR_R	1
Packit Service 1d0348
#else
Packit Service 1d0348
#undef	USE_READDIR_R
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
/* Set up defaults for internal error codes. */
Packit Service 1d0348
#ifndef ARCHIVE_ERRNO_FILE_FORMAT
Packit Service 1d0348
#if HAVE_EFTYPE
Packit Service 1d0348
#define	ARCHIVE_ERRNO_FILE_FORMAT EFTYPE
Packit Service 1d0348
#else
Packit Service 1d0348
#if HAVE_EILSEQ
Packit Service 1d0348
#define	ARCHIVE_ERRNO_FILE_FORMAT EILSEQ
Packit Service 1d0348
#else
Packit Service 1d0348
#define	ARCHIVE_ERRNO_FILE_FORMAT EINVAL
Packit Service 1d0348
#endif
Packit Service 1d0348
#endif
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
#ifndef ARCHIVE_ERRNO_PROGRAMMER
Packit Service 1d0348
#define	ARCHIVE_ERRNO_PROGRAMMER EINVAL
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
#ifndef ARCHIVE_ERRNO_MISC
Packit Service 1d0348
#define	ARCHIVE_ERRNO_MISC (-1)
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
#if defined(__GNUC__) && (__GNUC__ >= 7)
Packit Service 1d0348
#define	__LA_FALLTHROUGH	__attribute__((fallthrough))
Packit Service 1d0348
#else
Packit Service 1d0348
#define	__LA_FALLTHROUGH
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
#endif /* !ARCHIVE_PLATFORM_H_INCLUDED */