Explicitly include <unistd.h>.

This commit is contained in:
David Nadlinger
2012-06-11 00:07:55 +02:00
parent 295798877c
commit 7652fb8015
2 changed files with 16 additions and 4 deletions

View File

@@ -331,6 +331,12 @@ get_target_property(LDC_LOC ${LDC_EXE} LOCATION)
#
# LDMD
#
include(CheckSymbolExists)
CHECK_SYMBOL_EXISTS(_SC_ARG_MAX "unistd.h" HAVE_SC_ARG_MAX)
if (HAVE_SC_ARG_MAX)
add_definitions(-DHAVE_SC_ARG_MAX)
endif()
set_source_files_properties(dmd2/root/response.c dmd2/root/man.c PROPERTIES LANGUAGE CXX)
add_executable(${LDMD_EXE} dmd2/root/response.c dmd2/root/man.c driver/ldmd.cpp)
set_target_properties(${LDMD_EXE} PROPERTIES

View File

@@ -55,6 +55,10 @@
#include "llvm/Support/SystemUtils.h"
#include "llvm/Support/raw_ostream.h"
#ifdef HAVE_SC_ARG_MAX
# include <unistd.h>
#endif
namespace ls = llvm::sys;
// We reuse DMD's response file parsing routine for maximum compatibilty - it
@@ -784,13 +788,15 @@ void buildCommandLine(std::vector<const char*>& r, const Params& p)
*/
size_t maxCommandLineLen()
{
#ifdef WINDOWS
// http://blogs.msdn.com/b/oldnewthing/archive/2003/12/10/56028.aspx
return 32767;
#else
#if defined(HAVE_SC_ARG_MAX)
// http://www.in-ulm.de/~mascheck/various/argmax the factor 2 is just
// a wild guess to account for the enviroment.
return sysconf(_SC_ARG_MAX) / 2;
#elif defined(_WIN32)
// http://blogs.msdn.com/b/oldnewthing/archive/2003/12/10/56028.aspx
return 32767;
#else
# error "Do not know how to determine maximum command line length."
#endif
}