You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/03/31 13:03:57 UTC
[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #5915: sched/note: add support of trace section mark
xiaoxiang781216 commented on a change in pull request #5915:
URL: https://github.com/apache/incubator-nuttx/pull/5915#discussion_r839570395
##########
File path: sched/sched/sched_note.c
##########
@@ -107,6 +107,67 @@ static unsigned int g_note_disabled_irq_nest[CONFIG_SMP_NCPUS];
* Private Functions
****************************************************************************/
+/****************************************************************************
+ * Name: sched_note_format
Review comment:
sched_note_copy
##########
File path: sched/sched/sched_note.c
##########
@@ -107,6 +107,67 @@ static unsigned int g_note_disabled_irq_nest[CONFIG_SMP_NCPUS];
* Private Functions
****************************************************************************/
+/****************************************************************************
+ * Name: sched_note_format
+ *
+ * Description:
+ * swap the data to unified format
Review comment:
Copy the data in the little endian layout
##########
File path: sched/sched/sched_note.c
##########
@@ -107,6 +107,67 @@ static unsigned int g_note_disabled_irq_nest[CONFIG_SMP_NCPUS];
* Private Functions
****************************************************************************/
+/****************************************************************************
+ * Name: sched_note_format
+ *
+ * Description:
+ * swap the data to unified format
+ *
+ ****************************************************************************/
+
+static inline void sched_note_format(FAR uint8_t *dst,
Review comment:
format->copy
##########
File path: sched/sched/sched_note.c
##########
@@ -107,6 +107,67 @@ static unsigned int g_note_disabled_irq_nest[CONFIG_SMP_NCPUS];
* Private Functions
****************************************************************************/
+/****************************************************************************
+ * Name: sched_note_format
+ *
+ * Description:
+ * swap the data to unified format
+ *
+ ****************************************************************************/
+
+static inline void sched_note_format(FAR uint8_t *dst,
+ FAR void *src, size_t len)
+{
+ uint64_t u64;
+ uint32_t u32;
+ uint16_t u16;
+ uint8_t u8;
+
+ switch (len)
+ {
+ case 8:
+ {
+ u64 = *(uint64_t *)src;
+
+ dst[7] = (uint8_t)((u64 >> 56) & 0xff);
+ dst[6] = (uint8_t)((u64 >> 48) & 0xff);
+ dst[5] = (uint8_t)((u64 >> 40) & 0xff);
+ dst[4] = (uint8_t)((u64 >> 32) & 0xff);
+
+ u32 = u64 & 0xffffffff;
+ src = &u32;
+ }
+
+ case 4:
+ {
+ u32 = *(uint32_t *)src;
+
+ dst[3] = (uint8_t)((u32 >> 24) & 0xff);
+ dst[2] = (uint8_t)((u32 >> 16) & 0xff);
+
+ u16 = u32 & 0xffff;
+ src = &u16;
+ }
+
+ case 2:
+ {
+ u16 = *(uint16_t *)src;
+
+ dst[1] = (uint8_t)((u16 >> 8) & 0xff);
+
+ u8 = u16 & 0xff;
+ src = &u8;
+ }
+
+ case 1:
+ {
+ u8 = *(uint8_t *)src;
+
+ dst[0] = (uint8_t)(u8 & 0xff);
+ }
+ }
Review comment:
add:
```
default:
DEBGUASSERT(FALSE);
break;
```
##########
File path: sched/sched/sched_note.c
##########
@@ -144,25 +205,15 @@ static void note_common(FAR struct tcb_s *tcb,
#ifdef CONFIG_SMP
Review comment:
remove the extra space before =
##########
File path: sched/sched/sched_note.c
##########
@@ -419,19 +470,7 @@ static void note_spincommon(FAR struct tcb_s *tcb,
note_common(tcb, ¬e.nsp_cmn, sizeof(struct note_spinlock_s), type);
- note.nsp_spinlock[0] = (uint8_t)((uintptr_t)spinlock & 0xff);
- note.nsp_spinlock[1] = (uint8_t)(((uintptr_t)spinlock >> 8) & 0xff);
-#if UINTPTR_MAX > UINT16_MAX
- note.nsp_spinlock[2] = (uint8_t)(((uintptr_t)spinlock >> 16) & 0xff);
- note.nsp_spinlock[3] = (uint8_t)(((uintptr_t)spinlock >> 24) & 0xff);
-#if UINTPTR_MAX > UINT32_MAX
- note.nsp_spinlock[4] = (uint8_t)(((uintptr_t)spinlock >> 32) & 0xff);
- note.nsp_spinlock[5] = (uint8_t)(((uintptr_t)spinlock >> 40) & 0xff);
- note.nsp_spinlock[6] = (uint8_t)(((uintptr_t)spinlock >> 48) & 0xff);
- note.nsp_spinlock[7] = (uint8_t)(((uintptr_t)spinlock >> 56) & 0xff);
-#endif
-#endif
-
+ sched_note_format(note.nsp_spinlock, &spinlock, sizeof(uintptr_t));
note.nsp_value = (uint8_t)*spinlock;
Review comment:
ditto
##########
File path: sched/sched/sched_note.c
##########
@@ -107,6 +107,67 @@ static unsigned int g_note_disabled_irq_nest[CONFIG_SMP_NCPUS];
* Private Functions
****************************************************************************/
+/****************************************************************************
+ * Name: sched_note_format
+ *
+ * Description:
+ * swap the data to unified format
+ *
+ ****************************************************************************/
+
+static inline void sched_note_format(FAR uint8_t *dst,
+ FAR void *src, size_t len)
+{
+ uint64_t u64;
+ uint32_t u32;
+ uint16_t u16;
+ uint8_t u8;
+
+ switch (len)
+ {
+ case 8:
Review comment:
check CONFIG_HAVE_LONGLONG?
##########
File path: sched/sched/sched_note.c
##########
@@ -107,6 +107,67 @@ static unsigned int g_note_disabled_irq_nest[CONFIG_SMP_NCPUS];
* Private Functions
****************************************************************************/
+/****************************************************************************
+ * Name: sched_note_format
+ *
+ * Description:
+ * swap the data to unified format
+ *
+ ****************************************************************************/
+
+static inline void sched_note_format(FAR uint8_t *dst,
+ FAR void *src, size_t len)
+{
+ uint64_t u64;
+ uint32_t u32;
+ uint16_t u16;
+ uint8_t u8;
+
+ switch (len)
+ {
+ case 8:
+ {
Review comment:
don't need {}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org