Skip to content

Commit 1dfd977

Browse files
Rogier-5est31
authored andcommittedJul 4, 2016
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.
1 parent f649147 commit 1dfd977

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed
 

Diff for: ‎src/guiChatConsole.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ bool GUIChatConsole::OnEvent(const SEvent& event)
630630
}
631631
else if(event.KeyInput.Char != 0 && !event.KeyInput.Control)
632632
{
633-
#if (defined(linux) || defined(__linux))
633+
#if (defined(__linux__))
634634
wchar_t wc = L'_';
635635
mbtowc( &wc, (char *) &event.KeyInput.Char, sizeof(event.KeyInput.Char) );
636636
prompt.input(wc);

Diff for: ‎src/intlGUIEditBox.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ bool intlGUIEditBox::OnEvent(const SEvent& event)
271271
break;
272272
case EET_KEY_INPUT_EVENT:
273273
{
274-
#if (defined(linux) || defined(__linux) || defined(__FreeBSD__))
274+
#if (defined(__linux__) || defined(__FreeBSD__))
275275
// ################################################################
276276
// ValkaTR:
277277
// This part is the difference from the original intlGUIEditBox

Diff for: ‎src/porting.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ bool getCurrentExecPath(char *buf, size_t len)
258258

259259

260260
//// Linux
261-
#elif defined(linux) || defined(__linux) || defined(__linux__)
261+
#elif defined(__linux__)
262262

263263
bool getCurrentExecPath(char *buf, size_t len)
264264
{
@@ -374,7 +374,7 @@ bool setSystemPaths()
374374

375375

376376
//// Linux
377-
#elif defined(linux) || defined(__linux)
377+
#elif defined(__linux__)
378378

379379
bool setSystemPaths()
380380
{

Diff for: ‎src/porting.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
6060
#include <unistd.h>
6161
#include <stdint.h> //for uintptr_t
6262

63-
#if (defined(linux) || defined(__linux) || defined(__GNU__)) && !defined(_GNU_SOURCE)
63+
// Use standard Posix macro for Linux
64+
#if (defined(linux) || defined(__linux)) && !defined(__linux__)
65+
#define __linux__
66+
#endif
67+
#if (defined(__linux__) || defined(__GNU__)) && !defined(_GNU_SOURCE)
6468
#define _GNU_SOURCE
6569
#endif
6670

@@ -321,7 +325,7 @@ inline const char *getPlatformName()
321325
return
322326
#if defined(ANDROID)
323327
"Android"
324-
#elif defined(linux) || defined(__linux) || defined(__linux__)
328+
#elif defined(__linux__)
325329
"Linux"
326330
#elif defined(_WIN32) || defined(_WIN64)
327331
"Windows"

Diff for: ‎src/threading/thread.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ DEALINGS IN THE SOFTWARE.
5454

5555

5656
// for setName
57-
#if defined(linux) || defined(__linux)
57+
#if defined(__linux__)
5858
#include <sys/prctl.h>
5959
#elif defined(__FreeBSD__) || defined(__OpenBSD__)
6060
#include <pthread_np.h>
@@ -70,7 +70,7 @@ DEALINGS IN THE SOFTWARE.
7070
// for bindToProcessor
7171
#if __FreeBSD_version >= 702106
7272
typedef cpuset_t cpu_set_t;
73-
#elif defined(__linux) || defined(linux)
73+
#elif defined(__linux__)
7474
#include <sched.h>
7575
#elif defined(__sun) || defined(sun)
7676
#include <sys/types.h>
@@ -261,7 +261,7 @@ DWORD WINAPI Thread::threadProc(LPVOID param)
261261

262262
void Thread::setName(const std::string &name)
263263
{
264-
#if defined(linux) || defined(__linux)
264+
#if defined(__linux__)
265265

266266
// It would be cleaner to do this with pthread_setname_np,
267267
// which was added to glibc in version 2.12, but some major
@@ -363,7 +363,7 @@ bool Thread::bindToProcessor(unsigned int proc_number)
363363

364364
return SetThreadAffinityMask(getThreadHandle(), 1 << proc_number);
365365

366-
#elif __FreeBSD_version >= 702106 || defined(__linux) || defined(linux)
366+
#elif __FreeBSD_version >= 702106 || defined(__linux__)
367367

368368
cpu_set_t cpuset;
369369

0 commit comments

Comments
 (0)
Please sign in to comment.