Skip to content
This repository has been archived by the owner on Jul 8, 2022. It is now read-only.

Pollthread: Fix multiline macro definitions #451

Merged
merged 1 commit into from
May 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 36 additions & 24 deletions cppapi/server/pollthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,30 +183,42 @@ class PollThread: public omni_thread
// Three macros
//

#define T_DIFF(A,B,C) \
long delta_sec = B.tv_sec - A.tv_sec; \
if (delta_sec == 0) \
C = B.tv_usec - A.tv_usec; \
else \
{ \
C = ((delta_sec - 1) * 1000000) + (1000000 - A.tv_usec) + B.tv_usec; \
}

#define T_ADD(A,B) \
A.tv_usec = A.tv_usec + B; \
while (A.tv_usec > 1000000) \
{ \
A.tv_sec++; \
A.tv_usec = A.tv_usec - 1000000; \
}

#define T_DEC(A,B) \
A.tv_usec = A.tv_usec - B; \
if (A.tv_usec < 0) \
{ \
A.tv_sec--; \
A.tv_usec = 1000000 + A.tv_usec; \
}
#define T_DIFF(A,B,C) \
do \
{ \
long delta_sec = B.tv_sec - A.tv_sec; \
if (delta_sec == 0) \
C = B.tv_usec - A.tv_usec; \
else \
{ \
C = ((delta_sec - 1) * 1000000) + (1000000 - A.tv_usec) + B.tv_usec; \
} \
} \
while(0)

#define T_ADD(A,B) \
do \
{ \
A.tv_usec = A.tv_usec + B; \
while (A.tv_usec > 1000000) \
{ \
A.tv_sec++; \
A.tv_usec = A.tv_usec - 1000000; \
} \
} \
while(0)

#define T_DEC(A,B) \
do \
{ \
A.tv_usec = A.tv_usec - B; \
if (A.tv_usec < 0) \
{ \
A.tv_sec--; \
A.tv_usec = 1000000 + A.tv_usec; \
} \
} \
while(0)

} // End of Tango namespace

Expand Down