Changes For Bug 352
[oota-llvm.git] / lib / System / Unix / Unix.h
1 //===- llvm/System/Unix/Unix.h - Common Unix Include File -------*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by Reid Spencer and is distributed under the 
6 // University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines things specific to Unix implementations.
11 //
12 //===----------------------------------------------------------------------===//
13
14 //===----------------------------------------------------------------------===//
15 //=== WARNING: Implementation here must contain only generic UNIX code that
16 //===          is guaranteed to work on all UNIX variants.
17 //===----------------------------------------------------------------------===//
18
19 #include "llvm/Config/config.h"     // Get autoconf configuration settings
20 #include <unistd.h>
21 #include <cstdlib>
22 #include <cstdio>
23 #include <cstring>
24 #include <cerrno>
25 #include <sys/types.h>
26 #include <sys/param.h>
27 #include <assert.h>
28 #include <string>
29
30 inline void ThrowErrno(const std::string& prefix) {
31 #if defined __USE_XOPEN2K || defined __USE_MISC
32     char buffer[MAXPATHLEN];
33     strerror_r(errno,buffer, MAXPATHLEN);
34     throw prefix + ": " + buffer;
35 #else
36     throw prefix + ": " + strerror(errno);
37 #endif
38 }