Okay, I made a try myself via guessing/searching/reading.
Here attached is my SunOS.c (using Solaris 10/11 event ports). I have 2
questions:
- Can anyone knowledgeable verify this code ?
- How can I verify this actually works (next to installing and testing
from ruby) ?
FYI I compiled the progam (using opencsw.org gcc-4.8.0 and gmake-4.0) like
this:
- in Makefile:
- remove "-Werror" from CFLAGS
- set LDFLAGS to -lsocket -lnsl
- install the SunOS.c
- CC=gcc gmake
Thanks,
Pierre
On Tuesday, April 29, 2014 2:38:06 PM UTC+2, Pierre Dehaen wrote:
>
> Hi,
>
> I tried to compile v1.9 on Solaris 11 but obviously a SunOS.c file is
> missing. The darwin.c and linux.c do not work as Solaris does not have
> kqueue() nor epoll().
>
> Can anyone provide some information on the 4 functions for which a Solaris
> equivalent must be written ? I'm not an expert but I might maybe have a
> look... who knows, maybe with the linux/darwin.c files and some
> explanations, the man pages, some examples on the Internet, it might do...
>
> TIA
>
--
You received this message because you are subscribed to the Google Groups
"beanstalk-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/beanstalk-talk.
For more options, visit https://groups.google.com/d/optout.
#include <port.h>
#include <sys/poll.h>
#include <stdint.h>
#include <fcntl.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/time.h>
#include "dat.h"
static int port;
/* Allocate disk space.
* Expects fd's offset to be 0; may also reset fd's offset to 0.
* Returns 0 on success, and a positive errno otherwise. */
int
rawfalloc(int fd, int len)
{
return posix_fallocate(fd, 0, len);
}
int
sockinit(void)
{
port = port_create();
if (port == -1) {
twarn("port_create");
return -1;
}
return 0;
}
int
sockwant(Socket *s, int rw)
{
int events;
if (!s->added && !rw) {
return 0;
} else if (!s->added && rw) {
s->added = 1;
} else if (!rw) {
return port_dissociate(port, PORT_SOURCE_FD, s->fd);
}
switch (rw) {
case 'r':
events = POLLIN | POLLHUP | POLLPRI;
break;
case 'w':
events = POLLOUT | POLLWRBAND;
break;
default:
/* not very useful as POLLHUP is a revent only */
events = POLLHUP;
break;
}
return port_associate(port, PORT_SOURCE_FD, s->fd, events, s);
}
int
socknext(Socket **s, int64 timeout)
{
int r;
struct port_event ev;
static struct timespec ts;
ts.tv_sec = timeout / 1000000000;
ts.tv_nsec = timeout % 1000000000;
r = port_get(port, &ev, &ts);
if (r == -1 && errno != EINTR) {
twarn("port_get");
exit(1);
}
if (r && ev.portev_source == PORT_SOURCE_FD) {
*s = (Socket *)ev.portev_user;
if (ev.portev_events & (POLLHUP)) {
return 'h';
} else if (ev.portev_events & POLLIN) {
return 'r';
} else if (ev.portev_events & POLLOUT) {
return 'w';
}
}
return 0;
}