xiaoxiang781216 commented on code in PR #20130:
URL: https://github.com/apache/nuttx/pull/20130#discussion_r4064004868
##########
sched/timer/timer_create.c:
##########
@@ -196,6 +200,26 @@ int timer_create(clockid_t clockid, FAR struct sigevent
*evp,
/* Yes, copy the entire struct sigevent content */
memcpy(&ret->pt_event, evp, sizeof(struct sigevent));
+
+#if defined(CONFIG_FDPIC) && defined(CONFIG_SIG_EVTHREAD)
+ /* Record the callback here, where this still runs in the
+ * module's context. It fires later on a worker that carries
+ * no data base, so the base travels with it. The function
+ * shares a union with the thread ID, so only a SIGEV_THREAD
+ * event has one to record.
+ */
+
+ ret->pt_work.func.got = 0;
Review Comment:
why need zero here
##########
sched/timer/timer_create.c:
##########
@@ -196,6 +200,26 @@ int timer_create(clockid_t clockid, FAR struct sigevent
*evp,
/* Yes, copy the entire struct sigevent content */
memcpy(&ret->pt_event, evp, sizeof(struct sigevent));
+
+#if defined(CONFIG_FDPIC) && defined(CONFIG_SIG_EVTHREAD)
+ /* Record the callback here, where this still runs in the
+ * module's context. It fires later on a worker that carries
+ * no data base, so the base travels with it. The function
+ * shares a union with the thread ID, so only a SIGEV_THREAD
+ * event has one to record.
+ */
+
+ ret->pt_work.func.got = 0;
+
+ if ((evp->sigev_notify & SIGEV_THREAD) != 0)
+ {
+ fdpic_desc_init(&ret->pt_work.func,
+ (FAR void *)evp->sigev_notify_function);
+
+ ret->pt_event.sigev_notify_function =
Review Comment:
fdpic_callback
##########
include/nuttx/fdpic.h:
##########
@@ -96,33 +96,77 @@ static inline FAR void *fdpic_callback(FAR void *fn)
return fn;
}
+/****************************************************************************
+ * Name: fdpic_desc_init
+ *
+ * Description:
+ * Record a callback for a later call from a thread that carries no module
+ * base. Runs in the caller's own context, which is the only place the
+ * answer can be had.
+ *
+ * A module's function pointer is the address of a descriptor, and the base
+ * comes from there: a module can hand over a callback that belongs to
+ * another one. A firmware pointer is a code address and has no base.
+ *
+ * Input Parameters:
+ * desc - The descriptor to fill.
+ * fn - The callback, as the caller received it.
+ *
+ ****************************************************************************/
+
+static inline void fdpic_desc_init(FAR struct fdpic_desc_s *desc,
Review Comment:
fdpic_init
##########
sched/signal/sig_notification.c:
##########
@@ -155,7 +168,11 @@ int nxsig_notification(pid_t pid, FAR struct sigevent
*event,
/* Initialize the work information */
work->value = event->sigev_value;
+#ifdef CONFIG_FDPIC
+ work->func.entry = (uintptr_t)event->sigev_notify_function;
Review Comment:
fdpic_desc_init
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]