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,16 @@ 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
66+ #define fn (...) [=]( __VA_ARGS__ )
6667
6768/* ────────────────────────────────────────────────────────────────────────────*/
6869
@@ -81,7 +82,6 @@ template< class T > T clamp( const T& val, const T& _min, const T& _max ){ retur
8182
8283/* ────────────────────────────────────────────────────────────────────────────*/
8384
84- #define _JSON_ (...) json::parse(_STRING_(__VA_ARGS__))
8585#define _FUNC_ __PRETTY_FUNCTION__
8686#define _STRING_ (...) #__VA_ARGS__
8787#define _NAME_ __FUNCTION__
@@ -98,12 +98,7 @@ template< class T > T clamp( const T& val, const T& _min, const T& _max ){ retur
9898
9999/* ────────────────────────────────────────────────────────────────────────────*/
100100
101- static bool & NODEPP_SHTDWN (){ static bool out=false ; return out; }
102-
103- /* ────────────────────────────────────────────────────────────────────────────*/
104-
105- #define MAX_SOCKET limit::get_soft_fileno ()
106-
101+ #define MAX_SOCKET nodepp::limit::get_soft_fileno ()
107102#define HASH_TABLE_SIZE 16
108103#define MAX_BATCH 16
109104#define MAX_SSO 16
@@ -247,7 +242,7 @@ static bool& NODEPP_SHTDWN(){ static bool out=false; return out; }
247242
248243/* ────────────────────────────────────────────────────────────────────────────*/
249244
250- #define typeof (DATA ) string_t ( typeid (DATA).name() )
245+ #define typeof (DATA ) nodepp:: string_t ( typeid (DATA).name() )
251246
252247#define ullong unsigned long long int
253248#define ulong unsigned long int
@@ -281,7 +276,10 @@ static bool& NODEPP_SHTDWN(){ static bool out=false; return out; }
281276
282277/* ────────────────────────────────────────────────────────────────────────────*/
283278
284- using null_t = decltype ( nullptr );
279+ namespace nodepp {
280+ static bool & NODEPP_SHTDWN (){ static bool out=false ; return out; }
281+ /* --*/ using null_t = decltype ( nullptr );
282+ }
285283
286284/* ────────────────────────────────────────────────────────────────────────────*/
287285
0 commit comments