]> rtime.felk.cvut.cz Git - orte.git/blobdiff - orte/include/orte/defines_api.h
Reformat the sources with orte/uncrustify script
[orte.git] / orte / include / orte / defines_api.h
index 58f4cac1c9f9108839d7761dc2b472f865072d7f..f7e89a70afda2a55a49cae0e52b1faa6ffaef43d 100644 (file)
@@ -1,30 +1,30 @@
 /*
- *  $Id: defines_api.h,v 0.0.0.1        2003/08/21 
+ *  $Id: defines_api.h,v 0.0.0.1        2003/08/21
  *
- *  -------------------------------------------------------------------  
- *                                ORTE                                 
- *                      Open Real-Time Ethernet                       
- *                                                                    
- *                      Copyright (C) 2001-2006                       
- *  Department of Control Engineering FEE CTU Prague, Czech Republic  
- *                      http://dce.felk.cvut.cz                       
- *                      http://www.ocera.org                          
- *                                                                    
- *  Author:             Petr Smolik    petr@smoliku.cz             
- *  Advisor:            Pavel Pisa                                   
- *  Project Responsible: Zdenek Hanzalek                              
+ *  -------------------------------------------------------------------
+ *                                ORTE
+ *                      Open Real-Time Ethernet
+ *
+ *                      Copyright (C) 2001-2006
+ *  Department of Control Engineering FEE CTU Prague, Czech Republic
+ *                      http://dce.felk.cvut.cz
+ *                      http://www.ocera.org
+ *
+ *  Author:              Petr Smolik   petr@smoliku.cz
+ *  Advisor:             Pavel Pisa
+ *  Project Responsible: Zdenek Hanzalek
  *  --------------------------------------------------------------------
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or
  *  (at your option) any later version.
- *  
+ *
  *  This program is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
- *  
+ *
  */
 
 #ifndef _DEFINES_API_H
@@ -41,17 +41,17 @@ extern "C" {
 
 ////////////////////////////////////////////////////////////////////////////////
 //Return values
-#define ORTE_OK                          0
-#define ORTE_BAD_HANDLE                  -1
-#define ORTE_TIMEOUT             -2
-#define ORTE_QUEUE_FULL                  -3
+#define ORTE_OK                   0
+#define ORTE_BAD_HANDLE           -1
+#define ORTE_TIMEOUT              -2
+#define ORTE_QUEUE_FULL           -3
 
 ////////////////////////////////////////////////////////////////////////////////
 //Logging - flags
-#define LOG_FNONE                0x00
-#define LOG_FEXCEPTION           0x01
-#define LOG_FWARN                0x02
-#define LOG_FLOCAL_OBJECT        0x04  
+#define LOG_FNONE                 0x00
+#define LOG_FEXCEPTION            0x01
+#define LOG_FWARN                 0x02
+#define LOG_FLOCAL_OBJECT         0x04
 #define LOG_FREMOTE_OBJECT        0x08
 #define LOG_FPERIODIC             0x10
 #define LOG_FCONTENT              0x20
@@ -61,16 +61,16 @@ extern "C" {
  * SeqNumberCmp - comparison of two sequence numbers
  * @sn1: source sequential number 1
  * @sn2: source sequential number 2
- * 
+ *
  * Return:  1 if sn1 > sn2
  *         -1 if sn1 < sn2
  *          0 if sn1 = sn2
  */
-#define SeqNumberCmp(sn1, sn2) (                 \
-          (sn1).high>(sn2).high ? 1 :            \
-        ((sn1).high<(sn2).high ? -1 :            \
-          ((sn1).low>(sn2).low ? 1 :             \
-            ((sn1).low<(sn2).low ? -1 : 0)))     \
+#define SeqNumberCmp(sn1, sn2) (                \
+    (sn1).high > (sn2).high ? 1 :           \
+    ((sn1).high < (sn2).high ? -1 :           \
+     ((sn1).low > (sn2).low ? 1 :            \
+      ((sn1).low < (sn2).low ? -1 : 0)))     \
     )
 
 /*****************************************************************/
@@ -78,13 +78,14 @@ extern "C" {
  * SeqNumberInc - incrementation of a sequence number
  * @res: result
  * @sn: sequential number to be incremented
- * 
+ *
  * res = sn + 1
  */
-#define SeqNumberInc(res,sn) {                   \
-      (res) = (sn);                              \
-          if (++(res).low==0) (res).high++;      \
-        }
+#define SeqNumberInc(res, sn) {                          \
+    (res) = (sn);                             \
+    if (++(res).low == 0) \
+      (res).high++;     \
+}
 
 
 /*****************************************************************/
@@ -96,13 +97,13 @@ extern "C" {
  *
  * res = sn1 + sn2
  */
-#define SeqNumberAdd(res,sn1,sn2) {              \
-    (res).low = (sn1).low+(sn2).low;             \
-    (res).high = (sn1).high+(sn2).high;          \
-    if (((res).low < (sn1).low) ||               \
-        ((res).low < (sn2).low)) {               \
-      (res).high++;                              \
-    }                                            \
+#define SeqNumberAdd(res, sn1, sn2) {             \
+    (res).low = (sn1).low+(sn2).low;            \
+    (res).high = (sn1).high+(sn2).high;                 \
+    if (((res).low < (sn1).low) ||              \
+       ((res).low < (sn2).low)) {               \
+      (res).high++;                             \
+    }                                           \
 }
 
 /*****************************************************************/
@@ -110,13 +111,14 @@ extern "C" {
  * SeqNumberDec - decrementation of a sequence number
  * @res: result
  * @sn: sequential number to be decremented
- * 
+ *
  * res = sn - 1
  */
-#define SeqNumberDec(res,sn) {                   \
-      (res) = (sn);                              \
-          if ((res).low--==0) (res).high--;      \
-        }
+#define SeqNumberDec(res, sn) {                          \
+    (res) = (sn);                             \
+    if ((res).low-- == 0) \
+      (res).high--;     \
+}
 
 /*****************************************************************/
 /**
@@ -127,12 +129,12 @@ extern "C" {
  *
  * res = sn1 - sn2
  */
-#define SeqNumberSub(res,sn1,sn2) {                  \
-    (res).low = (sn1).low-(sn2).low;                 \
-    (res).high = (sn1).high-(sn2).high;              \
-    if ((res).low > (sn1).low) {                     \
-      (res).high--;                                  \
-    }                                                \
+#define SeqNumberSub(res, sn1, sn2) {                 \
+    (res).low = (sn1).low-(sn2).low;                \
+    (res).high = (sn1).high-(sn2).high;                     \
+    if ((res).low > (sn1).low) {                    \
+      (res).high--;                                 \
+    }                                               \
 }
 
 /*****************************************************************/
@@ -142,15 +144,15 @@ extern "C" {
  * @time2: source time 2
  *
  * Return value:
- * 1 if time 1 > time 2 
+ * 1 if time 1 > time 2
  * -1 if time 1 < time 2
  * 0 if time 1 = time 2
  */
-#define NtpTimeCmp(time1, time2)                     \
-((((time1).seconds) > ((time2).seconds)) ? 1 :       \
- ((((time1).seconds) < ((time2).seconds)) ? -1 :     \
-  ((((time1).fraction) > ((time2).fraction)) ? 1 :   \
-   ((((time1).fraction) < ((time2).fraction)) ? -1 : 0))))
+#define NtpTimeCmp(time1, time2)                    \
+  ((((time1).seconds) > ((time2).seconds)) ? 1 :       \
  ((((time1).seconds) < ((time2).seconds)) ? -1 :     \
+    ((((time1).fraction) > ((time2).fraction)) ? 1 :   \
+     ((((time1).fraction) < ((time2).fraction)) ? -1 : 0))))
 
 
 /*****************************************************************/
@@ -162,13 +164,13 @@ extern "C" {
  *
  * res = time1 + time2
  */
-#define NtpTimeAdd(res, time1, time2) {              \
-    (res).seconds  = (time1).seconds + (time2).seconds;   \
+#define NtpTimeAdd(res, time1, time2) {                     \
+    (res).seconds  = (time1).seconds + (time2).seconds;          \
     (res).fraction = (time1).fraction + (time2).fraction; \
-    if (((res).fraction < (time1).fraction) ||       \
-        ((res).fraction < (time2).fraction)) {       \
-      (res).seconds++;                               \
-    }                                                \
+    if (((res).fraction < (time1).fraction) ||      \
+       ((res).fraction < (time2).fraction)) {       \
+      (res).seconds++;                              \
+    }                                               \
 }
 
 /*****************************************************************/
@@ -180,12 +182,12 @@ extern "C" {
  *
  * res = time1 - time2
  */
-#define NtpTimeSub(res, time1, time2) {              \
-   (res).seconds  = (time1).seconds - (time2).seconds;   \
-   (res).fraction = (time1).fraction - (time2).fraction; \
-   if ((res).fraction > (time1).fraction) {          \
-     (res).seconds--;                                \
-                                                   \
+#define NtpTimeSub(res, time1, time2) {                     \
+    (res).seconds  = (time1).seconds - (time2).seconds;          \
+    (res).fraction = (time1).fraction - (time2).fraction; \
+    if ((res).fraction > (time1).fraction) {         \
+      (res).seconds--;                               \
+    }                                                \
 }
 
 /*****************************************************************/
@@ -195,10 +197,10 @@ extern "C" {
  * @s: seconds portion of given time
  * @msec: miliseconds portion of given time
  */
-#define NtpTimeAssembFromMs(time, s, msec) {         \
-    register uint32_t ms = msec;                     \
-    (time).seconds  = s;                             \
-    (time).fraction = (ms<<22) + ((ms*393)<<8);      \
+#define NtpTimeAssembFromMs(time, s, msec) {        \
+    register uint32_t ms = msec;                    \
+    (time).seconds  = s;                            \
+    (time).fraction = (ms<<22) + ((ms*393)<<8);             \
 }
 
 /**
@@ -207,11 +209,11 @@ extern "C" {
  * @msec: miliseconds portion of given time
  * @time: time given in NtpTime structure
  */
-#define NtpTimeDisAssembToMs(s, msec, time) {        \
-    s    = (time).seconds;                           \
+#define NtpTimeDisAssembToMs(s, msec, time) {       \
+    s    = (time).seconds;                          \
     msec = ((time).fraction - ((time).fraction>>6) - \
-           ((time).fraction>>7) + (1<<21))>>22;      \
-    if ((msec) >= 1000 ) { (msec) -= 1000; (s)++; }  \
+           ((time).fraction>>7) + (1<<21))>>22;      \
+    if ((msec) >= 1000) { (msec) -= 1000; (s)++; }  \
 }
 
 /**
@@ -220,9 +222,9 @@ extern "C" {
  * @s: seconds portion of given time
  * @usec: microseconds portion of given time
  */
-#define NtpTimeAssembFromUs(time, s, usec) {         \
-    register uint32_t us = usec;                     \
-    (time).seconds  = s;                             \
+#define NtpTimeAssembFromUs(time, s, usec) {        \
+    register uint32_t us = usec;                    \
+    (time).seconds  = s;                            \
     (time).fraction = (us<<12)+ ((us*99)<<1)+ ((us*15 + ((us*61)>>7))>>4); \
 }
 
@@ -232,12 +234,12 @@ extern "C" {
  * @usec: microseconds portion of given time
  * @time: time given in NtpTime structure
  */
-#define NtpTimeDisAssembToUs(s, usec, time) {        \
+#define NtpTimeDisAssembToUs(s, usec, time) {       \
     register uint32_t NtpTemp = (time).fraction;     \
-    s    = (time).seconds;                           \
+    s    = (time).seconds;                          \
     usec = ((time).fraction - (NtpTemp>>5)-(NtpTemp>>7)-(NtpTemp>>8)- \
-            (NtpTemp>>9)-(NtpTemp>>10) - (NtpTemp>>12) - \
-            (NtpTemp>>13)-(NtpTemp>>14) + (1<<11)) >> 12; \
+           (NtpTemp>>9)-(NtpTemp>>10) - (NtpTemp>>12) - \
+           (NtpTemp>>13)-(NtpTemp>>14) + (1<<11)) >> 12; \
     if ((usec) >= 1000000) { (usec) -= 1000000; (s)++; } \
 }
 
@@ -246,8 +248,8 @@ extern "C" {
  * @d: domain
  * @p: port
  */
-#define Domain2Port(d,p) {                   \
-  p = RTPS_DEFAULT_PORT + d*10;              \
+#define Domain2Port(d, p) {                  \
+    p = RTPS_DEFAULT_PORT + d*10;             \
 }
 
 /**
@@ -255,8 +257,8 @@ extern "C" {
  * @d: domain
  * @p: port
  */
-#define Domain2PortMulticastUserdata(d,p) {  \
-    p = RTPS_DEFAULT_PORT + d*10+1;          \
+#define Domain2PortMulticastUserdata(d, p) {  \
+    p = RTPS_DEFAULT_PORT + d*10+1;         \
 }
 
 /**
@@ -264,8 +266,8 @@ extern "C" {
  * @d: domain
  * @p: port
  */
-#define Domain2PortMulticastMetatraffic(d,p) {        \
-    p = RTPS_DEFAULT_PORT + d*10+2;          \
+#define Domain2PortMulticastMetatraffic(d, p) {               \
+    p = RTPS_DEFAULT_PORT + d*10+2;         \
 }
 
 
@@ -279,7 +281,7 @@ extern "C" {
  */
 
 #define ALIGN_ADDRESS(this, boundary) \
-  ((void*)((( ((unsigned long)(this)) + (((unsigned long)(boundary)) -1)) & (~(((unsigned long)(boundary))-1)))))
+  ((void *)((( ((unsigned long)(this)) + (((unsigned long)(boundary)) -1)) & (~(((unsigned long)(boundary))-1)))))
 
 
 #ifdef __cplusplus