nuttx/include/sys
hujun5 61caf7cce9 types: on some arch, execution speed can be accelerated
in arm64 Let's see how the following code looks like in assembly

volatile cpu_set_t g_cpu_set;
cpu_set_t set_cpu_set_t_set(int cpu) {
  g_cpu_set &= ~(1 << cpu);
  return g_cpu_set;
}

when
typedef volatile uint32_t cpu_set_t;
Dump of assembler code for function set_cpu_set_t_set:
   0x0000000040288570 <+0>:	adrp	x2, 0x403ce000 <g_irqvector+1160>
   0x0000000040288574 <+4>:	ldr	w3, [x2, #2368]
   0x0000000040288578 <+8>:	mov	w1, #0x1
   0x000000004028857c <+12>:	lsl	w1, w1, w0
   0x0000000040288580 <+16>:	bic	w1, w3, w1
   0x0000000040288584 <+20>:	str	w1, [x2, #2368]
   0x0000000040288588 <+24>:	ldr	w0, [x2, #2368]
   0x000000004028858c <+28>:	ret

when
typedef volatile uint8_t cpu_set_t;
Dump of assembler code for function set_cpu_set_t_set:
   0x000000004028856c <+0>:	adrp	x2, 0x403ce000 <g_irqvector+1192>
   0x0000000040288570 <+4>:	ldrb	w3, [x2, #2336]
   0x0000000040288574 <+8>:	mov	w1, #0x1
   0x0000000040288578 <+12>:	and	w3, w3, #0xff           // At this time, there will be one more instruction
   0x000000004028857c <+16>:	lsl	w1, w1, w0
   0x0000000040288580 <+20>:	bic	w1, w3, w1
   0x0000000040288584 <+24>:	strb	w1, [x2, #2336]
   0x0000000040288588 <+28>:	ldrb	w0, [x2, #2336]
   0x000000004028858c <+32>:	ret

test:
We can use qemu for testing.

compiling
make distclean -j20; ./tools/configure.sh -l qemu-armv8a:nsh_smp ;make -j20
running
qemu-system-aarch64 -cpu cortex-a53 -smp 4 -nographic -machine virt,virtualization=on,gic-version=3 -net none -chardev stdio,id=con,mux=on -serial chardev:con -mon chardev=con,mode=readline -kernel ./nuttx
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-05-22 19:10:03 +08:00
..
boardctl.h board/control: add irq affinity control 2024-03-30 12:21:25 +08:00
custom_file.h
endian.h endian: Make all endian related functions use the expicit type 2023-10-20 09:46:21 +08:00
epoll.h
eventfd.h
file.h
ioctl.h
ipc.h
mman.h
mount.h fs/ioctl: add BIOC_BLKGETSIZE cmd to get block sector numbers 2023-08-19 01:43:59 +08:00
msg.h
param.h
poll.h fs_epoll: serveral epoll issues fix 2023-11-02 00:44:52 +08:00
prctl.h
queue.h
random.h
resource.h
select.h
sendfile.h
shm.h
signalfd.h
socket.h sys/socket.h: add the definition of SCM_TIMESTAMP. 2024-05-15 16:12:10 +08:00
sockio.h
stat.h
statfs.h fs:support zipfs,can mount zipfile 2023-09-27 01:06:04 +08:00
statvfs.h
syscall_lookup.h sched/semaphore: Move named semaphores to user space 2023-11-27 04:52:54 -08:00
syscall.h
sysinfo.h
sysmacros.h
time.h
timerfd.h
times.h
tree.h
types.h types: on some arch, execution speed can be accelerated 2024-05-22 19:10:03 +08:00
uio.h
un.h
utsname.h
vfs.h
video_controls.h Update v4l2 ctrls & v4l2_outputparm 2024-03-21 19:23:53 +08:00
videoio.h videoio: modify data type of v4l2_buffer from uint32_t to uint16_t 2024-05-15 22:03:18 +08:00
wait.h