pal_error.h 3.4 KB

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