1f0777843c03deb26b1f78c8edd17c557041696e9Elliott Hughes/* 2f0777843c03deb26b1f78c8edd17c557041696e9Elliott Hughes * Copyright (C) 2013 The Android Open Source Project 3f0777843c03deb26b1f78c8edd17c557041696e9Elliott Hughes * 4f0777843c03deb26b1f78c8edd17c557041696e9Elliott Hughes * Licensed under the Apache License, Version 2.0 (the "License"); 5f0777843c03deb26b1f78c8edd17c557041696e9Elliott Hughes * you may not use this file except in compliance with the License. 6f0777843c03deb26b1f78c8edd17c557041696e9Elliott Hughes * You may obtain a copy of the License at 7f0777843c03deb26b1f78c8edd17c557041696e9Elliott Hughes * 8f0777843c03deb26b1f78c8edd17c557041696e9Elliott Hughes * http://www.apache.org/licenses/LICENSE-2.0 9f0777843c03deb26b1f78c8edd17c557041696e9Elliott Hughes * 10f0777843c03deb26b1f78c8edd17c557041696e9Elliott Hughes * Unless required by applicable law or agreed to in writing, software 11f0777843c03deb26b1f78c8edd17c557041696e9Elliott Hughes * distributed under the License is distributed on an "AS IS" BASIS, 12f0777843c03deb26b1f78c8edd17c557041696e9Elliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13f0777843c03deb26b1f78c8edd17c557041696e9Elliott Hughes * See the License for the specific language governing permissions and 14f0777843c03deb26b1f78c8edd17c557041696e9Elliott Hughes * limitations under the License. 15f0777843c03deb26b1f78c8edd17c557041696e9Elliott Hughes */ 16f0777843c03deb26b1f78c8edd17c557041696e9Elliott Hughes 17f0777843c03deb26b1f78c8edd17c557041696e9Elliott Hughes#ifndef _BIONIC_FREEBSD_COMPAT_H_included 18f0777843c03deb26b1f78c8edd17c557041696e9Elliott Hughes#define _BIONIC_FREEBSD_COMPAT_H_included 19f0777843c03deb26b1f78c8edd17c557041696e9Elliott Hughes 206b05c8e28017518fae04a3a601d0d245916561d2Elliott Hughes#define __USE_BSD 21d278b828fef47fb2d7098f8ec70867fbd3da09d6Elliott Hughes#define REPLACE_GETOPT 226b05c8e28017518fae04a3a601d0d245916561d2Elliott Hughes 23ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes/* 24ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes * FreeBSD's libc has three symbols for every symbol: 25ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes * 26ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes * __f will be the actual implementation. 27ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes * _f will be a weak reference to __f (used for calls to f from within the library). 28ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes * f will be a weak reference to __f (used for calls to f from outside the library). 29ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes * 30ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes * We collapse this into just the one symbol, f. 31ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes */ 32ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes 33ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes/* Prevent weak reference generation. */ 34ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes#define __weak_reference(sym,alias) 35ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes 36ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes/* Ensure that the implementation itself gets the underscore-free name. */ 37ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes#define __sleep sleep 38ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes#define __usleep usleep 39ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes 40ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes/* Redirect internal C library calls to the public function. */ 416b05c8e28017518fae04a3a601d0d245916561d2Elliott Hughes#define _close close 426b05c8e28017518fae04a3a601d0d245916561d2Elliott Hughes#define _fcntl fcntl 43677ee5647721df22f13909375d5d0e770a1a80bfElliott Hughes#define _fstat fstat 44ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes#define _nanosleep nanosleep 456b05c8e28017518fae04a3a601d0d245916561d2Elliott Hughes#define _open open 466b05c8e28017518fae04a3a601d0d245916561d2Elliott Hughes 47ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes/* This one is only needed as long as we have a mix of OpenBSD and FreeBSD stdio. */ 48ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes#define _sseek __sseek 496b05c8e28017518fae04a3a601d0d245916561d2Elliott Hughes 50a38cb088619d3e2f2194247038c10897d1c5036eElliott Hughes/* This is in BSD's <stdlib.h>. */ 51a38cb088619d3e2f2194247038c10897d1c5036eElliott Hughes#include <stdint.h> 52a38cb088619d3e2f2194247038c10897d1c5036eElliott Hughesextern uint32_t arc4random_uniform(uint32_t upper_bound); 53a38cb088619d3e2f2194247038c10897d1c5036eElliott Hughes 54f0777843c03deb26b1f78c8edd17c557041696e9Elliott Hughes#endif 55