ftp.nice.ch/Attic/openStep/implementation/gnustep/sources/alpha-snapshots/pthreads.0.9.2.tgz#/pthreads-0.9.2/socklib/sendmsg.c

This is sendmsg.c in view mode; [Download] [Up]

#include "pthread_socket.h"
#include "pthread_io_delay.h"

extern void fd_init( void );
extern pthread_once_t io_initialized;

static inline
_syscall2(long,socketcall,int,call,unsigned long *,args); 

static int 
syscall_sendmsg( int fd, const struct msghdr *msg, unsigned int flags )
{
   unsigned long args[3];
   int ret;

   args[0] = (unsigned long) fd;
   args[1] = (unsigned long) msg;
   args[2] = (unsigned long) flags;

   LOCK_ON

       ret = socketcall( SYS_SENDMSG, args );

   LOCK_OFF

   return( ret );
}

/*--------------------------------------------------------------------------
 * @@          S E N D M S G
 *-------------------------------------------------------------------------*/
int 
sendmsg( int fd, const struct msghdr *msg, unsigned int flags )
{
   int ret, err, st;

   st = pthread_once( &io_initialized, fd_init );
   if( st != SUCCESS )
       return( NOTOK );

   if( nonblock_is_set( fd ))
   {
       ret = syscall_sendmsg( fd, msg, flags );
       RETURN( ret );
   }

   set_fd_nonblock( fd );
   while( (ret = syscall_sendmsg( fd, msg, flags )) < OK )
   {
       (void) pthread_get_errno_np( NULL, &err );
       if( err != EWOULDBLOCK )
           break;

       pthread_delay_np( &delay_interval );
   }

   clear_fd_nonblock( fd );
   return( ret );
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.