1 From 2b69e9906e5087a796b3a15e9aabcd102c705b19 Mon Sep 17 00:00:00 2001
2 From: Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com>
3 Date: Wed, 16 Dec 2009 12:16:08 +0000
4 Subject: avr32: add varargs handling of prctl syscall
6 prctl is defined to use varargs in the header file, hence it needs varargs
7 specific handling in the source. This patch properly handles the variodic
8 argument before the syscall is passed to the kernel for the AVR32 architecture.
10 Signed-off-by: Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com>
12 diff --git a/libc/sysdeps/linux/avr32/Makefile.arch b/libc/sysdeps/linux/avr32/Makefile.arch
13 index bc5f625..98b85a7 100644
14 --- a/libc/sysdeps/linux/avr32/Makefile.arch
15 +++ b/libc/sysdeps/linux/avr32/Makefile.arch
17 # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
20 -CSRC := brk.c clone.c mmap.c sigaction.c
21 +CSRC := brk.c clone.c mmap.c prctl.c sigaction.c
23 SSRC := __longjmp.S setjmp.S bsd-setjmp.S bsd-_setjmp.S \
24 sigrestorer.S syscall.S vfork.S
25 diff --git a/libc/sysdeps/linux/avr32/prctl.c b/libc/sysdeps/linux/avr32/prctl.c
27 index 0000000..4e146e3
29 +++ b/libc/sysdeps/linux/avr32/prctl.c
32 + * prctl syscall for AVR32 Linux.
34 + * Copyright (C) 2010 Atmel Corporation
36 + * This file is subject to the terms and conditions of the GNU Lesser General
37 + * Public License. See the file "COPYING.LIB" in the main directory of this
38 + * archive for more details.
40 +#include <sys/syscall.h>
41 +#include <sys/prctl.h>
45 +#define __NR___syscall_prctl __NR_prctl
46 +static inline _syscall5(int, __syscall_prctl, int, option, long, arg2,
47 + long, arg3, long, arg4, long, arg5);
49 +int prctl(int __option, ...)
57 + va_start(ap, __option);
58 + arg2 = va_arg(ap, long);
59 + arg3 = va_arg(ap, long);
60 + arg4 = va_arg(ap, long);
61 + arg5 = va_arg(ap, long);
64 + return INLINE_SYSCALL(prctl, 5, __option, arg2, arg3, arg4, arg5);