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