Reid Spencer | c3de952 | 2004-08-29 19:24:20 +0000 | [diff] [blame] | 1 | //===- llvm/System/Unix/Unix.h - Common Unix Include File -------*- C++ -*-===// |
Reid Spencer | b89a223 | 2004-08-25 06:20:07 +0000 | [diff] [blame] | 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 | |
Reid Spencer | c3de952 | 2004-08-29 19:24:20 +0000 | [diff] [blame] | 19 | #include "Config/config.h" // Get autoconf configuration settings |
Reid Spencer | b89a223 | 2004-08-25 06:20:07 +0000 | [diff] [blame] | 20 | #include <unistd.h> |
Reid Spencer | c3de952 | 2004-08-29 19:24:20 +0000 | [diff] [blame] | 21 | #include <cstdlib> |
| 22 | #include <cstdio> |
| 23 | #include <cstring> |
| 24 | #include <cerrno> |
Reid Spencer | b89a223 | 2004-08-25 06:20:07 +0000 | [diff] [blame] | 25 | #include <sys/types.h> |
| 26 | #include <sys/param.h> |
Reid Spencer | b60bf61 | 2004-08-30 16:03:54 +0000 | [diff] [blame] | 27 | #include <assert.h> |
Reid Spencer | 387e5ec | 2004-08-31 17:43:29 +0000 | [diff] [blame^] | 28 | #include <string> |
Reid Spencer | b89a223 | 2004-08-25 06:20:07 +0000 | [diff] [blame] | 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 | } |