select function

Mark Mussetter mark at link-comm.com
Thu Feb 5 00:13:34 UTC 2004


Hello Everyone,

I'm working on a project that is based on a motorola 5272 running 
RTEMS.  I'm also using fltk1.1.4, nxlib, and microwindows in the project.

I'm getting an undefined reference to 'select' error when I build my 
project.  In a fltk file called Fl_x.cxx, the function fl_wait() references 
two functions called select() and poll().

The following is a clip from the fl_wait() function:

<SNIP>
#  if USE_POLL
     n = ::poll(pollfds, nfds, int(time_to_wait*1000 + .5));
#  else
     timeval t;
     t.tv_sec = int(time_to_wait);
     t.tv_usec = int(1000000 * (time_to_wait-t.tv_sec));
     n = ::select(maxfd+1,&fdt[0],&fdt[1],&fdt[2],&t);
#  endif
<END SNIP>

Here's my question:  Is there an RTEMS equivalent of one of these functions?

Currently I can get the project to build by adding conditionals that just 
make the function return, but I doubt that this will be a valid solution.

Any help on this matter would be greatly appreciated.

Thanks,

Mark Mussetter
Link Communications, Inc.
email: <mailto:mark at link-comm.com>mark at link-comm.com


The entire fl_wait() function follows:
<SNIP>
// This is never called with time_to_wait < 0.0:
// It should return negative on error, 0 if nothing happens before
// timeout, and >0 if any callbacks were done.
int fl_wait(double time_to_wait) {

   // OpenGL and other broken libraries call XEventsQueued
   // unnecessarily and thus cause the file descriptor to not be ready,
   // so we must check for already-read events:
   if (fl_display && XQLength(fl_display)) {do_queued_events(); return 1;}

#  if !USE_POLL
   fd_set fdt[3];
   fdt[0] = fdsets[0];
   fdt[1] = fdsets[1];
   fdt[2] = fdsets[2];
#  endif
   int n;

   fl_unlock_function();

   if (time_to_wait < 2147483.648) {
#  if USE_POLL
     n = ::poll(pollfds, nfds, int(time_to_wait*1000 + .5));
#  else
     timeval t;
     t.tv_sec = int(time_to_wait);
     t.tv_usec = int(1000000 * (time_to_wait-t.tv_sec));
     n = ::select(maxfd+1,&fdt[0],&fdt[1],&fdt[2],&t);
#  endif
   } else {
#  if USE_POLL
     n = ::poll(pollfds, nfds, -1);
#  else
     n = ::select(maxfd+1,&fdt[0],&fdt[1],&fdt[2],0);
#  endif
   }

   fl_lock_function();

   if (n > 0) {
     for (int i=0; i<nfds; i++) {
#  if USE_POLL
       if (pollfds[i].revents) fd[i].cb(pollfds[i].fd, fd[i].arg);
#  else
       int f = fd[i].fd;
       short revents = 0;
       if (FD_ISSET(f,&fdt[0])) revents |= POLLIN;
       if (FD_ISSET(f,&fdt[1])) revents |= POLLOUT;
       if (FD_ISSET(f,&fdt[2])) revents |= POLLERR;
       if (fd[i].events & revents) fd[i].cb(f, fd[i].arg);
#  endif
     }
   }
   return n;
}
<END SNIP>




More information about the users mailing list