1

我正在浏览仿生 libc 套接字系统调用,并注意到一些令人困惑的东西。android/bionic/libc/include/sys/socket.h 有一个 sendmsg 的系统调用声明为

__socketcall int sendmsg (int, const struct msghdr*, int);

而在其他地方 /android/bionic/libc/SYSCALLS.TXT #sockets 和 #sockets for x86 中 sendmsg 的系统调用声明有

int sendmsg(int, const struct msghdr*, unsigned int) arm,arm64,mips,mips64,x86_64

int sendmsg:socketcall:16(int, const struct msghdr*, unsigned int) x86

为什么标志数据类型的声明有变化(socket.h 中的 int 和 SYSCALLS.TXT 中的 unsigned int)。即使在 kernel/net/socket.c 中的内核系统调用中,系统调用也被定义为

SYSCALL_DEFINE3(sendmsg,int,fd,struct user_msghdr __user*,msg,unsigned int,flags) { }

该标志被声明为无符号整数。只有在 libc 的 include/sys/socket.h 中,标志是 int。你能解释一下为什么会这样吗?如果我在 socket.h 中将声明更改为 'unsigned int' 会发生什么

4

0 回答 0