xref: /onnv-gate/usr/src/lib/libc/i386/sys/forkx.s (revision 7298:b69e27387f74)
13235Sraf/*
23235Sraf * CDDL HEADER START
33235Sraf *
43235Sraf * The contents of this file are subject to the terms of the
53235Sraf * Common Development and Distribution License (the "License").
63235Sraf * You may not use this file except in compliance with the License.
73235Sraf *
83235Sraf * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
93235Sraf * or http://www.opensolaris.org/os/licensing.
103235Sraf * See the License for the specific language governing permissions
113235Sraf * and limitations under the License.
123235Sraf *
133235Sraf * When distributing Covered Code, include this CDDL HEADER in each
143235Sraf * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
153235Sraf * If applicable, add the following below this CDDL HEADER, with the
163235Sraf * fields enclosed by brackets "[]" replaced with your own identifying
173235Sraf * information: Portions Copyright [yyyy] [name of copyright owner]
183235Sraf *
193235Sraf * CDDL HEADER END
203235Sraf */
213235Sraf
223235Sraf/*
233235Sraf * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
243235Sraf * Use is subject to license terms.
253235Sraf */
263235Sraf
27*7298SMark.J.Nelson@Sun.COM	.file	"forkx.s"
283235Sraf
293235Sraf#include "SYS.h"
303235Sraf
313235Sraf/*
323235Sraf * pid = __forkx(flags);
333235Sraf *
343235Sraf * syscall trap: forksys(0, flags)
353235Sraf *
363235Sraf * From the syscall:
373235Sraf * %edx == 0 in parent process, %edx = 1 in child process.
383235Sraf * %eax == pid of child in parent, %eax == pid of parent in child.
393235Sraf *
403235Sraf * The child gets a zero return value.
413235Sraf * The parent gets the pid of the child.
423235Sraf */
433235Sraf
443235Sraf	ENTRY(__forkx)
453235Sraf	popl	%ecx
463235Sraf	pushl	$0
473235Sraf	pushl	%ecx
483235Sraf	SYSTRAP_2RVALS(forksys)
493235Sraf	popl	%ecx
503235Sraf	movl	%ecx, 0(%esp)
513235Sraf	SYSCERROR
523235Sraf	testl	%edx, %edx
533235Sraf	jz	1f		/* jump if parent */
543235Sraf	xorl	%eax, %eax	/* child, return (0) */
553235Sraf1:
563235Sraf	RET
573235Sraf	SET_SIZE(__forkx)
58