1 //===- llvm/System/Unix/Unix.h - Common Unix Include File -------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines things specific to Unix implementations.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_SYSTEM_UNIX_UNIX_H
15 #define LLVM_SYSTEM_UNIX_UNIX_H
17 //===----------------------------------------------------------------------===//
18 //=== WARNING: Implementation here must contain only generic UNIX code that
19 //=== is guaranteed to work on all UNIX variants.
20 //===----------------------------------------------------------------------===//
22 #include "llvm/Config/config.h" // Get autoconf configuration settings
23 #include "llvm/System/Errno.h"
35 #ifdef HAVE_SYS_TYPES_H
36 #include <sys/types.h>
39 #ifdef HAVE_SYS_PARAM_H
40 #include <sys/param.h>
47 #ifdef TIME_WITH_SYS_TIME
48 # include <sys/time.h>
51 # ifdef HAVE_SYS_TIME_H
52 # include <sys/time.h>
58 #ifdef HAVE_SYS_WAIT_H
59 # include <sys/wait.h>
63 # define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
67 # define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
70 /// This function builds an error message into \p ErrMsg using the \p prefix
71 /// string and the Unix error number given by \p errnum. If errnum is -1, the
72 /// default then the value of errno is used.
73 /// @brief Make an error message
75 /// If the error number can be converted to a string, it will be
76 /// separated from prefix by ": ".
77 static inline bool MakeErrMsg(
78 std::string
* ErrMsg
, const std::string
& prefix
, int errnum
= -1) {
83 *ErrMsg
= prefix
+ ": " + llvm::sys::StrError(errnum
);