#ident "$Header: bsdsigs.c 1.1 89/02/23 $"

/*
 * $Copyright:	$
 * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
 * Sequent Computer Systems, Inc.   All rights reserved.
 *  
 * This software is furnished under a license and may be used
 * only in accordance with the terms of that license and with the
 * inclusion of the above copyright notice.   This software may not
 * be provided or otherwise made available to, or used by, any
 * other person.  No title to or ownership of the software is
 * hereby transferred.
 */

/*
 * implement the POSIX signal set using native dynix3.0 system calls.
 */

#ifdef CROSS

#include	"/usr/.include/sys/signal.h"

typedef	int	sigset_t;

struct	sigaction {
	void		(*sa_handler)(); /* SIG_DFL, SIG_IGN, or pointer */
					 /* to a function                */
	sigset_t	sa_mask;	 /* set of signals to be blocked */
					 /* during execution of signal-  */
					 /* catching function            */
	int		sa_flags;	 /* spcial flags to be used when */
					 /* delivering signal 		 */
};

#define SIG_BLOCK	1
#define SIG_UNBLOCK	2
#define SIG_SETMASK	3

sigemptyset(set)
sigset_t	*set;
{
	*set = 0;
	return 0;
}
sigfillset(set)
sigset_t	*set;
{
	*set = -1;
	return 0;
}

sigaction(sig, newset, oldset)
int	sig;
struct sigaction *newset;
struct sigaction *oldset;
{
	struct	sigvec	new;
	struct	sigvec	old;

	new.sv_handler = (int (*)())newset->sa_handler;
	new.sv_mask = (int)newset->sa_mask;
	new.sv_onstack = 0;
	if (_sigvec(sig, &new, &old) == -1)
		return -1;
	if (oldset) {
		oldset->sa_handler = (void (*)())old.sv_handler;
		oldset->sa_mask = (sigset_t)old.sv_mask;
		oldset->sa_flags = 0;
	} 
	return 0;
}

sigprocmask(how,new,old)
int		how;
sigset_t	*new;
sigset_t	*old;
{
	int	tmp;

	switch(how) {
	case SIG_BLOCK:
		if (old)
			*old = (sigset_t)_sigblock((int)*new);
		else
			(void)_sigblock((int)*new);
		return 0;
	case SIG_UNBLOCK:
		tmp = _sigblock(0);
		tmp &= ~((int)*new);
		if (old)
			*old = (sigset_t)_sigsetmask(tmp);
		else
			(void)_sigsetmask(tmp);
	case SIG_SETMASK:
		if (old)
			*old = (sigset_t)_sigsetmask((int)*new);
		else
			(void)_sigsetmask((int)*new);
		return 0;
	default:
		return -1;
	}
}

sigaddset(set, sig)
sigset_t	*set;
int		sig;
{
	*set |= (1<<(sig-1));
	return 0;
}

sigdelset(set, sig)
sigset_t	*set;
int		sig;
{
	*set &= ~(1<<(sig-1));
	return 0;
}

sigcontext(item, addr)
int	item;
int	*addr;
{
	return 0;
}

#endif
