Fix & make linux conditionals uniform (#4278)

The source used a hodge-podge of different combinations of different
macros to check for linux: 'linux', '__linux', '__linux__'.

As '__linux__' is standard (Posix), and the others are not, the source
now uniformly uses __linux__. If either linux or __linux are defined,
it is made sure that __linux__ is defined as well.
This commit is contained in:
Rogier-5 2016-07-04 21:00:57 +02:00 committed by est31
parent f649147080
commit 1dfd977ec4
5 changed files with 14 additions and 10 deletions

@ -630,7 +630,7 @@ bool GUIChatConsole::OnEvent(const SEvent& event)
} }
else if(event.KeyInput.Char != 0 && !event.KeyInput.Control) else if(event.KeyInput.Char != 0 && !event.KeyInput.Control)
{ {
#if (defined(linux) || defined(__linux)) #if (defined(__linux__))
wchar_t wc = L'_'; wchar_t wc = L'_';
mbtowc( &wc, (char *) &event.KeyInput.Char, sizeof(event.KeyInput.Char) ); mbtowc( &wc, (char *) &event.KeyInput.Char, sizeof(event.KeyInput.Char) );
prompt.input(wc); prompt.input(wc);

@ -271,7 +271,7 @@ bool intlGUIEditBox::OnEvent(const SEvent& event)
break; break;
case EET_KEY_INPUT_EVENT: case EET_KEY_INPUT_EVENT:
{ {
#if (defined(linux) || defined(__linux) || defined(__FreeBSD__)) #if (defined(__linux__) || defined(__FreeBSD__))
// ################################################################ // ################################################################
// ValkaTR: // ValkaTR:
// This part is the difference from the original intlGUIEditBox // This part is the difference from the original intlGUIEditBox

@ -258,7 +258,7 @@ bool getCurrentExecPath(char *buf, size_t len)
//// Linux //// Linux
#elif defined(linux) || defined(__linux) || defined(__linux__) #elif defined(__linux__)
bool getCurrentExecPath(char *buf, size_t len) bool getCurrentExecPath(char *buf, size_t len)
{ {
@ -374,7 +374,7 @@ bool setSystemPaths()
//// Linux //// Linux
#elif defined(linux) || defined(__linux) #elif defined(__linux__)
bool setSystemPaths() bool setSystemPaths()
{ {

@ -60,7 +60,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <unistd.h> #include <unistd.h>
#include <stdint.h> //for uintptr_t #include <stdint.h> //for uintptr_t
#if (defined(linux) || defined(__linux) || defined(__GNU__)) && !defined(_GNU_SOURCE) // Use standard Posix macro for Linux
#if (defined(linux) || defined(__linux)) && !defined(__linux__)
#define __linux__
#endif
#if (defined(__linux__) || defined(__GNU__)) && !defined(_GNU_SOURCE)
#define _GNU_SOURCE #define _GNU_SOURCE
#endif #endif
@ -321,7 +325,7 @@ inline const char *getPlatformName()
return return
#if defined(ANDROID) #if defined(ANDROID)
"Android" "Android"
#elif defined(linux) || defined(__linux) || defined(__linux__) #elif defined(__linux__)
"Linux" "Linux"
#elif defined(_WIN32) || defined(_WIN64) #elif defined(_WIN32) || defined(_WIN64)
"Windows" "Windows"

@ -54,7 +54,7 @@ DEALINGS IN THE SOFTWARE.
// for setName // for setName
#if defined(linux) || defined(__linux) #if defined(__linux__)
#include <sys/prctl.h> #include <sys/prctl.h>
#elif defined(__FreeBSD__) || defined(__OpenBSD__) #elif defined(__FreeBSD__) || defined(__OpenBSD__)
#include <pthread_np.h> #include <pthread_np.h>
@ -70,7 +70,7 @@ DEALINGS IN THE SOFTWARE.
// for bindToProcessor // for bindToProcessor
#if __FreeBSD_version >= 702106 #if __FreeBSD_version >= 702106
typedef cpuset_t cpu_set_t; typedef cpuset_t cpu_set_t;
#elif defined(__linux) || defined(linux) #elif defined(__linux__)
#include <sched.h> #include <sched.h>
#elif defined(__sun) || defined(sun) #elif defined(__sun) || defined(sun)
#include <sys/types.h> #include <sys/types.h>
@ -261,7 +261,7 @@ DWORD WINAPI Thread::threadProc(LPVOID param)
void Thread::setName(const std::string &name) void Thread::setName(const std::string &name)
{ {
#if defined(linux) || defined(__linux) #if defined(__linux__)
// It would be cleaner to do this with pthread_setname_np, // It would be cleaner to do this with pthread_setname_np,
// which was added to glibc in version 2.12, but some major // which was added to glibc in version 2.12, but some major
@ -363,7 +363,7 @@ bool Thread::bindToProcessor(unsigned int proc_number)
return SetThreadAffinityMask(getThreadHandle(), 1 << proc_number); return SetThreadAffinityMask(getThreadHandle(), 1 << proc_number);
#elif __FreeBSD_version >= 702106 || defined(__linux) || defined(linux) #elif __FreeBSD_version >= 702106 || defined(__linux__)
cpu_set_t cpuset; cpu_set_t cpuset;