linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Why is the bit size different between a syscall and its wrapper?
@ 2021-03-12  2:48 Masahiro Yamada
  2021-03-12  3:17 ` Bhaskar Chowdhury
  2021-03-12  3:27 ` Willy Tarreau
  0 siblings, 2 replies; 4+ messages in thread
From: Masahiro Yamada @ 2021-03-12  2:48 UTC (permalink / raw)
  To: Linux Kernel Mailing List, linux-api

Hi.

I think I am missing something, but
is there any particular reason to
use a different bit size between
a syscall and its userspace wrapper?



For example, for the unshare syscall,

unshare(2) says the parameter is int.


SYNOPSIS
       #define _GNU_SOURCE
       #include <sched.h>

       int unshare(int flags);




In the kernel, it is unsigned long.


SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
{
        return ksys_unshare(unshare_flags);
}




I guess the upper 32-bit will be
zeroed out in the c library when
sizeof(int) != sizeof(unsigned long)
(i.e. 64-bit system), but I'd like to know
why we do it this way.


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-14  5:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-12  2:48 Why is the bit size different between a syscall and its wrapper? Masahiro Yamada
2021-03-12  3:17 ` Bhaskar Chowdhury
2021-03-12  3:27 ` Willy Tarreau
2021-03-14  5:10   ` Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).