blob: b0346d41876d89558b09269110ed9c0515b4dba3 [file] [log] [blame]
Elliott Hughes567a8de2013-10-24 17:14:55 -07001/*
2 * Copyright (C) 2013 The Android Open Source Project
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29// This file perpetuates the mistakes of the past, but only for 32-bit targets.
30#if !defined(__LP64__)
31
Calin Juravlea4eafa62014-03-10 18:10:04 +000032#include <pthread.h>
Elliott Hughes567a8de2013-10-24 17:14:55 -070033#include <stdlib.h>
34#include <sys/resource.h>
35#include <sys/time.h>
36#include <sys/types.h>
37#include <sys/wait.h>
38#include <unistd.h>
39
40// These were accidentally declared in <unistd.h> because we stupidly used to inline
41// getpagesize() and __getpageshift(). Needed for backwards compatibility with old NDK apps.
42extern "C" {
43 unsigned int __page_size = PAGE_SIZE;
Elliott Hughes0e44bc32014-02-24 15:55:31 -080044 unsigned int __page_shift = 12;
Elliott Hughes567a8de2013-10-24 17:14:55 -070045}
46
47// TODO: remove this backward compatibility hack (for jb-mr1 strace binaries).
48extern "C" pid_t __wait4(pid_t pid, int* status, int options, struct rusage* rusage) {
49 return wait4(pid, status, options, rusage);
50}
51
Elliott Hughes06209252013-11-06 16:20:54 -080052// TODO: does anything still need this?
Elliott Hughes567a8de2013-10-24 17:14:55 -070053extern "C" int __open() {
54 abort();
55}
56
Elliott Hughes06209252013-11-06 16:20:54 -080057// TODO: does anything still need this?
58extern "C" void** __get_tls() {
59#include "private/__get_tls.h"
60 return __get_tls();
61}
62
Elliott Hughes152b9de2014-03-10 15:54:40 -070063// This non-standard function was in our <string.h> for some reason.
64extern "C" void memswap(void* m1, void* m2, size_t n) {
65 char* p = reinterpret_cast<char*>(m1);
66 char* p_end = p + n;
67 char* q = reinterpret_cast<char*>(m2);
68 while (p < p_end) {
69 char tmp = *p;
70 *p = *q;
71 *q = tmp;
72 p++;
73 q++;
74 }
75}
76
Calin Juravlea4eafa62014-03-10 18:10:04 +000077extern "C" int pthread_attr_setstackaddr(pthread_attr_t*, void*) {
78 // This was removed from POSIX.1-2008, and is not implemented on bionic.
79 // Needed for ABI compatibility with the NDK.
80 return ENOSYS;
81}
82
83extern "C" int pthread_attr_getstackaddr(const pthread_attr_t* attr, void** stack_addr) {
84 // This was removed from POSIX.1-2008.
85 // Needed for ABI compatibility with the NDK.
86 *stack_addr = (char*)attr->stack_base + attr->stack_size;
87 return 0;
88}
89
Elliott Hughes567a8de2013-10-24 17:14:55 -070090#endif