ibcs2_util.h revision 139799
1139799Simp/*- 211394Sswallace * Copyright (c) 1994 Christos Zoulas 311394Sswallace * Copyright (c) 1995 Frank van der Linden 411394Sswallace * Copyright (c) 1995 Scott Bartram 511394Sswallace * All rights reserved. 611394Sswallace * 711394Sswallace * Redistribution and use in source and binary forms, with or without 811394Sswallace * modification, are permitted provided that the following conditions 911394Sswallace * are met: 1011394Sswallace * 1. Redistributions of source code must retain the above copyright 1111394Sswallace * notice, this list of conditions and the following disclaimer. 1211394Sswallace * 2. Redistributions in binary form must reproduce the above copyright 1311394Sswallace * notice, this list of conditions and the following disclaimer in the 1411394Sswallace * documentation and/or other materials provided with the distribution. 1511394Sswallace * 3. The name of the author may not be used to endorse or promote products 1611394Sswallace * derived from this software without specific prior written permission 1711394Sswallace * 1811394Sswallace * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1911394Sswallace * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2011394Sswallace * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2111394Sswallace * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2211394Sswallace * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2311394Sswallace * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2411394Sswallace * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2511394Sswallace * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2611394Sswallace * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2711394Sswallace * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2811394Sswallace * 2911394Sswallace * from: svr4_util.h,v 1.5 1994/11/18 02:54:31 christos Exp 3011394Sswallace * from: linux_util.h,v 1.2 1995/03/05 23:23:50 fvdl Exp 3183366Sjulian * 3283366Sjulian * $FreeBSD: head/sys/i386/ibcs2/ibcs2_util.h 139799 2005-01-06 23:22:04Z imp $ 3311394Sswallace */ 3411394Sswallace 3511394Sswallace/* 3611394Sswallace * This file is pretty much the same as Christos' svr4_util.h 3711394Sswallace * (for now). 3811394Sswallace */ 3911394Sswallace 4011394Sswallace#ifndef _IBCS2_UTIL_H_ 4111394Sswallace#define _IBCS2_UTIL_H_ 4211394Sswallace 4328750Sbde/* 4428750Sbde * XXX the inlines have obnoxious prerequisites, only some of which are 4528750Sbde * included here. 4628750Sbde */ 4711397Sswallace#include <vm/vm.h> 4812662Sdg#include <vm/pmap.h> 4911394Sswallace#include <machine/vmparam.h> 5011394Sswallace#include <sys/exec.h> 5114331Speter#include <sys/sysent.h> 5214331Speter#include <sys/proc.h> 5311394Sswallace 5411397Sswallacestatic __inline caddr_t stackgap_init(void); 5511397Sswallacestatic __inline void *stackgap_alloc(caddr_t *, size_t); 5611397Sswallace 5711394Sswallacestatic __inline caddr_t 5811394Sswallacestackgap_init() 5911394Sswallace{ 6083366Sjulian#define szsigcode (*(curthread->td_proc->p_sysent->sv_szsigcode)) 6141871Sbde return (caddr_t)(PS_STRINGS - szsigcode - SPARE_USRSPACE); 6211394Sswallace} 6311394Sswallace 6411394Sswallacestatic __inline void * 6511394Sswallacestackgap_alloc(sgp, sz) 6611394Sswallace caddr_t *sgp; 6711394Sswallace size_t sz; 6811394Sswallace{ 6911394Sswallace void *p = (void *) *sgp; 70121016Stjr sz = ALIGN(sz); 71121016Stjr if (*sgp + sz > (caddr_t)(PS_STRINGS - szsigcode)) 72121016Stjr return NULL; 73121016Stjr *sgp += sz; 7411394Sswallace return p; 7511394Sswallace} 7611394Sswallace 7711394Sswallace#ifdef DEBUG_IBCS2 7811394Sswallace#define DPRINTF(a) printf a; 7911394Sswallace#else 8011394Sswallace#define DPRINTF(a) 8111394Sswallace#endif 8211394Sswallace 8311394Sswallaceextern const char ibcs2_emul_path[]; 8411394Sswallace 8592761Salfredint ibcs2_emul_find(struct thread *, caddr_t *, const char *, char *, 8692761Salfred char **, int); 8711394Sswallace 8811394Sswallace#define CHECKALTEXIST(p, sgp, path) \ 8983366Sjulian ibcs2_emul_find(td, sgp, ibcs2_emul_path, path, &(path), 0) 9011394Sswallace 9111394Sswallace#define CHECKALTCREAT(p, sgp, path) \ 9283366Sjulian ibcs2_emul_find(td, sgp, ibcs2_emul_path, path, &(path), 1) 9311394Sswallace 9420652Sbde#ifdef SPX_HACK 9592761Salfredint spx_open(struct thread *td, void *uap); 9620652Sbde#endif 9720652Sbde 9811394Sswallace#endif /* !_IBCS2_UTIL_H_ */ 99