blob: f04776e2436f14da758ebd56bf31498792aa1e3f [file] [log] [blame]
Gennady Sharapovea2ba7d2006-01-08 01:01:31 -08001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#ifndef __USER_UTIL_H__
7#define __USER_UTIL_H__
8
9#include "sysdep/ptrace.h"
10
Rusty Russellc5e631c2007-05-06 14:51:05 -070011/* Copied from kernel.h and compiler-gcc.h */
12
13/* Force a compilation error if condition is true, but also produce a
14 result (of value 0 and type size_t), so the expression can be used
15 e.g. in a structure initializer (or where-ever else comma expressions
16 aren't permitted). */
17#define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1)
18
19/* &a[0] degrades to a pointer: a different type from an array */
20#define __must_be_array(a) \
21 BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0])))
22
23#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
Paolo 'Blaisorblade' Giarrusso3feb8852006-03-31 02:30:25 -080024
Linus Torvalds1da177e2005-04-16 15:20:36 -070025#define CATCH_EINTR(expr) while ((errno = 0, ((expr) < 0)) && (errno == EINTR))
26
27extern int mode_tt;
28
29extern int grantpt(int __fd);
30extern int unlockpt(int __fd);
31extern char *ptsname(int __fd);
32
Linus Torvalds1da177e2005-04-16 15:20:36 -070033extern void *add_signal_handler(int sig, void (*handler)(int));
Linus Torvalds1da177e2005-04-16 15:20:36 -070034extern void input_cb(void (*proc)(void *), void *arg, int arg_len);
35extern int get_pty(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070036extern int switcheroo(int fd, int prot, void *from, void *to, int size);
Linus Torvalds1da177e2005-04-16 15:20:36 -070037extern void do_exec(int old_pid, int new_pid);
Paolo 'Blaisorblade' Giarrusso9cf85b32006-04-10 22:53:31 -070038extern void tracer_panic(char *msg, ...)
39 __attribute__ ((format (printf, 1, 2)));
Linus Torvalds1da177e2005-04-16 15:20:36 -070040extern int detach(int pid, int sig);
41extern int attach(int pid);
42extern void kill_child_dead(int pid);
43extern int cont(int pid);
Linus Torvalds1da177e2005-04-16 15:20:36 -070044extern void check_sigio(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070045extern int raw(int fd);
46
47#endif