1*fc31befaSmiod/* $OpenBSD: tfork_thread.S,v 1.6 2024/03/27 20:03:29 miod Exp $ */ 2c6f64c6fSguenther 3c6f64c6fSguenther/* 4c6f64c6fSguenther * Copyright (c) 2007 Miodrag Vallat. 5c6f64c6fSguenther * 6c6f64c6fSguenther * Permission to use, copy, modify, and distribute this software for any 7c6f64c6fSguenther * purpose with or without fee is hereby granted, provided that the above 8c6f64c6fSguenther * copyright notice, this permission notice, and the disclaimer below 9c6f64c6fSguenther * appear in all copies. 10c6f64c6fSguenther * 11c6f64c6fSguenther * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12c6f64c6fSguenther * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13c6f64c6fSguenther * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14c6f64c6fSguenther * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15c6f64c6fSguenther * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16c6f64c6fSguenther * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17c6f64c6fSguenther * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18c6f64c6fSguenther */ 19c6f64c6fSguenther 20c6f64c6fSguenther#include "SYS.h" 21c6f64c6fSguenther 22c6f64c6fSguenther/* 2316b62b6aSguenther * int __tfork_thread(const struct __tfork *param, size_t psize, void (*func)(void *), void *arg); 24c6f64c6fSguenther * r4 r5 r6 r7 25c6f64c6fSguenther */ 26c6f64c6fSguentherENTRY(__tfork_thread) 27*fc31befaSmiod systrap SYS___tfork 28c6f64c6fSguenther bf 9f 29c6f64c6fSguenther 30c6f64c6fSguenther tst r0, r0 31c6f64c6fSguenther bt 1f 32c6f64c6fSguenther 33c6f64c6fSguenther /* 34c6f64c6fSguenther * In parent process: just return. 35c6f64c6fSguenther */ 36c6f64c6fSguenther rts 37c6f64c6fSguenther nop 38c6f64c6fSguenther 39*fc31befaSmiod systrap_data SYS___tfork 40*fc31befaSmiod 41c6f64c6fSguenther1: 42c6f64c6fSguenther /* 4316b62b6aSguenther * In child process: invoke function, then exit. 44c6f64c6fSguenther */ 45c6f64c6fSguenther jsr @r6 46c6f64c6fSguenther mov r7, r4 47c6f64c6fSguenther 48*fc31befaSmiod systrap SYS___threxit 49*fc31befaSmiod systrap_data SYS___threxit 50c6f64c6fSguenther 51c6f64c6fSguenther9: 52c6f64c6fSguenther /* 53c6f64c6fSguenther * System call failure. 54c6f64c6fSguenther */ 55*fc31befaSmiod SET_ERRNO_AND_RETURN(__tfork) 56c6f64c6fSguenther 57c6f64c6fSguenther SET_ENTRY_SIZE(__tfork_thread) 58