ndk_cruft.cpp revision 001f8f041bf21c53d4a0b919ef2c859b047bac0a
1567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes/* 2567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes * Copyright (C) 2013 The Android Open Source Project 3567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes * All rights reserved. 4567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes * 5567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes * Redistribution and use in source and binary forms, with or without 6567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes * modification, are permitted provided that the following conditions 7567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes * are met: 8567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes * * Redistributions of source code must retain the above copyright 9567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes * notice, this list of conditions and the following disclaimer. 10567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes * * Redistributions in binary form must reproduce the above copyright 11567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes * notice, this list of conditions and the following disclaimer in 12567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes * the documentation and/or other materials provided with the 13567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes * distribution. 14567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes * 15567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 22567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes * SUCH DAMAGE. 27567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes */ 28567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes 29567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes// This file perpetuates the mistakes of the past, but only for 32-bit targets. 30567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes#if !defined(__LP64__) 31567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes 32efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4Elliott Hughes#include <ctype.h> 33efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4Elliott Hughes#include <inttypes.h> 34a4eafa6dbc98378f3fa759fec8590871e2b5ae29Calin Juravle#include <pthread.h> 35fcac8ff97f6b6cced6546e0096cadc1039b68b5eElliott Hughes#include <stdio.h> 36567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes#include <stdlib.h> 37567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes#include <sys/resource.h> 38bd3a98c6b9850a8e55fb0e0ed9f045212c494881Elliott Hughes#include <sys/syscall.h> 39567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes#include <sys/time.h> 40567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes#include <sys/types.h> 41567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes#include <sys/wait.h> 42567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes#include <unistd.h> 43001f8f041bf21c53d4a0b919ef2c859b047bac0aDan Albert#include <wchar.h> 44567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes 45567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes// These were accidentally declared in <unistd.h> because we stupidly used to inline 46567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes// getpagesize() and __getpageshift(). Needed for backwards compatibility with old NDK apps. 47567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughesextern "C" { 48567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes unsigned int __page_size = PAGE_SIZE; 490e44bc3baeb1677e5fbdda87a737b9c508c95132Elliott Hughes unsigned int __page_shift = 12; 50567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes} 51567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes 52567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes// TODO: remove this backward compatibility hack (for jb-mr1 strace binaries). 53567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughesextern "C" pid_t __wait4(pid_t pid, int* status, int options, struct rusage* rusage) { 54567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes return wait4(pid, status, options, rusage); 55567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes} 56567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes 57062092543fdbd6fa2676e4f5b37a15f7bba94332Elliott Hughes// TODO: does anything still need this? 58567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughesextern "C" int __open() { 59567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes abort(); 60567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes} 61567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes 62062092543fdbd6fa2676e4f5b37a15f7bba94332Elliott Hughes// TODO: does anything still need this? 63062092543fdbd6fa2676e4f5b37a15f7bba94332Elliott Hughesextern "C" void** __get_tls() { 64062092543fdbd6fa2676e4f5b37a15f7bba94332Elliott Hughes#include "private/__get_tls.h" 65062092543fdbd6fa2676e4f5b37a15f7bba94332Elliott Hughes return __get_tls(); 66062092543fdbd6fa2676e4f5b37a15f7bba94332Elliott Hughes} 67062092543fdbd6fa2676e4f5b37a15f7bba94332Elliott Hughes 68152b9de19ade833ada124390ef153e53d3d3e2edElliott Hughes// This non-standard function was in our <string.h> for some reason. 69152b9de19ade833ada124390ef153e53d3d3e2edElliott Hughesextern "C" void memswap(void* m1, void* m2, size_t n) { 70152b9de19ade833ada124390ef153e53d3d3e2edElliott Hughes char* p = reinterpret_cast<char*>(m1); 71152b9de19ade833ada124390ef153e53d3d3e2edElliott Hughes char* p_end = p + n; 72152b9de19ade833ada124390ef153e53d3d3e2edElliott Hughes char* q = reinterpret_cast<char*>(m2); 73152b9de19ade833ada124390ef153e53d3d3e2edElliott Hughes while (p < p_end) { 74152b9de19ade833ada124390ef153e53d3d3e2edElliott Hughes char tmp = *p; 75152b9de19ade833ada124390ef153e53d3d3e2edElliott Hughes *p = *q; 76152b9de19ade833ada124390ef153e53d3d3e2edElliott Hughes *q = tmp; 77152b9de19ade833ada124390ef153e53d3d3e2edElliott Hughes p++; 78152b9de19ade833ada124390ef153e53d3d3e2edElliott Hughes q++; 79152b9de19ade833ada124390ef153e53d3d3e2edElliott Hughes } 80152b9de19ade833ada124390ef153e53d3d3e2edElliott Hughes} 81152b9de19ade833ada124390ef153e53d3d3e2edElliott Hughes 82a4eafa6dbc98378f3fa759fec8590871e2b5ae29Calin Juravleextern "C" int pthread_attr_setstackaddr(pthread_attr_t*, void*) { 83a4eafa6dbc98378f3fa759fec8590871e2b5ae29Calin Juravle // This was removed from POSIX.1-2008, and is not implemented on bionic. 84a4eafa6dbc98378f3fa759fec8590871e2b5ae29Calin Juravle // Needed for ABI compatibility with the NDK. 85a4eafa6dbc98378f3fa759fec8590871e2b5ae29Calin Juravle return ENOSYS; 86a4eafa6dbc98378f3fa759fec8590871e2b5ae29Calin Juravle} 87a4eafa6dbc98378f3fa759fec8590871e2b5ae29Calin Juravle 88a4eafa6dbc98378f3fa759fec8590871e2b5ae29Calin Juravleextern "C" int pthread_attr_getstackaddr(const pthread_attr_t* attr, void** stack_addr) { 89a4eafa6dbc98378f3fa759fec8590871e2b5ae29Calin Juravle // This was removed from POSIX.1-2008. 90a4eafa6dbc98378f3fa759fec8590871e2b5ae29Calin Juravle // Needed for ABI compatibility with the NDK. 91a4eafa6dbc98378f3fa759fec8590871e2b5ae29Calin Juravle *stack_addr = (char*)attr->stack_base + attr->stack_size; 92a4eafa6dbc98378f3fa759fec8590871e2b5ae29Calin Juravle return 0; 93a4eafa6dbc98378f3fa759fec8590871e2b5ae29Calin Juravle} 94a4eafa6dbc98378f3fa759fec8590871e2b5ae29Calin Juravle 95efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4Elliott Hughes// Non-standard cruft that should only ever have been in system/core/toolbox. 96efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4Elliott Hughesextern "C" char* strtotimeval(const char* str, struct timeval* ts) { 97efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4Elliott Hughes char* s; 98efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4Elliott Hughes ts->tv_sec = strtoumax(str, &s, 10); 99efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4Elliott Hughes 100efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4Elliott Hughes long fractional_seconds = 0; 101efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4Elliott Hughes if (*s == '.') { 102efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4Elliott Hughes s++; 103efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4Elliott Hughes int count = 0; 104efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4Elliott Hughes 105efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4Elliott Hughes // Read up to 6 digits (microseconds). 106efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4Elliott Hughes while (*s && isdigit(*s)) { 107efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4Elliott Hughes if (++count < 7) { 108efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4Elliott Hughes fractional_seconds = fractional_seconds*10 + (*s - '0'); 109efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4Elliott Hughes } 110efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4Elliott Hughes s++; 111efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4Elliott Hughes } 112efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4Elliott Hughes 113efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4Elliott Hughes for (; count < 6; count++) { 114efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4Elliott Hughes fractional_seconds *= 10; 115efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4Elliott Hughes } 116efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4Elliott Hughes } 117efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4Elliott Hughes 118efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4Elliott Hughes ts->tv_usec = fractional_seconds; 119efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4Elliott Hughes return s; 120efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4Elliott Hughes} 121efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4Elliott Hughes 122eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughesstatic inline int digitval(int ch) { 123eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes unsigned d; 124eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes 125eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes d = (unsigned)(ch - '0'); 126eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes if (d < 10) return (int)d; 127eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes 128eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes d = (unsigned)(ch - 'a'); 129eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes if (d < 6) return (int)(d+10); 130eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes 131eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes d = (unsigned)(ch - 'A'); 132eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes if (d < 6) return (int)(d+10); 133eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes 134eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes return -1; 135eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes} 136eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes 137eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes// This non-standard function was in our <inttypes.h> for some reason. 138eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughesextern "C" uintmax_t strntoumax(const char *nptr, char **endptr, int base, size_t n) { 139eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes const unsigned char* p = (const unsigned char *)nptr; 140eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes const unsigned char* end = p + n; 141eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes int minus = 0; 142eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes uintmax_t v = 0; 143eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes int d; 144eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes 145eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes while (p < end && isspace(*p)) { 146eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes p++; 147eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes } 148eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes 149eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes if (p < end) { 150eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes char c = p[0]; 151eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes if (c == '-' || c == '+') { 152eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes minus = (c == '-'); 153eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes p++; 154eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes } 155eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes } 156eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes 157eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes if (base == 0) { 158eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes if (p+2 < end && p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) { 159eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes p += 2; 160eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes base = 16; 161eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes } else if (p+1 < end && p[0] == '0') { 162eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes p += 1; 163eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes base = 8; 164eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes } else { 165eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes base = 10; 166eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes } 167eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes } else if (base == 16) { 168eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes if (p+2 < end && p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) { 169eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes p += 2; 170eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes } 171eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes } 172eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes 173eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes while (p < end && (d = digitval(*p)) >= 0 && d < base) { 174eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes v = v*base + d; 175eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes p += 1; 176eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes } 177eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes 178eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes if (endptr) { 179eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes *endptr = (char*) p; 180eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes } 181eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes 182eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes return minus ? -v : v; 183eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes} 184eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes 185eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes// This non-standard function was in our <inttypes.h> for some reason. 186eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughesextern "C" intmax_t strntoimax(const char* nptr, char** endptr, int base, size_t n) { 187eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes return (intmax_t) strntoumax(nptr, endptr, base, n); 188eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes} 189eae5902e73dc4381811e08fd2334bf4a9300a928Elliott Hughes 190fcac8ff97f6b6cced6546e0096cadc1039b68b5eElliott Hughes// POSIX calls this dprintf, but LP32 Android had fdprintf instead. 191fcac8ff97f6b6cced6546e0096cadc1039b68b5eElliott Hughesextern "C" int fdprintf(int fd, const char* fmt, ...) { 192fcac8ff97f6b6cced6546e0096cadc1039b68b5eElliott Hughes va_list ap; 193fcac8ff97f6b6cced6546e0096cadc1039b68b5eElliott Hughes va_start(ap, fmt); 194fcac8ff97f6b6cced6546e0096cadc1039b68b5eElliott Hughes int rc = vdprintf(fd, fmt, ap); 195fcac8ff97f6b6cced6546e0096cadc1039b68b5eElliott Hughes va_end(ap); 196fcac8ff97f6b6cced6546e0096cadc1039b68b5eElliott Hughes return rc; 197fcac8ff97f6b6cced6546e0096cadc1039b68b5eElliott Hughes} 198fcac8ff97f6b6cced6546e0096cadc1039b68b5eElliott Hughes 199fcac8ff97f6b6cced6546e0096cadc1039b68b5eElliott Hughes// POSIX calls this vdprintf, but LP32 Android had fdprintf instead. 200fcac8ff97f6b6cced6546e0096cadc1039b68b5eElliott Hughesextern "C" int vfdprintf(int fd, const char* fmt, va_list ap) { 201fcac8ff97f6b6cced6546e0096cadc1039b68b5eElliott Hughes return vdprintf(fd, fmt, ap); 202fcac8ff97f6b6cced6546e0096cadc1039b68b5eElliott Hughes} 203fcac8ff97f6b6cced6546e0096cadc1039b68b5eElliott Hughes 204b30aff405a220495941f1673b0a5e66c4fa8b84cElliott Hughes#define __futex_wake __real_futex_wake 205b30aff405a220495941f1673b0a5e66c4fa8b84cElliott Hughes#define __futex_wait __real_futex_wait 206b30aff405a220495941f1673b0a5e66c4fa8b84cElliott Hughes#include "private/bionic_futex.h" 207b30aff405a220495941f1673b0a5e66c4fa8b84cElliott Hughes#undef __futex_wake 208b30aff405a220495941f1673b0a5e66c4fa8b84cElliott Hughes#undef __futex_wait 209bd3a98c6b9850a8e55fb0e0ed9f045212c494881Elliott Hughes 210bd3a98c6b9850a8e55fb0e0ed9f045212c494881Elliott Hughes// This used to be in <sys/atomics.h>. 211bd3a98c6b9850a8e55fb0e0ed9f045212c494881Elliott Hughesextern "C" int __futex_wake(volatile void* ftx, int count) { 212b30aff405a220495941f1673b0a5e66c4fa8b84cElliott Hughes return __real_futex_wake(ftx, count); 213bd3a98c6b9850a8e55fb0e0ed9f045212c494881Elliott Hughes} 214bd3a98c6b9850a8e55fb0e0ed9f045212c494881Elliott Hughes 215bd3a98c6b9850a8e55fb0e0ed9f045212c494881Elliott Hughes// This used to be in <sys/atomics.h>. 216bd3a98c6b9850a8e55fb0e0ed9f045212c494881Elliott Hughesextern "C" int __futex_wait(volatile void* ftx, int value, const struct timespec* timeout) { 217b30aff405a220495941f1673b0a5e66c4fa8b84cElliott Hughes return __real_futex_wait(ftx, value, timeout); 218bd3a98c6b9850a8e55fb0e0ed9f045212c494881Elliott Hughes} 219bd3a98c6b9850a8e55fb0e0ed9f045212c494881Elliott Hughes 220001707363ddee680d466c88dd330900683dadf63Anthony King// Unity's libmono uses this. 221001707363ddee680d466c88dd330900683dadf63Anthony Kingextern "C" int tkill(pid_t tid, int sig) { 222001707363ddee680d466c88dd330900683dadf63Anthony King return syscall(__NR_tkill, tid, sig); 223001707363ddee680d466c88dd330900683dadf63Anthony King} 224001707363ddee680d466c88dd330900683dadf63Anthony King 225001f8f041bf21c53d4a0b919ef2c859b047bac0aDan Albertextern "C" wchar_t* wcswcs(wchar_t* haystack, wchar_t* needle) { 226001f8f041bf21c53d4a0b919ef2c859b047bac0aDan Albert return wcsstr(haystack, needle); 227001f8f041bf21c53d4a0b919ef2c859b047bac0aDan Albert} 228001f8f041bf21c53d4a0b919ef2c859b047bac0aDan Albert 229567a8de3ca5b4c4f033bfbcdd339a3fd59a76227Elliott Hughes#endif 230