__clone.S revision 1.1
11.1Stsubai/* $NetBSD: __clone.S,v 1.1 2001/07/20 17:19:15 tsubai Exp $ */ 21.1Stsubai 31.1Stsubai/*- 41.1Stsubai * Copyright (c) 2001 Tsubai Masanari. All rights reserved. 51.1Stsubai * 61.1Stsubai * Redistribution and use in source and binary forms, with or without 71.1Stsubai * modification, are permitted provided that the following conditions 81.1Stsubai * are met: 91.1Stsubai * 1. Redistributions of source code must retain the above copyright 101.1Stsubai * notice, this list of conditions and the following disclaimer. 111.1Stsubai * 2. Redistributions in binary form must reproduce the above copyright 121.1Stsubai * notice, this list of conditions and the following disclaimer in the 131.1Stsubai * documentation and/or other materials provided with the distribution. 141.1Stsubai * 3. The name of the author may not be used to endorse or promote products 151.1Stsubai * derived from this software without specific prior written permission. 161.1Stsubai * 171.1Stsubai * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 181.1Stsubai * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 191.1Stsubai * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 201.1Stsubai * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 211.1Stsubai * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 221.1Stsubai * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 231.1Stsubai * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 241.1Stsubai * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 251.1Stsubai * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 261.1Stsubai * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 271.1Stsubai */ 281.1Stsubai 291.1Stsubai#include <sys/errno.h> 301.1Stsubai#include "SYS.h" 311.1Stsubai 321.1Stsubai#ifdef WEAK_ALIAS 331.1StsubaiWEAK_ALIAS(clone, __clone) 341.1Stsubai#endif 351.1Stsubai 361.1Stsubai/* 371.1Stsubai * int __clone(int (*fn)(void *), void *stack, int flags, void *arg); 381.1Stsubai */ 391.1StsubaiENTRY(__clone) 401.1Stsubai /* 411.1Stsubai * Sanity checks: func and stack may not be NULL. 421.1Stsubai */ 431.1Stsubai cmpwi 3,0 441.1Stsubai beq 1f 451.1Stsubai cmpwi 4,0 461.1Stsubai beq 1f 471.1Stsubai 481.1Stsubai mr 7,3 /* Save fn in r7. */ 491.1Stsubai mr 3,5 501.1Stsubai li 0,SYS___clone /* (flags, stack) */ 511.1Stsubai sc 521.1Stsubai bso 2f /* error... */ 531.1Stsubai 541.1Stsubai cmpwi 3,0 551.1Stsubai bnelr /* We're the parent, just return. */ 561.1Stsubai 571.1Stsubai mtlr 7 /* fn */ 581.1Stsubai mr 3,6 /* arg */ 591.1Stsubai blrl /* Call the clone's entry point. */ 601.1Stsubai 611.1Stsubai bl PIC_PLT(_C_LABEL(_exit)) 621.1Stsubai 631.1Stsubai1: 641.1Stsubai li 3,EINVAL 651.1Stsubai2: 661.1Stsubai b PIC_PLT(_C_LABEL(__cerror)) 67