X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fporting.cpp;h=2fc5d036476e9304697924b2386bf239f57c4dcf;hb=77137a92cfc221b885b8eae68f13cede604fcac7;hp=3c2a5c82488f88dfea5b5b1d9c79c7d0e1b9f417;hpb=c410e9182d322a8c095ef94fbadf4d8f541e6b98;p=minetest.git diff --git a/src/porting.cpp b/src/porting.cpp index 3c2a5c824..2fc5d0364 100644 --- a/src/porting.cpp +++ b/src/porting.cpp @@ -167,6 +167,7 @@ int getNumberOfProcessors() { } +#ifndef __ANDROID__ bool threadBindToProcessor(threadid_t tid, int pnumber) { #if defined(_WIN32) @@ -194,7 +195,7 @@ bool threadBindToProcessor(threadid_t tid, int pnumber) { pnumber, NULL) == 0; #elif defined(_AIX) - + return bindprocessor(BINDTHREAD, (tid_t)tid, pnumber) == 0; #elif defined(__hpux) || defined(hpux) @@ -203,11 +204,11 @@ bool threadBindToProcessor(threadid_t tid, int pnumber) { return pthread_processor_bind_np(PTHREAD_BIND_ADVISORY_NP, &answer, pnumber, tid) == 0; - + #elif defined(__APPLE__) struct thread_affinity_policy tapol; - + thread_port_t threadport = pthread_mach_thread_np(tid); tapol.affinity_tag = pnumber + 1; return thread_policy_set(threadport, THREAD_AFFINITY_POLICY, @@ -219,7 +220,7 @@ bool threadBindToProcessor(threadid_t tid, int pnumber) { #endif } - +#endif bool threadSetPriority(threadid_t tid, int prio) { #if defined(_WIN32) @@ -232,21 +233,21 @@ bool threadSetPriority(threadid_t tid, int prio) { CloseHandle(hThread); return success; - + #else struct sched_param sparam; int policy; - + if (pthread_getschedparam(tid, &policy, &sparam) != 0) return false; - + int min = sched_get_priority_min(policy); int max = sched_get_priority_max(policy); sparam.sched_priority = min + prio * (max - min) / THREAD_PRIORITY_HIGHEST; return pthread_setschedparam(tid, policy, &sparam) == 0; - + #endif } @@ -458,9 +459,15 @@ void initializePaths() { char buf[BUFSIZ]; memset(buf, 0, BUFSIZ); - assert(readlink("/proc/self/exe", buf, BUFSIZ-1) != -1); - pathRemoveFile(buf, '/'); - bindir = buf; + if (readlink("/proc/self/exe", buf, BUFSIZ-1) == -1) { + errorstream << "Unable to read bindir "<< std::endl; +#ifndef __ANDROID__ + assert("Unable to read bindir" == 0); +#endif + } else { + pathRemoveFile(buf, '/'); + bindir = buf; + } } // Find share directory from these. @@ -472,6 +479,9 @@ void initializePaths() trylist.push_back( bindir + DIR_DELIM + ".." + DIR_DELIM + "share" + DIR_DELIM + PROJECT_NAME); trylist.push_back(bindir + DIR_DELIM + ".."); +#ifdef __ANDROID__ + trylist.push_back(path_user); +#endif for(std::list::const_iterator i = trylist.begin(); i != trylist.end(); i++) @@ -490,8 +500,9 @@ void initializePaths() path_share = trypath; break; } - +#ifndef __ANDROID__ path_user = std::string(getenv("HOME")) + DIR_DELIM + "." + PROJECT_NAME; +#endif /* OS X @@ -539,6 +550,7 @@ v2u32 getWindowSize() { return device->getVideoDriver()->getScreenSize(); } +#ifndef __ANDROID__ float getDisplayDensity() { float gui_scaling = g_settings->getFloat("gui_scaling"); @@ -562,6 +574,7 @@ v2u32 getDisplaySize() { return deskres; } #endif +#endif } //namespace porting