blob: 37bc53c28a5e881f73d211544627628dbe5822d5 [file] [log] [blame]
Reid Spencerc3de9522004-08-29 19:24:20 +00001//===- llvm/System/Unix/Unix.h - Common Unix Include File -------*- C++ -*-===//
Reid Spencerb89a2232004-08-25 06:20:07 +00002//
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 Spencer551ccae2004-09-01 22:55:40 +000019#include "llvm/Config/config.h" // Get autoconf configuration settings
Reid Spencerb89a2232004-08-25 06:20:07 +000020#include <unistd.h>
Reid Spencerc3de9522004-08-29 19:24:20 +000021#include <cstdlib>
22#include <cstdio>
23#include <cstring>
24#include <cerrno>
Reid Spencerb89a2232004-08-25 06:20:07 +000025#include <sys/types.h>
Tanya Lattnerc5a0bbf2004-10-05 00:51:26 +000026#include <sys/stat.h>
Reid Spencerb89a2232004-08-25 06:20:07 +000027#include <sys/param.h>
Reid Spencerb60bf612004-08-30 16:03:54 +000028#include <assert.h>
Reid Spencer387e5ec2004-08-31 17:43:29 +000029#include <string>
Reid Spencerb89a2232004-08-25 06:20:07 +000030
31inline void ThrowErrno(const std::string& prefix) {
32#if defined __USE_XOPEN2K || defined __USE_MISC
33 char buffer[MAXPATHLEN];
34 strerror_r(errno,buffer, MAXPATHLEN);
35 throw prefix + ": " + buffer;
36#else
37 throw prefix + ": " + strerror(errno);
38#endif
39}