Skip to content

Commit 8c05089

Browse files
committed
elif
1 parent 86aae21 commit 8c05089

File tree

1 file changed

+12
-25
lines changed

1 file changed

+12
-25
lines changed

log4z.cpp

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
#include <process.h>
5858
#pragma comment(lib, "shlwapi")
5959
#pragma warning(disable:4996)
60+
6061
#else
6162
#include <unistd.h>
6263
#include <netinet/in.h>
@@ -70,12 +71,12 @@
7071
#include <fcntl.h>
7172
#include <semaphore.h>
7273
#endif
73-
#if __APPLE__
74-
#include <dispatch/dispatch.h>
75-
#include <libproc.h>
76-
#endif
7774

7875

76+
#ifdef __APPLE__
77+
#include <dispatch/dispatch.h>
78+
#include <libproc.h>
79+
#endif
7980

8081

8182

@@ -226,14 +227,12 @@ class SemHelper
226227
private:
227228
#ifdef WIN32
228229
HANDLE _hSem;
229-
#else
230-
#if __APPLE__
230+
#elif defined(__APPLE__)
231231
dispatch_semaphore_t _semid;
232232
#else
233233
sem_t _semid;
234234
bool _isCreate;
235235
#endif
236-
#endif
237236

238237
};
239238

@@ -872,9 +871,8 @@ std::string getProcessName()
872871
name = name.substr(0, pos-0);
873872
}
874873

875-
#else
874+
#elif defined(__APPLE__)
876875

877-
#ifdef __APPLE__
878876
proc_name(getpid(), buf, 260);
879877
name = buf;
880878
return name;;
@@ -896,7 +894,6 @@ std::string getProcessName()
896894
}
897895
#endif
898896

899-
#endif
900897

901898
return name;
902899
}
@@ -954,13 +951,11 @@ SemHelper::SemHelper()
954951
{
955952
#ifdef WIN32
956953
_hSem = NULL;
957-
#else
958-
#if __APPLE__
954+
#elif defined(__APPLE__)
959955
_semid = NULL;
960956
#else
961957
_isCreate = false;
962958
#endif
963-
#endif
964959

965960
}
966961
SemHelper::~SemHelper()
@@ -971,8 +966,7 @@ SemHelper::~SemHelper()
971966
CloseHandle(_hSem);
972967
_hSem = NULL;
973968
}
974-
#else
975-
#if __APPLE__
969+
#elif defined(__APPLE__)
976970
if (_semid)
977971
{
978972
dispatch_release(_semid);
@@ -985,7 +979,6 @@ SemHelper::~SemHelper()
985979
sem_destroy(&_semid);
986980
}
987981
#endif
988-
#endif
989982

990983
}
991984

@@ -1005,8 +998,7 @@ bool SemHelper::create(int initcount)
1005998
{
1006999
return false;
10071000
}
1008-
#else
1009-
#if __APPLE__
1001+
#elif defined(__APPLE__)
10101002
_semid = dispatch_semaphore_create(initcount);
10111003
if (!_semid)
10121004
{
@@ -1018,7 +1010,6 @@ bool SemHelper::create(int initcount)
10181010
return false;
10191011
}
10201012
_isCreate = true;
1021-
#endif
10221013
#endif
10231014

10241015
return true;
@@ -1034,8 +1025,7 @@ bool SemHelper::wait(int timeout)
10341025
{
10351026
return false;
10361027
}
1037-
#else
1038-
#if __APPLE__
1028+
#elif defined(__APPLE__)
10391029
if (dispatch_semaphore_wait(_semid, dispatch_time(DISPATCH_TIME_NOW, timeout*1000)) != 0)
10401030
{
10411031
return false;
@@ -1076,7 +1066,6 @@ bool SemHelper::wait(int timeout)
10761066
} while (true);
10771067
return false;
10781068
}
1079-
#endif
10801069
#endif
10811070
return true;
10821071
}
@@ -1085,13 +1074,11 @@ bool SemHelper::post()
10851074
{
10861075
#ifdef WIN32
10871076
return ReleaseSemaphore(_hSem, 1, NULL) ? true : false;
1088-
#else
1089-
#if __APPLE__
1077+
#elif defined(__APPLE__)
10901078
return dispatch_semaphore_signal(_semid) == 0;
10911079
#else
10921080
return (sem_post(&_semid) == 0);
10931081
#endif
1094-
#endif
10951082

10961083
}
10971084

0 commit comments

Comments
 (0)