500-avr32_add_varargs_handling_of_prctl_syscall.patch 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. From 2b69e9906e5087a796b3a15e9aabcd102c705b19 Mon Sep 17 00:00:00 2001
  2. From: Hans-Christian Egtvedt <[email protected]>
  3. Date: Wed, 16 Dec 2009 12:16:08 +0000
  4. Subject: avr32: add varargs handling of prctl syscall
  5. prctl is defined to use varargs in the header file, hence it needs varargs
  6. specific handling in the source. This patch properly handles the variodic
  7. argument before the syscall is passed to the kernel for the AVR32 architecture.
  8. Signed-off-by: Hans-Christian Egtvedt <[email protected]>
  9. ---
  10. diff --git a/libc/sysdeps/linux/avr32/Makefile.arch b/libc/sysdeps/linux/avr32/Makefile.arch
  11. index bc5f625..98b85a7 100644
  12. --- a/libc/sysdeps/linux/avr32/Makefile.arch
  13. +++ b/libc/sysdeps/linux/avr32/Makefile.arch
  14. @@ -5,7 +5,7 @@
  15. # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  16. #
  17. -CSRC := brk.c clone.c mmap.c sigaction.c
  18. +CSRC := brk.c clone.c mmap.c prctl.c sigaction.c
  19. SSRC := __longjmp.S setjmp.S bsd-setjmp.S bsd-_setjmp.S \
  20. sigrestorer.S syscall.S vfork.S
  21. diff --git a/libc/sysdeps/linux/avr32/prctl.c b/libc/sysdeps/linux/avr32/prctl.c
  22. new file mode 100644
  23. index 0000000..4e146e3
  24. --- a/dev/null
  25. +++ b/libc/sysdeps/linux/avr32/prctl.c
  26. @@ -0,0 +1,36 @@
  27. +/*
  28. + * prctl syscall for AVR32 Linux.
  29. + *
  30. + * Copyright (C) 2010 Atmel Corporation
  31. + *
  32. + * This file is subject to the terms and conditions of the GNU Lesser General
  33. + * Public License. See the file "COPYING.LIB" in the main directory of this
  34. + * archive for more details.
  35. + */
  36. +#include <sys/syscall.h>
  37. +#include <sys/prctl.h>
  38. +#include <stdarg.h>
  39. +
  40. +#ifdef __NR_prctl
  41. +#define __NR___syscall_prctl __NR_prctl
  42. +static inline _syscall5(int, __syscall_prctl, int, option, long, arg2,
  43. + long, arg3, long, arg4, long, arg5);
  44. +
  45. +int prctl(int __option, ...)
  46. +{
  47. + long arg2;
  48. + long arg3;
  49. + long arg4;
  50. + long arg5;
  51. + va_list ap;
  52. +
  53. + va_start(ap, __option);
  54. + arg2 = va_arg(ap, long);
  55. + arg3 = va_arg(ap, long);
  56. + arg4 = va_arg(ap, long);
  57. + arg5 = va_arg(ap, long);
  58. + va_end(ap);
  59. +
  60. + return INLINE_SYSCALL(prctl, 5, __option, arg2, arg3, arg4, arg5);
  61. +}
  62. +#endif
  63. --
  64. cgit v0.8.2.1