From: VMware, Inc <> Date: Tue, 13 Mar 2012 19:58:31 +0000 (-0700) Subject: Allow certain libraries compile on Android & iOS. X-Git-Tag: 2012.03.13-651368~85 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5cef403580e36de476ace81394df10fd1cb34c7c;p=thirdparty%2Fopen-vm-tools.git Allow certain libraries compile on Android & iOS. Signed-off-by: Dmitry Torokhov --- diff --git a/open-vm-tools/lib/err/errPosix.c b/open-vm-tools/lib/err/errPosix.c index 73302a8cb..fde8ff6f1 100644 --- a/open-vm-tools/lib/err/errPosix.c +++ b/open-vm-tools/lib/err/errPosix.c @@ -63,7 +63,7 @@ ErrErrno2String(Err_Number errorNumber, // IN { char *p; -#if defined(linux) +#if defined(linux) && !defined(N_PLAT_NLM) && !defined(__ANDROID__) p = strerror_r(errorNumber, buf, bufSize); #else p = strerror(errorNumber); diff --git a/open-vm-tools/lib/file/fileIOPosix.c b/open-vm-tools/lib/file/fileIOPosix.c index 9b2ba5d2b..982706481 100644 --- a/open-vm-tools/lib/file/fileIOPosix.c +++ b/open-vm-tools/lib/file/fileIOPosix.c @@ -44,10 +44,23 @@ * These headers are needed to get __USE_LARGEFILE, __USE_LARGEFILE64, * and SYS__llseek. */ +# ifdef ANDROID_X86 +# undef _GNU_SOURCE +# endif # include +# ifndef _GNU_SOURCE +# define _GNU_SOURCE +# endif # include +#ifdef ANDROID_X86 +# include +#else # include #endif +#endif +#if defined __ANDROID__ +# include +#endif #include #include "su.h" @@ -1856,8 +1869,15 @@ FileIO_Pwritev(FileIODescriptor *fd, // IN: File descriptor goto exit; } if (retval < leftToWrite) { - LOG_ONCE((LGPFX" %s wrote %"FMTSZ"d out of %"FMTSZ"u bytes.\n", - __FUNCTION__, retval, leftToWrite)); + /* + * Using %zd on Android generated a warning about + * expecting a "signed size_t" argument; casting retval to + * "signed size_t" generated an error, though. We've + * already checked for retval == -1 above, so the cast + * below should be OK. Refer to bug 817761. + */ + LOG_ONCE((LGPFX" %s wrote %"FMTSZ"u out of %"FMTSZ"u bytes.\n", + __FUNCTION__, (size_t)retval, leftToWrite)); } buf += retval; diff --git a/open-vm-tools/lib/file/fileInt.h b/open-vm-tools/lib/file/fileInt.h index 37809f069..16c2dabb5 100644 --- a/open-vm-tools/lib/file/fileInt.h +++ b/open-vm-tools/lib/file/fileInt.h @@ -42,7 +42,7 @@ * think once more. */ -#define ADFS_SUPER_MAGIC 0xADF5 +#define ADFS_SUPER_MAGIC 0xadf5 #define AFFS_SUPER_MAGIC 0xADFF #define EXT_SUPER_MAGIC 0x137D #define EXT2_OLD_SUPER_MAGIC 0xEF51 @@ -53,10 +53,10 @@ #define NFS_SUPER_MAGIC 0x6969 #define SMB_SUPER_MAGIC 0x517B #define ISOFS_SUPER_MAGIC 0x9660 -#define JFFS2_SUPER_MAGIC 0x72B6 -#define PROC_SUPER_MAGIC 0x9FA0 -#define OPENPROM_SUPER_MAGIC 0x9FA1 -#define USBDEVICE_SUPER_MAGIC 0x9FA2 +#define JFFS2_SUPER_MAGIC 0x72b6 +#define PROC_SUPER_MAGIC 0x9fa0 +#define OPENPROM_SUPER_MAGIC 0x9fa1 +#define USBDEVICE_SUPER_MAGIC 0x9fa2 #define AUTOFS_SUPER_MAGIC 0x0187 #if !defined(MSDOS_SUPER_MAGIC) @@ -71,7 +71,7 @@ #define XFS_SUPER_MAGIC 0x58465342 #define VMFS_SUPER_MAGIC 0x2fABF15E #define TMPFS_SUPER_MAGIC 0x01021994 -#define JFS_SUPER_MAGIC 0x3153464A +#define JFS_SUPER_MAGIC 0x3153464a #define AFS_SUPER_MAGIC 0x5346414F #define CIFS_SUPER_MAGIC 0xFF534D42 diff --git a/open-vm-tools/lib/file/filePosix.c b/open-vm-tools/lib/file/filePosix.c index 6c2828867..31a77e9fa 100644 --- a/open-vm-tools/lib/file/filePosix.c +++ b/open-vm-tools/lib/file/filePosix.c @@ -39,9 +39,6 @@ # include # else # include -# if defined __ANDROID__ -# include /* for _PATH_MOUNTED */ -# endif # endif #include #endif @@ -99,7 +96,7 @@ static char *FilePosixNearestExistingAncestor(char const *path); * happens the prosix version should be updated to use the generic code. */ -#if defined(__USE_FILE_OFFSET64) || defined(sun) +#if defined(__USE_FILE_OFFSET64) || defined(sun) || defined(__ANDROID__) # define CAN_USE_FTS 0 #else # define CAN_USE_FTS 1 @@ -120,6 +117,14 @@ struct WalkDirContextImpl /* A string for VMFS on ESX file system type */ #define FS_VMFS_ON_ESX "VMFS" +#if defined __ANDROID__ +/* + * Android doesn't support setmntent(), endmntent() or MOUNTED. + */ +#define NO_SETMNTENT +#define NO_ENDMNTENT +#endif + /* *----------------------------------------------------------------------------- @@ -726,6 +731,23 @@ File_GetTimes(ConstUnicode pathName, // IN: timeBuf.tv_nsec = statBuf.__unused3; *attrChangeTime = TimeUtil_UnixTimeToNtTime(timeBuf); } +# elif defined(ANDROID_X86) + { + struct timespec timeBuf; + + timeBuf.tv_sec = statBuf.st_atime; + timeBuf.tv_nsec = statBuf.st_atime_nsec; + *accessTime = TimeUtil_UnixTimeToNtTime(timeBuf); + + + timeBuf.tv_sec = statBuf.st_mtime; + timeBuf.tv_nsec = statBuf.st_mtime_nsec; + *writeTime = TimeUtil_UnixTimeToNtTime(timeBuf); + + timeBuf.tv_sec = statBuf.st_ctime; + timeBuf.tv_nsec = statBuf.st_ctime_nsec; + *attrChangeTime = TimeUtil_UnixTimeToNtTime(timeBuf); + } # else *accessTime = TimeUtil_UnixTimeToNtTime(statBuf.st_atim); *writeTime = TimeUtil_UnixTimeToNtTime(statBuf.st_mtim); @@ -1494,6 +1516,11 @@ static char * FilePosixLookupMountPoint(char const *canPath, // IN: Canonical file path Bool *bind) // OUT: Mounted with --[r]bind? { +#if defined NO_SETMNTENT || defined NO_ENDMNTENT + NOT_IMPLEMENTED(); + errno = ENOSYS; + return NULL; +#else FILE *f; struct mntent mnt; char *buf; @@ -1507,16 +1534,7 @@ FilePosixLookupMountPoint(char const *canPath, // IN: Canonical file path size = 4 * FILE_MAXPATH; // Should suffice for most locales retry: -#if defined __ANDROID__ - /* - * Android supports neither setmntent() nor MOUNTED. - * The code below is a workaround. - */ - NOT_TESTED(); - f = fopen(_PATH_MOUNTED, "r"); -#else f = setmntent(MOUNTED, "r"); -#endif if (f == NULL) { return NULL; } @@ -1569,7 +1587,7 @@ retry: if (strcmp(mnt.mnt_dir, canPath) == 0) { /* - * The --bind and --rbind options behave differently. See + * The --bind and --rbind options behave differently. See * FilePosixGetBlockDevice() for details. * * Sadly (I blame a bug in 'mount'), there is no way to tell them @@ -1591,6 +1609,7 @@ retry: free(buf); return ret; +#endif } #endif diff --git a/open-vm-tools/lib/include/memaligned.h b/open-vm-tools/lib/include/memaligned.h index a784e56df..0044f3259 100644 --- a/open-vm-tools/lib/include/memaligned.h +++ b/open-vm-tools/lib/include/memaligned.h @@ -75,6 +75,7 @@ AlignedMallocImpl(size_t size) // IN void **buf; void **alignedResult; +#undef PAGE_MASK #define PAGE_MASK (PAGE_SIZE - 1) #define PAGE_ROUND_DOWN(_value) ((uintptr_t)(_value) & ~PAGE_MASK) #define PAGE_ROUND_UP(_value) PAGE_ROUND_DOWN((uintptr_t)(_value) + PAGE_MASK) diff --git a/open-vm-tools/lib/include/posix.h b/open-vm-tools/lib/include/posix.h index 13b7fa183..dd3d7b449 100644 --- a/open-vm-tools/lib/include/posix.h +++ b/open-vm-tools/lib/include/posix.h @@ -43,7 +43,7 @@ * leading to a (potentially undetected) mismatch. */ -#if defined(linux) && \ +#if defined(linux) && !defined(ANDROID_X86) && \ (!defined(_LARGEFILE64_SOURCE) || _FILE_OFFSET_BITS != 64) #error LFS support is not enabled! #endif diff --git a/open-vm-tools/lib/include/sigPosixRegs.h b/open-vm-tools/lib/include/sigPosixRegs.h index 29cf1fe80..81d7352b4 100644 --- a/open-vm-tools/lib/include/sigPosixRegs.h +++ b/open-vm-tools/lib/include/sigPosixRegs.h @@ -69,7 +69,9 @@ #endif #include +#ifndef __ANDROID__ #include +#endif #if __linux__ # if defined(__x86_64__) @@ -205,6 +207,16 @@ #define SC_ESP(uc) ((unsigned long) (uc)->uc_mcontext.gregs[ESP]) #define SC_EIP(uc) ((unsigned long) (uc)->uc_mcontext.gregs[EIP]) #endif +#elif defined(ANDROID_X86) +#define SC_EAX(uc) ((unsigned long) (uc)->uc_mcontext.eax) +#define SC_EBX(uc) ((unsigned long) (uc)->uc_mcontext.ebx) +#define SC_ECX(uc) ((unsigned long) (uc)->uc_mcontext.ecx) +#define SC_EDX(uc) ((unsigned long) (uc)->uc_mcontext.edx) +#define SC_EDI(uc) ((unsigned long) (uc)->uc_mcontext.edi) +#define SC_ESI(uc) ((unsigned long) (uc)->uc_mcontext.esi) +#define SC_EBP(uc) ((unsigned long) (uc)->uc_mcontext.ebp) +#define SC_ESP(uc) ((unsigned long) (uc)->uc_mcontext.esp) +#define SC_EIP(uc) ((unsigned long) (uc)->uc_mcontext.eip) #else #ifdef __x86_64__ #define SC_EAX(uc) ((unsigned long) (uc)->uc_mcontext.gregs[GNU_REG_RAX]) diff --git a/open-vm-tools/lib/misc/codesetOld.c b/open-vm-tools/lib/misc/codesetOld.c index b56614a7f..dc05e1744 100644 --- a/open-vm-tools/lib/misc/codesetOld.c +++ b/open-vm-tools/lib/misc/codesetOld.c @@ -81,6 +81,25 @@ static Bool CodeSetOldIso88591ToUtf8Db(char const *bufIn, size_t sizeIn, unsigned int flags, DynBuf *db); #endif +#if defined __ANDROID__ +#include "vm_basic_asm.h" +/* + * Android doesn't have swab(). + */ +void +swab(const void *__restrict src, // IN/OUT + void *__restrict dest, // IN/OUT + ssize_t nbytes) // IN +{ + const uint16 *p = src; + uint16 *q = dest; + ssize_t i; + + for (i = 0; i < nbytes / sizeof(*p); i++) { + q[i] = Bswap16(p[i]); + } +} +#endif #if defined(CURRENT_IS_UTF8) || defined(_WIN32) /* diff --git a/open-vm-tools/lib/misc/hostinfoPosix.c b/open-vm-tools/lib/misc/hostinfoPosix.c index 3a81092a6..f8e97d53f 100644 --- a/open-vm-tools/lib/misc/hostinfoPosix.c +++ b/open-vm-tools/lib/misc/hostinfoPosix.c @@ -66,10 +66,8 @@ #if !defined(USING_AUTOCONF) || defined(HAVE_SYS_VFS_H) #include #endif -#if !defined(sun) && (!defined(USING_AUTOCONF) || (defined(HAVE_SYS_IO_H) && defined(HAVE_SYS_SYSINFO_H))) -# ifndef __ANDROID__ -# include -# endif +#if !defined(sun) && !defined __ANDROID__ && (!defined(USING_AUTOCONF) || (defined(HAVE_SYS_IO_H) && defined(HAVE_SYS_SYSINFO_H))) +#include #include #ifndef HAVE_SYSINFO #define HAVE_SYSINFO 1 @@ -204,6 +202,14 @@ static const DistroInfo distroArray[] = { {NULL, NULL}, }; +#if defined __ANDROID__ +/* + * Android doesn't support getloadavg() or iopl(). + */ +#define NO_GETLOADAVG +#define NO_IOPL +#endif + /* *---------------------------------------------------------------------- @@ -1417,7 +1423,7 @@ HostinfoGetLoadAverage(float *avg0, // IN/OUT: float *avg1, // IN/OUT: float *avg2) // IN/OUT: { -#if (defined(__linux__) && !defined(__UCLIBC__)) || defined(__APPLE__) +#if !defined(NO_GETLOADAVG) && (defined(__linux__) && !defined(__UCLIBC__)) || defined(__APPLE__) double avg[3]; int res; @@ -1871,7 +1877,12 @@ Hostinfo_ResetProcessState(const int *keepFds, // IN: privileges --hpreg */ ASSERT(euid != 0 || getuid() == 0); Id_SetEUid(0); +#if defined NO_IOPL + NOT_IMPLEMENTED(); + errno = ENOSYS; +#else err = iopl(0); +#endif Id_SetEUid(euid); ASSERT_NOT_IMPLEMENTED(err == 0); } diff --git a/open-vm-tools/lib/misc/idLinux.c b/open-vm-tools/lib/misc/idLinux.c index a4e09070d..f6e93ead8 100644 --- a/open-vm-tools/lib/misc/idLinux.c +++ b/open-vm-tools/lib/misc/idLinux.c @@ -29,9 +29,15 @@ #include #ifdef __APPLE__ #include +#include +#if !defined TARGET_OS_IPHONE +#define TARGET_OS_IPHONE 0 +#endif +#if !TARGET_OS_IPHONE #include #include #endif +#endif #if defined __ANDROID__ #include #endif @@ -74,7 +80,7 @@ static int uid32 = 1; #endif #endif // __linux__ -#if defined(__APPLE__) +#if defined(__APPLE__) && !TARGET_OS_IPHONE #include static AuthorizationRef IdAuthCreate(void); @@ -338,7 +344,7 @@ Id_SetREGid(gid_t gid, // IN: new gid #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !TARGET_OS_IPHONE /* *---------------------------------------------------------------------------- * @@ -842,7 +848,11 @@ Id_BeginSuperUser(void) uid = (uid_t) -1; // already root; nothing to do } else { #if defined(__APPLE__) +#if TARGET_OS_IPHONE + Warning("XXXIOS: implement %s\n", __func__); +#else syscall(SYS_settid, KAUTH_UID_NONE, KAUTH_GID_NONE /* Ignored. */); +#endif #else Id_SetRESUid((uid_t) -1, (uid_t) 0, (uid_t) -1); // effectively root #endif diff --git a/open-vm-tools/lib/misc/machineID.c b/open-vm-tools/lib/misc/machineID.c index a51e64ef2..392a51221 100644 --- a/open-vm-tools/lib/misc/machineID.c +++ b/open-vm-tools/lib/misc/machineID.c @@ -361,11 +361,14 @@ ObtainHardwareID(uint64 *hardwareID) // OUT: return 0; } -#elif defined(linux) // Linux +#elif defined(linux) || defined __ANDROID__ #include #include #include #include +#if defined __ANDROID__ +#include // For SOCK_DGRAM etc. +#endif /* diff --git a/open-vm-tools/lib/misc/msgfmt.c b/open-vm-tools/lib/misc/msgfmt.c index 885f66a77..3681b2d09 100644 --- a/open-vm-tools/lib/misc/msgfmt.c +++ b/open-vm-tools/lib/misc/msgfmt.c @@ -175,6 +175,13 @@ memchr(const void *s, int c, size_t n) #endif // } +#if defined __ANDROID__ +/* + * Android doesn't support dtoa(). + */ +#define NO_DTOA +#endif + /* * Local data @@ -1965,7 +1972,7 @@ MsgFmtSnprintfWork(char **outbuf, size_t bufSize, const char *fmt0, */ char *decimal_point; /* locale specific decimal point */ #if defined __ANDROID__ - static const char dp = '.'; + static char dp = '.'; #endif int signflag; /* true if float is negative */ union { /* floating point arguments %[aAeEfFgG] */ @@ -2396,9 +2403,17 @@ MsgFmtSnprintfWork(char **outbuf, size_t bufSize, const char *fmt0, goto error; } fparg.dbl = a->v.float64; +#if defined NO_DTOA + NOT_TESTED(); + dtoaresult = NULL; + sbuf.error = TRUE; + + goto error; +#else dtoaresult = cp = dtoa(fparg.dbl, expchar ? 2 : 3, prec, &expt, &signflag, &dtoaend); +#endif if (expt == 9999) expt = INT_MAX; if (signflag) diff --git a/open-vm-tools/lib/misc/posixPosix.c b/open-vm-tools/lib/misc/posixPosix.c index 6c0df44f5..b4e3ba576 100644 --- a/open-vm-tools/lib/misc/posixPosix.c +++ b/open-vm-tools/lib/misc/posixPosix.c @@ -65,7 +65,7 @@ #include #endif -#if !defined(__FreeBSD__) || __FreeBSD_release >= 503001 +#if (!defined(__FreeBSD__) || __FreeBSD_release >= 503001) && !defined __ANDROID__ #define VM_SYSTEM_HAS_GETPWNAM_R 1 #define VM_SYSTEM_HAS_GETPWUID_R 1 #define VM_SYSTEM_HAS_GETGRNAM_R 1 @@ -89,6 +89,17 @@ static struct passwd *GetpwInternal(struct passwd *pw); static int GetpwInternal_r(struct passwd *pw, char *buf, size_t size, struct passwd **ppw); +#if defined __ANDROID__ +/* + * Android doesn't support getmntent_r(), getpwent() or setmntent(). + */ +#define NO_GETMNTENT_R +#define NO_GETPWENT +#define NO_SETMNTENT + +EXTERN int truncate(const char *, off_t); +#endif + /* *---------------------------------------------------------------------- @@ -1911,9 +1922,15 @@ Posix_Unsetenv(ConstUnicode name) // IN: struct passwd * Posix_Getpwent(void) { +#if defined NO_GETPWENT + NOT_IMPLEMENTED(); + errno = ENOSYS; + return NULL; +#else struct passwd *pw = getpwent(); return GetpwInternal(pw); +#endif } #if !defined(VM_SYSTEM_HAS_GETPWNAM_R) || \ @@ -2893,6 +2910,11 @@ FILE * Posix_Setmntent(ConstUnicode pathName, // IN: const char *mode) // IN: { +#if defined NO_SETMNTENT + NOT_IMPLEMENTED(); + errno = ENOSYS; + return NULL; +#else char *path; FILE *stream; @@ -2901,19 +2923,11 @@ Posix_Setmntent(ConstUnicode pathName, // IN: if (!PosixConvertToCurrent(pathName, &path)) { return NULL; } -#if defined __ANDROID__ - /* - * Android doesn't support setmntent(). - */ - NOT_TESTED(); - errno = ENOSYS; - return NULL; -#else stream = setmntent(path, mode); -#endif free(path); return stream; +#endif } @@ -3014,11 +3028,8 @@ Posix_Getmntent_r(FILE *fp, // IN: char *buf, // IN: int size) // IN: { -#if defined __ANDROID__ - /* - * Android doesn't support getmntent_r(); - * using getmntent() will break thread safety. - */ +#if defined NO_GETMNTENT_R + NOT_IMPLEMENTED(); errno = ENOSYS; return NULL; #else diff --git a/open-vm-tools/lib/misc/utilMem.c b/open-vm-tools/lib/misc/utilMem.c index 5b3410b32..d5714ea87 100644 --- a/open-vm-tools/lib/misc/utilMem.c +++ b/open-vm-tools/lib/misc/utilMem.c @@ -31,6 +31,14 @@ #include "vm_assert.h" +#ifdef __APPLE__ +#include +#if !defined TARGET_OS_IPHONE +#define TARGET_OS_IPHONE 0 +#endif +#endif + + /* *----------------------------------------------------------------------------- * @@ -242,6 +250,7 @@ Util_Memcpy(void *dest, const void *src, size_t count) { +#if !defined(__ANDROID__) && !defined(TARGET_OS_IPHONE) uintptr_t align = ((uintptr_t)dest | (uintptr_t)src | count); #if defined __GNUC__ @@ -313,6 +322,7 @@ Util_Memcpy(void *dest, #endif +#endif #endif memcpy(dest, src, count); diff --git a/open-vm-tools/lib/misc/util_misc.c b/open-vm-tools/lib/misc/util_misc.c index 3a67f341a..ecdb885b7 100644 --- a/open-vm-tools/lib/misc/util_misc.c +++ b/open-vm-tools/lib/misc/util_misc.c @@ -400,7 +400,12 @@ Util_GetPrime(unsigned n0) // IN: } -#if defined(linux) +#if defined(linux) && !defined(ANDROID_X86) +/* + * Android x86 has its own gettid. gettid has been declared on + * and defined as an extern function on . + */ + /* *----------------------------------------------------------------------------- * diff --git a/open-vm-tools/lib/misc/vthreadBase.c b/open-vm-tools/lib/misc/vthreadBase.c index 28b23ad3b..e938f2ddc 100644 --- a/open-vm-tools/lib/misc/vthreadBase.c +++ b/open-vm-tools/lib/misc/vthreadBase.c @@ -119,8 +119,13 @@ typedef DWORD VThreadBaseKeyType; #define VTHREADBASE_INVALID_KEY (VThreadBaseKeyType)(TLS_OUT_OF_INDEXES) #else typedef pthread_key_t VThreadBaseKeyType; +/* PTHREAD_KEYS_MAX not defined on Android. */ +#if defined __linux__ && !defined PTHREAD_KEYS_MAX +#define VTHREADBASE_INVALID_KEY (VThreadBaseKeyType)(1024) +#else #define VTHREADBASE_INVALID_KEY (VThreadBaseKeyType)(PTHREAD_KEYS_MAX) #endif +#endif static void VThreadBaseSimpleNoID(void); static void VThreadBaseSimpleFreeID(void *tlsData); diff --git a/open-vm-tools/lib/string/bsd_output_shared.c b/open-vm-tools/lib/string/bsd_output_shared.c index 1c49262f1..e0a310be2 100644 --- a/open-vm-tools/lib/string/bsd_output_shared.c +++ b/open-vm-tools/lib/string/bsd_output_shared.c @@ -40,7 +40,7 @@ //#include -#if !defined(STR_NO_WIN32_LIBS) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) +#if !defined(STR_NO_WIN32_LIBS) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__ANDROID__) #include #include diff --git a/open-vm-tools/lib/string/bsd_vsnprintf.c b/open-vm-tools/lib/string/bsd_vsnprintf.c index e3e2ad2e2..9b88f5805 100644 --- a/open-vm-tools/lib/string/bsd_vsnprintf.c +++ b/open-vm-tools/lib/string/bsd_vsnprintf.c @@ -73,6 +73,15 @@ #include "convertutf.h" #include "str.h" + +#if defined __ANDROID__ +/* + * Android doesn't support dtoa() or ldtoa(). + */ +#define NO_DTOA +#define NO_LDTOA +#endif + static char *__ultoa(u_long, char *, int, int, const char *, int, char, const char *); static void __find_arguments(const char *, va_list, union arg **); @@ -453,6 +462,9 @@ bsd_vsnprintf_core(char **outbuf, * D: expchar holds this character; '\0' if no exponent, e.g. %f * F: at least two digits for decimal, at least one digit for hex */ +#if defined __ANDROID__ + static char dp = '.'; +#endif int signflag; /* true if float is negative */ union { /* floating point arguments %[aAeEfFgG] */ double dbl; @@ -615,6 +627,15 @@ bsd_vsnprintf_core(char **outbuf, convbuf = NULL; #if !defined(NO_FLOATING_POINT) dtoaresult = NULL; +#if !defined __ANDROID__ + decimal_point = localeconv()->decimal_point; +#else + /* + * Struct lconv is not working! For decimal_point, + * using '.' instead is a workaround. + */ + decimal_point = &dp; +#endif #endif fmt = (char *)fmt0; @@ -733,9 +754,15 @@ bsd_vsnprintf_core(char **outbuf, goto rflag; case '\'': flags |= GROUPING; +#if !defined __ANDROID__ thousands_sep = thousands_sepIn; grouping = groupingIn; - +#else + /* + * Struct lconv is not working! The code below is a workaround. + */ + thousands_sep = ','; +#endif /* * Grouping should not begin with 0, but it nevertheless does (see * bug 281072) and makes the formatting code behave badly, so we @@ -901,12 +928,32 @@ bsd_vsnprintf_core(char **outbuf, } if (flags & LLONGINT) { fparg.ldbl = GETARG(long double); +#if defined NO_LDTOA + dtoaresult = NULL; + /* + * Below is to keep compiler happy + */ + signflag = -1; + expt = 0; + dtoaend = NULL; +#else dtoaresult = cp = ldtoa(&fparg.ldbl, expchar ? 2 : 3, prec, &expt, &signflag, &dtoaend); +#endif } else { fparg.dbl = GETARG(double); +#if defined NO_DTOA + dtoaresult = NULL; + /* + * Below is to keep compiler happy + */ + signflag = -1; + expt = 0; + dtoaend = NULL; +#else dtoaresult = cp = dtoa(fparg.dbl, expchar ? 2 : 3, prec, &expt, &signflag, &dtoaend); +#endif } /* Our dtoa / ldtoa call strdup(), which can fail. PR319844 */ diff --git a/open-vm-tools/lib/user/util.c b/open-vm-tools/lib/user/util.c index 9ee44f6b7..96bc09ff4 100644 --- a/open-vm-tools/lib/user/util.c +++ b/open-vm-tools/lib/user/util.c @@ -54,7 +54,7 @@ # include #endif -#if defined(__linux__) && !defined(VMX86_TOOLS) +#if defined(__linux__) && !defined(VMX86_TOOLS) && !defined(__ANDROID__) # include #endif @@ -428,7 +428,7 @@ UtilBacktraceFromPointerCallback(struct _Unwind_Context *ctx, // IN: Unwind cont return _URC_END_OF_STACK; } -#if !defined(_WIN32) && !defined(VMX86_TOOLS) +#if !defined(_WIN32) && !defined(VMX86_TOOLS) && !defined(__ANDROID__) /* *----------------------------------------------------------------------------- * @@ -575,7 +575,7 @@ Util_BacktraceFromPointerWithFunc(uintptr_t *basePtr, #elif !defined(VM_X86_64) uintptr_t *x = basePtr; int i; -#if !defined(_WIN32) && !defined(VMX86_TOOLS) +#if !defined(_WIN32) && !defined(VMX86_TOOLS) && !defined(__ANDROID__) Dl_info dli; #endif @@ -588,7 +588,7 @@ Util_BacktraceFromPointerWithFunc(uintptr_t *basePtr, x = (uintptr_t *) x[0]; } -#if !defined(_WIN32) && !defined(VMX86_TOOLS) +#if !defined(_WIN32) && !defined(VMX86_TOOLS) && !defined(__ANDROID__) /* * We do a separate pass here that includes symbols in order to * make sure the base backtrace that does not call dladdr() etc.