Move libcds 1.6.0 from SVN
[libcds.git] / cds / os / posix / syserror.h
1 //$$CDS-header$$
2
3 #ifndef __CDS_OS_POSIX_SYSERROR_H
4 #define __CDS_OS_POSIX_SYSERROR_H
5
6 #include <stdlib.h>     // system
7 #include <pthread.h>
8 #include <sched.h>
9 #include <cerrno>
10 #include <cstdlib>
11 #include <string>
12 #include <string.h>
13
14 namespace cds { namespace OS {
15     namespace posix {
16         /// Posix error code type
17         typedef int                error_code;
18
19         /// Get text for system error \p nCode
20         static inline std::string getSystemErrorText( error_code nCode )
21         {
22             char *msg = strerror( nCode );
23             return std::string( msg );
24         }
25
26         /// Get curent error code (returns \p errno)
27         static inline error_code  getErrorCode()
28         {
29             return errno;
30         }
31
32     }    // namespace posix
33
34     using posix::error_code;
35     using posix::getErrorCode;
36     using posix::getSystemErrorText;
37 }} // namespace cds::OS
38
39
40 #endif // #ifndef __CDS_OS_POSIX_SYSERROR_H