On Thu, Jul 7, 2016 at 4:11 PM, Tim Newsham <[email protected]> wrote: >> >> If you look at sys/kern/syscalls.master: >> 197 STD { void *sys_mmap(void *addr, size_t len, int prot, >> \ >> int flags, int fd, long pad, off_t pos); } >> >> There's a pad before any off_t syscall argument because 1993 or whatever.
(Because that guarantees that the stack layout of registers pushed in ABI-matching order match the structure layout of the args structure. sparc (32bit) is an example of the problem case, where longlong args are pushed into the next two registers, effectively giving 4 byte alignment while the args structure has 8 byte alignment.) > thank you. I didnt know about that. > I added an extra pad arg and I'm still getting weirdness: > > p2 = __syscall(197, 0x100000, 4*4096, 7, MAP_ANON, -1, 0, 0); varargs are so fun. That last argument is a 64bit type, not an int, so you have to use 0LL there for the compiler to fill in the full 64bits. Philip Guenther
