]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/valgrind/src/valgrind-3.6.0-svn/coregrind/l4re/fd_names.cpp
update
[l4.git] / l4 / pkg / valgrind / src / valgrind-3.6.0-svn / coregrind / l4re / fd_names.cpp
1 /*
2  * This file is part of the Valgrind port to L4Re.
3  *
4  * (c) 2009-2010 Aaron Pohle <apohle@os.inf.tu-dresden.de>,
5  *               Bjoern Doebel <doebel@os.inf.tu-dresden.de>
6  *     economic rights: Technische Universitaet Dresden (Germany)
7  */
8
9 #include <l4/sys/compiler.h>
10 __BEGIN_DECLS
11 #include "pub_core_basics.h"
12 #include "pub_l4re.h"
13 #include "pub_l4re_consts.h"
14 #include "pub_tool_libcbase.h"
15 #include "pub_tool_libcfile.h"
16 #include "pub_core_libcprint.h"
17 #include "l4re_helper.h"
18 __END_DECLS
19
20 // max number of fd->name mappings
21 static const int _num_filenames = 25;
22 // storage for mappings
23 Char _filenames[_num_filenames][50] = { { 0 } };
24
25
26 void vrm_register_filename(int fd, Char *name)
27 {
28     if (fd < 0)
29         return;
30
31     if (fd > _num_filenames) {
32         VG_(printf)("fd out of range: %d\n",fd);
33         enter_kdebug();
34     }
35
36     VG_(strncpy)(_filenames[fd], name, 50);
37 }
38
39
40 void vrm_unregister_filename(int fd)
41 {
42     if (fd < 0)
43         return;
44
45     if (fd > _num_filenames) {
46         VG_(printf)("fd out of range: %d\n",fd);
47         return;
48     }
49
50     VG_(memset)(_filenames[fd], 0, 50);
51 }
52
53
54 Char *vrm_get_filename(int fd)
55 {
56     if (fd < 0 || fd > _num_filenames) {
57         VG_(printf)("fd out of range: %d\n",fd);
58         enter_kdebug();
59     }
60
61     return _filenames[fd];
62 }