Use thread local storage for thread index
[vpp.git] / src / vlibapi / api_helper_macros.h
index 4e28134..a492c3f 100644 (file)
 #define f64_endian(a)
 #define f64_print(a,b)
 
+#ifndef REPLY_MSG_ID_BASE
+#define REPLY_MSG_ID_BASE 0
+#endif
+
 #define REPLY_MACRO(t)                                          \
 do {                                                            \
     unix_shared_memory_queue_t * q;                             \
@@ -32,7 +36,7 @@ do {                                                            \
         return;                                                 \
                                                                 \
     rmp = vl_msg_api_alloc (sizeof (*rmp));                     \
-    rmp->_vl_msg_id = ntohs((t));                               \
+    rmp->_vl_msg_id = htons((t)+(REPLY_MSG_ID_BASE));           \
     rmp->context = mp->context;                                 \
     rmp->retval = ntohl(rv);                                    \
                                                                 \
@@ -48,7 +52,7 @@ do {                                                            \
         return;                                                 \
                                                                 \
     rmp = vl_msg_api_alloc (sizeof (*rmp));                     \
-    rmp->_vl_msg_id = ntohs((t));                               \
+    rmp->_vl_msg_id = htons((t)+(REPLY_MSG_ID_BASE));           \
     rmp->context = mp->context;                                 \
     rmp->retval = ntohl(rv);                                    \
     do {body;} while (0);                                       \
@@ -64,7 +68,7 @@ do {                                                            \
         return;                                                 \
                                                                 \
     rmp = vl_msg_api_alloc (sizeof (*rmp) + n);                 \
-    rmp->_vl_msg_id = ntohs((t));                               \
+    rmp->_vl_msg_id = htons((t)+(REPLY_MSG_ID_BASE));           \
     rmp->context = mp->context;                                 \
     rmp->retval = ntohl(rv);                                    \
     do {body;} while (0);                                       \
@@ -93,7 +97,7 @@ do {                                                            \
         rv = VNET_API_ERROR_TABLE_TOO_BIG;                      \
         is_error = 1;                                           \
       }                                                         \
-    rmp->_vl_msg_id = ntohs((t));                               \
+    rmp->_vl_msg_id = htons((t)+(REPLY_MSG_ID_BASE));           \
     rmp->context = mp->context;                                 \
     rmp->retval = ntohl(rv);                                    \
     if (!is_error)                                              \