1*05b039f4Skurt/* $OpenBSD: tfork_thread.S,v 1.4 2021/02/03 13:00:39 kurt Exp $ */ 2c6f64c6fSguenther 3c6f64c6fSguenther/* 4c6f64c6fSguenther * Copyright (c) 2005, Miodrag Vallat 5c6f64c6fSguenther * 6c6f64c6fSguenther * Redistribution and use in source and binary forms, with or without 7c6f64c6fSguenther * modification, are permitted provided that the following conditions 8c6f64c6fSguenther * are met: 9c6f64c6fSguenther * 1. Redistributions of source code must retain the above copyright 10c6f64c6fSguenther * notice, this list of conditions and the following disclaimer. 11c6f64c6fSguenther * 2. Redistributions in binary form must reproduce the above copyright 12c6f64c6fSguenther * notice, this list of conditions and the following disclaimer in the 13c6f64c6fSguenther * documentation and/or other materials provided with the distribution. 14c6f64c6fSguenther * 15c6f64c6fSguenther * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16c6f64c6fSguenther * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17c6f64c6fSguenther * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18c6f64c6fSguenther * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 19c6f64c6fSguenther * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20c6f64c6fSguenther * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21c6f64c6fSguenther * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22c6f64c6fSguenther * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 23c6f64c6fSguenther * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 24c6f64c6fSguenther * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25c6f64c6fSguenther * POSSIBILITY OF SUCH DAMAGE. 26c6f64c6fSguenther */ 27c6f64c6fSguenther 28c6f64c6fSguenther#include "SYS.h" 29c6f64c6fSguenther 30c6f64c6fSguenther/* 3116b62b6aSguenther * int __tfork_thread(param, size_t psize, void (*func)(void *), void *arg); 32c6f64c6fSguenther */ 33c6f64c6fSguentherENTRY(__tfork_thread, 0) 34c6f64c6fSguenther SYSCALL(__tfork) 35c6f64c6fSguenther comb,<> r0, ret0, 1f 36c6f64c6fSguenther nop 37c6f64c6fSguenther 38c6f64c6fSguenther /* 3916b62b6aSguenther * In child process: invoke function, then exit. 40c6f64c6fSguenther */ 41c6f64c6fSguenther copy arg3, arg0 /* arg */ 42c6f64c6fSguenther copy arg2, t1 43c6f64c6fSguenther bl $$dyncall, r31 44c6f64c6fSguenther copy r31, rp 45c6f64c6fSguenther 46c6f64c6fSguenther copy r0, arg0 47c6f64c6fSguenther SYSCALL(__threxit) 48c6f64c6fSguenther 49c6f64c6fSguenther1: 50c6f64c6fSguenther bv r0(rp) 51c6f64c6fSguenther nop 52c6f64c6fSguenther 53c6f64c6fSguentherEXIT(__tfork_thread) 54