getcontext.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/privregs.h>
#include <sys/ucontext.h>
#include <sys/asm_linkage.h>
#include <sys/archsystm.h>
#include <sys/schedctl.h>
#include <sys/sysmacros.h>
/*
* Save user context.
*/
void
{
/*
* We unconditionally assign to every field through the end
* of the gregs, but we need to bzero() everything -after- that
* to avoid having any kernel stack garbage escape to userland.
*/
/*
* Try to copyin() the ustack if one is registered. If the stack
* has zero size, this indicates that stack bounds checking has
* been disabled for this LWP. If stack bounds checking is disabled
* or the copyin() fails, we fall back to the legacy behavior.
*/
} else {
}
}
else
}
/*
* Restore user context.
*/
void
{
else
}
t->t_post_sys = 1;
}
mutex_enter(&p->p_lock);
if (sigcheck(p, t))
t->t_sig_check = 1;
mutex_exit(&p->p_lock);
}
}
int
{
/*
* In future releases, when the ucontext structure grows,
* getcontext should be modified to only return the fields
* specified in the uc_flags. That way, the structure can grow
* and still be binary compatible will all .o's which will only
* have old fields defined in uc_flags
*/
switch (flag) {
default:
case GETCONTEXT:
if (schedctl_sigblock(curthread)) {
mutex_enter(&p->p_lock);
mutex_exit(&p->p_lock);
}
return (0);
case SETCONTEXT:
exit(CLD_EXITED, 0);
/*
* Don't copyin filler or floating state unless we need it.
* The ucontext_t struct and fields are specified in the ABI.
*/
}
}
restorecontext(&uc);
return (0);
case GETUSTACK:
return (0);
case SETUSTACK:
return (0);
}
}
#ifdef _SYSCALL32_IMPL
/*
* Save user context for 32-bit processes.
*/
void
{
} else {
(p->p_usrstack - p->p_stksize);
}
}
else
}
int
{
switch (flag) {
default:
case GETCONTEXT:
if (schedctl_sigblock(curthread)) {
mutex_enter(&p->p_lock);
mutex_exit(&p->p_lock);
}
return (0);
case SETCONTEXT:
exit(CLD_EXITED, 0);
}
}
return (0);
case GETUSTACK:
return (0);
case SETUSTACK:
return (0);
}
}
#endif /* _SYSCALL32_IMPL */