blob: 83d2865a11f42bbcb7b98da8e5c6ac890bc388d2 [file] [log] [blame]
Reid Spencerb89a2232004-08-25 06:20:07 +00001//===- 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 <unistd.h>
20#include <stdlib.h>
21#include <string.h>
22#include <errno.h>
23#include <sys/types.h>
24#include <sys/param.h>
25
26inline void ThrowErrno(const std::string& prefix) {
27#if defined __USE_XOPEN2K || defined __USE_MISC
28 char buffer[MAXPATHLEN];
29 strerror_r(errno,buffer, MAXPATHLEN);
30 throw prefix + ": " + buffer;
31#else
32 throw prefix + ": " + strerror(errno);
33#endif
34}