/*
 *	Prototypes and the like for functions that may be used anywhere.
 *
 *	10/22/93, kay roemer.
 */

#ifndef _UTIL_H
#define _UTIL_H

/* Unlimited amount of data for FIONREAD/FIONWRITE */
#define NO_LIMIT	0x7fffffffL

#define ALIGN2(x)	(((x) + 1) & ~1)
#define ALIGN4(x)	(((x) + 3) & ~3)

#define MIN(x,y)	((x) < (y) ? (x) : (y))
#define MAX(x,y)	((x) > (y) ? (x) : (y))

#define setstack(_sp) ({ \
	register void *_osp = 0; \
	__asm__ volatile("movel	sp, %0; movel %2, sp;" \
			 : "=a"(_osp) : "0"(_osp), "a"(_sp)); \
	_osp; \
})

#define spl7() ({ \
	register short _sr = 0; \
	__asm__ volatile("movew sr, %0; oriw #0x700, sr;" \
			 : "=d"(_sr) : "0"(_sr)); \
	_sr; \
})

#define spl(_sr) { __asm__ volatile("movew %0, sr;" :: "g"(_sr)); }

#ifndef NOEXTERNS
extern char	stack[8192];
#endif

#endif /* _UTIL_H */
