diff options
Diffstat (limited to 'pr/src/md/unix/unix.c')
-rw-r--r-- | pr/src/md/unix/unix.c | 65 |
1 files changed, 29 insertions, 36 deletions
diff --git a/pr/src/md/unix/unix.c b/pr/src/md/unix/unix.c index 740794a6..9a91a01c 100644 --- a/pr/src/md/unix/unix.c +++ b/pr/src/md/unix/unix.c @@ -1,39 +1,7 @@ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the Netscape Portable Runtime (NSPR). - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998-2000 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "primpl.h" @@ -2256,6 +2224,10 @@ PRInt32 _MD_open(const char *name, PRIntn flags, PRIntn mode) PR_Lock(_pr_rename_lock); } +#if defined(ANDROID) + osflags |= O_LARGEFILE; +#endif + rv = _md_iovector._open64(name, osflags, mode); if (rv < 0) { @@ -2742,6 +2714,23 @@ static void* _MD_Unix_mmap64( } /* _MD_Unix_mmap64 */ #endif /* defined(_PR_NO_LARGE_FILES) || defined(SOLARIS2_5) */ +/* Android doesn't have mmap64. */ +#if defined(ANDROID) +extern void *__mmap2(void *, size_t, int, int, int, size_t); + +#define ANDROID_PAGE_SIZE 4096 + +static void * +mmap64(void *addr, size_t len, int prot, int flags, int fd, loff_t offset) +{ + if (offset & (ANDROID_PAGE_SIZE - 1)) { + errno = EINVAL; + return MAP_FAILED; + } + return __mmap2(addr, len, prot, flags, fd, offset / ANDROID_PAGE_SIZE); +} +#endif + #if defined(OSF1) && defined(__GNUC__) /* @@ -2796,7 +2785,11 @@ static void _PR_InitIOV(void) _md_iovector._stat64 = stat; _md_iovector._lseek64 = _MD_Unix_lseek64; #elif defined(_PR_HAVE_OFF64_T) -#if defined(IRIX5_3) +#if defined(IRIX5_3) || defined(ANDROID) + /* + * Android doesn't have open64. We pass the O_LARGEFILE flag to open + * in _MD_open. + */ _md_iovector._open64 = open; #else _md_iovector._open64 = open64; |