blob: 85e2edc28f2a9f5befe68986efc0c2e6c3f7fc8e [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
2 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * $Id$
30 */
31
Wichert Akkermanb859bea1999-04-18 22:50:50 +000032#ifdef linux
33#include <features.h>
34#endif
35
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000036#ifdef HAVE_CONFIG_H
37#include "config.h"
38#endif
39
40/* configuration section */
41#ifndef MAX_QUALS
Wichert Akkermanfd89ced2000-04-13 17:06:09 +000042#if defined(linux) && defined(MIPS)
43#define MAX_QUALS 4999 /* maximum number of syscalls, signals, etc. */
44#else
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +000045#define MAX_QUALS 2048 /* maximum number of syscalls, signals, etc. */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000046#endif
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +000047#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000048#ifndef MAX_PROCS
Wichert Akkermanfaf72222000-02-19 23:59:03 +000049#define MAX_PROCS 64 /* maximum number of processes tracable */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000050#endif
51#ifndef DEFAULT_STRLEN
52#define DEFAULT_STRLEN 32 /* default maximum # of bytes printed in
53 `printstr', change with `-s' switch */
54#endif
55#ifndef DEFAULT_ACOLUMN
56#define DEFAULT_ACOLUMN 40 /* default alignment column for results */
57#endif
58#ifndef MAX_ARGS
59#define MAX_ARGS 32 /* maximum number of args to a syscall */
60#endif
61#ifndef DEFAULT_SORTBY
62#define DEFAULT_SORTBY "time" /* default sorting method for call profiling */
63#endif
64
65#include <sys/types.h>
66#include <unistd.h>
67#include <stdlib.h>
68#include <stdio.h>
69#include <ctype.h>
70#include <string.h>
Wichert Akkerman8c7122c2001-02-16 19:59:55 +000071#include <time.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000072#include <sys/time.h>
73#include <errno.h>
74
75#ifdef STDC_HEADERS
76#include <stddef.h>
77#endif /* STDC_HEADERS */
78
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +000079#if defined(LINUX)
80# if defined(SPARC)
81# define LINUXSPARC
82# endif
83# if defined(ALPHA)
84# define LINUX_64BIT
85# endif
86#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000087
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +000088#if defined(SVR4) || defined(FREEBSD)
89#define USE_PROCFS
90#else
91#undef USE_PROCFS
92#endif
93
94#ifdef FREEBSD
95#ifndef I386
96#error "FreeBSD support is only for i386 arch right now."
97#endif
98#include <machine/psl.h>
99#include <machine/reg.h>
100#include <sys/syscall.h>
101#endif
102
103#ifdef USE_PROCFS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000104#include <sys/procfs.h>
Wichert Akkermanea78f0f1999-11-29 15:34:02 +0000105#ifdef HAVE_MP_PROCFS
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000106#include <sys/uio.h>
107#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000108#ifdef FREEBSD
109#include <sys/pioctl.h>
110#endif /* FREEBSD */
111#else /* !USE_PROCFS */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000112#if defined(LINUXSPARC) && defined(__GLIBC__)
113#include <sys/ptrace.h>
114#else
115/* Work around awkward prototype in ptrace.h. */
116#define ptrace xptrace
117#include <sys/ptrace.h>
118#undef ptrace
119#ifdef POWERPC
120#define __KERNEL__
121#include <asm/ptrace.h>
122#undef __KERNEL__
123/* TEMP */
124#define UESP PT_R1
125#define EIP PT_NIP
126#define EAX PT_R3
127#define ORIG_EAX PT_ORIG_R3
128#endif
129#ifdef __STDC__
130#ifdef LINUX
131extern long ptrace(int, int, char *, long);
132#else /* !LINUX */
133extern int ptrace(int, int, char *, int, ...);
134#endif /* !LINUX */
135#else /* !__STDC__ */
136extern int ptrace();
137#endif /* !__STDC__ */
138#endif /* !LINUXSPARC */
139#endif /* !SVR4 */
140
141#ifdef LINUX
Wichert Akkermanb859bea1999-04-18 22:50:50 +0000142#if !defined(__GLIBC__)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000143#define PTRACE_PEEKUSER PTRACE_PEEKUSR
144#define PTRACE_POKEUSER PTRACE_POKEUSR
145#endif
146#ifdef ALPHA
Wichert Akkermanf90da011999-10-31 21:15:38 +0000147# define REG_R0 0
148# define REG_A0 16
149# define REG_A3 19
150# define REG_FP 30
151# define REG_PC 64
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000152#endif /* ALPHA */
Wichert Akkermanf90da011999-10-31 21:15:38 +0000153#ifdef MIPS
154# define REG_V0 2
155# define REG_A0 4
156# define REG_A3 7
157# define REG_SP 29
158# define REG_EPC 64
159#endif /* MIPS */
Wichert Akkermanc1652e22001-03-27 12:17:16 +0000160#ifdef HPPA
161# define PT_GR20 (20*4)
162# define PT_GR26 (26*4)
163# define PT_GR28 (28*4)
164# define PT_IAOQ0 (106*4)
165# define PT_IAOQ1 (107*4)
166#endif /* HPPA */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000167#endif /* LINUX */
168
169#define SUPPORTED_PERSONALITIES 1
170#define DEFAULT_PERSONALITY 0
171
172#ifdef LINUXSPARC
173#include <linux/a.out.h>
174#include <asm/psr.h>
175#undef SUPPORTED_PERSONALITIES
Wichert Akkermanb859bea1999-04-18 22:50:50 +0000176#define SUPPORTED_PERSONALITIES 2
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000177#endif /* LINUXSPARC */
178
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000179#ifdef SVR4
Wichert Akkermanea78f0f1999-11-29 15:34:02 +0000180#ifdef HAVE_MP_PROCFS
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000181extern int mp_ioctl (int f, int c, void *a, int s);
182#define IOCTL(f,c,a) mp_ioctl (f, c, a, sizeof *a)
183#define IOCTL_STATUS(t) \
184 pread (t->pfd_stat, &t->status, sizeof t->status, 0)
185#define IOCTL_WSTOP(t) \
Wichert Akkerman16a03d22000-08-10 02:14:04 +0000186 (IOCTL (t->pfd, PCWSTOP, (char *)NULL) < 0 ? -1 : \
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000187 IOCTL_STATUS (t))
188#define PR_WHY pr_lwp.pr_why
189#define PR_WHAT pr_lwp.pr_what
190#define PR_REG pr_lwp.pr_context.uc_mcontext.gregs
191#define PR_FLAGS pr_lwp.pr_flags
John Hughes25299712001-03-06 10:10:06 +0000192#define PR_SYSCALL pr_lwp.pr_syscall
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000193#define PIOCSTIP PCSTOP
194#define PIOCSET PCSET
195#define PIOCRESET PCRESET
196#define PIOCSTRACE PCSTRACE
197#define PIOCSFAULT PCSFAULT
198#define PIOCWSTOP PCWSTOP
199#define PIOCSTOP PCSTOP
200#define PIOCSENTRY PCSENTRY
201#define PIOCSEXIT PCSEXIT
202#define PIOCRUN PCRUN
203#else
204#define IOCTL ioctl
205#define IOCTL_STATUS(t) ioctl (t->pfd, PIOCSTATUS, &t->status)
206#define IOCTL_WSTOP(t) ioctl (t->pfd, PIOCWSTOP, &t->status)
207#define PR_WHY pr_why
208#define PR_WHAT pr_what
209#define PR_REG pr_reg
210#define PR_FLAGS pr_flags
John Hughes25299712001-03-06 10:10:06 +0000211#define PR_SYSCALL pr_syscall
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000212#endif
213#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000214#ifdef FREEBSD
215#define IOCTL ioctl
216#define IOCTL_STATUS(t) ioctl (t->pfd, PIOCSTATUS, &t->status)
217#define IOCTL_WSTOP(t) ioctl (t->pfd, PIOCWAIT, &t->status)
218#define PIOCRUN PIOCCONT
219#define PIOCWSTOP PIOCWAIT
220#define PR_WHY why
221#define PR_WHAT val
Wichert Akkerman2e4ffe52000-09-03 23:57:48 +0000222#define PR_FLAGS state
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000223/* from /usr/src/sys/miscfs/procfs/procfs_vnops.c,
224 status.state = 0 for running, 1 for stopped */
Wichert Akkerman2e4ffe52000-09-03 23:57:48 +0000225#define PR_ASLEEP 1
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000226#define PR_SYSENTRY S_SCE
227#define PR_SYSEXIT S_SCX
228#define PR_SIGNALLED S_SIG
229#define PR_FAULTED S_CORE
230#endif
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000231
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000232/* Trace Control Block */
233struct tcb {
234 short flags; /* See below for TCB_ values */
235 int pid; /* Process Id of this entry */
236 long scno; /* System call number */
237 int u_nargs; /* System call arguments */
238 long u_arg[MAX_ARGS]; /* System call arguments */
239 int u_error; /* Error code */
240 long u_rval; /* (first) return value */
Wichert Akkerman16a03d22000-08-10 02:14:04 +0000241#ifdef HAVE_LONG_LONG
242 long long u_lrval; /* long long return value */
243#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000244 FILE *outf; /* Output file for this process */
Wichert Akkerman43a74822000-06-27 17:33:32 +0000245 const char *auxstr; /* Auxiliary info from syscall (see RVAL_STR) */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000246 struct timeval stime; /* System time usage as of last process wait */
247 struct timeval dtime; /* Delta for system time usage */
248 struct timeval etime; /* Syscall entry time */
249 /* Support for tracing forked processes */
250 struct tcb *parent; /* Parent of this process */
251 int nchildren; /* # of traced children */
252 int waitpid; /* pid(s) this process is waiting for */
253 /* (1st arg of wait4()) */
254 long baddr; /* `Breakpoint' address */
255 long inst[2]; /* Instructions on above */
256 int pfd; /* proc file descriptor */
257#ifdef SVR4
Wichert Akkermanea78f0f1999-11-29 15:34:02 +0000258#ifdef HAVE_MP_PROCFS
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000259 int pfd_stat;
260 int pfd_as;
261 pstatus_t status;
262#else
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000263 prstatus_t status; /* procfs status structure */
264#endif
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000265#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000266#ifdef FREEBSD
267 struct procfs_status status;
268 int pfd_reg;
269 int pfd_status;
270#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000271};
272
273/* TCB flags */
274#define TCB_STARTUP 00001 /* We have just begun ptracing this process */
275#define TCB_INUSE 00002 /* This table entry is in use */
276#define TCB_INSYSCALL 00004 /* A system call is in progress */
277#define TCB_ATTACHED 00010 /* Process is not our own child */
278#define TCB_EXITING 00020 /* As far as we know, this process is exiting */
279#define TCB_SUSPENDED 00040 /* Process has done a wait(4), that can
280 not be allowed to complete just now */
281#define TCB_BPTSET 00100 /* "Breakpoint" set after fork(2) */
282#define TCB_SIGTRAPPED 00200 /* Process wanted to block SIGTRAP */
283#define TCB_FOLLOWFORK 00400 /* Process should have forks followed */
284#define TCB_REPRINT 01000 /* We should reprint this syscall on exit */
285#ifdef LINUX
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000286# if defined(ALPHA) || defined(SPARC) || defined(POWERPC) || defined(IA64) || defined(HPPA)
287# define TCB_WAITEXECVE 02000 /* ignore SIGTRAP after exceve */
288# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000289#endif /* LINUX */
290
291/* qualifier flags */
292#define QUAL_TRACE 0001 /* this system call should be traced */
293#define QUAL_ABBREV 0002 /* abbreviate the structures of this syscall */
294#define QUAL_VERBOSE 0004 /* decode the structures of this syscall */
295#define QUAL_RAW 0010 /* print all args in hex for this syscall */
296#define QUAL_SIGNAL 0020 /* report events with this signal */
297#define QUAL_FAULT 0040 /* report events with this fault */
298#define QUAL_READ 0100 /* dump data read on this file descriptor */
299#define QUAL_WRITE 0200 /* dump data written to this file descriptor */
300
301#define entering(tcp) (!((tcp)->flags & TCB_INSYSCALL))
302#define exiting(tcp) ((tcp)->flags & TCB_INSYSCALL)
303#define syserror(tcp) ((tcp)->u_error != 0)
304#define verbose(tcp) (qual_flags[(tcp)->scno] & QUAL_VERBOSE)
305#define abbrev(tcp) (qual_flags[(tcp)->scno] & QUAL_ABBREV)
306#define waiting_parent(tcp) \
307 (tcp->parent && \
308 (tcp->parent->flags & TCB_SUSPENDED) && \
309 (tcp->parent->waitpid <= 0 || tcp->parent->waitpid == tcp->pid))
310
311struct xlat {
312 int val;
313 char *str;
314};
315
316/* Format of syscall return values */
317#define RVAL_DECIMAL 000 /* decimal format */
318#define RVAL_HEX 001 /* hex format */
319#define RVAL_OCTAL 002 /* octal format */
320#define RVAL_UDECIMAL 003 /* unsigned decimal format */
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000321#define RVAL_LDECIMAL 004 /* long decimal format */
322#define RVAL_LHEX 005 /* long hex format */
323#define RVAL_LOCTAL 006 /* long octal format */
324#define RVAL_LUDECIMAL 007 /* long unsigned decimal format */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000325#define RVAL_MASK 007 /* mask for these values */
326
327#define RVAL_STR 010 /* Print `auxstr' field after return val */
328#define RVAL_NONE 020 /* Print nothing */
329
330#ifndef offsetof
331#define offsetof(type, member) (((char *) &(((type *) NULL)->member)) - \
332 ((char *) (type *) NULL))
333#endif /* !offsetof */
334
335/* get offset of member within a user struct */
336#define uoff(member) offsetof(struct user, member)
337
338#define TRACE_FILE 001 /* Trace file-related syscalls. */
339#define TRACE_IPC 002 /* Trace IPC-related syscalls. */
340#define TRACE_NETWORK 004 /* Trace network-related syscalls. */
341#define TRACE_PROCESS 010 /* Trace process-related syscalls. */
342#define TRACE_SIGNAL 020 /* Trace signal-related syscalls. */
343
344extern struct tcb tcbtab[];
345extern int qual_flags[];
346extern int debug, followfork, followvfork;
347extern int rflag, tflag, dtime, cflag, xflag, qflag;
348extern int acolumn;
349extern char *outfname;
350extern int nprocs;
351extern int max_strlen;
352extern struct tcb *tcp_last;
353
354#ifdef __STDC__
355#define P(args) args
356#else
357#define P(args) ()
358#endif
359
360extern int set_personality P((int personality));
361extern char *xlookup P((struct xlat *, int));
362extern struct tcb *alloctcb P((int));
363extern void droptcb P((struct tcb *));
364
365extern void set_sortby P((char *));
366extern void set_overhead P((int));
367extern void qualify P((char *));
368extern void newoutf P((struct tcb *));
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000369extern int get_scno P((struct tcb *));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000370extern int trace_syscall P((struct tcb *));
371extern void printxval P((struct xlat *, int, char *));
372extern int printargs P((struct tcb *));
373extern int addflags P((struct xlat *, int));
374extern int printflags P((struct xlat *, int));
375extern int umoven P((struct tcb *, long, int, char *));
376extern int umovestr P((struct tcb *, long, int, char *));
377extern int upeek P((int, long, long *));
John Hughes1d08dcf2001-07-10 13:48:44 +0000378extern void dumpiov P((struct tcb *, int, long));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000379extern void dumpstr P((struct tcb *, long, int));
380extern void string_quote P((char *str));
381extern void printstr P((struct tcb *, long, int));
382extern void printnum P((struct tcb *, long, char *));
383extern void printpath P((struct tcb *, long));
384extern void printpathn P((struct tcb *, long, int));
385extern void printtv P((struct tcb *, long));
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000386extern void printsock P((struct tcb *, long, int));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000387extern void printrusage P((struct tcb *, long));
388extern int clearbpt P((struct tcb *));
389extern int setbpt P((struct tcb *));
390extern int sigishandled P((struct tcb *, int));
391extern void printcall P((struct tcb *));
Nate Sammonsce780fc1999-03-29 23:23:13 +0000392extern char *signame P((int));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000393extern void printsignal P((int));
394extern void printleader P((struct tcb *));
395extern void printtrailer P((struct tcb *));
396extern void tabto P((int));
397extern void call_summary P((FILE *));
398extern void fake_execve P((struct tcb *, char *, char *[], char *[]));
Wichert Akkerman221f54f1999-11-18 17:26:45 +0000399extern void printtv32 P((struct tcb*, long));
John Hughes1d08dcf2001-07-10 13:48:44 +0000400extern void tprint_iov P((struct tcb *, int, long));
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000401
Wichert Akkerman7a0b6491999-12-23 15:08:17 +0000402#ifdef LINUX
403extern int internal_clone P((struct tcb *));
404#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000405extern int internal_fork P((struct tcb *));
406extern int internal_exec P((struct tcb *));
407extern int internal_wait P((struct tcb *));
408extern int internal_exit P((struct tcb *));
409
410extern char *ioctl_lookup P((long));
411extern int ioctl_decode P((struct tcb *, long, long));
412extern int term_ioctl P((struct tcb *, long, long));
413extern int sock_ioctl P((struct tcb *, long, long));
414extern int proc_ioctl P((struct tcb *, int, int));
415extern int stream_ioctl P((struct tcb *, int, int));
416
417extern void tv_tv P((struct timeval *, int, int));
418extern int tv_nz P((struct timeval *));
419extern int tv_cmp P((struct timeval *, struct timeval *));
420extern double tv_float P((struct timeval *));
421extern void tv_add P((struct timeval *, struct timeval *, struct timeval *));
422extern void tv_sub P((struct timeval *, struct timeval *, struct timeval *));
423extern void tv_mul P((struct timeval *, struct timeval *, int));
424extern void tv_div P((struct timeval *, struct timeval *, int));
425
426#ifdef SUNOS4
427extern int fixvfork P((struct tcb *));
428#endif
429#if !(defined(LINUX) && !defined(SPARC))
430extern long getrval2 P((struct tcb *));
431#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000432#ifdef USE_PROCFS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000433extern int proc_open P((struct tcb *tcp, int attaching));
434#endif
435
436#define umove(pid, addr, objp) \
437 umoven((pid), (addr), sizeof *(objp), (char *) (objp))
438
439#ifdef __STDC__
440#ifdef __GNUC__
441extern void tprintf(const char *fmt, ...)
442 __attribute__ ((format (printf, 1, 2)));
443#else
444extern void tprintf(const char *fmt, ...);
445#endif
446#else
447extern void tprintf();
448#endif
449
450#ifndef HAVE_STRERROR
451const char *strerror P((int));
452#endif
453#ifndef HAVE_STRSIGNAL
454const char *strsignal P((int));
455#endif
456
457extern int current_personality;
458
459struct sysent {
460 int nargs;
461 int sys_flags;
462 int (*sys_func)();
463 char *sys_name;
464};
465
466extern struct sysent *sysent;
467extern int nsyscalls;
468
469extern char **errnoent;
470extern int nerrnos;
471
472struct ioctlent {
473 char *doth;
474 char *symbol;
475 unsigned long code;
476};
477
478extern struct ioctlent *ioctlent;
479extern int nioctlent;
480
481extern char **signalent;
482extern int nsignals;
483
484extern struct ioctlent *ioctlent;
485extern int nioctlents;
486extern char **signalent;
487extern int nsignals;
488
489extern struct ioctlent ioctlent0[];
490extern int nioctlents0;
491extern char *signalent0[];
492extern int nsignals0;
493
494#if SUPPORTED_PERSONALITIES >= 2
495extern struct ioctlent ioctlent1[];
496extern int nioctlents1;
497extern char *signalent1[];
498extern int nsignals1;
499#endif /* SUPPORTED_PERSONALITIES >= 2 */
500
501#if SUPPORTED_PERSONALITIES >= 3
502extern struct ioctlent ioctlent2[];
503extern int nioctlents2;
504extern char *signalent2[];
505extern int nsignals2;
506#endif /* SUPPORTED_PERSONALITIES >= 3 */
John Hughesbdf48f52001-03-06 15:08:09 +0000507
John Hughes5a826b82001-03-07 13:21:24 +0000508#if FREEBSD
509/* ARRGH! off_t args are aligned on 64 bit boundaries! */
510#define ALIGN64(tcp,arg) \
511do { \
512 if (arg % 2) \
513 memmove (&tcp->u_arg[arg], &tcp->u_arg[arg + 1], \
514 (tcp->u_nargs - arg - 1) * sizeof tcp->u_arg[0]); \
515} while (0)
516#else
517#define ALIGN64(tcp,arg) do { } while (0)
518#endif
519
John Hughes0c79e012001-03-08 14:40:06 +0000520#if HAVE_LONG_LONG
John Hughes5a826b82001-03-07 13:21:24 +0000521
John Hughesbdf48f52001-03-06 15:08:09 +0000522/* _l refers to the lower numbered u_arg,
523 * _h refers to the higher numbered u_arg
524 */
John Hughes5a826b82001-03-07 13:21:24 +0000525
John Hughesb8a85a42001-03-28 08:05:27 +0000526#if HAVE_LITTLE_ENDIAN_LONG_LONG
John Hughes0c79e012001-03-08 14:40:06 +0000527#define LONG_LONG(_l,_h) \
528 ((long long)((unsigned long long)(_l) | ((unsigned long long)(_h)<<32)))
John Hughesbdf48f52001-03-06 15:08:09 +0000529#else
John Hughes0c79e012001-03-08 14:40:06 +0000530#define LONG_LONG(_l,_h) \
531 ((long long)((unsigned long long)(_h) | ((unsigned long long)(_l)<<32)))
John Hughesbdf48f52001-03-06 15:08:09 +0000532#endif
533#endif
Wichert Akkerman7b3346b2001-10-09 23:47:38 +0000534
535#ifdef IA64
536extern long ia32;
537#endif