< prev index next >
src/os/aix/vm/misc_aix.cpp
Print this page
rev 9449 : 8143125-Further Developments for AIX
@@ -24,10 +24,12 @@
#include "misc_aix.hpp"
#include "runtime/stubRoutines.hpp"
#include <pthread.h>
+#include <unistd.h>
+#include <errno.h>
void MiscUtils::init_critsect(MiscUtils::critsect_t* cs) {
const int rc = pthread_mutex_init(cs, NULL);
assert0(rc == 0);
}
@@ -56,6 +58,238 @@
int deadbeef = 0xdeadbeef;
return (SafeFetch32(aligned, cafebabe) != cafebabe) ||
(SafeFetch32(aligned, deadbeef) != deadbeef);
}
+const char* MiscUtils::describe_errno(int err_no) {
+ switch (err_no) {
+ case E2BIG: return "E2BIG";
+ case EACCES: return "EACCES";
+#ifdef EADDRINUSE
+ case EADDRINUSE: return "EADDRINUSE";
+#endif
+#ifdef EADDRNOTAVAIL
+ case EADDRNOTAVAIL: return "EADDRNOTAVAIL";
+#endif
+#ifdef EAFNOSUPPORT
+ case EAFNOSUPPORT: return "EAFNOSUPPORT";
+#endif
+ case EAGAIN: return "EAGAIN";
+#ifdef EALREADY
+ case EALREADY: return "EALREADY";
+#endif
+ case EBADF: return "EBADF";
+#ifdef EBADMSG
+ case EBADMSG: return "EBADMSG";
+#endif
+ case EBUSY: return "EBUSY";
+#ifdef ECANCELED
+ case ECANCELED: return "ECANCELED";
+#endif
+#ifdef ECHILD
+ case ECHILD: return "ECHILD";
+#endif
+#ifdef ECONNABORTED
+ case ECONNABORTED: return "ECONNABORTED";
+#endif
+#ifdef ECONNREFUSED
+ case ECONNREFUSED: return "ECONNREFUSED";
+#endif
+#ifdef ECONNRESET
+ case ECONNRESET: return "ECONNRESET";
+#endif
+#ifdef EDEADLK
+ case EDEADLK: return "EDEADLK";
+#endif
+#ifdef EDESTADDRREQ
+ case EDESTADDRREQ: return "EDESTADDRREQ";
+#endif
+#ifdef EDOM
+ case EDOM: return "EDOM";
+#endif
+#ifdef EDQUOT
+ case EDQUOT: return "EDQUOT";
+#endif
+#ifdef EEXIST
+ case EEXIST: return "EEXIST";
+#endif
+ case EFAULT: return "EFAULT";
+#ifdef EFBIG
+ case EFBIG: return "EFBIG";
+#endif
+#ifdef EHOSTUNREACH
+ case EHOSTUNREACH: return "EHOSTUNREACH";
+#endif
+#ifdef EIDRM
+ case EIDRM: return "EIDRM";
+#endif
+#ifdef EILSEQ
+ case EILSEQ: return "EILSEQ";
+#endif
+#ifdef EINPROGRESS
+ case EINPROGRESS: return "EINPROGRESS";
+#endif
+ case EINTR: return "EINTR";
+ case EINVAL: return "EINVAL";
+#ifdef EIO
+ case EIO: return "EIO";
+#endif
+#ifdef EISCONN
+ case EISCONN: return "EISCONN";
+#endif
+ case EISDIR: return "EISDIR";
+#ifdef ELOOP
+ case ELOOP: return "ELOOP";
+#endif
+#ifdef EMFILE
+ case EMFILE: return "EMFILE";
+#endif
+#ifdef EMLINK
+ case EMLINK: return "EMLINK";
+#endif
+#ifdef EMSGSIZE
+ case EMSGSIZE: return "EMSGSIZE";
+#endif
+#ifdef EMULTIHOP
+ case EMULTIHOP: return "EMULTIHOP";
+#endif
+ case ENAMETOOLONG: return "ENAMETOOLONG";
+#ifdef ENETDOWN
+ case ENETDOWN: return "ENETDOWN";
+#endif
+#ifdef ENETRESET
+ case ENETRESET: return "ENETRESET";
+#endif
+#ifdef ENETUNREACH
+ case ENETUNREACH: return "ENETUNREACH";
+#endif
+#ifdef ENFILE
+ case ENFILE: return "ENFILE";
+#endif
+#ifdef ENOBUFS
+ case ENOBUFS: return "ENOBUFS";
+#endif
+#ifdef ENODATA
+ case ENODATA: return "ENODATA";
+#endif
+#ifdef ENODEV
+ case ENODEV: return "ENODEV";
+#endif
+ case ENOENT: return "ENOENT";
+#ifdef ENOEXEC
+ case ENOEXEC: return "ENOEXEC";
+#endif
+#ifdef ENOLCK
+ case ENOLCK: return "ENOLCK";
+#endif
+#ifdef ENOLINK
+ case ENOLINK: return "ENOLINK";
+#endif
+ case ENOMEM: return "ENOMEM";
+#ifdef ENOMSG
+ case ENOMSG: return "ENOMSG";
+#endif
+#ifdef ENOPROTOOPT
+ case ENOPROTOOPT: return "ENOPROTOOPT";
+#endif
+#ifdef ENOSPC
+ case ENOSPC: return "ENOSPC";
+#endif
+#ifdef ENOSR
+ case ENOSR: return "ENOSR";
+#endif
+#ifdef ENOSTR
+ case ENOSTR: return "ENOSTR";
+#endif
+#ifdef ENOSYS
+ case ENOSYS: return "ENOSYS";
+#endif
+#ifdef ENOTCONN
+ case ENOTCONN: return "ENOTCONN";
+#endif
+#ifdef ENOTDIR
+ case ENOTDIR: return "ENOTDIR";
+#endif
+// AIX: ENOTEMPTY == EEXIST
+#if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST)
+ case ENOTEMPTY: return "ENOTEMPTY";
+#endif
+#ifdef ENOTSOCK
+ case ENOTSOCK: return "ENOTSOCK";
+#endif
+#ifdef ENOTSUP
+ case ENOTSUP: return "ENOTSUP";
+#endif
+#ifdef ENOTTY
+ case ENOTTY: return "ENOTTY";
+#endif
+#ifdef ENXIO
+ case ENXIO: return "ENXIO";
+#endif
+// on some unices EOPNOTSUPP==ENOTSUPP
+#if defined(ENOTSUP) && defined(EOPNOTSUPP) && (EOPNOTSUPP != ENOTSUP)
+ case EOPNOTSUPP: return "EOPNOTSUPP";
+#endif
+#ifdef EOVERFLOW
+ case EOVERFLOW: return "EOVERFLOW";
+#endif
+#ifdef EPERM
+ case EPERM: return "EPERM";
+#endif
+#ifdef EPIPE
+ case EPIPE: return "EPIPE";
+#endif
+#ifdef EPROTO
+ case EPROTO: return "EPROTO";
+#endif
+#ifdef EPROTONOSUPPORT
+ case EPROTONOSUPPORT: return "EPROTONOSUPPORT";
+#endif
+#ifdef EPROTOTYPE
+ case EPROTOTYPE: return "EPROTOTYPE";
+#endif
+ case ERANGE: return "ERANGE";
+#ifdef EROFS
+ case EROFS: return "EROFS";
+#endif
+#ifdef ESPIPE
+ case ESPIPE: return "ESPIPE";
+#endif
+#ifdef ESRCH
+ case ESRCH: return "ESRCH";
+#endif
+#ifdef ESTALE
+ case ESTALE: return "ESTALE";
+#endif
+#ifdef ETIME
+ case ETIME: return "ETIME";
+#endif
+#ifdef ETIMEDOUT
+ case ETIMEDOUT: return "ETIMEDOUT";
+#endif
+#ifdef ETXTBSY
+ case ETXTBSY: return "ETXTBSY";
+#endif
+// on some unices EWOULDBLOCK==EAGAIN
+#if defined(EWOULDBLOCK) && (EWOULDBLOCK != EAGAIN)
+ case EWOULDBLOCK: return "EWOULDBLOCK";
+#endif
+#ifdef EXDEV
+ case EXDEV: return "EXDEV";
+#endif
+ default: return "unknown";
+ }
+}
+
+void MiscUtils::sleep_ms(int milliseconds) {
+ // from usleep() manpage:
+ // "The useconds argument must be less than 1,000,000 "
+ // fallback to sleep for that.
+ if (milliseconds >= 1000) {
+ const int seconds = (milliseconds / 1000) + 1;
+ ::sleep(seconds);
+ }
+
+ ::usleep(milliseconds * 1000);
+}
+
< prev index next >