Skip to content

Commit 386d695

Browse files
committedApr 19, 2015
Porting: Refactor initalizePaths()
Add support for Solaris and HP-UX Search additional potential procfs locations for current executable
1 parent f1a41e4 commit 386d695

File tree

3 files changed

+294
-184
lines changed

3 files changed

+294
-184
lines changed
 

Diff for: ‎src/filesys.h

+2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2626

2727
#ifdef _WIN32 // WINDOWS
2828
#define DIR_DELIM "\\"
29+
#define DIR_DELIM_CHAR '\\'
2930
#define FILESYS_CASE_INSENSITIVE 1
3031
#else // POSIX
3132
#define DIR_DELIM "/"
33+
#define DIR_DELIM_CHAR '/'
3234
#define FILESYS_CASE_INSENSITIVE 0
3335
#endif
3436

Diff for: ‎src/porting.cpp

+285-181
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
3535
#include <unistd.h>
3636
#include <sys/utsname.h>
3737
#endif
38-
38+
#if defined(__hpux)
39+
#define _PSTAT64
40+
#include <sys/pstat.h>
41+
#endif
3942
#if !defined(_WIN32) && !defined(__APPLE__) && \
4043
!defined(__ANDROID__) && !defined(SERVER)
4144
#define XORG_USED
4245
#endif
43-
4446
#ifdef XORG_USED
4547
#include <X11/Xlib.h>
4648
#include <X11/Xutil.h>
@@ -99,39 +101,29 @@ void signal_handler_init(void)
99101
#else // _WIN32
100102
#include <signal.h>
101103

102-
BOOL WINAPI event_handler(DWORD sig)
103-
{
104-
switch(sig)
105-
{
106-
case CTRL_C_EVENT:
107-
case CTRL_CLOSE_EVENT:
108-
case CTRL_LOGOFF_EVENT:
109-
case CTRL_SHUTDOWN_EVENT:
110-
111-
if(g_killed == false)
112-
{
113-
dstream<<DTIME<<"INFO: event_handler(): "
114-
<<"Ctrl+C, Close Event, Logoff Event or Shutdown Event, shutting down."<<std::endl;
115-
// Comment out for less clutter when testing scripts
116-
/*dstream<<DTIME<<"INFO: event_handler(): "
117-
<<"Printing debug stacks"<<std::endl;
118-
debug_stacks_print();*/
119-
120-
g_killed = true;
121-
}
122-
else
123-
{
124-
(void)signal(SIGINT, SIG_DFL);
125-
}
126-
127-
break;
128-
case CTRL_BREAK_EVENT:
129-
break;
104+
BOOL WINAPI event_handler(DWORD sig)
105+
{
106+
switch (sig) {
107+
case CTRL_C_EVENT:
108+
case CTRL_CLOSE_EVENT:
109+
case CTRL_LOGOFF_EVENT:
110+
case CTRL_SHUTDOWN_EVENT:
111+
if (g_killed == false) {
112+
dstream << DTIME << "INFO: event_handler(): "
113+
<< "Ctrl+C, Close Event, Logoff Event or Shutdown Event,"
114+
" shutting down." << std::endl;
115+
g_killed = true;
116+
} else {
117+
(void)signal(SIGINT, SIG_DFL);
130118
}
131-
132-
return TRUE;
119+
break;
120+
case CTRL_BREAK_EVENT:
121+
break;
133122
}
134123

124+
return TRUE;
125+
}
126+
135127
void signal_handler_init(void)
136128
{
137129
SetConsoleCtrlHandler( (PHANDLER_ROUTINE)event_handler,TRUE);
@@ -143,7 +135,8 @@ void signal_handler_init(void)
143135
/*
144136
Multithreading support
145137
*/
146-
int getNumberOfProcessors() {
138+
int getNumberOfProcessors()
139+
{
147140
#if defined(_SC_NPROCESSORS_ONLN)
148141

149142
return sysconf(_SC_NPROCESSORS_ONLN);
@@ -177,7 +170,8 @@ int getNumberOfProcessors() {
177170

178171

179172
#ifndef __ANDROID__
180-
bool threadBindToProcessor(threadid_t tid, int pnumber) {
173+
bool threadBindToProcessor(threadid_t tid, int pnumber)
174+
{
181175
#if defined(_WIN32)
182176

183177
HANDLE hThread = OpenThread(THREAD_ALL_ACCESS, 0, tid);
@@ -201,7 +195,7 @@ bool threadBindToProcessor(threadid_t tid, int pnumber) {
201195
#elif defined(__sun) || defined(sun)
202196

203197
return processor_bind(P_LWPID, MAKE_LWPID_PTHREAD(tid),
204-
pnumber, NULL) == 0;
198+
pnumber, NULL) == 0;
205199

206200
#elif defined(_AIX)
207201

@@ -212,7 +206,7 @@ bool threadBindToProcessor(threadid_t tid, int pnumber) {
212206
pthread_spu_t answer;
213207

214208
return pthread_processor_bind_np(PTHREAD_BIND_ADVISORY_NP,
215-
&answer, pnumber, tid) == 0;
209+
&answer, pnumber, tid) == 0;
216210

217211
#elif defined(__APPLE__)
218212

@@ -221,7 +215,7 @@ bool threadBindToProcessor(threadid_t tid, int pnumber) {
221215
thread_port_t threadport = pthread_mach_thread_np(tid);
222216
tapol.affinity_tag = pnumber + 1;
223217
return thread_policy_set(threadport, THREAD_AFFINITY_POLICY,
224-
(thread_policy_t)&tapol, THREAD_AFFINITY_POLICY_COUNT) == KERN_SUCCESS;
218+
(thread_policy_t)&tapol, THREAD_AFFINITY_POLICY_COUNT) == KERN_SUCCESS;
225219

226220
#else
227221

@@ -231,7 +225,8 @@ bool threadBindToProcessor(threadid_t tid, int pnumber) {
231225
}
232226
#endif
233227

234-
bool threadSetPriority(threadid_t tid, int prio) {
228+
bool threadSetPriority(threadid_t tid, int prio)
229+
{
235230
#if defined(_WIN32)
236231

237232
HANDLE hThread = OpenThread(THREAD_ALL_ACCESS, 0, tid);
@@ -286,14 +281,14 @@ void pathRemoveFile(char *path, char delim)
286281
path[i] = 0;
287282
}
288283

289-
bool detectMSVCBuildDir(char *c_path)
284+
bool detectMSVCBuildDir(const std::string &path)
290285
{
291-
std::string path(c_path);
292286
const char *ends[] = {
293287
"bin\\Release",
294288
"bin\\Debug",
295289
"bin\\Build",
296-
NULL};
290+
NULL
291+
};
297292
return (removeStringEnd(path, ends) != "");
298293
}
299294

@@ -333,224 +328,322 @@ std::string get_sysinfo()
333328
#endif
334329
}
335330

336-
void initializePaths()
331+
332+
bool getCurrentWorkingDir(char *buf, size_t len)
337333
{
338-
#if RUN_IN_PLACE
339-
/*
340-
Use relative paths if RUN_IN_PLACE
341-
*/
334+
#ifdef _WIN32
335+
DWORD ret = GetCurrentDirectory(len, buf);
336+
return (ret != 0) && (ret <= len);
337+
#else
338+
return getcwd(buf, len);
339+
#endif
340+
}
342341

343-
infostream<<"Using relative paths (RUN_IN_PLACE)"<<std::endl;
344342

345-
/*
346-
Windows
347-
*/
348-
#if defined(_WIN32)
343+
bool getExecPathFromProcfs(char *buf, size_t buflen)
344+
{
345+
#ifndef _WIN32
346+
buflen--;
349347

350-
const DWORD buflen = 1000;
351-
char buf[buflen];
352-
DWORD len;
348+
ssize_t len;
349+
if ((len = readlink("/proc/self/exe", buf, buflen)) == -1 &&
350+
(len = readlink("/proc/curproc/file", buf, buflen)) == -1 &&
351+
(len = readlink("/proc/curproc/exe", buf, buflen)) == -1)
352+
return false;
353353

354-
// Find path of executable and set path_share relative to it
355-
len = GetModuleFileName(GetModuleHandle(NULL), buf, buflen);
356-
assert(len < buflen);
357-
pathRemoveFile(buf, '\\');
354+
buf[len] = '\0';
355+
return true;
356+
#else
357+
return false;
358+
#endif
359+
}
358360

359-
if(detectMSVCBuildDir(buf)){
360-
infostream<<"MSVC build directory detected"<<std::endl;
361-
path_share = std::string(buf) + "\\..\\..";
362-
path_user = std::string(buf) + "\\..\\..";
363-
}
364-
else{
365-
path_share = std::string(buf) + "\\..";
366-
path_user = std::string(buf) + "\\..";
367-
}
361+
//// Windows
362+
#if defined(_WIN32)
368363

369-
/*
370-
Linux
371-
*/
372-
#elif defined(linux) || defined(__linux)
364+
bool getCurrentExecPath(char *buf, size_t len)
365+
{
366+
DWORD written = GetModuleFileNameA(NULL, buf, len);
367+
if (written == 0 || written == len)
368+
return false;
373369

374-
char buf[BUFSIZ];
375-
memset(buf, 0, BUFSIZ);
376-
// Get path to executable
377-
FATAL_ERROR_IF(readlink("/proc/self/exe", buf, BUFSIZ-1) == -1, "Failed to get cwd");
370+
return true;
371+
}
378372

379-
pathRemoveFile(buf, '/');
380373

381-
path_share = std::string(buf) + "/..";
382-
path_user = std::string(buf) + "/..";
374+
//// Linux
375+
#elif defined(linux) || defined(__linux) || defined(__linux__)
376+
377+
bool getCurrentExecPath(char *buf, size_t len)
378+
{
379+
if (!getExecPathFromProcfs(buf, len))
380+
return false;
383381

384-
/*
385-
OS X
386-
*/
387-
#elif defined(__APPLE__)
382+
return true;
383+
}
388384

389-
CFBundleRef main_bundle = CFBundleGetMainBundle();
390-
CFURLRef resources_url = CFBundleCopyResourcesDirectoryURL(main_bundle);
391-
char path[PATH_MAX];
392-
if (CFURLGetFileSystemRepresentation(resources_url, TRUE, (UInt8 *)path, PATH_MAX)) {
393-
path_share = std::string(path);
394-
path_user = std::string(path) + "/../User";
395-
} else {
396-
dstream << "WARNING: Could not determine bundle resource path" << std::endl;
397-
}
398-
CFRelease(resources_url);
399385

400-
/*
401-
FreeBSD
402-
*/
403-
#elif defined(__FreeBSD__)
386+
//// Mac OS X, Darwin
387+
#elif defined(__APPLE__)
388+
389+
bool getCurrentExecPath(char *buf, size_t len)
390+
{
391+
if (_NSGetExecutablePath(buf, &len) == -1)
Has a conversation. Original line has a conversation.
392+
return false;
393+
394+
return true;
395+
}
396+
397+
398+
//// FreeBSD, NetBSD, DragonFlyBSD
399+
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
400+
401+
bool getCurrentExecPath(char *buf, size_t len)
402+
{
403+
// Try getting path from procfs first, since valgrind
404+
// doesn't work with the latter
405+
if (getExecPathFromProcfs(buf, len))
406+
return true;
404407

405408
int mib[4];
406-
char buf[BUFSIZ];
407-
size_t len = sizeof(buf);
408409

409410
mib[0] = CTL_KERN;
410411
mib[1] = KERN_PROC;
411412
mib[2] = KERN_PROC_PATHNAME;
412413
mib[3] = -1;
413-
FATAL_ERROR_IF(sysctl(mib, 4, buf, &len, NULL, 0) == -1, "");
414414

415-
pathRemoveFile(buf, '/');
415+
if (sysctl(mib, 4, buf, &len, NULL, 0) == -1)
416+
return false;
416417

417-
path_share = std::string(buf) + "/..";
418-
path_user = std::string(buf) + "/..";
418+
return true;
419+
}
419420

420-
#else
421421

422-
//TODO: Get path of executable. This assumes working directory is bin/
423-
dstream<<"WARNING: Relative path not properly supported on this platform"
424-
<<std::endl;
422+
//// Solaris
423+
#elif defined(__sun) || defined(sun)
425424

426-
/* scriptapi no longer allows paths that start with "..", so assuming that
427-
the current working directory is bin/, strip off the last component. */
428-
char *cwd = getcwd(NULL, 0);
429-
pathRemoveFile(cwd, '/');
430-
path_share = std::string(cwd);
431-
path_user = std::string(cwd);
425+
bool getCurrentExecPath(char *buf, size_t len)
426+
{
427+
const char *exec = getexecname();
428+
if (exec == NULL)
429+
return false;
432430

433-
#endif
431+
if (strlcpy(buf, exec, len) >= len)
432+
return false;
433+
434+
return true;
435+
}
434436

435-
#else // RUN_IN_PLACE
436437

437-
/*
438-
Use platform-specific paths otherwise
439-
*/
438+
// HP-UX
439+
#elif defined(__hpux)
440440

441-
infostream<<"Using system-wide paths (NOT RUN_IN_PLACE)"<<std::endl;
441+
bool getCurrentExecPath(char *buf, size_t len)
442+
{
443+
struct pst_status psts;
444+
445+
if (pstat_getproc(&psts, sizeof(psts), 0, getpid()) == -1)
446+
return false;
442447

443-
/*
444-
Windows
445-
*/
446-
#if defined(_WIN32)
448+
if (pstat_getpathname(buf, len, &psts.pst_fid_text) == -1)
449+
return false;
450+
451+
return true;
452+
}
447453

448-
const DWORD buflen = 1000; // FIXME: Surely there is a better way to do this
449-
char buf[buflen];
450-
DWORD len;
454+
455+
#else
456+
457+
bool getCurrentExecPath(char *buf, size_t len)
458+
{
459+
return false;
460+
}
461+
462+
#endif
463+
464+
465+
//// Windows
466+
#if defined(_WIN32)
467+
468+
bool setSystemPaths()
469+
{
470+
char buf[BUFSIZ];
451471

452472
// Find path of executable and set path_share relative to it
453-
len = GetModuleFileName(GetModuleHandle(NULL), buf, buflen);
454-
FATAL_ERROR_IF(len >= buflen, "Overlow");
473+
FATAL_ERROR_IF(!getCurrentExecPath(buf, sizeof(buf)),
474+
"Failed to get current executable path");
455475
pathRemoveFile(buf, '\\');
456476

457477
// Use ".\bin\.."
458478
path_share = std::string(buf) + "\\..";
459479

460480
// Use "C:\Documents and Settings\user\Application Data\<PROJECT_NAME>"
461-
len = GetEnvironmentVariable("APPDATA", buf, buflen);
462-
FATAL_ERROR_IF(len >= buflen, "Overlow");
481+
DWORD len = GetEnvironmentVariable("APPDATA", buf, sizeof(buf));
482+
FATAL_ERROR_IF(len == 0 || len > sizeof(buf), "Failed to get APPDATA");
483+
463484
path_user = std::string(buf) + DIR_DELIM + lowercase(PROJECT_NAME);
485+
return true;
486+
}
464487

465-
/*
466-
Linux
467-
*/
468-
#elif defined(linux) || defined(__linux)
469488

470-
// Get path to executable
471-
std::string bindir = "";
472-
{
473-
char buf[BUFSIZ];
474-
memset(buf, 0, BUFSIZ);
475-
if (readlink("/proc/self/exe", buf, BUFSIZ-1) == -1) {
476-
errorstream << "Unable to read bindir "<< std::endl;
477-
#ifndef __ANDROID__
478-
FATAL_ERROR("Unable to read bindir");
489+
//// Linux
490+
#elif defined(linux) || defined(__linux)
491+
492+
bool setSystemPaths()
493+
{
494+
char buf[BUFSIZ];
495+
496+
if (!getCurrentExecPath(buf, sizeof(buf))) {
497+
#ifdef __ANDROID__
498+
errorstream << "Unable to read bindir "<< std::endl;
499+
#else
500+
FATAL_ERROR("Unable to read bindir");
479501
#endif
480-
} else {
481-
pathRemoveFile(buf, '/');
482-
bindir = buf;
483-
}
502+
return false;
484503
}
485504

505+
pathRemoveFile(buf, '/');
506+
std::string bindir(buf);
507+
486508
// Find share directory from these.
487509
// It is identified by containing the subdirectory "builtin".
488510
std::list<std::string> trylist;
489511
std::string static_sharedir = STATIC_SHAREDIR;
490-
if(static_sharedir != "" && static_sharedir != ".")
512+
if (static_sharedir != "" && static_sharedir != ".")
491513
trylist.push_back(static_sharedir);
492-
trylist.push_back(
493-
bindir + DIR_DELIM + ".." + DIR_DELIM + "share" + DIR_DELIM + lowercase(PROJECT_NAME));
494-
trylist.push_back(bindir + DIR_DELIM + "..");
514+
515+
trylist.push_back(bindir + DIR_DELIM ".." DIR_DELIM "share"
516+
DIR_DELIM + lowercase(PROJECT_NAME));
517+
trylist.push_back(bindir + DIR_DELIM "..");
518+
495519
#ifdef __ANDROID__
496520
trylist.push_back(path_user);
497521
#endif
498522

499-
for(std::list<std::string>::const_iterator i = trylist.begin();
500-
i != trylist.end(); i++)
501-
{
523+
for (std::list<std::string>::const_iterator
524+
i = trylist.begin(); i != trylist.end(); i++) {
502525
const std::string &trypath = *i;
503-
if(!fs::PathExists(trypath) || !fs::PathExists(trypath + DIR_DELIM + "builtin")){
504-
dstream<<"WARNING: system-wide share not found at \""
505-
<<trypath<<"\""<<std::endl;
526+
if (!fs::PathExists(trypath) ||
527+
!fs::PathExists(trypath + DIR_DELIM + "builtin")) {
528+
dstream << "WARNING: system-wide share not found at \""
529+
<< trypath << "\""<< std::endl;
506530
continue;
507531
}
532+
508533
// Warn if was not the first alternative
509-
if(i != trylist.begin()){
510-
dstream<<"WARNING: system-wide share found at \""
511-
<<trypath<<"\""<<std::endl;
534+
if (i != trylist.begin()) {
535+
dstream << "WARNING: system-wide share found at \""
536+
<< trypath << "\"" << std::endl;
512537
}
538+
513539
path_share = trypath;
514540
break;
515541
}
542+
516543
#ifndef __ANDROID__
517-
path_user = std::string(getenv("HOME")) + DIR_DELIM + "." + lowercase(PROJECT_NAME);
544+
path_user = std::string(getenv("HOME")) + DIR_DELIM "."
545+
+ lowercase(PROJECT_NAME);
518546
#endif
519547

520-
/*
521-
OS X
522-
*/
523-
#elif defined(__APPLE__)
548+
return true;
549+
}
550+
551+
552+
//// Mac OS X
553+
#elif defined(__APPLE__)
524554

555+
bool setSystemPaths()
556+
{
525557
CFBundleRef main_bundle = CFBundleGetMainBundle();
526558
CFURLRef resources_url = CFBundleCopyResourcesDirectoryURL(main_bundle);
527559
char path[PATH_MAX];
528-
if (CFURLGetFileSystemRepresentation(resources_url, TRUE, (UInt8 *)path, PATH_MAX)) {
560+
if (CFURLGetFileSystemRepresentation(resources_url,
561+
TRUE, (UInt8 *)path, PATH_MAX)) {
529562
path_share = std::string(path);
530563
} else {
531564
dstream << "WARNING: Could not determine bundle resource path" << std::endl;
532565
}
533566
CFRelease(resources_url);
534567

535-
path_user = std::string(getenv("HOME")) + "/Library/Application Support/" + lowercase(PROJECT_NAME);
568+
path_user = std::string(getenv("HOME"))
569+
+ "/Library/Application Support/"
570+
+ lowercase(PROJECT_NAME);
571+
return true;
572+
}
573+
536574

537-
#else // FreeBSD, and probably many other POSIX-like systems.
575+
#else
538576

577+
bool setSystemPaths()
578+
{
539579
path_share = STATIC_SHAREDIR;
540-
path_user = std::string(getenv("HOME")) + DIR_DELIM + "." + lowercase(PROJECT_NAME);
580+
path_user = std::string(getenv("HOME")) + DIR_DELIM "."
581+
+ lowercase(PROJECT_NAME);
582+
return true;
583+
}
541584

542-
#endif
543585

544-
#endif // RUN_IN_PLACE
545-
}
586+
#endif
546587

547-
static irr::IrrlichtDevice *device;
548588

549-
void initIrrlicht(irr::IrrlichtDevice *device_)
589+
void initializePaths()
550590
{
551-
device = device_;
591+
#if RUN_IN_PLACE
592+
char buf[BUFSIZ];
593+
594+
infostream << "Using relative paths (RUN_IN_PLACE)" << std::endl;
595+
596+
bool success =
597+
getCurrentExecPath(buf, sizeof(buf)) ||
598+
getExecPathFromProcfs(buf, sizeof(buf));
599+
600+
if (success) {
601+
pathRemoveFile(buf, '/');
602+
std::string execpath(buf);
603+
604+
path_share = execpath + DIR_DELIM "..";
605+
path_user = execpath + DIR_DELIM "..";
606+
607+
if (detectMSVCBuildDir(execpath)) {
608+
path_share += DIR_DELIM "..";
609+
path_user += DIR_DELIM "..";
610+
}
611+
} else {
612+
errorstream << "Failed to get paths by executable location, "
613+
"trying cwd" << std::endl;
614+
615+
if (!getCurrentWorkingDir(buf, sizeof(buf)))
616+
FATAL_ERROR("Ran out of methods to get paths");
617+
618+
size_t cwdlen = strlen(buf);
619+
if (cwdlen >= 1 && buf[cwdlen - 1] == DIR_DELIM_CHAR) {
620+
cwdlen--;
621+
buf[cwdlen] = '\0';
622+
}
623+
624+
if (cwdlen >= 4 && !strcmp(buf + cwdlen - 4, DIR_DELIM "bin"))
625+
pathRemoveFile(buf, DIR_DELIM_CHAR);
626+
627+
std::string execpath(buf);
628+
629+
path_share = execpath;
630+
path_user = execpath;
631+
}
632+
633+
#else
634+
infostream << "Using system-wide paths (NOT RUN_IN_PLACE)" << std::endl;
635+
636+
if (!setSystemPaths())
637+
errorstream << "Failed to get one or more system-wide path" << std::endl;
638+
639+
#endif
640+
641+
infostream << "Detected share path: " << path_share << std::endl;
642+
infostream << "Detected user path: " << path_user << std::endl;
552643
}
553644

645+
646+
554647
void setXorgClassHint(const video::SExposedVideoData &video_data,
555648
const std::string &name)
556649
{
@@ -568,8 +661,20 @@ void setXorgClassHint(const video::SExposedVideoData &video_data,
568661
#endif
569662
}
570663

664+
665+
////
666+
//// Video/Display Information (Client-only)
667+
////
668+
571669
#ifndef SERVER
572670

671+
static irr::IrrlichtDevice *device;
672+
673+
void initIrrlicht(irr::IrrlichtDevice *device_)
674+
{
675+
device = device_;
676+
}
677+
573678
v2u32 getWindowSize()
574679
{
575680
return device->getVideoDriver()->getScreenSize();
@@ -641,9 +746,8 @@ const char *getVideoDriverFriendlyName(irr::video::E_DRIVER_TYPE type)
641746
return driver_names[type];
642747
}
643748

644-
645-
#ifndef __ANDROID__
646-
#ifdef XORG_USED
749+
# ifndef __ANDROID__
750+
# ifdef XORG_USED
647751

648752
static float calcDisplayDensity()
649753
{
@@ -679,12 +783,12 @@ float getDisplayDensity()
679783
}
680784

681785

682-
#else
786+
# else // XORG_USED
683787
float getDisplayDensity()
684788
{
685789
return g_settings->getFloat("screen_dpi")/96.0;
686790
}
687-
#endif
791+
# endif // XORG_USED
688792

689793
v2u32 getDisplaySize()
690794
{
@@ -695,8 +799,8 @@ v2u32 getDisplaySize()
695799

696800
return deskres;
697801
}
698-
#endif
699-
#endif
802+
# endif // __ANDROID__
803+
#endif // SERVER
700804

701805
} //namespace porting
702806

Diff for: ‎src/porting.h

+7-3
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ const char *getVideoDriverName(irr::video::E_DRIVER_TYPE type);
377377
const char *getVideoDriverFriendlyName(irr::video::E_DRIVER_TYPE type);
378378
#endif
379379

380-
inline const char * getPlatformName()
380+
inline const char *getPlatformName()
381381
{
382382
return
383383
#if defined(ANDROID)
@@ -401,8 +401,12 @@ inline const char * getPlatformName()
401401
"AIX"
402402
#elif defined(__hpux)
403403
"HP-UX"
404-
#elif defined(__sun) && defined(__SVR4)
405-
"Solaris"
404+
#elif defined(__sun) || defined(sun)
405+
#if defined(__SVR4)
406+
"Solaris"
407+
#else
408+
"SunOS"
409+
#endif
406410
#elif defined(__CYGWIN__)
407411
"Cygwin"
408412
#elif defined(__unix__) || defined(__unix)

0 commit comments

Comments
 (0)
Please sign in to comment.