touched up code a bit

This commit is contained in:
hyunghwan.chung 2018-11-01 14:17:40 +00:00
parent 5580b1abc2
commit 4edebb2a45
2 changed files with 60 additions and 5 deletions

View File

@ -228,6 +228,10 @@ static const moo_ooch_t* synerr_to_errstr (moo_synerrnum_t errnum)
moo_errnum_t moo_syserr_to_errnum (int e)
{
#if 0
/* -------------------------------------- */
/* currently 'e' is expected to be 'errno'. it doesn't support GetLastError() on win32 or APIRET on os2 yet */
/* -------------------------------------- */
#if defined(__OS2__)
/* APIRET e */
switch (e)
@ -268,6 +272,7 @@ moo_errnum_t moo_syserr_to_errnum (int e)
}
#else
switch (e)
{
case ENOMEM: return MOO_ESYSMEM;
@ -315,6 +320,57 @@ moo_errnum_t moo_syserr_to_errnum (int e)
default: return MOO_ESYSERR;
}
#endif
#else
/* ------------------------------------------------------------------- */
switch (e)
{
case ENOMEM: return MOO_ESYSMEM;
case EINVAL: return MOO_EINVAL;
#if defined(EBUSY)
case EBUSY: return MOO_EBUSY;
#endif
case EACCES: return MOO_EACCES;
#if defined(EPERM)
case EPERM: return MOO_EPERM;
#endif
#if defined(ENOTDIR)
case ENOTDIR: return MOO_ENOTDIR;
#endif
case ENOENT: return MOO_ENOENT;
#if defined(EEXIST)
case EEXIST: return MOO_EEXIST;
#endif
#if defined(EINTR)
case EINTR: return MOO_EINTR;
#endif
#if defined(EPIPE)
case EPIPE: return MOO_EPIPE;
#endif
#if defined(EAGAIN) && defined(EWOULDBLOCK) && (EAGAIN != EWOULDBLOCK)
case EAGAIN:
case EWOULDBLOCK: return MOO_EAGAIN;
#elif defined(EAGAIN)
case EAGAIN: return MOO_EAGAIN;
#elif defined(EWOULDBLOCK)
case EWOULDBLOCK: return MOO_EAGAIN;
#endif
#if defined(EBADF)
case EBADF: return MOO_EBADHND;
#endif
#if defined(EIO)
case EIO: return MOO_EIOERR;
#endif
default: return MOO_ESYSERR;
}
/* ------------------------------------------------------------------- */
#endif
}
/* --------------------------------------------------------------------------

View File

@ -48,7 +48,6 @@
# define USE_LTDL
# else
# define USE_WIN_DLL
/* TODO: write sys_dl_error() properly */
# define sys_dl_error() win_dlerror()
# define sys_dl_open(x) LoadLibraryExA(x, MOO_NULL, 0)
# define sys_dl_openext(x) LoadLibraryExA(x, MOO_NULL, 0)
@ -1176,7 +1175,7 @@ static int _add_poll_fd (moo_t* moo, int fd, int event_mask)
ev.fd = fd;
ev.events = event_mask;
ev.revents = 0;
if (write (xtn->ep, &ev, MOO_SIZEOF(ev)) != MOO_SIZEOF(ev))
if (write(xtn->ep, &ev, MOO_SIZEOF(ev)) != MOO_SIZEOF(ev))
{
moo_seterrwithsyserr (moo, errno);
MOO_DEBUG2 (moo, "Cannot add file descriptor %d to devpoll - %hs\n", fd, strerror(errno));
@ -1383,7 +1382,7 @@ static int _mod_poll_fd (moo_t* moo, int fd, int event_mask)
ev.events |= EPOLLET;
#endif
ev.data.fd = fd;
if (epoll_ctl (xtn->ep, EPOLL_CTL_MOD, fd, &ev) == -1)
if (epoll_ctl(xtn->ep, EPOLL_CTL_MOD, fd, &ev) == -1)
{
moo_seterrwithsyserr (moo, errno);
MOO_DEBUG2 (moo, "Cannot modify file descriptor %d in epoll - %hs\n", fd, strerror(errno));
@ -1455,7 +1454,7 @@ static int vm_startup (moo_t* moo)
#endif
#if defined(USE_DEVPOLL)
xtn->ep = open ("/dev/poll", O_RDWR);
xtn->ep = open("/dev/poll", O_RDWR);
if (xtn->ep == -1)
{
moo_seterrwithsyserr (moo, errno);
@ -1463,7 +1462,7 @@ static int vm_startup (moo_t* moo)
goto oops;
}
flag = fcntl (xtn->ep, F_GETFD);
flag = fcntl(xtn->ep, F_GETFD);
if (flag >= 0) fcntl (xtn->ep, F_SETFD, flag | FD_CLOEXEC);
#elif defined(USE_EPOLL)