pal_error.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* Copyright (C) 2014 Stony Brook University
  2. This file is part of Graphene Library OS.
  3. Graphene Library OS is free software: you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public License
  5. as published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. Graphene Library OS is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  13. /*
  14. * pal_error.h
  15. *
  16. * This file contains definitions of PAL error codes.
  17. */
  18. #ifndef PAL_ERROR_H
  19. #define PAL_ERROR_H
  20. #define PAL_ERROR_NOTIMPLEMENTED 1
  21. #define PAL_ERROR_NOTDEFINED 2
  22. #define PAL_ERROR_NOTSUPPORT 3
  23. #define PAL_ERROR_INVAL 4
  24. #define PAL_ERROR_TOOLONG 5
  25. #define PAL_ERROR_DENIED 6
  26. #define PAL_ERROR_BADHANDLE 7
  27. #define PAL_ERROR_STREAMEXIST 8
  28. #define PAL_ERROR_STREAMNOTEXIST 9
  29. #define PAL_ERROR_STREAMISFILE 10
  30. #define PAL_ERROR_STREAMISDIR 11
  31. #define PAL_ERROR_STREAMISDEVICE 12
  32. #define PAL_ERROR_INTERRUPTED 13
  33. #define PAL_ERROR_OVERFLOW 14
  34. #define PAL_ERROR_BADADDR 15
  35. #define PAL_ERROR_NOMEM 16
  36. #define PAL_ERROR_NOTKILLABLE 17
  37. #define PAL_ERROR_INCONSIST 18
  38. #define PAL_ERROR_TRYAGAIN 19
  39. #define PAL_ERROR_ENDOFSTREAM 20
  40. #define PAL_ERROR_NOTSERVER 21
  41. #define PAL_ERROR_NOTCONNECTION 22
  42. #define PAL_ERROR_ZEROSIZE 23
  43. #define PAL_ERROR_CONNFAILED 24
  44. #define PAL_ERROR_ADDRNOTEXIST 25
  45. #define PAL_ERROR_BOUND 25
  46. static const char* pal_errstring[]
  47. #ifdef __GNUC__
  48. __attribute__((unused))
  49. #endif
  50. = {
  51. /* 0. */ "Success",
  52. /* 1. */ "Function not implemented",
  53. /* 2. */ "Symbol not defined",
  54. /* 3. */ "Function not supported",
  55. /* 4. */ "Invalid argument",
  56. /* 5. */ "Name/Path is too long",
  57. /* 6. */ "Operation Denied",
  58. /* 7. */ "Handle Corrupted",
  59. /* 8. */ "Stream already exists",
  60. /* 9. */ "Stream does not exists",
  61. /* 10. */ "Stream is File",
  62. /* 11. */ "Stream is Directory",
  63. /* 12. */ "Stream is Device",
  64. /* 13. */ "Operation interrupted",
  65. /* 14. */ "Buffer overflowed",
  66. /* 15. */ "Invalid address",
  67. /* 16. */ "Not enough memory",
  68. /* 17. */ "Thread state unkillable",
  69. /* 18. */ "Inconsistent system state",
  70. /* 19. */ "Try again",
  71. /* 20. */ "End of stream",
  72. /* 21. */ "Not a server",
  73. /* 22. */ "Not a connection",
  74. /* 23. */ "Zero size",
  75. /* 24. */ "Connection failed",
  76. /* 25. */ "Resource address not exist",
  77. };
  78. static inline const char* PAL_STRERROR(int err) {
  79. int _e = -err;
  80. if (_e >= 0 && _e <= PAL_ERROR_BOUND)
  81. return pal_errstring[_e];
  82. return "Unknown error";
  83. }
  84. #endif