mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-27 17:31:33 +00:00
Back out include/llvm/System changes until a satisfactory solution can
be determined. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15817 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
08bfab175a
commit
d771c5340a
@ -1,208 +0,0 @@
|
|||||||
//===- ErrorCode.h - Declare ErrorCode class --------------------*- C++ -*-===//
|
|
||||||
//
|
|
||||||
// Copyright (C) 2004 eXtensible Systems, Inc. All Rights Reserved.
|
|
||||||
//
|
|
||||||
// This program is open source software; you can redistribute it and/or modify
|
|
||||||
// it under the terms of the University of Illinois Open Source License. See
|
|
||||||
// LICENSE.TXT (distributed with this software) for details.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful, but
|
|
||||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
||||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
/// @file lib/System/ErrorCode.h
|
|
||||||
/// @author Reid Spencer <raspencer@x10sys.com> (original author)
|
|
||||||
/// @version \verbatim $Id$ \endverbatim
|
|
||||||
/// @date 2004/08/14
|
|
||||||
/// @since 1.4
|
|
||||||
/// @brief Declares the llvm::sys::ErrorCode class.
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
#ifndef LLVM_SYSTEM_ERRORCODE_H
|
|
||||||
#define LLVM_SYSTEM_ERRORCODE_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
/// @brief Computes an errorcode value from its domain and index values.
|
|
||||||
#define LLVM_ERROR_CODE( domain, index ) \
|
|
||||||
( ( domain << ::llvm::sys::ERROR_DOMAIN_SHIFT ) + \
|
|
||||||
( index & ::llvm::sys::ERROR_INDEX_MASK ))
|
|
||||||
|
|
||||||
namespace llvm {
|
|
||||||
namespace sys {
|
|
||||||
|
|
||||||
/// @brief The number of bits to shift right to get the domain part of an error code.
|
|
||||||
const uint32_t ERROR_DOMAIN_SHIFT = (sizeof(uint32_t)*8)*3/4;
|
|
||||||
|
|
||||||
const uint32_t ERROR_DOMAIN_MASK =
|
|
||||||
((1<<((sizeof(uint32_t)*8)-ERROR_DOMAIN_SHIFT))-1)<<ERROR_DOMAIN_SHIFT;
|
|
||||||
|
|
||||||
/// @brief The mask to get only the index part of an error code.
|
|
||||||
const uint32_t ERROR_INDEX_MASK = ( 1 << ERROR_DOMAIN_SHIFT) - 1;
|
|
||||||
|
|
||||||
/// @brief The maximum value for the index part of an error code.
|
|
||||||
const uint32_t MAX_ERROR_INDEX= ERROR_INDEX_MASK;
|
|
||||||
|
|
||||||
/// @brief The minimum value for the index part of an error code.
|
|
||||||
const uint32_t MIN_ERROR_INDEX= 1;
|
|
||||||
|
|
||||||
/// @brief A constant to represent the non error condition.
|
|
||||||
const uint32_t NOT_AN_ERROR = 0;
|
|
||||||
|
|
||||||
/// @brief An enumeration of the possible error code domains
|
|
||||||
enum ErrorDomains {
|
|
||||||
OSDomain = 0, ///< The domain of operating system specific error codes
|
|
||||||
SystemDomain = 1, ///< The domain of lib/System specific error codes
|
|
||||||
};
|
|
||||||
|
|
||||||
/// @brief An enumeration of the error codes defined by lib/System.
|
|
||||||
enum SystemErrors {
|
|
||||||
ERR_SYS_INVALID_ARG = LLVM_ERROR_CODE(SystemDomain,1),
|
|
||||||
};
|
|
||||||
|
|
||||||
/// This class provides the error code value for every error that the System
|
|
||||||
/// library can produce. It simply partitions a uint32_t into a domain part
|
|
||||||
/// (top 8 bits) and an index part (low 24 bits). This is necessary since
|
|
||||||
/// lib/System can generate its own error codes and there needs to be a way
|
|
||||||
/// to distinguish them from the operating system errors.
|
|
||||||
///
|
|
||||||
/// Note that ErrorCode is the only way to determine if an error occurred
|
|
||||||
/// resulting from a lib/System call. lib/System will (by design) never throw
|
|
||||||
/// an exception. This is done to make lib/System calls very efficient and to
|
|
||||||
/// avoid the overhead of exception processing since most of the time the
|
|
||||||
/// calls will succeed.
|
|
||||||
///
|
|
||||||
/// There are various methods on the ErrorCode class to translate the error
|
|
||||||
/// code into a readable string, should the need arise. There are also methods
|
|
||||||
/// to distinguish the kind of error and this works in a platform agnostic
|
|
||||||
/// way for most of the common cases.
|
|
||||||
///
|
|
||||||
/// @since 1.4
|
|
||||||
/// @brief Provides a 32 bit error code that encapsulates error domain and
|
|
||||||
/// index.
|
|
||||||
class ErrorCode
|
|
||||||
{
|
|
||||||
/// @name Constructors
|
|
||||||
/// @{
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// This constructor instantiates a new ErrorCode object
|
|
||||||
/// with a "no error" error code.
|
|
||||||
/// @brief Constructor.
|
|
||||||
ErrorCode() throw() : Code(NOT_AN_ERROR) {}
|
|
||||||
|
|
||||||
/// This constructor instantiates a new ErrorCode object
|
|
||||||
/// with an integer code.
|
|
||||||
/// @brief Constructor.
|
|
||||||
ErrorCode (uint32_t code) throw() : Code(code) {}
|
|
||||||
|
|
||||||
/// This constructor instantiates a new ErrorCode object
|
|
||||||
/// with an integer code.
|
|
||||||
/// @brief Constructor.
|
|
||||||
ErrorCode(int code) throw()
|
|
||||||
: Code ( static_cast<uint32_t>( code ) ) { }
|
|
||||||
|
|
||||||
/// Copies one ErrorCode to another.
|
|
||||||
/// @brief Copy Constructor.
|
|
||||||
ErrorCode(const ErrorCode& that) throw() : Code ( that.Code ) { }
|
|
||||||
|
|
||||||
/// Nothing much to do.
|
|
||||||
/// @brief Destructor
|
|
||||||
~ErrorCode(void) throw() {}
|
|
||||||
|
|
||||||
/// @}
|
|
||||||
/// @name Operators
|
|
||||||
/// @{
|
|
||||||
public:
|
|
||||||
/// Assigns one ErrorCode object to another
|
|
||||||
/// @brief Assignment Operator.
|
|
||||||
ErrorCode & operator = (const ErrorCode& that) throw() {
|
|
||||||
Code = that.Code;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns true if \p this and \p that refer to the same type of error
|
|
||||||
/// @brief Equality Operator.
|
|
||||||
bool operator == (const ErrorCode& that) const throw() {
|
|
||||||
return Code == that.Code;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns true if \p this and \p that do not refer to the same type of error
|
|
||||||
/// @brief Inequality Operator.
|
|
||||||
bool operator != (const ErrorCode& that) const throw() {
|
|
||||||
return Code != that.Code;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @return a non zero value if an error condition exists
|
|
||||||
/// @brief Test Operator
|
|
||||||
operator bool() const throw() { return Code == NOT_AN_ERROR; }
|
|
||||||
|
|
||||||
/// @return a non zero value if an error condition exists
|
|
||||||
/// @brief Test Operator.
|
|
||||||
operator int() const throw() { return Code; }
|
|
||||||
|
|
||||||
/// @brief unsigned conversion operator.
|
|
||||||
operator unsigned int() const throw() { return Code; }
|
|
||||||
|
|
||||||
/// @brief long conversion operator.
|
|
||||||
operator long() const throw() { return Code; }
|
|
||||||
|
|
||||||
/// @brief unsigned long conversion operator
|
|
||||||
operator unsigned long() const throw() { return Code; }
|
|
||||||
|
|
||||||
/// @}
|
|
||||||
/// @name Accessors
|
|
||||||
/// @{
|
|
||||||
public:
|
|
||||||
/// @returns the integer error code value.
|
|
||||||
/// @brief Provides the integer error code value.
|
|
||||||
uint32_t code() const throw() { return Code; }
|
|
||||||
|
|
||||||
/// @returns the integer domain number for the error number
|
|
||||||
/// @brief Provides the domain of the error
|
|
||||||
uint32_t domain() const throw() {
|
|
||||||
return (Code & ERROR_DOMAIN_MASK) >> ERROR_DOMAIN_SHIFT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @brief Provides the index of the error
|
|
||||||
uint32_t index() const throw() {
|
|
||||||
return Code & ERROR_INDEX_MASK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @brief Provides a readable string related to the error code
|
|
||||||
std::string description() const throw();
|
|
||||||
|
|
||||||
/// If \p this ErrorCode and \p ec have the same error code then return
|
|
||||||
/// true, otherwise false.
|
|
||||||
/// @param ec An errorcode value to compare against this ErrorCode
|
|
||||||
/// @returns true if \p this ErrorCode has the same error code as \p errcode
|
|
||||||
/// @brief Determines identity of the error code.
|
|
||||||
bool is( const ErrorCode& ec ) const throw() { return Code == ec.Code; }
|
|
||||||
|
|
||||||
/// @}
|
|
||||||
/// @name Mutators
|
|
||||||
/// @{
|
|
||||||
public:
|
|
||||||
/// @returns the previous integer error code value.
|
|
||||||
/// @brief allows the integer error code to be set.
|
|
||||||
uint32_t code(uint32_t code) throw() {
|
|
||||||
uint32_t old_code = Code;
|
|
||||||
Code = code;
|
|
||||||
return old_code;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @}
|
|
||||||
/// @name Data
|
|
||||||
/// @{
|
|
||||||
private:
|
|
||||||
uint32_t Code; ///< The error code value
|
|
||||||
/// @}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,214 +0,0 @@
|
|||||||
//===- Path.h - Implement the Path class ------------------------*- C++ -*-===//
|
|
||||||
//
|
|
||||||
// The LLVM Compiler Infrastructure
|
|
||||||
//
|
|
||||||
// Copyright (C) 2003 eXtensible Systems, Inc. All Rights Reserved.
|
|
||||||
//
|
|
||||||
// This program is open source software; you can redistribute it and/or modify
|
|
||||||
// it under the terms of the University of Illinois Open Source License. See
|
|
||||||
// LICENSE.TXT (distributed with this software) for details.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful, but
|
|
||||||
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
||||||
// or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// This file declares the llvm::sys::Path class. The Path class provides the
|
|
||||||
// operating system agnostic concept of the name of a file or directory.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
/// @file lib/System/Path.h
|
|
||||||
/// @author Reid Spencer <raspencer@x10sys.com> (original author)
|
|
||||||
/// @version \verbatim $Id$ \endverbatim
|
|
||||||
/// @date 2004/08/14
|
|
||||||
/// @since 1.4
|
|
||||||
/// @brief Declares the llvm::sys::Path class.
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
#ifndef LLVM_SYSTEM_PATH_H
|
|
||||||
#define LLVM_SYSTEM_PATH_H
|
|
||||||
|
|
||||||
#include "llvm/System/ErrorCode.h"
|
|
||||||
|
|
||||||
namespace llvm {
|
|
||||||
namespace sys {
|
|
||||||
|
|
||||||
/// This class provides an abstraction for the name of a path
|
|
||||||
/// to a file or directory in the filesystem.
|
|
||||||
/// @since 1.4
|
|
||||||
/// @brief An abstraction for operating system paths.
|
|
||||||
class Path : public std::string
|
|
||||||
{
|
|
||||||
/// @name Types
|
|
||||||
/// @{
|
|
||||||
public:
|
|
||||||
/// @brief An enumerator for specifying special ways to construct
|
|
||||||
/// the path.
|
|
||||||
enum ConstructSpecial {
|
|
||||||
CONSTRUCT_TEMP_FILE = 1, ///< make a temporary file name
|
|
||||||
CONSTRUCT_TEMP_DIR = 2, ///< Make a temporary directory name
|
|
||||||
};
|
|
||||||
|
|
||||||
/// @}
|
|
||||||
/// @name Constructors
|
|
||||||
/// @{
|
|
||||||
public:
|
|
||||||
/// Forward declare this because constructors need to use it.
|
|
||||||
/// @returns true if the path is valid
|
|
||||||
/// @brief Determines if the path is valid (properly formed) or not.
|
|
||||||
inline bool is_valid() const throw();
|
|
||||||
|
|
||||||
/// Creates a null (empty) path
|
|
||||||
/// @brief Default Constructor
|
|
||||||
Path () throw() {}
|
|
||||||
|
|
||||||
/// Creates a path from char*
|
|
||||||
/// @brief char* converter
|
|
||||||
Path ( const char * name ) throw() : std::string(name) {
|
|
||||||
assert(is_valid());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @brief std::string converter
|
|
||||||
Path ( const std::string& name ) throw() : std::string(name) {
|
|
||||||
assert(is_valid());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Copies the path with copy-on-write semantics. The \p this Path
|
|
||||||
/// will reference \p the that Path until one of them is modified
|
|
||||||
/// at which point a full copy is taken before the write.
|
|
||||||
/// @brief Copy Constructor
|
|
||||||
Path ( const Path & that ) throw() : std::string(that) {
|
|
||||||
assert(is_valid());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// This constructor will construct the path using a special
|
|
||||||
/// construction argument that will pre-fill the path with the name
|
|
||||||
/// of some special path name
|
|
||||||
/// @brief Construct a special, well known path
|
|
||||||
Path( ConstructSpecial ) throw();
|
|
||||||
|
|
||||||
/// Releases storage associated with the Path object
|
|
||||||
/// @brief Destructor
|
|
||||||
~Path () throw() {}
|
|
||||||
|
|
||||||
/// @}
|
|
||||||
/// @name Operators
|
|
||||||
/// @{
|
|
||||||
public:
|
|
||||||
/// Makes a copy of \p that to \p this with copy-on-write semantics.
|
|
||||||
/// @returns \p this
|
|
||||||
/// @brief Assignment Operator
|
|
||||||
Path & operator = ( const Path & that ) throw() {
|
|
||||||
this->assign ( that );
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Comparies \p this Path with \p that Path for equality.
|
|
||||||
/// @returns true if \p this and \p that refer to the same item.
|
|
||||||
/// @brief Equality Operator
|
|
||||||
bool operator ==( const Path & that ) const throw() {
|
|
||||||
return 0 == this->compare( that ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Comparies \p this Path with \p that Path for inequality.
|
|
||||||
/// @returns true if \p this and \p that refer to different items.
|
|
||||||
/// @brief Inequality Operator
|
|
||||||
bool operator !=( const Path & that ) const throw() {
|
|
||||||
return 0 != this->compare( that );
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @}
|
|
||||||
/// @name Accessors
|
|
||||||
/// @{
|
|
||||||
public:
|
|
||||||
/// @returns true if the path could reference a file
|
|
||||||
/// @brief Determines if the path is valid for a file reference.
|
|
||||||
bool is_file() const throw();
|
|
||||||
|
|
||||||
/// @returns true if the path could reference a directory
|
|
||||||
/// @brief Determines if the path is valid for a directory reference.
|
|
||||||
bool is_directory() const throw();
|
|
||||||
|
|
||||||
/// @brief Fills and zero terminates a buffer with the path
|
|
||||||
inline void fill( char* buffer, uint32_t len ) const throw();
|
|
||||||
|
|
||||||
/// @}
|
|
||||||
/// @name Mutators
|
|
||||||
/// @{
|
|
||||||
public:
|
|
||||||
/// This ensures that the pathname is terminated with a /
|
|
||||||
/// @brief Make the path reference a directory.
|
|
||||||
ErrorCode make_directory() throw();
|
|
||||||
|
|
||||||
/// This ensures that the pathname is not terminated with a /
|
|
||||||
/// @brief Makes the path reference a file.
|
|
||||||
ErrorCode make_file() throw();
|
|
||||||
|
|
||||||
/// the file system.
|
|
||||||
/// @returns true if the pathname references an existing file.
|
|
||||||
/// @brief Determines if the path is a file or directory in
|
|
||||||
ErrorCode exists() throw();
|
|
||||||
|
|
||||||
/// The \p dirname is added to the end of the Path.
|
|
||||||
/// @param dirname A string providing the directory name to
|
|
||||||
/// be appended to the path.
|
|
||||||
/// @brief Appends the name of a directory.
|
|
||||||
ErrorCode append_directory( const std::string & dirname ) throw();
|
|
||||||
|
|
||||||
/// The \p filename is added to the end of the Path.
|
|
||||||
/// @brief Appends the name of a file.
|
|
||||||
ErrorCode append_file( const std::string& filename ) throw();
|
|
||||||
|
|
||||||
/// Directories will have no entries. Files will be zero length. If
|
|
||||||
/// the file or directory already exists, no error results.
|
|
||||||
/// @throws SystemException if any error occurs.
|
|
||||||
/// @brief Causes the file or directory to exist in the filesystem.
|
|
||||||
ErrorCode create( bool create_parents = false ) throw();
|
|
||||||
|
|
||||||
ErrorCode create_directory() throw();
|
|
||||||
ErrorCode create_directories() throw() ;
|
|
||||||
ErrorCode create_file() throw() ;
|
|
||||||
|
|
||||||
/// Directories must be empty before they can be removed. If not,
|
|
||||||
/// an error will result. Files will be unlinked, even if another
|
|
||||||
/// process is using them.
|
|
||||||
/// @brief Removes the file or directory from the filesystem.
|
|
||||||
ErrorCode remove() throw();
|
|
||||||
ErrorCode remove_directory() throw() ;
|
|
||||||
ErrorCode remove_file() throw() ;
|
|
||||||
|
|
||||||
/// Temporary file names are a common need. This method uses the
|
|
||||||
/// template in the existing path and uniquifies a file name based
|
|
||||||
/// on the template.
|
|
||||||
ErrorCode make_temp_file() throw();
|
|
||||||
|
|
||||||
/// Temporary directory names are a common need. This method uses
|
|
||||||
/// the template in the existing path and uniqufies a directory
|
|
||||||
/// name based on the template.
|
|
||||||
ErrorCode make_temp_directory() throw();
|
|
||||||
|
|
||||||
/// Find library.
|
|
||||||
ErrorCode find_lib( const char * file ) throw();
|
|
||||||
/// @}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
inline bool Path::is_valid() const throw() {
|
|
||||||
if ( empty() ) return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Path::fill( char* buffer, size_t bufflen ) const throw() {
|
|
||||||
size_t pathlen = length();
|
|
||||||
assert( bufflen > pathlen );
|
|
||||||
size_t copylen = pathlen <? (bufflen - 1);
|
|
||||||
this->copy(buffer, copylen, 0 );
|
|
||||||
buffer[ copylen ] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,14 +0,0 @@
|
|||||||
System Utilities Interface
|
|
||||||
==========================
|
|
||||||
|
|
||||||
The design of this library has several key constraints aimed at shielding LLVM
|
|
||||||
from the vagaries of operating system differences. The goal here is to provide
|
|
||||||
interfaces to operating system concepts (files, memory maps, sockets, signals,
|
|
||||||
locking, etc) efficiently and in such a way that the remainder of LLVM is
|
|
||||||
completely operating system agnostic.
|
|
||||||
|
|
||||||
PLEASE READ AND COMPREHEND FULLY THE DOCUMENTATION in
|
|
||||||
|
|
||||||
llvm/docs/SystemLibrary.html
|
|
||||||
|
|
||||||
before making changes to this library.
|
|
Loading…
x
Reference in New Issue
Block a user