/* 
 * machine.c
 *
 * x-kernel v3.3
 *
 * Copyright (c) 1993,1991,1990,1996  Arizona Board of Regents
 *
 * $Revision: 1.3 $
 * $Date: 1996/02/01 15:23:16 $
 * 
 * HISTORY
 * $Log: machine.c,v $
 * Revision 1.3  1996/02/01 15:23:16  slm
 * Updated copyright and version.
 *
 * Revision 1.2  1995/08/28  16:16:38  acb
 * Initial revision for x3.3
 *
 * Revision 1.2  1994/11/22  21:23:28  hkaram
 * Changed Pfi to Ptrfi
 *
 * Revision 1.1  1994/10/26  20:48:59  hkaram
 * Initial revision
 */

#include <sys/time.h>

#include "xk_debug.h"
#include "upi.h"
#include "platform.h"

extern int SignalsPossible;

int inInterrupt;

/* don't know how many sockets we should allow for */
/* update this in [udp,tcp].c too */
#define NUMSOCKETSICANUSE 30
extern  int     errno;

void
cancelSignalHandler(sock)
int sock;
{
}

void
installSignalHandler(sock, f)
int sock;
Ptrfi f;
{
}

void
xholdsignals(sock)
int sock;
{
}

void
xreleasesignals(sock)
int sock;
{
}

void
findsocket()
{
}

void
fixFileMask()
{
}

void
dispatch(interruptNo)
int interruptNo;
{
}

struct itimerval i_value, i_zero;

#define handlerresulttype void
typedef handlerresulttype (*handlertype)();

void definehandler(int, handlertype);

void
onfault(h)
handlertype h;
{
}

void sig_int_handler();
void event_handler();


void
sig_int_handler()
{

}


/*
int sig_int_handler();
void event_handler();
*/

/*#ifdef XKCLOCK_WITH_SIGNALS*/
void
init_clock()
{
  errno = 0;

  definehandler(SIGPIPE, SIG_IGN);
  definehandler(SIGINT, (handlertype) sig_int_handler);
  definehandler(SIGIO,  (handlertype) dispatch);
  definehandler(SIGURG,  (handlertype) dispatch);

  /* start event processor */
  CreateProcess((Ptrfi)event_handler, 5/*THREAD_MAXPRIO*/, 1, 0);   /* LSB */

  if (errno)
    perror("init_clock:");
  return;
}
/*#endif XKCLOCK_WITH_SIGNALS*/

#ifdef READ_CLOCK
int
read_clock(msec)        /* returns the number of msec */
long    *msec;          /* since sometime in late 1986 */
{
  struct  timeval   time;
  struct  timezone  zone;

  gettimeofday(&time, &zone);
  *msec = (time.tv_sec - 500000000)*1000 + (time.tv_usec / 1000);
  return(0);
}
#endif READ_CLOCK


void
definehandler(sig, handler)
int sig;
handlertype handler;
{
}

void signal_handler(sigid, handler)
int sigid;
handlertype handler;
{
}

int state;
int state_int;

void event_handler()
{
  xk_master_unlock();

  for (;;) {
    xk_master_lock();
    clock_ih();
    xk_master_unlock();
  }
}
