L4Re Operating System Framework – Interface and Usage Documentation
Loading...
Searching...
No Matches
fd_store_impl.h
1/*
2 * (c) 2010 Alexander Warg <warg@os.inf.tu-dresden.de>
3 * economic rights: Technische Universität Dresden (Germany)
4 *
5 * This file is part of TUD:OS and distributed under the terms of the
6 * GNU General Public License 2.
7 * Please see the COPYING-GPL-2 file for details.
8 *
9 * As a special exception, you may use this file as part of a free software
10 * library without restriction. Specifically, if other files instantiate
11 * templates or use macros or inline functions from this file, or you compile
12 * this file and link it with other files to produce an executable, this
13 * file does not by itself cause the resulting executable to be covered by
14 * the GNU General Public License. This exception does not however
15 * invalidate any other reasons why the executable file might be covered by
16 * the GNU General Public License.
17 */
18#include "fd_store.h"
19
20namespace L4Re { namespace Core {
21
22int
23Fd_store::alloc() noexcept
24{
25 for (int i = _fd_hint; i < MAX_FILES; ++i)
26 {
27 if (!_files[i])
28 {
29 _fd_hint = i + 1;
30 return i;
31 }
32 }
33
34 return -1;
35}
36
37void
38Fd_store::free(int fd) noexcept
39{
40 _files[fd] = 0;
41 if (fd < _fd_hint)
42 _fd_hint = fd;
43}
44
45}}
46
L4Re C++ Interfaces.
Definition cmd_control:15