Skip to contentSkip to conversation

Time representation in RTDM profiles

Xenomai-core Jan Kiszka 2 participants 7 messages Aug 16, 2006

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

Hi all,

the current representation of timeouts and timestamps in RTDM device profiles is inconsistent. In the serial profile we use [u]int64_t directly, the CAN profile defines its own types called nanosecs_{abs|rel}_t (though they just wrap the int64 ones).

What is the idea of nanosecs? Having a way to redefine that type looks nice, but it's unfortunately the ABI, so we cannot easily change it without breaking apps.

Jan

#1 lore raw
Quoted 2 lines · Jan Kiszka

the current representation of timeouts and timestamps in RTDM device profiles is inconsistent.

I would welcome a consistent time value representation above all RTDM profiles, too.

Quoted 7 lines

In the serial profile we use [u]int64_t
directly, the CAN profile defines its own types called nanosecs_{abs|rel}_t (though they just wrap the int64 ones).

What is the idea of nanosecs? Having a way to redefine that type looks nice, but it's unfortunately the ABI, so we cannot easily change it without breaking apps.

The possibility of redefinition was not the main goal here. As you mentioned it would be problematic. No, I introduced nanosecs_abs_t and nanosecs_rel_t because they are more intuitive and more "speaking" to the programmer. The meaning of a variable of such a type is clear at first sight.

Sebastian

author
#2 lore raw
Quoted 11 lines · Sebastian Smolorz
Quoted 2 lines · Jan Kiszka

the current representation of timeouts and timestamps in RTDM device profiles is inconsistent.

I would welcome a consistent time value representation above all RTDM profiles, too.

Quoted 4 lines

In the serial profile we use [u]int64_t
directly, the CAN profile defines its own types called nanosecs_{abs|rel}_t (though they just wrap the int64 ones).

Quoted 9 lines
Quoted 3 lines

What is the idea of nanosecs? Having a way to redefine that type looks nice, but it's unfortunately the ABI, so we cannot easily change it without breaking apps.

The possibility of redefinition was not the main goal here. As you mentioned it would be problematic. No, I introduced nanosecs_abs_t and nanosecs_rel_t because they are more intuitive and more "speaking" to the programmer. The meaning of a variable of such a type is clear at first sight.

Yeah, sounds reasonable to me. Then let's move these typedefs to rtdm.h and document them as self-explanatory defines of the underlying standard types, freezing their width and signedness at the same time.

Actually, this would be useful for the driver API of RTDM as well.

Jan

#3 lore raw
Quoted 10 lines · Jan Kiszka
Quoted 5 lines · Sebastian Smolorz

The possibility of redefinition was not the main goal here. As you mentioned it would be problematic. No, I introduced nanosecs_abs_t and nanosecs_rel_t because they are more intuitive and more "speaking" to the programmer. The meaning of a variable of such a type is clear at first sight.

Yeah, sounds reasonable to me. Then let's move these typedefs to rtdm.h and document them as self-explanatory defines of the underlying standard types, freezing their width and signedness at the same time.

Agreed.

Quoted 2 lines

Actually, this would be useful for the driver API of RTDM as well.

That's right. No objections from my side.

Sebastian

author
#4 lore raw
Quoted 11 lines · Sebastian Smolorz
Quoted 9 lines · Jan Kiszka
Quoted 5 lines · Sebastian Smolorz

The possibility of redefinition was not the main goal here. As you mentioned it would be problematic. No, I introduced nanosecs_abs_t and nanosecs_rel_t because they are more intuitive and more "speaking" to the programmer. The meaning of a variable of such a type is clear at first sight.

Yeah, sounds reasonable to me. Then let's move these typedefs to rtdm.h and document them as self-explanatory defines of the underlying standard types, freezing their width and signedness at the same time.

Quoted 6 lines

Agreed.

Quoted 1 line

Actually, this would be useful for the driver API of RTDM as well.

That's right. No objections from my side.

Done.

Though I checked things more then twice, some regression may be hidden, specifically as I changed the signedness of timeout parameters of a few RTDM driver API functions. All documented under ksrc/skins/rtdm/API.CHANGES, and everyone is warned now.

Jan

#5 lore raw
Quoted 17 lines · Jan Kiszka
Quoted 16 lines · Sebastian Smolorz
Quoted 10 lines · Jan Kiszka
Quoted 5 lines · Sebastian Smolorz

The possibility of redefinition was not the main goal here. As you mentioned it would be problematic. No, I introduced nanosecs_abs_t and nanosecs_rel_t because they are more intuitive and more "speaking" to the programmer. The meaning of a variable of such a type is clear at first sight.

Yeah, sounds reasonable to me. Then let's move these typedefs to rtdm.h and document them as self-explanatory defines of the underlying standard types, freezing their width and signedness at the same time.

Agreed.

Quoted 1 line

Actually, this would be useful for the driver API of RTDM as well.

Quoted 8 lines
Quoted 1 line

That's right. No objections from my side.

Done.

Though I checked things more then twice, some regression may be hidden, specifically as I changed the signedness of timeout parameters of a few RTDM driver API functions. All documented under ksrc/skins/rtdm/API.CHANGES, and everyone is warned now.

Here comes a follow-up patch. Compile-tested successfully.

Sebastian

rtdm/rtcan.h +2 -12
Index: include/rtdm/rtcan.h
===================================================================
@@ -507,16 +507,6 @@
 /** @} */
 
 
-/*!
- * @anchor RTCAN_TIMEOUTS   @name Timeouts
- * Special reception and transmission timeouts
- * @{ */
-#define RTCAN_TIMEOUT_INFINITE    0     /**< wait for ever  */
-#define RTCAN_TIMEOUT_NONE        (-1)  /**< equivalent to non-blocking */
-/** @} */
-
-
-
 #define RTIOC_TYPE_CAN              RTDM_CLASS_CAN
 
 
@@ -946,7 +936,7 @@
  * @param [in] arg Pointer to @ref nanosecs_rel_t variable. The value is
  *                interpreted as relative timeout in nanoseconds in case
  *                of a positive value.
- *                See @ref RTCAN_TIMEOUTS "Timeouts" for special timeouts.
+ *                See @ref RTDM_TIMEOUT_xxx "Timeouts" for special timeouts.
  *
  * @return 0 on success, otherwise:
  * - -EFAULT: It was not possible to access user space memory area at the
@@ -976,7 +966,7 @@
  * @param [in] arg Pointer to @ref nanosecs_rel_t variable. The value is
  *                interpreted as relative timeout in nanoseconds in case
  *                of a positive value.
- *                See @ref RTCAN_TIMEOUTS "Timeouts" for special timeouts.
+ *                See @ref RTDM_TIMEOUT_xxx "Timeouts" for special timeouts.
  *
  * @return 0 on success, otherwise:
  * - -EFAULT: It was not possible to access user space memory area at the
ChangeLog +5 -0
Index: ChangeLog
===================================================================
@@ -1,3 +1,8 @@
+2006-08-16  Sebastian Smolorz  <[email protected]>
+
+	* include/rtdm/rtcan.h, ksrc/drivers/can/rtcan_{module,socket,raw}.c:
+	Get rid of RTCAN_TIMEOUT_* defines and replace them with RTDM_TIMEOUT_*
+
 2006-08-16  Jan Kiszka  <[email protected]>
 
 	* include/rtdm/*.h, ksrc/skins/rtdm/drvlib.c: Refactor RTDM types
drivers/can/rtcan_module.c +1 -1
Index: ksrc/drivers/can/rtcan_module.c
===================================================================
@@ -112,7 +112,7 @@
 static void rtcan_get_timeout_name(nanosecs_rel_t timeout,
 				   char* name, int max_len)
 {
-    if (timeout == RTCAN_TIMEOUT_INFINITE) 
+    if (timeout == RTDM_TIMEOUT_INFINITE) 
 	strncpy(name, "infinite", max_len);
     else
 	sprintf(name, "%lld", timeout);
drivers/can/rtcan_socket.c +2 -2
Index: ksrc/drivers/can/rtcan_socket.c
===================================================================
@@ -49,8 +49,8 @@
     sock->err_mask = 0;
     sock->rx_buf_full = 0;
 
-    sock->tx_timeout = RTCAN_TIMEOUT_INFINITE;
-    sock->rx_timeout = RTCAN_TIMEOUT_INFINITE;
+    sock->tx_timeout = RTDM_TIMEOUT_INFINITE;
+    sock->rx_timeout = RTDM_TIMEOUT_INFINITE;
 
     INIT_LIST_HEAD(&sock->tx_wait_head);
     list_add(&sock->socket_list, &rtcan_socket_list);
drivers/can/rtcan_raw.c +2 -2
Index: ksrc/drivers/can/rtcan_raw.c
===================================================================
@@ -556,7 +556,7 @@
     /* Set RX timeout */
     rtdm_lock_get_irqsave(&rtcan_socket_lock, lock_ctx);
 
-    timeout = (flags & MSG_DONTWAIT) ? RTCAN_TIMEOUT_NONE : sock->rx_timeout;
+    timeout = (flags & MSG_DONTWAIT) ? RTDM_TIMEOUT_NONE : sock->rx_timeout;
 
     rtdm_lock_put_irqrestore(&rtcan_socket_lock, lock_ctx);
 
@@ -839,7 +839,7 @@
    
     rtdm_lock_get_irqsave(&rtcan_socket_lock, lock_ctx);
 
-    timeout = (flags & MSG_DONTWAIT) ? RTCAN_TIMEOUT_NONE : sock->tx_timeout;
+    timeout = (flags & MSG_DONTWAIT) ? RTDM_TIMEOUT_NONE : sock->tx_timeout;
 
     rtdm_lock_put_irqrestore(&rtcan_socket_lock, lock_ctx);
 
author
#6 lore raw
Quoted 16 lines · Sebastian Smolorz
Quoted 15 lines · Jan Kiszka
Quoted 14 lines · Sebastian Smolorz
Quoted 9 lines · Jan Kiszka
Quoted 5 lines · Sebastian Smolorz

The possibility of redefinition was not the main goal here. As you mentioned it would be problematic. No, I introduced nanosecs_abs_t and nanosecs_rel_t because they are more intuitive and more "speaking" to the programmer. The meaning of a variable of such a type is clear at first sight.

Yeah, sounds reasonable to me. Then let's move these typedefs to rtdm.h and document them as self-explanatory defines of the underlying standard types, freezing their width and signedness at the same time.

Agreed.

Quoted 1 line

Actually, this would be useful for the driver API of RTDM as well.

That's right. No objections from my side.

Quoted 9 lines
Quoted 6 lines

Done.

Though I checked things more then twice, some regression may be hidden, specifically as I changed the signedness of timeout parameters of a few RTDM driver API functions. All documented under ksrc/skins/rtdm/API.CHANGES, and everyone is warned now.

Here comes a follow-up patch. Compile-tested successfully.

Just applied, thanks.

[I thought about dropping the RTSER_TIMEOUT_* stuff as well, but A) there are already users and B) it aligns so well with the other defines for rtser_config.]

Jan