BarryServer : Git

All the code for all my projects
// BarryServer : Git / OrionLibC / blob / master / signal / sigsetops.c

// Related

OrionLibC

Barry Adding more signal functions fd1ac46 (2 years, 2 months ago)
#include <signal.h>
#include <errno.h>

/* Empty a signal set */
int
sigemptyset(sigset_t *set)
{
	*set = 0;
	return 0;
}

/* Fill a signal set */
int
sigfillset(sigset_t *set)
{
	*set = 0xFFFFFFFF;
	return 0;
}

/* Add a signal to a signal set */
int
sigaddset(sigset_t *set, int signum)
{
	if (signum < 0 || signum >= 32) {
		errno = EINVAL;
		return -1;
	}
	*set |= (1 << (signum - 1));
	return 0;
}

/* Remove a signal from a signal set */
int
sigdelset(sigset_t *set, int signum)
{
	if (signum < 0 || signum >= 32) {
		errno = EINVAL;
		return -1;
	}
	*set &= ~(1 << (signum - 1));
	return 0;
}

/* Check if a signal is in a signal set */
int
sigismember(const sigset_t *set, int signum)
{
	if (signum < 0 || signum >= 32) {
		errno = EINVAL;
		return -1;
	}
	return (*set & (1 << (signum - 1)));
}