From 657b1f3d64bcf8eaa2385dba72a6047f089433b2 Mon Sep 17 00:00:00 2001 From: raf Date: Wed, 13 Dec 2006 11:41:29 -0800 Subject: PSARC 2006/659 fork extensions 6497356 fork extensions --HG-- rename : usr/src/lib/libc/amd64/sys/forkall.s => usr/src/lib/libc/amd64/sys/forkallx.s rename : usr/src/lib/libc/amd64/sys/fork1.s => usr/src/lib/libc/amd64/sys/forkx.s rename : usr/src/lib/libc/amd64/sys/vfork.s => usr/src/lib/libc/amd64/sys/vforkx.s rename : usr/src/lib/libc/i386/sys/forkall.s => usr/src/lib/libc/i386/sys/forkallx.s rename : usr/src/lib/libc/i386/sys/fork1.s => usr/src/lib/libc/i386/sys/forkx.s rename : usr/src/lib/libc/i386/sys/vfork.s => usr/src/lib/libc/i386/sys/vforkx.s rename : usr/src/lib/libc/sparc/sys/forkall.s => usr/src/lib/libc/sparc/sys/forkallx.s rename : usr/src/lib/libc/sparc/sys/fork1.s => usr/src/lib/libc/sparc/sys/forkx.s rename : usr/src/lib/libc/sparc/sys/vfork.s => usr/src/lib/libc/sparc/sys/vforkx.s --- usr/src/lib/libc/sparc/Makefile | 8 +-- usr/src/lib/libc/sparc/sys/fork1.s | 56 --------------- usr/src/lib/libc/sparc/sys/forkall.s | 56 --------------- usr/src/lib/libc/sparc/sys/forkallx.s | 56 +++++++++++++++ usr/src/lib/libc/sparc/sys/forkx.s | 56 +++++++++++++++ usr/src/lib/libc/sparc/sys/vfork.s | 115 ------------------------------ usr/src/lib/libc/sparc/sys/vforkx.s | 128 ++++++++++++++++++++++++++++++++++ 7 files changed, 244 insertions(+), 231 deletions(-) delete mode 100644 usr/src/lib/libc/sparc/sys/fork1.s delete mode 100644 usr/src/lib/libc/sparc/sys/forkall.s create mode 100644 usr/src/lib/libc/sparc/sys/forkallx.s create mode 100644 usr/src/lib/libc/sparc/sys/forkx.s delete mode 100644 usr/src/lib/libc/sparc/sys/vfork.s create mode 100644 usr/src/lib/libc/sparc/sys/vforkx.s (limited to 'usr/src/lib/libc/sparc') diff --git a/usr/src/lib/libc/sparc/Makefile b/usr/src/lib/libc/sparc/Makefile index 452b116802..eced13c518 100644 --- a/usr/src/lib/libc/sparc/Makefile +++ b/usr/src/lib/libc/sparc/Makefile @@ -330,8 +330,8 @@ SYSOBJS= \ _lwp_mutex_unlock.o \ _stack_grow.o \ door.o \ - fork1.o \ - forkall.o \ + forkx.o \ + forkallx.o \ gettimeofday.o \ pipe.o \ ptrace.o \ @@ -341,7 +341,7 @@ SYSOBJS= \ uadmin.o \ umount.o \ uname.o \ - vfork.o + vforkx.o # objects under ../port which contain transitional large file interfaces PORTGEN64= \ @@ -1214,7 +1214,7 @@ ASSYMDEP_OBJS= \ asm_subr.o \ tls_get_addr.o \ unwind_frame.o \ - vfork.o + vforkx.o $(ASSYMDEP_OBJS:%=pics/%) := CPPFLAGS += -I. diff --git a/usr/src/lib/libc/sparc/sys/fork1.s b/usr/src/lib/libc/sparc/sys/fork1.s deleted file mode 100644 index 1d011cbb37..0000000000 --- a/usr/src/lib/libc/sparc/sys/fork1.s +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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) 1988 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" - - .file "%M%" - -/* - * C library -- fork1 - * pid_t fork1(void) - */ - -/* - * From the syscall: - * %o1 == 0 in parent process, %o1 == 1 in child process. - * %o0 == pid of child in parent, %o0 == pid of parent in child. - * - * The child gets a zero return value. - * The parent gets the pid of the child. - */ - -#include "SYS.h" - - ENTRY(__fork1); - SYSTRAP_2RVALS(fork1); - SYSCERROR - movrnz %o1, 0, %o0 - RET - SET_SIZE(__fork1) diff --git a/usr/src/lib/libc/sparc/sys/forkall.s b/usr/src/lib/libc/sparc/sys/forkall.s deleted file mode 100644 index 43ef74e8bb..0000000000 --- a/usr/src/lib/libc/sparc/sys/forkall.s +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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) 1988 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" - - .file "%M%" - -/* - * C library -- forkall - * pid_t forkall(void) - */ - -/* - * From the syscall: - * %o1 == 0 in parent process, %o1 == 1 in child process. - * %o0 == pid of child in parent, %o0 == pid of parent in child. - * - * The child gets a zero return value. - * The parent gets the pid of the child. - */ - -#include "SYS.h" - - ENTRY(__forkall) - SYSTRAP_2RVALS(forkall) - SYSCERROR - movrnz %o1, 0, %o0 - RET - SET_SIZE(__forkall) diff --git a/usr/src/lib/libc/sparc/sys/forkallx.s b/usr/src/lib/libc/sparc/sys/forkallx.s new file mode 100644 index 0000000000..32dbdadd6e --- /dev/null +++ b/usr/src/lib/libc/sparc/sys/forkallx.s @@ -0,0 +1,56 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (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 + * or http://www.opensolaris.org/os/licensing. + * 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) 1988 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + .file "%M%" + +#include "SYS.h" + +/* + * pid = __forkallx(flags); + * + * syscall trap: forksys(1, flags) + * + * From the syscall: + * %o1 == 0 in parent process, %o1 == 1 in child process. + * %o0 == pid of child in parent, %o0 == pid of parent in child. + * + * The child gets a zero return value. + * The parent gets the pid of the child. + */ + + ENTRY(__forkallx) + mov %o0, %o1 + mov 1, %o0 + SYSTRAP_2RVALS(forksys) + SYSCERROR + movrnz %o1, 0, %o0 + RET + SET_SIZE(__forkallx) diff --git a/usr/src/lib/libc/sparc/sys/forkx.s b/usr/src/lib/libc/sparc/sys/forkx.s new file mode 100644 index 0000000000..b86bcbbfcc --- /dev/null +++ b/usr/src/lib/libc/sparc/sys/forkx.s @@ -0,0 +1,56 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (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 + * or http://www.opensolaris.org/os/licensing. + * 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) 1988 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + .file "%M%" + +#include "SYS.h" + +/* + * pid = __forkx(flags); + * + * syscall trap: forksys(0, flags) + * + * From the syscall: + * %o1 == 0 in parent process, %o1 == 1 in child process. + * %o0 == pid of child in parent, %o0 == pid of parent in child. + * + * The child gets a zero return value. + * The parent gets the pid of the child. + */ + + ENTRY(__forkx) + mov %o0, %o1 + clr %o0 + SYSTRAP_2RVALS(forksys) + SYSCERROR + movrnz %o1, 0, %o0 + RET + SET_SIZE(__forkx) diff --git a/usr/src/lib/libc/sparc/sys/vfork.s b/usr/src/lib/libc/sparc/sys/vfork.s deleted file mode 100644 index 45153a1374..0000000000 --- a/usr/src/lib/libc/sparc/sys/vfork.s +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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) 1988 AT&T */ -/* All Rights Reserved */ - - -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -.ident "%Z%%M% %I% %E% SMI" - -/* - * C library -- vfork - * pid_t vfork(void); - */ - -/* - * From the syscall: - * %o1 == 0 in parent process, %o1 == 1 in child process. - * %o0 == pid of child in parent, %o0 == pid of parent in child. - * - * The child process gets a zero return value from vfork; the parent - * gets the pid of the child. - * - * We block all blockable signals while performing the vfork() system call - * trap. This enables us to set curthread->ul_vfork safely, so that we - * don't end up in a signal handler with curthread->ul_vfork set wrong. - * - * Note that since the SPARC architecture maintains stack maintence - * information (return pc, sp, fp) in the register windows, both parent - * and child can execute in a common address space without conflict. - */ - - .file "%M%" - -#include - - ANSI_PRAGMA_WEAK(vfork,function) - -#include "SYS.h" -#include <../assym.h> - - ENTRY(vfork) - mov SIG_SETMASK, %o0 ! block signals - set MASKSET0, %o1 - set MASKSET1, %o2 - SYSTRAP_2RVALS(lwp_sigmask) - - SYSTRAP_2RVALS(vfork) - bcc,a,pt %icc, 1f - tst %o1 - mov %o0, %o3 ! save the vfork() error number - - mov SIG_SETMASK, %o0 ! reinstate signals - ld [%g7 + UL_SIGMASK], %o1 - ld [%g7 + UL_SIGMASK + 4], %o2 - SYSTRAP_2RVALS(lwp_sigmask) - - mov %o3, %o0 ! restore the vfork() error number - ba,a __cerror -1: - /* - * To determine if we are (still) a child of vfork(), the child - * increments curthread->ul_vfork by one and the parent decrements - * it by one. If the result is zero, then we are not a child of - * vfork(), else we are. We do this to deal with the case of - * a vfork() child calling vfork(). - */ - bnz,pt %icc, 2f - ld [%g7 + UL_VFORK], %g1 - brnz,a,pt %g1, 3f ! don't let it go negative - sub %g1, 1, %g1 ! curthread->ul_vfork--; - ba,a 3f -2: - clr %o0 ! child, return (0) - add %g1, 1, %g1 ! curthread->ul_vfork++; -3: - st %g1, [%g7 + UL_VFORK] - /* - * Clear the schedctl interface in both parent and child. - * (The child might have modified the parent.) - */ - stn %g0, [%g7 + UL_SCHEDCTL] - stn %g0, [%g7 + UL_SCHEDCTL_CALLED] - mov %o0, %o3 ! save the vfork() return value - - mov SIG_SETMASK, %o0 ! reinstate signals - ld [%g7 + UL_SIGMASK], %o1 - ld [%g7 + UL_SIGMASK + 4], %o2 - SYSTRAP_2RVALS(lwp_sigmask) - - retl - mov %o3, %o0 ! restore the vfork() return value - SET_SIZE(vfork) diff --git a/usr/src/lib/libc/sparc/sys/vforkx.s b/usr/src/lib/libc/sparc/sys/vforkx.s new file mode 100644 index 0000000000..d5e41b571a --- /dev/null +++ b/usr/src/lib/libc/sparc/sys/vforkx.s @@ -0,0 +1,128 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (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 + * or http://www.opensolaris.org/os/licensing. + * 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) 1988 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + .file "%M%" + +#include + + ANSI_PRAGMA_WEAK(vforkx,function) + ANSI_PRAGMA_WEAK(vfork,function) + +#include "SYS.h" +#include + +/* + * pid = vforkx(flags); + * syscall trap: forksys(2, flags) + * + * pid = vfork(); + * syscall trap: forksys(2, 0) + * + * From the syscall: + * %o1 == 0 in parent process, %o1 == 1 in child process. + * %o0 == pid of child in parent, %o0 == pid of parent in child. + * + * The child gets a zero return value. + * The parent gets the pid of the child. + */ + +/* + * Note that since the SPARC architecture maintains stack maintence + * information (return pc, sp, fp) in the register windows, both parent + * and child can execute in a common address space without conflict. + * + * We block all blockable signals while performing the vfork() system call + * trap. This enables us to set curthread->ul_vfork safely, so that we + * don't end up in a signal handler with curthread->ul_vfork set wrong. + */ + + ENTRY_NP(vforkx) + ba 0f + mov %o0, %o3 /* flags */ + ENTRY_NP(vfork) + clr %o3 /* flags = 0 */ +0: + mov SIG_SETMASK, %o0 /* block all signals */ + set MASKSET0, %o1 + set MASKSET1, %o2 + SYSTRAP_2RVALS(lwp_sigmask) + + mov %o3, %o1 /* flags */ + mov 2, %o0 + SYSTRAP_2RVALS(forksys) /* vforkx(flags) */ + bcc,a,pt %icc, 1f + tst %o1 + + mov %o0, %o3 /* save the vfork() error number */ + + mov SIG_SETMASK, %o0 /* reinstate signals */ + ld [%g7 + UL_SIGMASK], %o1 + ld [%g7 + UL_SIGMASK + 4], %o2 + SYSTRAP_2RVALS(lwp_sigmask) + + ba __cerror + mov %o3, %o0 /* restore the vfork() error number */ + +1: + /* + * To determine if we are (still) a child of vfork(), the child + * increments curthread->ul_vfork by one and the parent decrements + * it by one. If the result is zero, then we are not a child of + * vfork(), else we are. We do this to deal with the case of + * a vfork() child calling vfork(). + */ + bnz,pt %icc, 2f + ld [%g7 + UL_VFORK], %g1 + brnz,a,pt %g1, 3f /* don't let it go negative */ + sub %g1, 1, %g1 /* curthread->ul_vfork--; */ + ba,a 3f +2: + clr %o0 /* zero the return value in the child */ + add %g1, 1, %g1 /* curthread->ul_vfork++; */ +3: + st %g1, [%g7 + UL_VFORK] + /* + * Clear the schedctl interface in both parent and child. + * (The child might have modified the parent.) + */ + stn %g0, [%g7 + UL_SCHEDCTL] + stn %g0, [%g7 + UL_SCHEDCTL_CALLED] + mov %o0, %o3 /* save the vfork() return value */ + + mov SIG_SETMASK, %o0 /* reinstate signals */ + ld [%g7 + UL_SIGMASK], %o1 + ld [%g7 + UL_SIGMASK + 4], %o2 + SYSTRAP_2RVALS(lwp_sigmask) + + retl + mov %o3, %o0 /* restore the vfork() return value */ + SET_SIZE(vfork) + SET_SIZE(vforkx) -- cgit v1.2.3