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

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


The following commit(s) were added to refs/heads/releases/12.10 by this push:
     new 0a22cccfa8 sched/wqueue: Fix windows compilation errors.
0a22cccfa8 is described below

commit 0a22cccfa819b371cb91eef8ad2e863b0fdb37e2
Author: ouyangxiangzhen <[email protected]>
AuthorDate: Wed Jun 18 09:53:02 2025 +0800

    sched/wqueue: Fix windows compilation errors.
    
    This commit fixed windows compilation errors `struct
    lp_wqueue_s/hp_wqueue_s has an illegal zero-sized array`.
    
    Signed-off-by: ouyangxiangzhen <[email protected]>
---
 sched/wqueue/kwork_cancel.c |  8 ++++----
 sched/wqueue/kwork_thread.c | 13 +++++++++----
 sched/wqueue/wqueue.h       |  8 +++++++-
 3 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/sched/wqueue/kwork_cancel.c b/sched/wqueue/kwork_cancel.c
index 4a2019ce53..8a8bc6036b 100644
--- a/sched/wqueue/kwork_cancel.c
+++ b/sched/wqueue/kwork_cancel.c
@@ -80,16 +80,16 @@ static int work_qcancel(FAR struct kwork_wqueue_s *wqueue, 
bool sync,
     {
       int wndx;
       pid_t pid = nxsched_gettid();
+      FAR struct kworker_s *worker = wq_get_worker(wqueue);
 
       /* Wait until the worker thread finished the work. */
 
       for (wndx = 0; wndx < wqueue->nthreads; wndx++)
         {
-          if (wqueue->worker[wndx].work == work &&
-              wqueue->worker[wndx].pid != pid)
+          if (worker[wndx].work == work && worker[wndx].pid != pid)
             {
-              wqueue->worker[wndx].wait_count++;
-              sync_wait = &wqueue->worker[wndx].wait;
+              worker[wndx].wait_count++;
+              sync_wait = &worker[wndx].wait;
               break;
             }
         }
diff --git a/sched/wqueue/kwork_thread.c b/sched/wqueue/kwork_thread.c
index be1a77185e..ce81a519a2 100644
--- a/sched/wqueue/kwork_thread.c
+++ b/sched/wqueue/kwork_thread.c
@@ -327,6 +327,7 @@ static int work_thread_create(FAR const char *name, int 
priority,
                               FAR void *stack_addr, int stack_size,
                               FAR struct kwork_wqueue_s *wqueue)
 {
+  FAR struct kworker_s *worker = wq_get_worker(wqueue);
   FAR char *argv[3];
   char arg0[32];
   char arg1[32];
@@ -341,10 +342,10 @@ static int work_thread_create(FAR const char *name, int 
priority,
 
   for (wndx = 0; wndx < wqueue->nthreads; wndx++)
     {
-      nxsem_init(&wqueue->worker[wndx].wait, 0, 0);
+      nxsem_init(&worker[wndx].wait, 0, 0);
 
       snprintf(arg0, sizeof(arg0), "%p", wqueue);
-      snprintf(arg1, sizeof(arg1), "%p", &wqueue->worker[wndx]);
+      snprintf(arg1, sizeof(arg1), "%p", &worker[wndx]);
       argv[0] = arg0;
       argv[1] = arg1;
       argv[2] = NULL;
@@ -360,7 +361,7 @@ static int work_thread_create(FAR const char *name, int 
priority,
           return pid;
         }
 
-      wqueue->worker[wndx].pid = pid;
+      worker[wndx].pid = pid;
     }
 
   sched_unlock();
@@ -525,6 +526,7 @@ int work_queue_free(FAR struct kwork_wqueue_s *wqueue)
 
 int work_queue_priority_wq(FAR struct kwork_wqueue_s *wqueue)
 {
+  FAR struct kworker_s *worker;
   FAR struct tcb_s *tcb;
 
   if (wqueue == NULL)
@@ -534,7 +536,10 @@ int work_queue_priority_wq(FAR struct kwork_wqueue_s 
*wqueue)
 
   /* Find for the TCB associated with matching PID */
 
-  tcb = nxsched_get_tcb(wqueue->worker[0].pid);
+  worker = wq_get_worker(wqueue);
+
+  tcb = nxsched_get_tcb(worker[0].pid);
+
   if (!tcb)
     {
       return -ESRCH;
diff --git a/sched/wqueue/wqueue.h b/sched/wqueue/wqueue.h
index 57177ad98d..3ac7407290 100644
--- a/sched/wqueue/wqueue.h
+++ b/sched/wqueue/wqueue.h
@@ -48,6 +48,13 @@
 #define HPWORKNAME "hpwork"
 #define LPWORKNAME "lpwork"
 
+/* Get the worker structure from the work queue.
+ * This function requires the workers are located next to the wqueue.
+ */
+
+#define wq_get_worker(wq) \
+  (FAR struct kworker_s *)((FAR char *)(wq) + sizeof(struct kwork_wqueue_s))
+
 /****************************************************************************
  * Public Type Definitions
  ****************************************************************************/
@@ -74,7 +81,6 @@ struct kwork_wqueue_s
   uint8_t          nthreads;  /* Number of worker threads */
   bool             exit;      /* A flag to request the thread to exit */
   struct wdog_s    timer;     /* Timer to pending. */
-  struct kworker_s worker[0]; /* Describes a worker thread */
 };
 
 /* This structure defines the state of one high-priority work queue.  This

Reply via email to