vfs: check userland buffers before reading them.
[haiku.git] / headers / libs / udis86 / libudis86 / input.h
blob217e768e36d95b0a7da8c690e678d336f5c4ae3b
1 /* -----------------------------------------------------------------------------
2 * input.h
4 * Copyright (c) 2006, Vivek Mohan <vivek@sig9.com>
5 * All rights reserved. See LICENSE
6 * -----------------------------------------------------------------------------
7 */
8 #ifndef UD_INPUT_H
9 #define UD_INPUT_H
11 #include "types.h"
13 uint8_t inp_next(struct ud*);
14 uint8_t inp_peek(struct ud*);
15 uint8_t inp_uint8(struct ud*);
16 uint16_t inp_uint16(struct ud*);
17 uint32_t inp_uint32(struct ud*);
18 uint64_t inp_uint64(struct ud*);
19 void inp_move(struct ud*, size_t);
20 void inp_back(struct ud*);
22 /* inp_init() - Initializes the input system. */
23 #define inp_init(u) \
24 do { \
25 u->inp_curr = 0; \
26 u->inp_fill = 0; \
27 u->inp_ctr = 0; \
28 u->inp_end = 0; \
29 } while (0)
31 /* inp_start() - Should be called before each de-code operation. */
32 #define inp_start(u) u->inp_ctr = 0
34 /* inp_back() - Resets the current pointer to its position before the current
35 * instruction disassembly was started.
37 #define inp_reset(u) \
38 do { \
39 u->inp_curr -= u->inp_ctr; \
40 u->inp_ctr = 0; \
41 } while (0)
43 /* inp_sess() - Returns the pointer to current session. */
44 #define inp_sess(u) (u->inp_sess)
46 /* inp_cur() - Returns the current input byte. */
47 #define inp_curr(u) ((u)->inp_cache[(u)->inp_curr])
49 #endif