ibcs2_util.h revision 83366
199129Sobrien
299129Sobrien/*
399129Sobrien * Copyright (c) 1994 Christos Zoulas
499129Sobrien * Copyright (c) 1995 Frank van der Linden
599129Sobrien * Copyright (c) 1995 Scott Bartram
699129Sobrien * All rights reserved.
799129Sobrien *
899129Sobrien * Redistribution and use in source and binary forms, with or without
999129Sobrien * modification, are permitted provided that the following conditions
1099129Sobrien * are met:
1199129Sobrien * 1. Redistributions of source code must retain the above copyright
1299129Sobrien *    notice, this list of conditions and the following disclaimer.
1399129Sobrien * 2. Redistributions in binary form must reproduce the above copyright
1499129Sobrien *    notice, this list of conditions and the following disclaimer in the
1599129Sobrien *    documentation and/or other materials provided with the distribution.
1699129Sobrien * 3. The name of the author may not be used to endorse or promote products
1799129Sobrien *    derived from this software without specific prior written permission
1899129Sobrien *
1999129Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
2099129Sobrien * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2199129Sobrien * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2299129Sobrien * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2399129Sobrien * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2499129Sobrien * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2599129Sobrien * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2699129Sobrien * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2799129Sobrien * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2899129Sobrien * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2999129Sobrien *
3099129Sobrien * from: svr4_util.h,v 1.5 1994/11/18 02:54:31 christos Exp
3199129Sobrien * from: linux_util.h,v 1.2 1995/03/05 23:23:50 fvdl Exp
3299129Sobrien *
3399129Sobrien * $FreeBSD: head/sys/i386/ibcs2/ibcs2_util.h 83366 2001-09-12 08:38:13Z julian $
3499129Sobrien */
3599129Sobrien
3699129Sobrien/*
3799129Sobrien * This file is pretty much the same as Christos' svr4_util.h
3899129Sobrien * (for now).
3999129Sobrien */
4099129Sobrien
4199129Sobrien#ifndef	_IBCS2_UTIL_H_
4299129Sobrien#define	_IBCS2_UTIL_H_
4399129Sobrien
4499129Sobrien/*
4599129Sobrien * XXX the inlines have obnoxious prerequisites, only some of which are
4699129Sobrien * included here.
4799129Sobrien */
4899129Sobrien#include <vm/vm.h>
4999129Sobrien#include <vm/pmap.h>
5099129Sobrien#include <machine/vmparam.h>
5199129Sobrien#include <sys/exec.h>
5299129Sobrien#include <sys/sysent.h>
5399129Sobrien#include <sys/proc.h>
5499129Sobrien
5599129Sobrien#ifndef SCARG
5699129Sobrien#define SCARG(p, x)  (p)->x
5799129Sobrien#endif
5899129Sobrien
5999129Sobrienstatic __inline caddr_t stackgap_init(void);
6099129Sobrienstatic __inline void *stackgap_alloc(caddr_t *, size_t);
6199129Sobrien
6299129Sobrienstatic __inline caddr_t
6399129Sobrienstackgap_init()
6499129Sobrien{
6599129Sobrien#define szsigcode (*(curthread->td_proc->p_sysent->sv_szsigcode))
6699129Sobrien        return (caddr_t)(PS_STRINGS - szsigcode - SPARE_USRSPACE);
6799129Sobrien}
6899129Sobrien
6999129Sobrienstatic __inline void *
7099129Sobrienstackgap_alloc(sgp, sz)
7199129Sobrien	caddr_t	*sgp;
7299129Sobrien	size_t   sz;
7399129Sobrien{
7499129Sobrien	void	*p = (void *) *sgp;
7599129Sobrien	*sgp += ALIGN(sz);
7699129Sobrien	return p;
7799129Sobrien}
7899129Sobrien
7999129Sobrien#ifdef DEBUG_IBCS2
8099129Sobrien#define DPRINTF(a)      printf a;
8199129Sobrien#else
8299129Sobrien#define DPRINTF(a)
8399129Sobrien#endif
8499129Sobrien
8599129Sobrienextern const char ibcs2_emul_path[];
8699129Sobrien
8799129Sobrienint ibcs2_emul_find __P((struct thread *, caddr_t *, const char *, char *,
8899129Sobrien			char **, int));
8999129Sobrien
9099129Sobrien#define CHECKALTEXIST(p, sgp, path) \
9199129Sobrien    ibcs2_emul_find(td, sgp, ibcs2_emul_path, path, &(path), 0)
9299129Sobrien
9399129Sobrien#define CHECKALTCREAT(p, sgp, path) \
9499129Sobrien    ibcs2_emul_find(td, sgp, ibcs2_emul_path, path, &(path), 1)
9599129Sobrien
9699129Sobrien#ifdef SPX_HACK
9799129Sobrienint spx_open __P((struct thread *td, void *uap));
9899129Sobrien#endif
9999129Sobrien
10099129Sobrien#endif /* !_IBCS2_UTIL_H_ */
10199129Sobrien