Skip to content

Commit

Permalink
Fix compilation on Debian kFreeBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
ellert committed Dec 18, 2020
1 parent fbfc54c commit 70d2919
Show file tree
Hide file tree
Showing 36 changed files with 118 additions and 61 deletions.
6 changes: 3 additions & 3 deletions cmake/XRootDFindLibs.cmake
Expand Up @@ -54,7 +54,7 @@ if( ENABLE_KRB5 )
endif()

# mac fuse not supported
if( ENABLE_FUSE AND LINUX )
if( ENABLE_FUSE AND (LINUX OR KFREEBSD) )
find_package( fuse )
if( FUSE_FOUND )
add_definitions( -DHAVE_FUSE )
Expand Down Expand Up @@ -123,7 +123,7 @@ if( ENABLE_XRDEC )
endif()
endif()

if( ENABLE_PYTHON AND (LINUX OR Hurd OR MacOSX) )
if( ENABLE_PYTHON AND (LINUX OR KFREEBSD OR Hurd OR MacOSX) )
find_package( PythonInterp ${XRD_PYTHON_REQ_VERSION} )
find_package( PythonLibs ${XRD_PYTHON_REQ_VERSION} )
if( PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND )
Expand All @@ -134,7 +134,7 @@ if( ENABLE_PYTHON AND (LINUX OR Hurd OR MacOSX) )
endif()
endif()

if( ENABLE_VOMS AND (LINUX OR Hurd) )
if( ENABLE_VOMS AND (LINUX OR KFREEBSD OR Hurd) )
find_package( VOMS )
if( VOMS_FOUND )
set( BUILD_VOMS TRUE )
Expand Down
10 changes: 10 additions & 0 deletions cmake/XRootDOSDefs.cmake
Expand Up @@ -5,6 +5,7 @@
include( CheckCXXSourceRuns )

set( LINUX FALSE )
set( KFREEBSD FALSE )
set( Hurd FALSE )
set( MacOSX FALSE )
set( Solaris FALSE )
Expand Down Expand Up @@ -67,6 +68,15 @@ if( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" )
set( EXTRA_LIBS rt )
endif()

#-------------------------------------------------------------------------------
# GNU/kFreeBSD
#-------------------------------------------------------------------------------
if( ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD" )
set( KFREEBSD TRUE )
include( GNUInstallDirs )
set( EXTRA_LIBS rt )
endif()

#-------------------------------------------------------------------------------
# GNU/Hurd
#-------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/Xrd/XrdConfig.cc
Expand Up @@ -1152,7 +1152,7 @@ int XrdConfig::setFDL()

// The scheduler will have already set the thread limit. We just report it
//
#if ( defined(__linux__) || defined(__GNU__) ) && defined(RLIMIT_NPROC)
#if ( defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__)) ) && defined(RLIMIT_NPROC)

// Obtain the actual limit now (Scheduler construction sets this to rlim_max)
//
Expand Down
4 changes: 4 additions & 0 deletions src/Xrd/XrdLink.cc
Expand Up @@ -69,6 +69,10 @@
#include "Xrd/XrdTrace.hh"

#include "XrdSys/XrdSysError.hh"

#ifndef ETIME
#define ETIME ETIMEDOUT
#endif

/******************************************************************************/
/* G l o b a l s */
Expand Down
14 changes: 9 additions & 5 deletions src/Xrd/XrdLinkXeq.cc
Expand Up @@ -45,7 +45,7 @@

#ifdef HAVE_SENDFILE

#ifndef __APPLE__
#if defined(__solaris__) || defined(__linux__) || defined(__GNU__)
#include <sys/sendfile.h>
#endif

Expand Down Expand Up @@ -608,12 +608,12 @@ int XrdLinkXeq::Send(const struct iovec *iov, int iocnt, int bytes)

int XrdLinkXeq::Send(const sfVec *sfP, int sfN)
{
#if !defined(HAVE_SENDFILE) || defined(__APPLE__)
#if !defined(HAVE_SENDFILE)

return -1;

#else
#elif defined(__solaris__)

#ifdef __solaris__
sendfilevec_t vecSF[XrdOucSFVec::sfMax], *vecSFP = vecSF;
size_t xframt, totamt, bytes = 0;
ssize_t retc;
Expand Down Expand Up @@ -729,7 +729,11 @@ do{retc = sendfilev(LinkInfo.FD, vecSFP, sfN, &xframt);
AtomicAdd(BytesOut, xfrbytes);
wrMutex.UnLock();
return xfrbytes;
#endif

#else

return -1;

#endif
}

Expand Down
2 changes: 1 addition & 1 deletion src/Xrd/XrdScheduler.cc
Expand Up @@ -107,7 +107,7 @@ XrdScheduler::XrdScheduler(XrdSysError *eP, XrdOucTrace *tP,

// Make sure we are using the maximum number of threads allowed (Linux only)
//
#if ( defined(__linux__) || defined(__GNU__) ) && defined(RLIMIT_NPROC)
#if ( defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__)) ) && defined(RLIMIT_NPROC)

struct rlimit rlim;

Expand Down
6 changes: 3 additions & 3 deletions src/XrdApps/Xrdadler32.cc
Expand Up @@ -43,7 +43,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#if defined(__linux__) || defined(__GNU__)
#if defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
#include <sys/xattr.h>
#endif
#include <zlib.h>
Expand Down Expand Up @@ -71,7 +71,7 @@ void fSetXattrAdler32(const char *path, int fd, const char* attr, char *value)

// Remove any old attribute at this point
//
#if defined(__linux__) || defined(__GNU__)
#if defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
fremovexattr(fd, attr);
#elif defined(__solaris__)
int attrfd;
Expand All @@ -90,7 +90,7 @@ int fGetXattrAdler32(int fd, const char* attr, char *value)
if (fstat(fd, &st)) return 0;
sprintf(mtime, "%ld", st.st_mtime);

#if defined(__linux__) || defined(__GNU__)
#if defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
rc = fgetxattr(fd, attr, attr_val, 25);
#elif defined(__solaris__)
int attrfd;
Expand Down
2 changes: 1 addition & 1 deletion src/XrdCl/XrdClSocket.cc
Expand Up @@ -463,7 +463,7 @@ namespace XrdCl
//--------------------------------------------------------------------------
// We use send with MSG_NOSIGNAL to avoid SIGPIPEs on Linux
//--------------------------------------------------------------------------
#if defined(__linux__) || defined(__GNU__)
#if defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
int status = ::send( pSocket, buffer, size, MSG_NOSIGNAL );
#else
int status = ::write( pSocket, buffer, size );
Expand Down
2 changes: 1 addition & 1 deletion src/XrdDig/XrdDigFS.cc
Expand Up @@ -239,7 +239,7 @@ const char *XrdDigDirectory::nextEntry()

// Read the next directory entry
//
#if defined(__linux__) || defined(__GNU__)
#if defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
do{errno = 0;
rp = readdir(dh);
if (!rp)
Expand Down
6 changes: 4 additions & 2 deletions src/XrdFfs/XrdFfsXrootdfs.cc
Expand Up @@ -55,10 +55,10 @@
#include <libgen.h>
#include <syslog.h>
#include <signal.h>
#if defined(__linux__)
#include <sys/prctl.h>
#if !defined(__solaris__)
#include <sys/xattr.h>
#endif
#include <sys/xattr.h>

#include "XrdFfs/XrdFfsPosix.hh"
#include "XrdFfs/XrdFfsMisc.hh"
Expand Down Expand Up @@ -120,7 +120,9 @@ static void* xrootdfs_init(struct fuse_conn_info *conn)
syslog( LOG_ERR, "ERROR: Unable to set gid to %d", pw.pw_gid );
if( setuid((uid_t)pw.pw_uid) != 0 )
syslog( LOG_ERR, "ERROR: Unable to set uid to %d", pw.pw_uid );
#if defined(__linux__)
prctl(PR_SET_DUMPABLE, 1); // enable core dump after setuid/setgid
#endif
}
free(pwbuf);

Expand Down
4 changes: 4 additions & 0 deletions src/XrdOfs/XrdOfsCPFile.cc
Expand Up @@ -48,6 +48,10 @@
#include "XrdSys/XrdSysPthread.hh"
#include "XrdSys/XrdSysXAttr.hh"

#ifndef ENODATA
#define ENODATA ENOATTR
#endif

/******************************************************************************/
/* E x t e r n a l L i n k a g e s */
/******************************************************************************/
Expand Down
4 changes: 4 additions & 0 deletions src/XrdOfs/XrdOfsChkPnt.cc
Expand Up @@ -44,6 +44,10 @@
#include "XrdOuc/XrdOucString.hh"
#include "XrdSys/XrdSysPthread.hh"

#ifndef ENODATA
#define ENODATA ENOATTR
#endif

/******************************************************************************/
/* L o c a l C l a s s e s */
/******************************************************************************/
Expand Down
10 changes: 5 additions & 5 deletions src/XrdOss/XrdOssApi.cc
Expand Up @@ -835,7 +835,7 @@ ssize_t XrdOssFile::Read(off_t offset, size_t blen)

if (fd < 0) return (ssize_t)-XRDOSS_E8004;

#if defined(__linux__)
#if defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
posix_fadvise(fd, offset, blen, POSIX_FADV_WILLNEED);
#endif

Expand Down Expand Up @@ -901,7 +901,7 @@ ssize_t XrdOssFile::ReadV(XrdOucIOVec *readV, int n)

// For platforms that support fadvise, pre-advise what we will be reading
//
#if defined(__linux__) && defined(HAVE_ATOMICS)
#if (defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))) && defined(HAVE_ATOMICS)
EPNAME("ReadV");
long long begOff, endOff, begLst = -1, endLst = -1;
int nPR = n;
Expand Down Expand Up @@ -935,7 +935,7 @@ ssize_t XrdOssFile::ReadV(XrdOucIOVec *readV, int n)
if (rdsz < 0 || rdsz != readV[i].size)
{totBytes = (rdsz < 0 ? -errno : -ESPIPE); break;}
totBytes += rdsz;
#if defined(__linux__) && defined(HAVE_ATOMICS)
#if (defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))) && defined(HAVE_ATOMICS)
if (nPR < n && readV[nPR].size > 0)
{begOff = XrdOssSS->prPMask & readV[nPR].offset;
endOff = XrdOssSS->prPBits | (readV[nPR].offset+readV[nPR].size);
Expand All @@ -953,7 +953,7 @@ ssize_t XrdOssFile::ReadV(XrdOucIOVec *readV, int n)

// All done, return bytes read.
//
#if defined(__linux__) && defined(HAVE_ATOMICS)
#if (defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))) && defined(HAVE_ATOMICS)
if (XrdOssSS->prDepth) AtomicDec((XrdOssSS->prActive));
#endif
return totBytes;
Expand Down Expand Up @@ -1083,7 +1083,7 @@ void XrdOssFile::Flush()
{
// This actually only works in Linux so we punt otherwise
//
#if defined(__linux__)
#if defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
if (fd>= 0)
{fdatasync(fd);
posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);
Expand Down
2 changes: 1 addition & 1 deletion src/XrdOss/XrdOssCache.hh
Expand Up @@ -48,7 +48,7 @@
#define FS_BLKSZ f_frsize
#define FS_FFREE f_favail
#endif
#if defined(__linux__) || defined(__GNU__)
#if defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
#include <sys/vfs.h>
#define FS_Stat(a,b) statfs(a,b)
#define STATFS_t struct statfs
Expand Down
2 changes: 1 addition & 1 deletion src/XrdPfc/XrdPfcFile.cc
Expand Up @@ -1248,7 +1248,7 @@ void File::ProcessBlockResponse(BlockResponseHandler* brh, int res)
TRACEF(Error, tpfx << "block " << b << ", idx=" << b->m_offset/BufferSize() << ", off=" << b->m_offset << " error=" << res);
} else {
TRACEF(Error, tpfx << "block " << b << ", idx=" << b->m_offset/BufferSize() << ", off=" << b->m_offset << " incomplete, got " << res << " expected " << b->get_size());
#if defined(__APPLE__) || defined(__GNU__)
#if defined(__APPLE__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
res = -EIO;
#else
res = -EREMOTEIO;
Expand Down
10 changes: 5 additions & 5 deletions src/XrdPosix/XrdPosix.cc
Expand Up @@ -213,7 +213,7 @@ int XrdPosix_Fdatasync(int fildes)
/* X r d P o s i x _ F g e t x a t t r */
/******************************************************************************/

#if defined(__linux__) || defined(__GNU__)
#if defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
extern "C"
{
long long XrdPosix_Fgetxattr (int fd, const char *name, void *value,
Expand Down Expand Up @@ -310,7 +310,7 @@ size_t XrdPosix_Fread(void *ptr, size_t size, size_t nitems, FILE *stream)
//
if (bytes > 0 && size) rc = bytes/size;
#ifndef SUNX86
#if defined(__linux__) || defined(__GNU__)
#if defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
else if (bytes < 0) stream->_flags |= _IO_ERR_SEEN;
else stream->_flags |= _IO_EOF_SEEN;
#elif defined(__APPLE__) || defined(__FreeBSD__)
Expand Down Expand Up @@ -481,7 +481,7 @@ size_t XrdPosix_Fwrite(const void *ptr, size_t size, size_t nitems, FILE *stream
//
if (bytes > 0 && size) rc = bytes/size;
#ifndef SUNX86
#if defined(__linux__) || defined(__GNU__)
#if defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
else stream->_flags |= _IO_ERR_SEEN;
#elif defined(__APPLE__) || defined(__FreeBSD__)
else stream->_flags |= __SERR;
Expand All @@ -498,7 +498,7 @@ size_t XrdPosix_Fwrite(const void *ptr, size_t size, size_t nitems, FILE *stream
/* X r d P o s i x _ G e t x a t t r */
/******************************************************************************/

#if defined(__linux__) || defined(__GNU__)
#if defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
extern "C"
{
long long XrdPosix_Getxattr (const char *path, const char *name, void *value,
Expand All @@ -518,7 +518,7 @@ long long XrdPosix_Getxattr (const char *path, const char *name, void *value,
/* X r d P o s i x _ L g e t x a t t r */
/******************************************************************************/

#if defined(__linux__) || defined(__GNU__)
#if defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
extern "C"
{
long long XrdPosix_Lgetxattr (const char *path, const char *name, void *value,
Expand Down
2 changes: 1 addition & 1 deletion src/XrdPosix/XrdPosixDir.cc
Expand Up @@ -73,7 +73,7 @@ dirent64 *XrdPosixDir::nextEntry(dirent64 *dp)
#ifndef __solaris__
dp->d_type = DT_DIR;
#endif
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__GNU__)
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
dp->d_fileno = nxtEnt;
dp->d_namlen = d_nlen;
#else
Expand Down
4 changes: 2 additions & 2 deletions src/XrdPosix/XrdPosixExtern.hh
Expand Up @@ -100,7 +100,7 @@ extern int XrdPosix_Fdatasync(int fildes);

extern int XrdPosix_Fflush(FILE *stream);

#if defined(__linux__) || defined(__GNU__)
#if defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
extern long long XrdPosix_Fgetxattr (int fd, const char *name,
void *value, unsigned long long size);
#endif
Expand Down Expand Up @@ -129,7 +129,7 @@ extern int XrdPosix_Ftruncate(int fildes, long long offset);

extern size_t XrdPosix_Fwrite(const void *ptr, size_t size, size_t nitems, FILE *stream);

#if defined(__linux__) || defined(__GNU__)
#if defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
extern long long XrdPosix_Getxattr (const char *path, const char *name,
void *value, unsigned long long size);

Expand Down
4 changes: 4 additions & 0 deletions src/XrdPosix/XrdPosixMap.cc
Expand Up @@ -40,6 +40,10 @@
#define EAUTH EBADE
#endif

#ifndef ENOSR
#define ENOSR ENOSPC
#endif

/******************************************************************************/
/* S t a t i c M e m b e r s */
/******************************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion src/XrdPosix/XrdPosixOsDep.hh
Expand Up @@ -72,7 +72,7 @@
#define ELIBACC EFTYPE
#endif

#ifdef __GNU__
#if defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
#define ELIBACC EFTYPE
#endif

Expand Down
6 changes: 3 additions & 3 deletions src/XrdPosix/XrdPosixPreload.cc
Expand Up @@ -351,7 +351,7 @@ size_t fwrite(const void *ptr, size_t size, size_t nitems, FILE *stream)
/* f g e t x a t t r */
/******************************************************************************/

#if defined(__linux__) || defined(__GNU__)
#if defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
extern "C"
{
ssize_t fgetxattr (int fd, const char *name, void *value, size_t size)
Expand All @@ -367,7 +367,7 @@ ssize_t fgetxattr (int fd, const char *name, void *value, size_t size)
/* g e t x a t t r */
/******************************************************************************/

#if defined(__linux__) || defined(__GNU__)
#if defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
extern "C"
{
ssize_t getxattr (const char *path, const char *name, void *value, size_t size)
Expand All @@ -383,7 +383,7 @@ ssize_t getxattr (const char *path, const char *name, void *value, size_t size)
/* l g e t x a t t r */
/******************************************************************************/

#if defined(__linux__) || defined(__GNU__)
#if defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
extern "C"
{
ssize_t lgetxattr (const char *path, const char *name, void *value, size_t size)
Expand Down

0 comments on commit 70d2919

Please sign in to comment.