1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2024, Michal Meloun <mmel@freebsd.org> 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice unmodified, this list of conditions, and the following 11 * disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28 #include <stdlib.h> 29 #include <string.h> 30 31 #include "thr_private.h" 32 33 int __aeabi_idiv(int , int ); 34 unsigned __aeabi_uidiv(unsigned, unsigned ); 35 36 struct {int q; int r;} __aeabi_idivmod(int, int ); 37 struct {unsigned q; unsigned r;} __aeabi_uidivmod(unsigned, unsigned); 38 39 struct {int64_t q; int64_t r;} __aeabi_ldivmod(int64_t, int64_t); 40 struct {uint64_t q; uint64_t r;} __aeabi_uldivmod(uint64_t, uint64_t); 41 42 void __aeabi_memset(void *dest, size_t n, int c); 43 void __aeabi_memclr(void *dest, size_t n); 44 void __aeabi_memmove(void *dest, void *src, size_t n); 45 void __aeabi_memcpy(void *dest, void *src, size_t n); 46 void __aeabi_memcmp(void *dest, void *src, size_t n); 47 48 void 49 _thr_resolve_machdep(void) 50 { 51 char tmp[2]; 52 53 __aeabi_idiv(1, 1); 54 __aeabi_uidiv(1, 1); 55 56 __aeabi_idivmod(1, 1); 57 __aeabi_uidivmod(1, 1); 58 59 __aeabi_ldivmod(1, 1); 60 __aeabi_uldivmod(1, 1); 61 62 __aeabi_memset(tmp, 1, 0); 63 __aeabi_memclr(tmp, 1); 64 __aeabi_memmove(tmp, tmp + 1, 1); 65 __aeabi_memcpy(tmp, tmp + 1, 1); 66 __aeabi_memcmp(tmp, tmp + 1, 1); 67 } 68