svr4_util.h revision 49770
143412Snewton/* 243412Snewton * Copyright (c) 1998 Mark Newton 343412Snewton * Copyright (c) 1994 Christos Zoulas 443412Snewton * All rights reserved. 543412Snewton * 643412Snewton * Redistribution and use in source and binary forms, with or without 743412Snewton * modification, are permitted provided that the following conditions 843412Snewton * are met: 943412Snewton * 1. Redistributions of source code must retain the above copyright 1043412Snewton * notice, this list of conditions and the following disclaimer. 1143412Snewton * 2. Redistributions in binary form must reproduce the above copyright 1243412Snewton * notice, this list of conditions and the following disclaimer in the 1343412Snewton * documentation and/or other materials provided with the distribution. 1443412Snewton * 3. The name of the author may not be used to endorse or promote products 1543412Snewton * derived from this software without specific prior written permission 1643412Snewton * 1743412Snewton * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1843412Snewton * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1943412Snewton * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2043412Snewton * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2143412Snewton * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2243412Snewton * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2343412Snewton * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2443412Snewton * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2543412Snewton * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2643412Snewton * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2749267Snewton * 2849770Snewton * $Id: svr4_util.h,v 1.2 1999/07/30 12:45:21 newton Exp $ 2943412Snewton */ 3043412Snewton 3143412Snewton#ifndef _SVR4_UTIL_H_ 3243412Snewton#define _SVR4_UTIL_H_ 3343412Snewton 3443412Snewton/*#include <compat/common/compat_util.h>*/ 3543412Snewton#include <vm/vm.h> 3643412Snewton#include <vm/vm_param.h> 3743412Snewton#include <vm/pmap.h> 3843412Snewton#include <machine/vmparam.h> 3943412Snewton#include <sys/exec.h> 4043412Snewton#include <sys/sysent.h> 4143412Snewton#include <sys/cdefs.h> 4243412Snewton 4343412Snewton#ifdef DEBUG_SVR4 4443412Snewton#define DPRINTF(a) uprintf a; 4543412Snewton#else 4643412Snewton#define DPRINTF(a) 4743412Snewton#endif 4843412Snewton 4943412Snewton 5043412Snewtonstatic __inline caddr_t stackgap_init(void); 5143412Snewtonstatic __inline void *stackgap_alloc(caddr_t *, size_t); 5243412Snewton 5343412Snewtonstatic __inline caddr_t 5443412Snewtonstackgap_init() 5543412Snewton{ 5643412Snewton#define szsigcode (*(curproc->p_sysent->sv_szsigcode)) 5743412Snewton return (caddr_t)(((caddr_t)PS_STRINGS) - szsigcode - SPARE_USRSPACE); 5843412Snewton} 5943412Snewton 6043412Snewtonstatic __inline void * 6143412Snewtonstackgap_alloc(sgp, sz) 6243412Snewton caddr_t *sgp; 6343412Snewton size_t sz; 6443412Snewton{ 6543412Snewton void *p = (void *) *sgp; 6643412Snewton *sgp += ALIGN(sz); 6743412Snewton return p; 6843412Snewton} 6943412Snewton 7043412Snewtonextern const char svr4_emul_path[]; 7143412Snewtonint svr4_emul_find __P((struct proc *, caddr_t *, const char *, char *, 7243412Snewton char **, int)); 7343412Snewton 7449770Snewton#define CHECKALT(p, sgp, path, i) \ 7549770Snewton do { \ 7649770Snewton int _error; \ 7749770Snewton \ 7849770Snewton _error = svr4_emul_find(p, sgp, svr4_emul_path, path, \ 7949770Snewton &path, i); \ 8049770Snewton if (_error == EFAULT) \ 8149770Snewton return (_error); \ 8249770Snewton } while (0) 8343412Snewton 8449770Snewton#define CHECKALTEXIST(p, sgp, path) CHECKALT(p, sgp, path, 0) 8549770Snewton#define CHECKALTCREAT(p, sgp, path) CHECKALT(p, sgp, path, 1) 8643412Snewton 8743412Snewton#endif /* !_SVR4_UTIL_H_ */ 88