Skip to content

Commit

Permalink
fixing some issues for android: localeconv, sysinfo, thread schedulin…
Browse files Browse the repository at this point in the history
…g param
  • Loading branch information
apaikan committed Apr 21, 2016
1 parent fd5eece commit f47e999
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
33 changes: 31 additions & 2 deletions src/libYARP_OS/src/BottleImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -805,10 +805,25 @@ ConstString StoreDouble::toStringFlex() const

// YARP Bug 2526259: Locale settings influence YARP behavior
// Need to deal with alternate versions of the decimal point.
#ifndef __ANDROID__
struct lconv* lc = localeconv();
size_t offset = str.find(lc->decimal_point);
if (offset != ConstString::npos) {
str[offset] = '.';
#else
const char *decimalPoint;
#ifdef HAVE_LOCALECONV
struct lconv * lc=localeconv();
decimalPoint = lc->decimal_point;
#else
decimalPoint = getenv("LOCALE_DECIMAL_POINT");
#endif
if (!decimalPoint)
decimalPoint = ".";
size_t offset = str.find(decimalPoint);
if (offset!=String::npos){
str[offset]='.';
#endif
} else {
str += ".0";
}
Expand Down Expand Up @@ -837,8 +852,22 @@ void StoreDouble::fromString(const ConstString& src)
ConstString tmp = src;
size_t offset = tmp.find(".");
if (offset != ConstString::npos) {
struct lconv* lc = localeconv();
tmp[offset] = lc->decimal_point[0];
#ifndef __ANDROID__
struct lconv* lc = localeconv();
tmp[offset] = lc->decimal_point[0];
#else
const char *decimalPoint;
#ifdef HAVE_LOCALECONV
struct lconv * lc=localeconv();
decimalPoint = lc->decimal_point;
#else
decimalPoint = getenv("LOCALE_DECIMAL_POINT");
#endif
if (!decimalPoint)
decimalPoint = ".";

tmp[offset] = decimalPoint[0];
#endif
}
x = ACE_OS::strtod(tmp.c_str(), NULL);
}
Expand Down
2 changes: 2 additions & 0 deletions src/libYARP_OS/src/PortCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2419,7 +2419,9 @@ bool PortCore::setProcessSchedulingParam(int priority, int policy) {
#if defined(__linux__)
// set the sched properties of all threads within the process
struct sched_param sch_param;
#ifndef __ANDROID__
sch_param.__sched_priority = priority;
#endif

DIR *dir;
char path[PATH_MAX];
Expand Down
7 changes: 6 additions & 1 deletion src/libYARP_OS/src/SystemInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ using namespace yarp::os;
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <linux/if.h>
#ifndef __ANDROID__
#include <sys/statvfs.h>
#endif
#include <pwd.h>

extern char **environ;
Expand Down Expand Up @@ -296,13 +298,14 @@ SystemInfo::StorageInfo SystemInfo::getStorageInfo()
yarp::os::ConstString strHome = getUserInfo().homeDir;
if(!strHome.length())
strHome = "/home";

#ifndef __ANDROID__
struct statvfs vfs;
if(statvfs(strHome.c_str(), &vfs) == 0)
{
storage.totalSpace = (int)(vfs.f_blocks*vfs.f_bsize/(1048576)); // in MB
storage.freeSpace = (int)(vfs.f_bavail*vfs.f_bsize/(1048576)); // in MB
}
#endif

#endif
return storage;
Expand Down Expand Up @@ -696,8 +699,10 @@ SystemInfo::ProcessInfo SystemInfo::getProcessInfo(int pid) {

// scheduling params
struct sched_param param;
#ifndef __ANDROID__
if( sched_getparam(pid, &param) == 0 )
info.schedPriority = param.__sched_priority;
#endif
info.schedPolicy = sched_getscheduler(pid);

#elif defined(WIN32)
Expand Down
4 changes: 4 additions & 0 deletions src/libYARP_OS/src/ThreadImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ PLATFORM_THREAD_RETURN theExecutiveBranch (void *args)
#if defined(__linux__)
// Use the POSIX syscalls to get
// the real thread ID (gettid) on Linux machine
#ifndef __ANDROID__
thread->tid = (long) syscall(SYS_gettid);
#else
thread->tid = 0;
#endif
#endif

// c++11 std::thread, pthread and ace threads on some platforms do not
Expand Down

0 comments on commit f47e999

Please sign in to comment.