anjiahao1 commented on code in PR #11351:
URL: https://github.com/apache/nuttx/pull/11351#discussion_r1421899579


##########
mm/mempool/mempool.c:
##########
@@ -46,43 +46,56 @@
  * Private Functions
  ****************************************************************************/
 
-static inline FAR sq_entry_t *mempool_remove_queue(FAR sq_queue_t *queue)
+static inline FAR dq_entry_t *
+mempool_remove_queue(FAR struct mempool_s *pool, FAR dq_queue_t *queue)
 {
-  if (!sq_empty(queue))
-    {
-      FAR sq_entry_t *entry = queue->head;
+  FAR dq_entry_t *ret = queue->tail;
 
-      queue->head = entry->flink;
-      return entry;
-    }
-  else
+  if (ret)
     {
-      return NULL;
-    }
-}
-
-static inline size_t mempool_queue_lenth(FAR sq_queue_t *queue)
-{
-  FAR sq_entry_t *node;
-  size_t count;
+      FAR dq_entry_t *prev = ret->blink;
+      if (prev == NULL)
+        {
+          queue->head = NULL;
+          queue->tail = NULL;
+        }
+      else
+        {
+          pool->check(pool, prev);
+          queue->tail = prev;
+          prev->flink = NULL;
+        }
 
-  for (node = queue->head, count = 0;
-       node != NULL;
-       node = node->flink, count++);
+      ret->flink = NULL;
+      ret->blink = NULL;
+    }
 
-  return count;
+  return ret;
 }
 
-static inline void mempool_add_queue(FAR sq_queue_t *queue,
+static inline void mempool_add_queue(FAR dq_queue_t *queue,
                                      FAR char *base, size_t nblks,
                                      size_t blocksize)
 {
   while (nblks-- > 0)
     {
-      sq_addfirst((FAR sq_entry_t *)(base + blocksize * nblks), queue);
+      dq_addfirst((FAR dq_entry_t *)(base + blocksize * nblks), queue);
     }
 }
 
+static size_t mempool_dq_count(FAR dq_queue_t *queue)
+{
+  FAR dq_entry_t *entry;
+  size_t count = 0;
+
+  dq_for_every(queue, entry)
+    {
+      count++;
+    }

Review Comment:
   ```
   $ make -j20
   CC:  pthread/pthread_detach.c In file included from 
/home/ajh/work/work/nuttx/include/nuttx/irq.h:37,
                    from /home/ajh/work/work/nuttx/include/nuttx/sched.h:40,
                    from /home/ajh/work/work/nuttx/include/nuttx/arch.h:87,
                    from /home/ajh/work/work/nuttx/include/nuttx/userspace.h:35,
                    from /home/ajh/work/work/nuttx/include/nuttx/mm/mm.h:30,
                    from mm_heap/mm_initialize.c:31:
   /home/ajh/work/work/nuttx/include/arch/irq.h:129:8: error: unknown type name 
‘inline’
     129 | static inline uintptr_t up_getsp(void)
         |        ^~~~~~
   /home/ajh/work/work/nuttx/include/arch/irq.h:129:25: error: expected ‘=’, 
‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘up_getsp’
     129 | static inline uintptr_t up_getsp(void)
         |                         ^~~~~~~~
   /home/ajh/work/work/nuttx/include/arch/irq.h:149:8: error: unknown type name 
‘inline’
     149 | static inline bool up_interrupt_context(void)
         |        ^~~~~~
   /home/ajh/work/work/nuttx/include/arch/irq.h:149:20: error: expected ‘=’, 
‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘up_interrupt_context’
     149 | static inline bool up_interrupt_context(void)
         |                    ^~~~~~~~~~~~~~~~~~~~
   CC:  syslog/syslog_putc.c In file included from 
/home/ajh/work/work/nuttx/include/nuttx/irq.h:37,
                    from /home/ajh/work/work/nuttx/include/nuttx/sched.h:40,
                    from /home/ajh/work/work/nuttx/include/nuttx/arch.h:87,
                    from /home/ajh/work/work/nuttx/include/nuttx/userspace.h:35,
                    from /home/ajh/work/work/nuttx/include/nuttx/mm/mm.h:30,
                    from mm_heap/mm_addfreechunk.c:29:
   /home/ajh/work/work/nuttx/include/arch/irq.h:129:8: error: unknown type name 
‘inline’
     129 | static inline uintptr_t up_getsp(void)
         |        ^~~~~~
   /home/ajh/work/work/nuttx/include/arch/irq.h:129:25: error: expected ‘=’, 
‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘up_getsp’
     129 | static inline uintptr_t up_getsp(void)
         |                         ^~~~~~~~
   /home/ajh/work/work/nuttx/include/arch/irq.h:149:8: error: unknown type name 
‘inline’
     149 | static inline bool up_interrupt_context(void)
         |        ^~~~~~
   /home/ajh/work/work/nuttx/include/arch/irq.h:149:20: error: expected ‘=’, 
‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘up_interrupt_context’
     149 | static inline bool up_interrupt_context(void)
         |                    ^~~~~~~~~~~~~~~~~~~~
   In file included from 
/home/ajh/work/work/nuttx/include/nuttx/mm/mempool.h:30,
                    from /home/ajh/work/work/nuttx/mm/mm_heap/mm.h:34,
                    from mm_heap/mm_initialize.c:33:
   /home/ajh/work/work/nuttx/include/nuttx/list.h:288:14: error: expected ‘;’ 
before ‘struct’
     288 | static inline FAR struct list_node *
         |              ^    ~~~~~~
         |              ;
   /home/ajh/work/work/nuttx/include/nuttx/list.h:303:14: error: expected ‘;’ 
before ‘struct’
     303 | static inline FAR struct list_node *
         |              ^    ~~~~~~
         |              ;
   /home/ajh/work/work/nuttx/include/nuttx/list.h:318:8: error: unknown type 
name ‘inline’
     318 | static inline size_t list_length(FAR struct list_node *list)
         |        ^~~~~~
   /home/ajh/work/work/nuttx/include/nuttx/list.h:318:22: error: expected ‘=’, 
‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘list_length’
     318 | static inline size_t list_length(FAR struct list_node *list)
         |                      ^~~~~~~~~~~
   CC:  pthread/pthread_getschedparam.c In file included from 
/home/ajh/work/work/nuttx/include/nuttx/mm/mempool.h:30,
                    from /home/ajh/work/work/nuttx/mm/mm_heap/mm.h:34,
                    from mm_heap/mm_addfreechunk.c:31:
   /home/ajh/work/work/nuttx/include/nuttx/list.h:288:14: error: expected ‘;’ 
before ‘struct’
     288 | static inline FAR struct list_node *
         |              ^    ~~~~~~
         |              ;
   /home/ajh/work/work/nuttx/include/nuttx/list.h:303:14: error: expected ‘;’ 
before ‘struct’
     303 | static inline FAR struct list_node *
         |              ^    ~~~~~~
         |              ;
   In file included from /home/ajh/work/work/nuttx/include/nuttx/irq.h:37,
                    from /home/ajh/work/work/nuttx/include/nuttx/sched.h:40,
                    from /home/ajh/work/work/nuttx/include/nuttx/arch.h:87,
                    from mm_heap/mm_lock.c:32:
   /home/ajh/work/work/nuttx/include/arch/irq.h:129:8: error: unknown type name 
‘inline’
     129 | static inline uintptr_t up_getsp(void)
         |        ^~~~~~
   /home/ajh/work/work/nuttx/include/nuttx/list.h:318:8: error: unknown type 
name ‘inline’
     318 | static inline size_t list_length(FAR struct list_node *list)
         |        ^~~~~~
   /home/ajh/work/work/nuttx/include/arch/irq.h:129:25: error: expected ‘=’, 
‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘up_getsp’
     129 | static inline uintptr_t up_getsp(void)
         |                         ^~~~~~~~
   /home/ajh/work/work/nuttx/include/arch/irq.h:149:8: error: unknown type name 
‘inline’
     149 | static inline bool up_interrupt_context(void)
         |        ^~~~~~
   /home/ajh/work/work/nuttx/include/arch/irq.h:149:20: error: expected ‘=’, 
‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘up_interrupt_context’
     149 | static inline bool up_interrupt_context(void)
         |                    ^~~~~~~~~~~~~~~~~~~~
   CC:  pthread/pthread_setschedparam.c In file included from 
/home/ajh/work/work/nuttx/include/nuttx/mm/mempool.h:30,
                    from /home/ajh/work/work/nuttx/mm/mm_heap/mm.h:34,
                    from mm_heap/mm_lock.c:35:
   /home/ajh/work/work/nuttx/include/nuttx/list.h:288:14: error: expected ‘;’ 
before ‘struct’
     288 | static inline FAR struct list_node *
         |              ^    ~~~~~~
         |              ;
   /home/ajh/work/work/nuttx/include/nuttx/list.h:318:22: error: expected ‘=’, 
‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘list_length’
     318 | static inline size_t list_length(FAR struct list_node *list)
         |                      ^~~~~~~~~~~
   CC:  pthread/pthread_mutexdestroy.c 
/home/ajh/work/work/nuttx/include/nuttx/list.h:303:14: error: expected ‘;’ 
before ‘struct’
     303 | static inline FAR struct list_node *
         |              ^    ~~~~~~
         |              ;
   /home/ajh/work/work/nuttx/include/nuttx/list.h:318:8: error: unknown type 
name ‘inline’
     318 | static inline size_t list_length(FAR struct list_node *list)
         |        ^~~~~~
   /home/ajh/work/work/nuttx/include/nuttx/list.h:318:22: error: expected ‘=’, 
‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘list_length’
     318 | static inline size_t list_length(FAR struct list_node *list)
         |                      ^~~~~~~~~~~
   make[1]: *** [Makefile:75: bin/mm_initialize.o] Error 1
   make[1]: *** Waiting for unfinished jobs....
   CC:  ctype/lib_isalpha.c make[1]: *** [Makefile:75: bin/mm_addfreechunk.o] 
Error 1
   CC:  ctype/lib_isascii.c mm_heap/mm_lock.c: In function ‘mm_lock’:
   mm_heap/mm_lock.c:63:7: warning: implicit declaration of function 
‘up_interrupt_context’ [-Wimplicit-function-declaration]
      63 |   if (up_interrupt_context())
         |       ^~~~~~~~~~~~~~~~~~~~
   make[1]: *** [Makefile:75: bin/mm_lock.o] Error 1
   CC:  syslog/syslog_device.c In file included from 
/home/ajh/work/work/nuttx/include/nuttx/irq.h:37,
                    from /home/ajh/work/work/nuttx/include/nuttx/sched.h:40,
                    from /home/ajh/work/work/nuttx/include/nuttx/arch.h:87,
                    from /home/ajh/work/work/nuttx/include/nuttx/userspace.h:35,
                    from /home/ajh/work/work/nuttx/include/nuttx/mm/mm.h:30,
                    from mm_heap/mm_size2ndx.c:29:
   /home/ajh/work/work/nuttx/include/arch/irq.h:129:8: error: unknown type name 
‘inline’
     129 | static inline uintptr_t up_getsp(void)
         |        ^~~~~~
   /home/ajh/work/work/nuttx/include/arch/irq.h:129:25: error: expected ‘=’, 
‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘up_getsp’
     129 | static inline uintptr_t up_getsp(void)
         |                         ^~~~~~~~
   /home/ajh/work/work/nuttx/include/arch/irq.h:149:8: error: unknown type name 
‘inline’
     149 | static inline bool up_interrupt_context(void)
         |        ^~~~~~
   /home/ajh/work/work/nuttx/include/arch/irq.h:149:20: error: expected ‘=’, 
‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘up_interrupt_context’
     149 | static inline bool up_interrupt_context(void)
         |                    ^~~~~~~~~~~~~~~~~~~~
   CC:  ctype/lib_isgraph.c In file included from 
/home/ajh/work/work/nuttx/include/nuttx/mm/mempool.h:30,
                    from /home/ajh/work/work/nuttx/mm/mm_heap/mm.h:34,
                    from mm_heap/mm_size2ndx.c:31:
   /home/ajh/work/work/nuttx/include/nuttx/list.h:288:14: error: expected ‘;’ 
before ‘struct’
     288 | static inline FAR struct list_node *
         |              ^    ~~~~~~
         |              ;
   /home/ajh/work/work/nuttx/include/nuttx/list.h:303:14: error: expected ‘;’ 
before ‘struct’
     303 | static inline FAR struct list_node *
         |              ^    ~~~~~~
         |              ;
   /home/ajh/work/work/nuttx/include/nuttx/list.h:318:8: error: unknown type 
name ‘inline’
     318 | static inline size_t list_length(FAR struct list_node *list)
         |        ^~~~~~
   /home/ajh/work/work/nuttx/include/nuttx/list.h:318:22: error: expected ‘=’, 
‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘list_length’
     318 | static inline size_t list_length(FAR struct list_node *list)
         |                      ^~~~~~~~~~~
   CC:  ctype/lib_isupper.c make[1]: *** [Makefile:75: bin/mm_size2ndx.o] Error 
1
   CC:  ctype/lib_ispunct.c make: *** [tools/LibTargets.mk:210: mm/libmm.a] 
Error 2
   make: *** Waiting for unfinished jobs....
   ```
   I compiled sim:nsh with -std=c89 but got this, which seems to have nothing 
to do with the current PR



-- 
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-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to