This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 1fdb3f5107 notesnap_driver.c: modify struct notesnap_s member type
1fdb3f5107 is described below

commit 1fdb3f5107dd92a085af9055eb818a2111bc88cc
Author: wangmingrong1 <[email protected]>
AuthorDate: Wed Jul 24 10:46:33 2024 +0800

    notesnap_driver.c: modify struct notesnap_s member type
    
    clang atomic no support other type:
    modify .index type size_t --- atomic_int
    modify .dumping type bool --- atomic_bool
    
    Signed-off-by: wangmingrong1 <[email protected]>
---
 drivers/note/notesnap_driver.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/note/notesnap_driver.c b/drivers/note/notesnap_driver.c
index 097aaed80c..413ea836d4 100644
--- a/drivers/note/notesnap_driver.c
+++ b/drivers/note/notesnap_driver.c
@@ -48,8 +48,8 @@ struct notesnap_s
 {
   struct note_driver_s driver;
   struct notifier_block nb;
-  size_t index;
-  bool dumping;
+  atomic_int index;
+  atomic_bool dumping;
   struct notesnap_chunk_s buffer[CONFIG_DRIVERS_NOTESNAP_NBUFFERS];
 };
 
@@ -197,7 +197,7 @@ static inline void notesnap_common(FAR struct note_driver_s 
*drv,
   FAR struct notesnap_chunk_s *note;
   size_t index;
 
-  if (snap->dumping)
+  if (atomic_load(&snap->dumping))
     {
       return;
     }
@@ -369,7 +369,8 @@ int notesnap_register(void)
 void notesnap_dump_with_stream(FAR struct lib_outstream_s *stream)
 {
   size_t i;
-  size_t index = g_notesnap.index % CONFIG_DRIVERS_NOTESNAP_NBUFFERS;
+  size_t index = atomic_load(&g_notesnap.index) %
+                 CONFIG_DRIVERS_NOTESNAP_NBUFFERS;
   clock_t lastcount = g_notesnap.buffer[index].count;
   struct timespec lasttime =
   {

Reply via email to