Commit 44ada9e4 authored by Nils Goroll's avatar Nils Goroll

common include for interpose/non-interpose, some solaris specifics for interpose code

parent f13da48d
......@@ -47,6 +47,7 @@ sys/varargs.h
stdarg.h
dirent.h
sys/mkdev.h
sys/stat_impl.h
)
## functions we currently require.
......@@ -100,6 +101,7 @@ mkdirat
attropen
fgetxattr
fsetxattr
_xstat
)
......
......@@ -27,109 +27,16 @@
*
*/
/*
* structure taken from OpenSolaris fcntl.h
*/
#ifndef _LONGPATH_H
#define _LONGPATH_H
#include "longpath_config.h"
#include "longpath_common.h"
/*
* XXX HACK: This prevents the solaris includes to win the redefine_extname race
* -- is there a better way ?
* large file compilation environment setup
*
* structure taken from OpenSolaris fcntl.h
*/
#if defined(_LONGPATH_REDEFINE_PRE_H) && defined(__PRAGMA_REDEFINE_EXTNAME)
#define __PRAGMA_REDEFINE_EXTNAME_SAVE
#undef __PRAGMA_REDEFINE_EXTNAME
#endif
// XXX conditional includes incomplete
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
// mktemp
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <utime.h> // utimbuf
// stdlib stuff
#include <dirent.h>
#ifdef __PRAGMA_REDEFINE_EXTNAME_SAVE
#undef __PRAGMA_REDEFINE_EXTNAME_SAVE
#define __PRAGMA_REDEFINE_EXTNAME
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifdef DEBUG_LF
#ifdef _FILE_OFFSET_BITS
# if (_FILE_OFFSET_BITS == 64)
# warning _FILE_OFFSET_BITS == 64
# elif (_FILE_OFFSET_BITS == 32)
# warning _FILE_OFFSET_BITS == 32
# else
# warning _FILE_OFFSET_BITS other value
# endif
#else
#warning _FILE_OFFSET_BITS UN_defined
#endif
#ifdef _LARGEFILE64_SOURCE
#warning _LARGEFILE64_SOURCE defined
#else
#warning _LARGEFILE64_SOURCE UN_defined
#endif
#ifdef _LARGEFILE_SOURCE
#warning _LARGEFILE_SOURCE defined
#else
#warning _LARGEFILE_SOURCE UN_defined
#endif
#ifdef _LP64
#warning _LP64 defined
#else
#warning _LP64 UN_defined
#endif
#endif /* DEBUG_LF */
/* from solaris sys/feature_tests.h */
#if defined(_LP64)
#ifndef _FILE_OFFSET_BITS
#define _FILE_OFFSET_BITS 64
#endif
#if _FILE_OFFSET_BITS - 0 != 64
#error "invalid _FILE_OFFSET_BITS value specified"
#endif
#else /* _LP64 */
#ifndef _FILE_OFFSET_BITS
#define _FILE_OFFSET_BITS 32
#endif
#if _FILE_OFFSET_BITS - 0 != 32 && _FILE_OFFSET_BITS - 0 != 64
#error "invalid _FILE_OFFSET_BITS value specified"
#endif
#endif /* _LP64 */
/* large file compilation environment setup */
/* func -> func64 */
#if !defined(_LP64) && _FILE_OFFSET_BITS == 64
......@@ -225,6 +132,10 @@ extern "C" {
# endif /* __PRAGMA_REDEFINE_EXTNAME */
#endif /* _LP64 && _LARGEFILE64_SOURCE */
#ifdef __cplusplus
extern "C" {
#endif
#if defined(__STDC__)
# define FUNCTION(type, name, ...) extern type name ## l (__VA_ARGS__);
# if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
......
/*-
* Copyright (c) 2013 UPLEX Nils Goroll Systemoptimierung
* All rights reserved
*
* Author: Nils Goroll <nils.goroll@uplex.de>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#ifndef _LONGPATH_COMMON_H
#define _LONGPATH_COMMON_H
#include "longpath_config.h"
/*
* XXX HACK: This prevents the solaris includes to win the redefine_extname race
* -- is there a better way ?
*/
#if defined(_LONGPATH_REDEFINE_PRE_H) && defined(__PRAGMA_REDEFINE_EXTNAME)
#define __PRAGMA_REDEFINE_EXTNAME_SAVE
#undef __PRAGMA_REDEFINE_EXTNAME
#endif
// XXX conditional includes incomplete
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
// mktemp
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <utime.h> // utimbuf
// stdlib stuff
#include <dirent.h>
#ifdef __PRAGMA_REDEFINE_EXTNAME_SAVE
#undef __PRAGMA_REDEFINE_EXTNAME_SAVE
#define __PRAGMA_REDEFINE_EXTNAME
#endif
#ifdef DEBUG_LF
#ifdef _FILE_OFFSET_BITS
# if (_FILE_OFFSET_BITS == 64)
# warning _FILE_OFFSET_BITS == 64
# elif (_FILE_OFFSET_BITS == 32)
# warning _FILE_OFFSET_BITS == 32
# else
# warning _FILE_OFFSET_BITS other value
# endif
#else
#warning _FILE_OFFSET_BITS UN_defined
#endif
#ifdef _LARGEFILE64_SOURCE
#warning _LARGEFILE64_SOURCE defined
#else
#warning _LARGEFILE64_SOURCE UN_defined
#endif
#ifdef _LARGEFILE_SOURCE
#warning _LARGEFILE_SOURCE defined
#else
#warning _LARGEFILE_SOURCE UN_defined
#endif
#ifdef _LP64
#warning _LP64 defined
#else
#warning _LP64 UN_defined
#endif
#endif /* DEBUG_LF */
/* from solaris sys/feature_tests.h */
#if defined(_LP64)
#ifndef _FILE_OFFSET_BITS
#define _FILE_OFFSET_BITS 64
#endif
#if _FILE_OFFSET_BITS - 0 != 64
#error "invalid _FILE_OFFSET_BITS value specified"
#endif
#else /* _LP64 */
#ifndef _FILE_OFFSET_BITS
#define _FILE_OFFSET_BITS 32
#endif
#if _FILE_OFFSET_BITS - 0 != 32 && _FILE_OFFSET_BITS - 0 != 64
#error "invalid _FILE_OFFSET_BITS value specified"
#endif
#endif /* _LP64 */
#endif /* _LONGPATH_COMMON_H */
......@@ -71,45 +71,60 @@
#define assert(EX) ((void)0)
#endif
/*
* work around solaris implementing stat() and lstat() in sys/stat_impl.h
* on the basis of _xstat()
*/
#ifdef INTERPOSE
# ifdef HAVE__XSTAT
# ifdef HAVE_SYS_STAT_IMPL_H
# define _SYS_STAT_IMPL_H
# else
# error This machine probably needs different _xstat handling
# endif
# endif
#endif
// string functions
#if defined(HAVE_STRING_H)
#include <string.h>
# include <string.h>
#endif
#ifdef HAVE_LIMITS_H
#include <limits.h>
# include <limits.h>
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
# include <errno.h>
#endif
#ifdef HAVE_STDIO_H
#include <stdio.h>
# include <stdio.h>
#endif
// varargs for open
#if defined(HAVE_SYS_VARARGS_H)
#include <sys/varargs.h>
# include <sys/varargs.h>
#elif defined(HAVE_STDARG_H)
#include <stdarg.h>
# include <stdarg.h>
#endif
// opendir
#ifdef HAVE_DIRENT_H
#include <dirent.h>
# include <dirent.h>
#endif
// linux xattr
#ifdef HAVE_FGETXATTR
#include <sys/xattr.h>
# include <sys/xattr.h>
#endif
#ifdef INTERPOSE
# include <longpath/longpath_common.h>
# define real(x) real_ ## x
# define real64(x) real_ ## x ## 64
# define our(x) x
# define our64(x) x ## 64
#else /* ! INTERPOSE */
#include <longpath/longpath.h>
# include <longpath/longpath.h>
# define real(x) x
# if defined(_LP64)
# define real64(x) x
......@@ -831,11 +846,7 @@ _mkxtempl(char *template, int slen, int flags, enum temp_kind kind) {
int ifd, fd;
char *rest;
char *save, *r, *spos;
#if defined(_LP64)
struct stat tstat;
#else
struct stat64 tstat;
#endif
if (slen < 0 || template == NULL || *template == '\0') {
errno = EINVAL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment