1//===---------------------------- system_error ------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This was lifted from libc++ and modified for C++03. This is called 11// system_error even though it does not define that class because that's what 12// it's called in C++0x. We don't define system_error because it is only used 13// for exception handling, which we don't use in LLVM. 14// 15//===----------------------------------------------------------------------===// 16 17#ifndef LLVM_SYSTEM_SYSTEM_ERROR_H 18#define LLVM_SYSTEM_SYSTEM_ERROR_H 19 20#include "llvm/Support/Compiler.h" 21 22/* 23 system_error synopsis 24 25namespace std 26{ 27 28class error_category 29{ 30public: 31 virtual ~error_category(); 32 33 error_category(const error_category&) = delete; 34 error_category& operator=(const error_category&) = delete; 35 36 virtual const char* name() const = 0; 37 virtual error_condition default_error_condition(int ev) const; 38 virtual bool equivalent(int code, const error_condition& condition) const; 39 virtual bool equivalent(const error_code& code, int condition) const; 40 virtual std::string message(int ev) const = 0; 41 42 bool operator==(const error_category& rhs) const; 43 bool operator!=(const error_category& rhs) const; 44 bool operator<(const error_category& rhs) const; 45}; 46 47const error_category& generic_category(); 48const error_category& system_category(); 49 50template <class T> struct is_error_code_enum 51 : public false_type {}; 52 53template <class T> struct is_error_condition_enum 54 : public false_type {}; 55 56class error_code 57{ 58public: 59 // constructors: 60 error_code(); 61 error_code(int val, const error_category& cat); 62 template <class ErrorCodeEnum> 63 error_code(ErrorCodeEnum e); 64 65 // modifiers: 66 void assign(int val, const error_category& cat); 67 template <class ErrorCodeEnum> 68 error_code& operator=(ErrorCodeEnum e); 69 void clear(); 70 71 // observers: 72 int value() const; 73 const error_category& category() const; 74 error_condition default_error_condition() const; 75 std::string message() const; 76 explicit operator bool() const; 77}; 78 79// non-member functions: 80bool operator<(const error_code& lhs, const error_code& rhs); 81template <class charT, class traits> 82 basic_ostream<charT,traits>& 83 operator<<(basic_ostream<charT,traits>& os, const error_code& ec); 84 85class error_condition 86{ 87public: 88 // constructors: 89 error_condition(); 90 error_condition(int val, const error_category& cat); 91 template <class ErrorConditionEnum> 92 error_condition(ErrorConditionEnum e); 93 94 // modifiers: 95 void assign(int val, const error_category& cat); 96 template <class ErrorConditionEnum> 97 error_condition& operator=(ErrorConditionEnum e); 98 void clear(); 99 100 // observers: 101 int value() const; 102 const error_category& category() const; 103 std::string message() const; 104 explicit operator bool() const; 105}; 106 107bool operator<(const error_condition& lhs, const error_condition& rhs); 108 109class system_error 110 : public runtime_error 111{ 112public: 113 system_error(error_code ec, const std::string& what_arg); 114 system_error(error_code ec, const char* what_arg); 115 system_error(error_code ec); 116 system_error(int ev, const error_category& ecat, const std::string& what_arg); 117 system_error(int ev, const error_category& ecat, const char* what_arg); 118 system_error(int ev, const error_category& ecat); 119 120 const error_code& code() const throw(); 121 const char* what() const throw(); 122}; 123 124enum class errc 125{ 126 address_family_not_supported, // EAFNOSUPPORT 127 address_in_use, // EADDRINUSE 128 address_not_available, // EADDRNOTAVAIL 129 already_connected, // EISCONN 130 argument_list_too_long, // E2BIG 131 argument_out_of_domain, // EDOM 132 bad_address, // EFAULT 133 bad_file_descriptor, // EBADF 134 bad_message, // EBADMSG 135 broken_pipe, // EPIPE 136 connection_aborted, // ECONNABORTED 137 connection_already_in_progress, // EALREADY 138 connection_refused, // ECONNREFUSED 139 connection_reset, // ECONNRESET 140 cross_device_link, // EXDEV 141 destination_address_required, // EDESTADDRREQ 142 device_or_resource_busy, // EBUSY 143 directory_not_empty, // ENOTEMPTY 144 executable_format_error, // ENOEXEC 145 file_exists, // EEXIST 146 file_too_large, // EFBIG 147 filename_too_long, // ENAMETOOLONG 148 function_not_supported, // ENOSYS 149 host_unreachable, // EHOSTUNREACH 150 identifier_removed, // EIDRM 151 illegal_byte_sequence, // EILSEQ 152 inappropriate_io_control_operation, // ENOTTY 153 interrupted, // EINTR 154 invalid_argument, // EINVAL 155 invalid_seek, // ESPIPE 156 io_error, // EIO 157 is_a_directory, // EISDIR 158 message_size, // EMSGSIZE 159 network_down, // ENETDOWN 160 network_reset, // ENETRESET 161 network_unreachable, // ENETUNREACH 162 no_buffer_space, // ENOBUFS 163 no_child_process, // ECHILD 164 no_link, // ENOLINK 165 no_lock_available, // ENOLCK 166 no_message_available, // ENODATA 167 no_message, // ENOMSG 168 no_protocol_option, // ENOPROTOOPT 169 no_space_on_device, // ENOSPC 170 no_stream_resources, // ENOSR 171 no_such_device_or_address, // ENXIO 172 no_such_device, // ENODEV 173 no_such_file_or_directory, // ENOENT 174 no_such_process, // ESRCH 175 not_a_directory, // ENOTDIR 176 not_a_socket, // ENOTSOCK 177 not_a_stream, // ENOSTR 178 not_connected, // ENOTCONN 179 not_enough_memory, // ENOMEM 180 not_supported, // ENOTSUP 181 operation_canceled, // ECANCELED 182 operation_in_progress, // EINPROGRESS 183 operation_not_permitted, // EPERM 184 operation_not_supported, // EOPNOTSUPP 185 operation_would_block, // EWOULDBLOCK 186 owner_dead, // EOWNERDEAD 187 permission_denied, // EACCES 188 protocol_error, // EPROTO 189 protocol_not_supported, // EPROTONOSUPPORT 190 read_only_file_system, // EROFS 191 resource_deadlock_would_occur, // EDEADLK 192 resource_unavailable_try_again, // EAGAIN 193 result_out_of_range, // ERANGE 194 state_not_recoverable, // ENOTRECOVERABLE 195 stream_timeout, // ETIME 196 text_file_busy, // ETXTBSY 197 timed_out, // ETIMEDOUT 198 too_many_files_open_in_system, // ENFILE 199 too_many_files_open, // EMFILE 200 too_many_links, // EMLINK 201 too_many_symbolic_link_levels, // ELOOP 202 value_too_large, // EOVERFLOW 203 wrong_protocol_type // EPROTOTYPE 204}; 205 206template <> struct is_error_condition_enum<errc> : true_type { } 207 208error_code make_error_code(errc e); 209error_condition make_error_condition(errc e); 210 211// Comparison operators: 212bool operator==(const error_code& lhs, const error_code& rhs); 213bool operator==(const error_code& lhs, const error_condition& rhs); 214bool operator==(const error_condition& lhs, const error_code& rhs); 215bool operator==(const error_condition& lhs, const error_condition& rhs); 216bool operator!=(const error_code& lhs, const error_code& rhs); 217bool operator!=(const error_code& lhs, const error_condition& rhs); 218bool operator!=(const error_condition& lhs, const error_code& rhs); 219bool operator!=(const error_condition& lhs, const error_condition& rhs); 220 221template <> struct hash<std::error_code>; 222 223} // std 224 225*/ 226 227#include "llvm/Config/llvm-config.h" 228#include "llvm/Support/type_traits.h" 229#include <cerrno> 230#include <string> 231 232// This must be here instead of a .inc file because it is used in the definition 233// of the enum values below. 234#ifdef LLVM_ON_WIN32 235 236 // The following numbers were taken from VS2010. 237# ifndef EAFNOSUPPORT 238# define EAFNOSUPPORT 102 239# endif 240# ifndef EADDRINUSE 241# define EADDRINUSE 100 242# endif 243# ifndef EADDRNOTAVAIL 244# define EADDRNOTAVAIL 101 245# endif 246# ifndef EISCONN 247# define EISCONN 113 248# endif 249# ifndef E2BIG 250# define E2BIG 7 251# endif 252# ifndef EDOM 253# define EDOM 33 254# endif 255# ifndef EFAULT 256# define EFAULT 14 257# endif 258# ifndef EBADF 259# define EBADF 9 260# endif 261# ifndef EBADMSG 262# define EBADMSG 104 263# endif 264# ifndef EPIPE 265# define EPIPE 32 266# endif 267# ifndef ECONNABORTED 268# define ECONNABORTED 106 269# endif 270# ifndef EALREADY 271# define EALREADY 103 272# endif 273# ifndef ECONNREFUSED 274# define ECONNREFUSED 107 275# endif 276# ifndef ECONNRESET 277# define ECONNRESET 108 278# endif 279# ifndef EXDEV 280# define EXDEV 18 281# endif 282# ifndef EDESTADDRREQ 283# define EDESTADDRREQ 109 284# endif 285# ifndef EBUSY 286# define EBUSY 16 287# endif 288# ifndef ENOTEMPTY 289# define ENOTEMPTY 41 290# endif 291# ifndef ENOEXEC 292# define ENOEXEC 8 293# endif 294# ifndef EEXIST 295# define EEXIST 17 296# endif 297# ifndef EFBIG 298# define EFBIG 27 299# endif 300# ifndef ENAMETOOLONG 301# define ENAMETOOLONG 38 302# endif 303# ifndef ENOSYS 304# define ENOSYS 40 305# endif 306# ifndef EHOSTUNREACH 307# define EHOSTUNREACH 110 308# endif 309# ifndef EIDRM 310# define EIDRM 111 311# endif 312# ifndef EILSEQ 313# define EILSEQ 42 314# endif 315# ifndef ENOTTY 316# define ENOTTY 25 317# endif 318# ifndef EINTR 319# define EINTR 4 320# endif 321# ifndef EINVAL 322# define EINVAL 22 323# endif 324# ifndef ESPIPE 325# define ESPIPE 29 326# endif 327# ifndef EIO 328# define EIO 5 329# endif 330# ifndef EISDIR 331# define EISDIR 21 332# endif 333# ifndef EMSGSIZE 334# define EMSGSIZE 115 335# endif 336# ifndef ENETDOWN 337# define ENETDOWN 116 338# endif 339# ifndef ENETRESET 340# define ENETRESET 117 341# endif 342# ifndef ENETUNREACH 343# define ENETUNREACH 118 344# endif 345# ifndef ENOBUFS 346# define ENOBUFS 119 347# endif 348# ifndef ECHILD 349# define ECHILD 10 350# endif 351# ifndef ENOLINK 352# define ENOLINK 121 353# endif 354# ifndef ENOLCK 355# define ENOLCK 39 356# endif 357# ifndef ENODATA 358# define ENODATA 120 359# endif 360# ifndef ENOMSG 361# define ENOMSG 122 362# endif 363# ifndef ENOPROTOOPT 364# define ENOPROTOOPT 123 365# endif 366# ifndef ENOSPC 367# define ENOSPC 28 368# endif 369# ifndef ENOSR 370# define ENOSR 124 371# endif 372# ifndef ENXIO 373# define ENXIO 6 374# endif 375# ifndef ENODEV 376# define ENODEV 19 377# endif 378# ifndef ENOENT 379# define ENOENT 2 380# endif 381# ifndef ESRCH 382# define ESRCH 3 383# endif 384# ifndef ENOTDIR 385# define ENOTDIR 20 386# endif 387# ifndef ENOTSOCK 388# define ENOTSOCK 128 389# endif 390# ifndef ENOSTR 391# define ENOSTR 125 392# endif 393# ifndef ENOTCONN 394# define ENOTCONN 126 395# endif 396# ifndef ENOMEM 397# define ENOMEM 12 398# endif 399# ifndef ENOTSUP 400# define ENOTSUP 129 401# endif 402# ifndef ECANCELED 403# define ECANCELED 105 404# endif 405# ifndef EINPROGRESS 406# define EINPROGRESS 112 407# endif 408# ifndef EPERM 409# define EPERM 1 410# endif 411# ifndef EOPNOTSUPP 412# define EOPNOTSUPP 130 413# endif 414# ifndef EWOULDBLOCK 415# define EWOULDBLOCK 140 416# endif 417# ifndef EOWNERDEAD 418# define EOWNERDEAD 133 419# endif 420# ifndef EACCES 421# define EACCES 13 422# endif 423# ifndef EPROTO 424# define EPROTO 134 425# endif 426# ifndef EPROTONOSUPPORT 427# define EPROTONOSUPPORT 135 428# endif 429# ifndef EROFS 430# define EROFS 30 431# endif 432# ifndef EDEADLK 433# define EDEADLK 36 434# endif 435# ifndef EAGAIN 436# define EAGAIN 11 437# endif 438# ifndef ERANGE 439# define ERANGE 34 440# endif 441# ifndef ENOTRECOVERABLE 442# define ENOTRECOVERABLE 127 443# endif 444# ifndef ETIME 445# define ETIME 137 446# endif 447# ifndef ETXTBSY 448# define ETXTBSY 139 449# endif 450# ifndef ETIMEDOUT 451# define ETIMEDOUT 138 452# endif 453# ifndef ENFILE 454# define ENFILE 23 455# endif 456# ifndef EMFILE 457# define EMFILE 24 458# endif 459# ifndef EMLINK 460# define EMLINK 31 461# endif 462# ifndef ELOOP 463# define ELOOP 114 464# endif 465# ifndef EOVERFLOW 466# define EOVERFLOW 132 467# endif 468# ifndef EPROTOTYPE 469# define EPROTOTYPE 136 470# endif 471#endif 472 473namespace llvm { 474 475// is_error_code_enum 476 477template <class Tp> struct is_error_code_enum : public false_type {}; 478 479// is_error_condition_enum 480 481template <class Tp> struct is_error_condition_enum : public false_type {}; 482 483// Some error codes are not present on all platforms, so we provide equivalents 484// for them: 485 486//enum class errc 487struct errc { 488enum _ { 489 success = 0, 490 address_family_not_supported = EAFNOSUPPORT, 491 address_in_use = EADDRINUSE, 492 address_not_available = EADDRNOTAVAIL, 493 already_connected = EISCONN, 494 argument_list_too_long = E2BIG, 495 argument_out_of_domain = EDOM, 496 bad_address = EFAULT, 497 bad_file_descriptor = EBADF, 498#ifdef EBADMSG 499 bad_message = EBADMSG, 500#else 501 bad_message = EINVAL, 502#endif 503 broken_pipe = EPIPE, 504 connection_aborted = ECONNABORTED, 505 connection_already_in_progress = EALREADY, 506 connection_refused = ECONNREFUSED, 507 connection_reset = ECONNRESET, 508 cross_device_link = EXDEV, 509 destination_address_required = EDESTADDRREQ, 510 device_or_resource_busy = EBUSY, 511 directory_not_empty = ENOTEMPTY, 512 executable_format_error = ENOEXEC, 513 file_exists = EEXIST, 514 file_too_large = EFBIG, 515 filename_too_long = ENAMETOOLONG, 516 function_not_supported = ENOSYS, 517 host_unreachable = EHOSTUNREACH, 518 identifier_removed = EIDRM, 519 illegal_byte_sequence = EILSEQ, 520 inappropriate_io_control_operation = ENOTTY, 521 interrupted = EINTR, 522 invalid_argument = EINVAL, 523 invalid_seek = ESPIPE, 524 io_error = EIO, 525 is_a_directory = EISDIR, 526 message_size = EMSGSIZE, 527 network_down = ENETDOWN, 528 network_reset = ENETRESET, 529 network_unreachable = ENETUNREACH, 530 no_buffer_space = ENOBUFS, 531 no_child_process = ECHILD, 532#ifdef ENOLINK 533 no_link = ENOLINK, 534#else 535 no_link = EINVAL, 536#endif 537 no_lock_available = ENOLCK, 538#ifdef ENODATA 539 no_message_available = ENODATA, 540#else 541 no_message_available = ENOMSG, 542#endif 543 no_message = ENOMSG, 544 no_protocol_option = ENOPROTOOPT, 545 no_space_on_device = ENOSPC, 546#ifdef ENOSR 547 no_stream_resources = ENOSR, 548#else 549 no_stream_resources = ENOMEM, 550#endif 551 no_such_device_or_address = ENXIO, 552 no_such_device = ENODEV, 553 no_such_file_or_directory = ENOENT, 554 no_such_process = ESRCH, 555 not_a_directory = ENOTDIR, 556 not_a_socket = ENOTSOCK, 557#ifdef ENOSTR 558 not_a_stream = ENOSTR, 559#else 560 not_a_stream = EINVAL, 561#endif 562 not_connected = ENOTCONN, 563 not_enough_memory = ENOMEM, 564 not_supported = ENOTSUP, 565#ifdef ECANCELED 566 operation_canceled = ECANCELED, 567#else 568 operation_canceled = EINVAL, 569#endif 570 operation_in_progress = EINPROGRESS, 571 operation_not_permitted = EPERM, 572 operation_not_supported = EOPNOTSUPP, 573 operation_would_block = EWOULDBLOCK, 574#ifdef EOWNERDEAD 575 owner_dead = EOWNERDEAD, 576#else 577 owner_dead = EINVAL, 578#endif 579 permission_denied = EACCES, 580#ifdef EPROTO 581 protocol_error = EPROTO, 582#else 583 protocol_error = EINVAL, 584#endif 585 protocol_not_supported = EPROTONOSUPPORT, 586 read_only_file_system = EROFS, 587 resource_deadlock_would_occur = EDEADLK, 588 resource_unavailable_try_again = EAGAIN, 589 result_out_of_range = ERANGE, 590#ifdef ENOTRECOVERABLE 591 state_not_recoverable = ENOTRECOVERABLE, 592#else 593 state_not_recoverable = EINVAL, 594#endif 595#ifdef ETIME 596 stream_timeout = ETIME, 597#else 598 stream_timeout = ETIMEDOUT, 599#endif 600 text_file_busy = ETXTBSY, 601 timed_out = ETIMEDOUT, 602 too_many_files_open_in_system = ENFILE, 603 too_many_files_open = EMFILE, 604 too_many_links = EMLINK, 605 too_many_symbolic_link_levels = ELOOP, 606 value_too_large = EOVERFLOW, 607 wrong_protocol_type = EPROTOTYPE 608}; 609 610 _ v_; 611 612 errc(_ v) : v_(v) {} 613 operator int() const {return v_;} 614}; 615 616template <> struct is_error_condition_enum<errc> : true_type { }; 617 618template <> struct is_error_condition_enum<errc::_> : true_type { }; 619 620class error_condition; 621class error_code; 622 623// class error_category 624 625class _do_message; 626 627class error_category 628{ 629public: 630 virtual ~error_category(); 631 632private: 633 error_category(); 634 error_category(const error_category&) LLVM_DELETED_FUNCTION; 635 error_category& operator=(const error_category&) LLVM_DELETED_FUNCTION; 636 637public: 638 virtual const char* name() const = 0; 639 virtual error_condition default_error_condition(int _ev) const; 640 virtual bool equivalent(int _code, const error_condition& _condition) const; 641 virtual bool equivalent(const error_code& _code, int _condition) const; 642 virtual std::string message(int _ev) const = 0; 643 644 bool operator==(const error_category& _rhs) const {return this == &_rhs;} 645 646 bool operator!=(const error_category& _rhs) const {return !(*this == _rhs);} 647 648 bool operator< (const error_category& _rhs) const {return this < &_rhs;} 649 650 friend class _do_message; 651}; 652 653class _do_message : public error_category 654{ 655public: 656 virtual std::string message(int ev) const LLVM_OVERRIDE; 657}; 658 659const error_category& generic_category(); 660const error_category& system_category(); 661 662/// Get the error_category used for errno values from POSIX functions. This is 663/// the same as the system_category on POSIX systems, but is the same as the 664/// generic_category on Windows. 665const error_category& posix_category(); 666 667class error_condition 668{ 669 int _val_; 670 const error_category* _cat_; 671public: 672 error_condition() : _val_(0), _cat_(&generic_category()) {} 673 674 error_condition(int _val, const error_category& _cat) 675 : _val_(_val), _cat_(&_cat) {} 676 677 template <class E> 678 error_condition(E _e, typename enable_if_c< 679 is_error_condition_enum<E>::value 680 >::type* = 0) 681 {*this = make_error_condition(_e);} 682 683 void assign(int _val, const error_category& _cat) { 684 _val_ = _val; 685 _cat_ = &_cat; 686 } 687 688 template <class E> 689 typename enable_if_c 690 < 691 is_error_condition_enum<E>::value, 692 error_condition& 693 >::type 694 operator=(E _e) 695 {*this = make_error_condition(_e); return *this;} 696 697 void clear() { 698 _val_ = 0; 699 _cat_ = &generic_category(); 700 } 701 702 int value() const {return _val_;} 703 704 const error_category& category() const {return *_cat_;} 705 std::string message() const; 706 707 typedef void (*unspecified_bool_type)(); 708 static void unspecified_bool_true() {} 709 710 operator unspecified_bool_type() const { // true if error 711 return _val_ == 0 ? 0 : unspecified_bool_true; 712 } 713}; 714 715inline error_condition make_error_condition(errc _e) { 716 return error_condition(static_cast<int>(_e), generic_category()); 717} 718 719inline bool operator<(const error_condition& _x, const error_condition& _y) { 720 return _x.category() < _y.category() 721 || (_x.category() == _y.category() && _x.value() < _y.value()); 722} 723 724// error_code 725 726class error_code { 727 int _val_; 728 const error_category* _cat_; 729public: 730 error_code() : _val_(0), _cat_(&system_category()) {} 731 732 static error_code success() { 733 return error_code(); 734 } 735 736 error_code(int _val, const error_category& _cat) 737 : _val_(_val), _cat_(&_cat) {} 738 739 template <class E> 740 error_code(E _e, typename enable_if_c< 741 is_error_code_enum<E>::value 742 >::type* = 0) { 743 *this = make_error_code(_e); 744 } 745 746 void assign(int _val, const error_category& _cat) { 747 _val_ = _val; 748 _cat_ = &_cat; 749 } 750 751 template <class E> 752 typename enable_if_c 753 < 754 is_error_code_enum<E>::value, 755 error_code& 756 >::type 757 operator=(E _e) 758 {*this = make_error_code(_e); return *this;} 759 760 void clear() { 761 _val_ = 0; 762 _cat_ = &system_category(); 763 } 764 765 int value() const {return _val_;} 766 767 const error_category& category() const {return *_cat_;} 768 769 error_condition default_error_condition() const 770 {return _cat_->default_error_condition(_val_);} 771 772 std::string message() const; 773 774 typedef void (*unspecified_bool_type)(); 775 static void unspecified_bool_true() {} 776 777 operator unspecified_bool_type() const { // true if error 778 return _val_ == 0 ? 0 : unspecified_bool_true; 779 } 780}; 781 782inline error_code make_error_code(errc _e) { 783 return error_code(static_cast<int>(_e), generic_category()); 784} 785 786inline bool operator<(const error_code& _x, const error_code& _y) { 787 return _x.category() < _y.category() 788 || (_x.category() == _y.category() && _x.value() < _y.value()); 789} 790 791inline bool operator==(const error_code& _x, const error_code& _y) { 792 return _x.category() == _y.category() && _x.value() == _y.value(); 793} 794 795inline bool operator==(const error_code& _x, const error_condition& _y) { 796 return _x.category().equivalent(_x.value(), _y) 797 || _y.category().equivalent(_x, _y.value()); 798} 799 800inline bool operator==(const error_condition& _x, const error_code& _y) { 801 return _y == _x; 802} 803 804inline bool operator==(const error_condition& _x, const error_condition& _y) { 805 return _x.category() == _y.category() && _x.value() == _y.value(); 806} 807 808inline bool operator!=(const error_code& _x, const error_code& _y) { 809 return !(_x == _y); 810} 811 812inline bool operator!=(const error_code& _x, const error_condition& _y) { 813 return !(_x == _y); 814} 815 816inline bool operator!=(const error_condition& _x, const error_code& _y) { 817 return !(_x == _y); 818} 819 820inline bool operator!=(const error_condition& _x, const error_condition& _y) { 821 return !(_x == _y); 822} 823 824// Windows errors. 825 826// To construct an error_code after an API error: 827// 828// error_code( ::GetLastError(), system_category() ) 829struct windows_error { 830enum _ { 831 success = 0, 832 // These names and values are based on Windows WinError.h 833 // This is not a complete list. Add to this list if you need to explicitly 834 // check for it. 835 invalid_function = 1, // ERROR_INVALID_FUNCTION, 836 file_not_found = 2, // ERROR_FILE_NOT_FOUND, 837 path_not_found = 3, // ERROR_PATH_NOT_FOUND, 838 too_many_open_files = 4, // ERROR_TOO_MANY_OPEN_FILES, 839 access_denied = 5, // ERROR_ACCESS_DENIED, 840 invalid_handle = 6, // ERROR_INVALID_HANDLE, 841 arena_trashed = 7, // ERROR_ARENA_TRASHED, 842 not_enough_memory = 8, // ERROR_NOT_ENOUGH_MEMORY, 843 invalid_block = 9, // ERROR_INVALID_BLOCK, 844 bad_environment = 10, // ERROR_BAD_ENVIRONMENT, 845 bad_format = 11, // ERROR_BAD_FORMAT, 846 invalid_access = 12, // ERROR_INVALID_ACCESS, 847 outofmemory = 14, // ERROR_OUTOFMEMORY, 848 invalid_drive = 15, // ERROR_INVALID_DRIVE, 849 current_directory = 16, // ERROR_CURRENT_DIRECTORY, 850 not_same_device = 17, // ERROR_NOT_SAME_DEVICE, 851 no_more_files = 18, // ERROR_NO_MORE_FILES, 852 write_protect = 19, // ERROR_WRITE_PROTECT, 853 bad_unit = 20, // ERROR_BAD_UNIT, 854 not_ready = 21, // ERROR_NOT_READY, 855 bad_command = 22, // ERROR_BAD_COMMAND, 856 crc = 23, // ERROR_CRC, 857 bad_length = 24, // ERROR_BAD_LENGTH, 858 seek = 25, // ERROR_SEEK, 859 not_dos_disk = 26, // ERROR_NOT_DOS_DISK, 860 sector_not_found = 27, // ERROR_SECTOR_NOT_FOUND, 861 out_of_paper = 28, // ERROR_OUT_OF_PAPER, 862 write_fault = 29, // ERROR_WRITE_FAULT, 863 read_fault = 30, // ERROR_READ_FAULT, 864 gen_failure = 31, // ERROR_GEN_FAILURE, 865 sharing_violation = 32, // ERROR_SHARING_VIOLATION, 866 lock_violation = 33, // ERROR_LOCK_VIOLATION, 867 wrong_disk = 34, // ERROR_WRONG_DISK, 868 sharing_buffer_exceeded = 36, // ERROR_SHARING_BUFFER_EXCEEDED, 869 handle_eof = 38, // ERROR_HANDLE_EOF, 870 handle_disk_full = 39, // ERROR_HANDLE_DISK_FULL, 871 rem_not_list = 51, // ERROR_REM_NOT_LIST, 872 dup_name = 52, // ERROR_DUP_NAME, 873 bad_net_path = 53, // ERROR_BAD_NETPATH, 874 network_busy = 54, // ERROR_NETWORK_BUSY, 875 file_exists = 80, // ERROR_FILE_EXISTS, 876 cannot_make = 82, // ERROR_CANNOT_MAKE, 877 broken_pipe = 109, // ERROR_BROKEN_PIPE, 878 open_failed = 110, // ERROR_OPEN_FAILED, 879 buffer_overflow = 111, // ERROR_BUFFER_OVERFLOW, 880 disk_full = 112, // ERROR_DISK_FULL, 881 insufficient_buffer = 122, // ERROR_INSUFFICIENT_BUFFER, 882 lock_failed = 167, // ERROR_LOCK_FAILED, 883 busy = 170, // ERROR_BUSY, 884 cancel_violation = 173, // ERROR_CANCEL_VIOLATION, 885 already_exists = 183 // ERROR_ALREADY_EXISTS 886}; 887 _ v_; 888 889 windows_error(_ v) : v_(v) {} 890 explicit windows_error(int v) : v_(_(v)) {} 891 operator int() const {return v_;} 892}; 893 894 895template <> struct is_error_code_enum<windows_error> : true_type { }; 896 897template <> struct is_error_code_enum<windows_error::_> : true_type { }; 898 899inline error_code make_error_code(windows_error e) { 900 return error_code(static_cast<int>(e), system_category()); 901} 902 903} // end namespace llvm 904 905#endif 906