/*
 * Distributed under the terms of the GNU General Public License v2
 *  $Header: $
 */

#ifndef __SSP_H__
#define __SSP_H__


#ifdef __SSP__
#error "ssp.c must not be compiled with stack protection enabled on it. Use -fno-stack-protector"
#endif

#ifdef __PROPOLICE_BLOCK_SEGV__
# define SSP_SIGTYPE SIGSEGV
#elif __PROPOLICE_BLOCK_KILL__
# define SSP_SIGTYPE SIGKILL
#else
# define SSP_SIGTYPE SIGABRT
#endif


/* FIXME: need klogctl "<2>" */
#define SYSLOG syslog

#ifdef __linux__
#include <linux/unistd.h>
// #include <asm/unistd.h>

# define OPEN(path, flags)	syscall(__NR_open, path, flags)
# define READ(fd, buf, count)	syscall(__NR_read, fd, buf, count)
# define WRITE(a,b,c)		syscall(__NR_write, a, b, c)
# define CLOSE(fd)		syscall(__NR_close, fd)

# define GETPID()		syscall(__NR_getpid)
# define GETTIMEOFDAY(a, b)	syscall(__NR_gettimeofday, a, b)

# define SIGACTION(a, b, c)	syscall(__NR_sigaction, a, b, c)
# define SIGPROCMASK(a, b, c)	syscall(__NR_sigprocmask, a, b, c)
# define KILL(sig, pid)		syscall(__NR_kill, sig, pid)

# define EXIT(status)		syscall(__NR_exit, status)

#else /* ! __linux__ */

# define OPEN		open
# define READ		read
# define WRITE		write
# define CLOSE		close

# define GETPID		getpid
# define GETTIMEOFDAY	gettimeofday

# define SIGACTION	sigaction
# define SIGPROCMASK	sigprocmask
# define KILL		kill

# define EXIT		exit

#endif /* __linux__ */

#endif /* __SSP_H__ */
