Update.
[glibc.git] / sysdeps / unix / sysv / linux / ptrace.c
blob109191ea47d278050ccfecba631af781c2e53970
1 /* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
19 #include <errno.h>
20 #include <sys/types.h>
21 #include <sys/ptrace.h>
22 #include <stdarg.h>
24 #include <sysdep.h>
25 #include <sys/syscall.h>
27 extern long int __syscall_ptrace (int, pid_t, void *, void *);
29 long int
30 ptrace (enum __ptrace_request request, ...)
32 long int res, ret;
33 va_list ap;
34 pid_t pid;
35 void *addr, *data;
37 va_start (ap, request);
38 pid = va_arg (ap, pid_t);
39 addr = va_arg (ap, void *);
40 data = va_arg (ap, void *);
41 va_end (ap);
43 if (request > 0 && request < 4)
44 data = &ret;
46 res = INLINE_SYSCALL (ptrace, 4, request, pid, addr, data);
47 if (res >= 0 && request > 0 && request < 4)
49 __set_errno (0);
50 return ret;
53 return res;