|
5 | 5 | /* */ |
6 | 6 | /* OpenPOWER HostBoot Project */ |
7 | 7 | /* */ |
8 | | -/* COPYRIGHT International Business Machines Corp. 2011,2014 */ |
| 8 | +/* Contributors Listed Below - COPYRIGHT 2011,2016 */ |
| 9 | +/* [+] International Business Machines Corp. */ |
| 10 | +/* */ |
9 | 11 | /* */ |
10 | 12 | /* Licensed under the Apache License, Version 2.0 (the "License"); */ |
11 | 13 | /* you may not use this file except in compliance with the License. */ |
|
23 | 25 | #ifndef _ERRNO_H |
24 | 26 | #define _ERRNO_H |
25 | 27 |
|
| 28 | +#include <map> |
| 29 | + |
| 30 | +// Map to to store strings of errorno codes |
| 31 | +typedef std::map<int, const char*> ErrorNoNames; |
| 32 | + |
| 33 | +// Add new ERRNO's to ErrorNoNames init function |
26 | 34 | #define ENOENT 2 // No such file or directory |
27 | 35 | #define EIO 5 // I/O error |
28 | 36 | #define ENXIO 6 // No such device or address |
29 | 37 | #define ENOEXEC 8 // Exec format error |
30 | 38 | #define EBADF 9 // Bad file descriptor |
31 | 39 | #define EAGAIN 11 // Try again |
32 | | -#define EFAULT 14 // Bad address |
| 40 | +#define EACCES 13 // Permission denied |
| 41 | +#define EFAULT 14 // Bad address |
33 | 42 | #define EINVAL 22 // Invalid argument |
34 | 43 | #define ENFILE 23 // Too many open files in system |
35 | 44 | #define EDEADLK 35 // Operation would cause deadlock. |
|
38 | 47 |
|
39 | 48 | #define EWOULDBLOCK EAGAIN // operation would block |
40 | 49 |
|
| 50 | +// @Brief Initialize an ErrorNoNames map |
| 51 | +// Note: All keys and values are preceded with a '-', this is because the |
| 52 | +// the errno's will be set to 2's complement when there's an error. |
| 53 | +inline ErrorNoNames init_map() |
| 54 | +{ |
| 55 | + ErrorNoNames l_map; |
| 56 | + l_map[-ENOENT] = "-ENOENT"; |
| 57 | + l_map[-EIO] = "-EIO"; |
| 58 | + l_map[-ENXIO] = "-ENXIO"; |
| 59 | + l_map[-ENOEXEC] = "-ENOEXEC"; |
| 60 | + l_map[-EBADF] = "-EBADF"; |
| 61 | + l_map[-EAGAIN] = "-EAGAIN"; |
| 62 | + l_map[-EACCES] = "-EACCES"; |
| 63 | + l_map[-EFAULT] = "-EFAULT"; |
| 64 | + l_map[-EINVAL] = "-EINVAL"; |
| 65 | + l_map[-ENFILE] = "-ENFILE"; |
| 66 | + l_map[-EDEADLK] = "-EDEADLK"; |
| 67 | + l_map[-ETIME] = "-ETIME"; |
| 68 | + l_map[-EALREADY] = "-EALREADY"; |
| 69 | + l_map[-EWOULDBLOCK] = "-EWOULDBLOCK"; |
| 70 | + return l_map; |
| 71 | +}; |
| 72 | + |
41 | 73 | #endif |
0 commit comments