1 From 85bc04d5436ca6c8a30a1ad28862260a04b8b3d5 Mon Sep 17 00:00:00 2001
2 From: Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com>
3 Date: Wed, 16 Dec 2009 13:16:08 +0100
4 Subject: [PATCH 02/15] 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 libc/sysdeps/linux/avr32/Makefile.arch | 2 +-
13 libc/sysdeps/linux/avr32/prctl.c | 36 ++++++++++++++++++++++++++++++++
14 2 files changed, 37 insertions(+), 1 deletions(-)
15 create mode 100644 libc/sysdeps/linux/avr32/prctl.c
17 diff --git a/libc/sysdeps/linux/avr32/Makefile.arch b/libc/sysdeps/linux/avr32/Makefile.arch
18 index bc5f625..98b85a7 100644
19 --- a/libc/sysdeps/linux/avr32/Makefile.arch
20 +++ b/libc/sysdeps/linux/avr32/Makefile.arch
22 # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
25 -CSRC := brk.c clone.c mmap.c sigaction.c
26 +CSRC := brk.c clone.c mmap.c prctl.c sigaction.c
28 SSRC := __longjmp.S setjmp.S bsd-setjmp.S bsd-_setjmp.S \
29 sigrestorer.S syscall.S vfork.S
30 diff --git a/libc/sysdeps/linux/avr32/prctl.c b/libc/sysdeps/linux/avr32/prctl.c
32 index 0000000..4e146e3
34 +++ b/libc/sysdeps/linux/avr32/prctl.c
37 + * prctl syscall for AVR32 Linux.
39 + * Copyright (C) 2010 Atmel Corporation
41 + * This file is subject to the terms and conditions of the GNU Lesser General
42 + * Public License. See the file "COPYING.LIB" in the main directory of this
43 + * archive for more details.
45 +#include <sys/syscall.h>
46 +#include <sys/prctl.h>
50 +#define __NR___syscall_prctl __NR_prctl
51 +static inline _syscall5(int, __syscall_prctl, int, option, long, arg2,
52 + long, arg3, long, arg4, long, arg5);
54 +int prctl(int __option, ...)
62 + va_start(ap, __option);
63 + arg2 = va_arg(ap, long);
64 + arg3 = va_arg(ap, long);
65 + arg4 = va_arg(ap, long);
66 + arg5 = va_arg(ap, long);
69 + return INLINE_SYSCALL(prctl, 5, __option, arg2, arg3, arg4, arg5);