diff --git a/xpcom/base/nsDebugImpl.cpp b/xpcom/base/nsDebugImpl.cpp index eb2357e3ef7f..2992f37ebcf8 100644 --- a/xpcom/base/nsDebugImpl.cpp +++ b/xpcom/base/nsDebugImpl.cpp @@ -50,6 +50,10 @@ #include "prenv.h" #include "pratom.h" +#ifdef ANDROID +#include +#endif + #if defined(XP_BEOS) /* For DEBUGGER macros */ #include @@ -309,6 +313,10 @@ NS_DebugBreak(PRUint32 aSeverity, const char *aStr, const char *aExpr, fprintf(stderr, "\07"); #endif +#ifdef ANDROID + __android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", buf.buffer); +#endif + // Write the message to stderr fprintf(stderr, "%s\n", buf.buffer); fflush(stderr); diff --git a/xpcom/base/nsUUIDGenerator.cpp b/xpcom/base/nsUUIDGenerator.cpp index 0d2bc2c99286..a9f74fd45cd3 100644 --- a/xpcom/base/nsUUIDGenerator.cpp +++ b/xpcom/base/nsUUIDGenerator.cpp @@ -76,7 +76,7 @@ nsUUIDGenerator::Init() // We're a service, so we're guaranteed that Init() is not going // to be reentered while we're inside Init(). -#if !defined(XP_WIN) && !defined(XP_MACOSX) +#if !defined(XP_WIN) && !defined(XP_MACOSX) && !defined(ANDROID) /* initialize random number generator using NSPR random noise */ unsigned int seed; @@ -171,11 +171,19 @@ nsUUIDGenerator::GenerateUUIDInPlace(nsID* id) * back to it; instead, we use the value returned when we called * initstate, since older glibc's have broken setstate() return values */ +#ifndef ANDROID setstate(mState); +#endif PRSize bytesLeft = sizeof(nsID); while (bytesLeft > 0) { +#ifdef ANDROID + long rval = arc4random(); + const int mRBytes = 4; +#else long rval = random(); +#endif + PRUint8 *src = (PRUint8*)&rval; // We want to grab the mRBytes least significant bytes of rval, since @@ -199,8 +207,10 @@ nsUUIDGenerator::GenerateUUIDInPlace(nsID* id) id->m3[0] &= 0x3f; id->m3[0] |= 0x80; +#ifndef ANDROID /* Restore the previous RNG state */ setstate(mSavedState); +#endif #endif return NS_OK; diff --git a/xpcom/base/nsUUIDGenerator.h b/xpcom/base/nsUUIDGenerator.h index ee0fd11df2d6..a07e633449de 100644 --- a/xpcom/base/nsUUIDGenerator.h +++ b/xpcom/base/nsUUIDGenerator.h @@ -59,7 +59,7 @@ protected: PRLock* mLock; #if defined(WINCE) -#elif !defined(XP_WIN) && !defined(XP_MACOSX) +#elif !defined(XP_WIN) && !defined(XP_MACOSX) && !defined(ANDROID) char mState[128]; char *mSavedState; PRUint8 mRBytes; diff --git a/xpcom/build/nsXPComInit.cpp b/xpcom/build/nsXPComInit.cpp index 0fbf4b7ad8e6..2152e601b9de 100644 --- a/xpcom/build/nsXPComInit.cpp +++ b/xpcom/build/nsXPComInit.cpp @@ -536,7 +536,7 @@ NS_InitXPCOM3(nsIServiceManager* *result, rv = nsTimerImpl::Startup(); NS_ENSURE_SUCCESS(rv, rv); -#ifndef WINCE +#if !defined(WINCE) && !defined(ANDROID) NS_TIME_FUNCTION_MARK("Next: setlocale"); // If the locale hasn't already been setup by our embedder, diff --git a/xpcom/glue/nsCRTGlue.cpp b/xpcom/glue/nsCRTGlue.cpp index 5baf337188a0..fea67263d3aa 100644 --- a/xpcom/glue/nsCRTGlue.cpp +++ b/xpcom/glue/nsCRTGlue.cpp @@ -49,6 +49,10 @@ #include #endif +#ifdef ANDROID +#include +#endif + const char* NS_strspnp(const char *delims, const char *str) { @@ -279,6 +283,15 @@ printf_stderr(const char *fmt, ...) fclose(fp); } +#elif defined(ANDROID) +void +printf_stderr(const char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + __android_log_vprint(ANDROID_LOG_INFO, "Gecko", fmt, args); + va_end(args); +} #else void printf_stderr(const char *fmt, ...) diff --git a/xpcom/io/SpecialSystemDirectory.cpp b/xpcom/io/SpecialSystemDirectory.cpp index 0c29bcfca695..458c6a23253f 100644 --- a/xpcom/io/SpecialSystemDirectory.cpp +++ b/xpcom/io/SpecialSystemDirectory.cpp @@ -291,6 +291,9 @@ GetUnixHomeDir(nsILocalFile** aFile) PR_TRUE, aFile); } +#elif defined(ANDROID) + // XXX no home dir on android; maybe we should return the sdcard if present? + return NS_ERROR_FAILURE; #else return NS_NewNativeLocalFile(nsDependentCString(PR_GetEnv("HOME")), PR_TRUE, aFile); diff --git a/xpcom/io/nsLocalFileUnix.cpp b/xpcom/io/nsLocalFileUnix.cpp index d5987538ac60..500903067f34 100644 --- a/xpcom/io/nsLocalFileUnix.cpp +++ b/xpcom/io/nsLocalFileUnix.cpp @@ -1105,7 +1105,18 @@ nsLocalFile::SetFileSize(PRInt64 aFileSize) { CHECK_mPath(); -#ifdef HAVE_TRUNCATE64 +#if defined(ANDROID) + /* no truncate on bionic */ + int fd = open(mPath.get(), O_WRONLY); + if (fd == -1) + return NSRESULT_FOR_ERRNO(); + + int ret = ftruncate(fd, (off_t)aFileSize); + close(fd); + + if (ret == -1) + return NSRESULT_FOR_ERRNO(); +#elif defined(HAVE_TRUNCATE64) if (truncate64(mPath.get(), (off64_t)aFileSize) == -1) return NSRESULT_FOR_ERRNO(); #else diff --git a/xpcom/io/nsNativeCharsetUtils.cpp b/xpcom/io/nsNativeCharsetUtils.cpp index eabcc8c9be51..e717d09f4ff9 100644 --- a/xpcom/io/nsNativeCharsetUtils.cpp +++ b/xpcom/io/nsNativeCharsetUtils.cpp @@ -43,9 +43,9 @@ #include "xpcom-private.h" //----------------------------------------------------------------------------- -// XP_MACOSX or XP_BEOS +// XP_MACOSX or XP_BEOS or ANDROID //----------------------------------------------------------------------------- -#if defined(XP_BEOS) || defined(XP_MACOSX) +#if defined(XP_BEOS) || defined(XP_MACOSX) || defined(ANDROID) #include "nsAString.h" #include "nsReadableUtils.h" diff --git a/xpcom/io/nsNativeCharsetUtils.h b/xpcom/io/nsNativeCharsetUtils.h index c7358e27b2b0..258a19cfe1f6 100644 --- a/xpcom/io/nsNativeCharsetUtils.h +++ b/xpcom/io/nsNativeCharsetUtils.h @@ -70,12 +70,12 @@ NS_COM nsresult NS_CopyUnicodeToNative(const nsAString &input, nsACString &outp * a real function. On Mac OS X and BeOS, it's always UTF-8 while on Windows * and other platforms (e.g. OS2), it's never UTF-8. */ -#if defined(XP_UNIX) && !defined(XP_MACOSX) +#if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(ANDROID) NS_COM PRBool NS_IsNativeUTF8(); #else inline PRBool NS_IsNativeUTF8() { -#if defined(XP_MACOSX) || defined(XP_BEOS) +#if defined(XP_MACOSX) || defined(XP_BEOS) || defined(ANDROID) return PR_TRUE; #else return PR_FALSE; diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_arm.cpp b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_arm.cpp index df3bc2135566..a269fa3b9f45 100644 --- a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_arm.cpp +++ b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_arm.cpp @@ -40,7 +40,7 @@ #include "xptcprivate.h" -#if !defined(LINUX) || !defined(__arm__) +#if !defined(__arm__) && !(defined(LINUX) || defined(ANDROID)) #error "This code is for Linux ARM only. Check that it works on your system, too.\nBeware that this code is highly compiler dependent." #endif diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_arm.cpp b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_arm.cpp index 0982415d58cb..ca66382ebb02 100644 --- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_arm.cpp +++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_arm.cpp @@ -41,7 +41,7 @@ #include "xptcprivate.h" #include "xptiprivate.h" -#if !defined(LINUX) || !defined(__arm__) +#if !defined(__arm__) && !(defined(LINUX) || defined(ANDROID)) #error "This code is for Linux ARM only. Please check if it works for you, too.\nDepends strongly on gcc behaviour." #endif diff --git a/xpcom/typelib/xpidl/Makefile.in b/xpcom/typelib/xpidl/Makefile.in index 5b01c65a9004..f79b269c7917 100644 --- a/xpcom/typelib/xpidl/Makefile.in +++ b/xpcom/typelib/xpidl/Makefile.in @@ -44,8 +44,10 @@ include $(DEPTH)/config/autoconf.mk MODULE = xpcom -ifneq (,$(filter-out WINCE SYMBIAN,$(OS_ARCH))) -# Sadly, the code here is too smart for the WinCE/Symbian compiler's brain +# there's no reason to build a target xpidl, why do we do this at all? +##ifneq (,$(filter-out WINCE SYMBIAN,$(OS_ARCH))) +### Sadly, the code here is too smart for the WinCE/Symbian compiler's brain +ifndef CROSS_COMPILE PROGRAM = xpidl$(BIN_SUFFIX) SDK_BINARY = $(PROGRAM) endif