Path: blob/main/contrib/libarchive/tar/bsdtar_platform.h
39483 views
/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2003-2007 Tim Kientzle4* All rights reserved.5*/67/*8* This header is the first thing included in any of the bsdtar9* source files. As far as possible, platform-specific issues should10* be dealt with here and not within individual source files.11*/1213#ifndef BSDTAR_PLATFORM_H_INCLUDED14#define BSDTAR_PLATFORM_H_INCLUDED1516#if defined(PLATFORM_CONFIG_H)17/* Use hand-built config.h in environments that need it. */18#include PLATFORM_CONFIG_H19#else20/* Not having a config.h of some sort is a serious problem. */21#include "config.h"22#endif2324#if defined(_WIN32) && !defined(__CYGWIN__)25#include "bsdtar_windows.h"26#endif2728#ifdef HAVE_LIBARCHIVE29/* If we're using the platform libarchive, include system headers. */30#include <archive.h>31#include <archive_entry.h>32#else33/* Otherwise, include user headers. */34#include "archive.h"35#include "archive_entry.h"36#endif3738#ifdef HAVE_LIBACL39#include <acl/libacl.h>40#endif4142/*43* Include "dirent.h" (or its equivalent on several different platforms).44*45* This is slightly modified from the GNU autoconf recipe.46* In particular, FreeBSD includes d_namlen in its dirent structure,47* so my configure script includes an explicit test for the d_namlen48* field.49*/50#if HAVE_DIRENT_H51# include <dirent.h>52# if HAVE_DIRENT_D_NAMLEN53# define DIRENT_NAMLEN(dirent) (dirent)->d_namlen54# else55# define DIRENT_NAMLEN(dirent) strlen((dirent)->d_name)56# endif57#else58# define dirent direct59# define DIRENT_NAMLEN(dirent) (dirent)->d_namlen60# if HAVE_SYS_NDIR_H61# include <sys/ndir.h>62# endif63# if HAVE_SYS_DIR_H64# include <sys/dir.h>65# endif66# if HAVE_NDIR_H67# include <ndir.h>68# endif69#endif7071#if HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC72#define ARCHIVE_STAT_CTIME_NANOS(st) (st)->st_ctimespec.tv_nsec73#define ARCHIVE_STAT_MTIME_NANOS(st) (st)->st_mtimespec.tv_nsec74#elif HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC75#define ARCHIVE_STAT_CTIME_NANOS(st) (st)->st_ctim.tv_nsec76#define ARCHIVE_STAT_MTIME_NANOS(st) (st)->st_mtim.tv_nsec77#elif HAVE_STRUCT_STAT_ST_MTIME_N78#define ARCHIVE_STAT_CTIME_NANOS(st) (st)->st_ctime_n79#define ARCHIVE_STAT_MTIME_NANOS(st) (st)->st_mtime_n80#elif HAVE_STRUCT_STAT_ST_UMTIME81#define ARCHIVE_STAT_CTIME_NANOS(st) (st)->st_uctime * 100082#define ARCHIVE_STAT_MTIME_NANOS(st) (st)->st_umtime * 100083#elif HAVE_STRUCT_STAT_ST_MTIME_USEC84#define ARCHIVE_STAT_CTIME_NANOS(st) (st)->st_ctime_usec * 100085#define ARCHIVE_STAT_MTIME_NANOS(st) (st)->st_mtime_usec * 100086#else87#define ARCHIVE_STAT_CTIME_NANOS(st) (0)88#define ARCHIVE_STAT_MTIME_NANOS(st) (0)89#endif9091/* How to mark functions that don't return. */92/* This facilitates use of some newer static code analysis tools. */93#undef __LA_NORETURN94#if defined(__GNUC__) && (__GNUC__ > 2 || \95(__GNUC__ == 2 && __GNUC_MINOR__ >= 5))96#define __LA_NORETURN __attribute__((__noreturn__))97#elif defined(_MSC_VER)98#define __LA_NORETURN __declspec(noreturn)99#else100#define __LA_NORETURN101#endif102103#endif /* !BSDTAR_PLATFORM_H_INCLUDED */104105106