xiaoxiang781216 commented on PR #9199:
URL: https://github.com/apache/nuttx/pull/9199#issuecomment-1537430352

   > > > Also I need some more time to identify why do we have two version of 
`task_setcanceltype`, one in `libs/libc/sched/task_setcanceltype.c` another in 
`sched/task/task_setcanceltype.c`
   > > 
   > > 
   > > The rule to put the source file is very simple:
   > > 
   > > 1. If the function touches any field which belong to kernel space must 
move out of libs
   > > 2. Otherwise, the function should put into libs
   > > 
   > > task_setcanceltype follow this rule well.
   > 
   > Yes. But I see the same API implemented in two places.
   
   But the implementation is different. libc version is used when 
CONFIG_CANCELLATION_POINTS isn't enabled it put to libs/libc because this 
version doesn't need touch any kernel memory.
   
   > Also the same API is in a list of system calls. So when application calls 
`task_setcanceltype` which API is called, a system call or a libc variant?
   
   syscall is guarded by defined(CONFIG_CANCELLATION_POINTS):
   ```
   
"task_setcanceltype","sched.h","defined(CONFIG_CANCELLATION_POINTS)","int","int","FAR
 int *"
   ```
   So, if you enable CONFIG_CANCELLATION_POINTS, system call is used, otherwise 
libc.


-- 
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]

Reply via email to