1717#if defined(_POSIX_THREADS) && (_POSIX_THREADS > 0)
1818#define NODEPP_THREAD_SUPPORTED
1919#else
20- #define thread_local
20+ #define thread_local /* unused */
2121#endif
2222
2323/* ────────────────────────────────────────────────────────────────────────────*/
@@ -28,24 +28,24 @@ template< class T > T clamp( const T& val, const T& _min, const T& _max ){ retur
2828
2929/* ────────────────────────────────────────────────────────────────────────────*/
3030
31- #define coDelay (VALUE ) do { _time_=process::millis ()+VALUE; while ( process::millis ()<_time_ ){ coErrno (VALUE,_LINE_,1 ); }} while (0 );
32- #define coUDelay (VALUE ) do { _time_=process::micros ()+VALUE; while ( process::micros ()<_time_ ){ coNext; }} while (0 );
33- #define coErrno (DELAY,STATE,OUT ) do { coSet (STATE); coroutine::getno ( OUT,coGet,DELAY ); return OUT; case STATE:; } while (0 );
31+ #define coDelay (VALUE ) do { _time_=nodepp:: process::millis ()+VALUE; while ( nodepp:: process::millis ()<_time_ ){ coErrno (VALUE,_LINE_,1 ); }} while (0 );
32+ #define coUDelay (VALUE ) do { _time_=nodepp:: process::micros ()+VALUE; while ( nodepp:: process::micros ()<_time_ ){ /* ------------ */ coNext; }} while (0 );
33+ #define coErrno (DELAY,STATE,OUT ) do { coSet (STATE); nodepp :: coroutine::getno ( OUT,coGet,DELAY ); return OUT; case STATE:; } while (0 );
3434
3535/* ────────────────────────────────────────────────────────────────────────────*/
3636
37- #define coGoto (VALUE ) do { coSet ( VALUE ); coroutine::getno (1 ,coGet); return 1 ; } while (0 );
38- #define coStay (VALUE ) do { coSet ( VALUE ); coroutine::getno (0 ,coGet); return 0 ; } while (0 );
39- #define coNext do { coErrno (0UL ,_LINE_,1 ); /* -------------------------*/ } while (0 );
40- #define coYield (VALUE ) do { coErrno (0UL , VALUE,1 ); /* -------------------------*/ } while (0 );
41- #define coWait (VALUE ) do { while ( VALUE ){ /* ------------------------*/ coNext;}} while (0 );
42- #define coEnd do { _time_=0 ; _state_=_time_; /* */ coroutine::getno (-1 ); } while (0 ); return -1 ;
43- #define coStop } _time_=0 ; _state_=_time_; /* */ coroutine::getno(-1 ); } while (0 ); return -1 ;
37+ #define coGoto (VALUE ) do { coSet ( VALUE ); nodepp:: coroutine::getno (1 ,coGet); return 1 ; } while (0 );
38+ #define coStay (VALUE ) do { coSet ( VALUE ); nodepp:: coroutine::getno (0 ,coGet); return 0 ; } while (0 );
39+ #define coNext do { coErrno (0UL ,_LINE_,1 ); /* --------------------------------- */ } while (0 );
40+ #define coYield (VALUE ) do { coErrno (0UL , VALUE,1 ); /* --------------------------------- */ } while (0 );
41+ #define coWait (VALUE ) do { while ( VALUE ){ /* ------------------------------- */ coNext; }} while (0 );
42+ #define coEnd do { _time_=0 ; _state_=_time_; /* */ nodepp:: coroutine::getno (-1 ); } while (0 ); return -1 ;
43+ #define coStop } _time_=0 ; _state_=_time_; /* */ nodepp:: coroutine::getno(-1 ); } while (0 ); return -1 ;
4444
4545/* ────────────────────────────────────────────────────────────────────────────*/
4646
4747#define coStart thread_local static int _state_=0 ; thread_local static ulong _time_=0 ; coBegin
48- #define coBegin do { switch (_state_) { case 0 :; coroutine::getno (-2 );
48+ #define coBegin do { switch (_state_) { case 0 :; nodepp:: coroutine::getno (-2 );
4949#define coEmit int operator ()
5050
5151#define coSet (VALUE ) _state_ = VALUE
@@ -54,15 +54,15 @@ template< class T > T clamp( const T& val, const T& _min, const T& _max ){ retur
5454
5555/* ────────────────────────────────────────────────────────────────────────────*/
5656
57- #define onMain INIT (); int main ( int argc, char ** args ) { \
58- process::start ( argc,args ); INIT (); \
59- process::wait (); return 0 ; \
60- } void INIT
57+ #define onMain NODEPP_BEGIN (); int main ( int argc, char ** args ) { \
58+ nodepp:: process::start ( argc,args ); NODEPP_BEGIN (); \
59+ nodepp:: process::wait (); return 0 ; \
60+ } void NODEPP_BEGIN
6161
6262/* ────────────────────────────────────────────────────────────────────────────*/
6363
64+ #define GENERATOR (NAME ) struct NAME : public nodepp ::generator_t
6465#define COROUTINE () [=]( int & _state_, ulong& _time_ )
65- #define GENERATOR (NAME ) struct NAME : public generator_t
6666
6767/* ────────────────────────────────────────────────────────────────────────────*/
6868
@@ -81,7 +81,6 @@ template< class T > T clamp( const T& val, const T& _min, const T& _max ){ retur
8181
8282/* ────────────────────────────────────────────────────────────────────────────*/
8383
84- #define _JSON_ (...) json::parse(_STRING_(__VA_ARGS__))
8584#define _FUNC_ __PRETTY_FUNCTION__
8685#define _STRING_ (...) #__VA_ARGS__
8786#define _NAME_ __FUNCTION__
@@ -98,12 +97,7 @@ template< class T > T clamp( const T& val, const T& _min, const T& _max ){ retur
9897
9998/* ────────────────────────────────────────────────────────────────────────────*/
10099
101- static bool & NODEPP_SHTDWN (){ static bool out=false ; return out; }
102-
103- /* ────────────────────────────────────────────────────────────────────────────*/
104-
105- #define MAX_SOCKET limit::get_soft_fileno ()
106-
100+ #define MAX_SOCKET nodepp::limit::get_soft_fileno ()
107101#define HASH_TABLE_SIZE 16
108102#define MAX_BATCH 16
109103#define MAX_SSO 16
@@ -247,7 +241,7 @@ static bool& NODEPP_SHTDWN(){ static bool out=false; return out; }
247241
248242/* ────────────────────────────────────────────────────────────────────────────*/
249243
250- #define typeof (DATA ) string_t ( typeid (DATA).name() )
244+ #define typeof (DATA ) nodepp:: string_t ( typeid (DATA).name() )
251245
252246#define ullong unsigned long long int
253247#define ulong unsigned long int
@@ -281,7 +275,10 @@ static bool& NODEPP_SHTDWN(){ static bool out=false; return out; }
281275
282276/* ────────────────────────────────────────────────────────────────────────────*/
283277
284- using null_t = decltype ( nullptr );
278+ namespace nodepp {
279+ static bool & NODEPP_SHTDWN (){ static bool out=false ; return out; }
280+ /* --*/ using null_t = decltype ( nullptr );
281+ }
285282
286283/* ────────────────────────────────────────────────────────────────────────────*/
287284
0 commit comments