Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Pfc] Fix compilation on OSX #827

Merged
merged 3 commits into from
Sep 20, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/XrdFileCache.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ add_library(
XrdFileCache/XrdFileCacheIO.cc XrdFileCache/XrdFileCacheIO.hh
XrdFileCache/XrdFileCacheIOEntireFile.cc XrdFileCache/XrdFileCacheIOEntireFile.hh
XrdFileCache/XrdFileCacheIOFileBlock.cc XrdFileCache/XrdFileCacheIOFileBlock.hh
XrdFileCache/XrdFileCacheDecision.hh
XrdFileCache/posix_fallocate_osx.hh)
XrdFileCache/XrdFileCacheDecision.hh)

target_link_libraries(
${LIB_XRD_FILECACHE}
Expand Down
5 changes: 1 addition & 4 deletions src/XrdFileCache/XrdFileCacheCommand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "XrdOuc/XrdOucEnv.hh"
#include "XrdOuc/XrdOucStream.hh"
#include "XrdSys/XrdSysLogger.hh"
#include "XrdSys/XrdSysFallocate.hh"

#include <algorithm>
#include <cstring>
Expand All @@ -35,10 +36,6 @@
#include <vector>
#include <sys/time.h>

#ifdef __APPLE__
#include "posix_fallocate_osx.hh"
#endif

using namespace XrdFileCache;

//______________________________________________________________________________
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
// along with XRootD. If not, see <http://www.gnu.org/licenses/>.
//----------------------------------------------------------------------------------

// Implementation of posix_allocate for OSX.

#ifdef __APPLE__

#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
Expand Down Expand Up @@ -69,7 +73,7 @@
// file descriptions associated with the file.


static int posix_fallocate(int fd, off_t offset, off_t len)
int posix_fallocate(int fd, off_t offset, off_t len)
{
off_t c_test;
int ret;
Expand All @@ -92,3 +96,5 @@ static int posix_fallocate(int fd, off_t offset, off_t len)
}
return ret;
}

#endif
35 changes: 35 additions & 0 deletions src/XrdSys/XrdSysFallocate.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//----------------------------------------------------------------------------------
// 1. The Original Code is Mozilla code.
// The Initial Developer of the Original Code is Mozilla Foundation.
// Portions created by the Initial Developer are Copyright (C) 2010 the Initial Developer. All Rights Reserved.
// Contributor(s): Taras Glek <tglek@mozilla.com>
// 2. Created from the OSX-specific code from Mozilla's mozilla::fallocation() function.
// Adaptation (C) 2015,2016 R.J.V. Bertin for KDE, project.
//
// Original license allows modification / redistribution under LGPL 2.1 or higher.
//----------------------------------------------------------------------------------
// XRootD 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 3 of the License, or
// (at your option) any later version.
//
// XRootD 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 General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with XRootD. If not, see <http://www.gnu.org/licenses/>.
//----------------------------------------------------------------------------------

// Implementation of posix_allocate for OSX.

#ifdef __APPLE__

extern int posix_fallocate(int fd, off_t offset, off_t len);

#else

#include <fcntl.h>

#endif
2 changes: 2 additions & 0 deletions src/XrdUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ add_library(
XrdSys/XrdSysLogPI.hh
XrdSys/XrdSysLinuxSemaphore.hh
XrdSys/XrdSysXAttr.cc XrdSys/XrdSysXAttr.hh
XrdSys/XrdSysFallocate.cc XrdSys/XrdSysFallocate.hh


#-----------------------------------------------------------------------------
# XrdOuc
Expand Down