Mir
anonymous_shm_file.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by:
17  * Alexandros Frantzis <alexandros.frantzis@canonical.com>
18  */
19 
20 #ifndef MIR_GRAPHICS_MESA_ANONYMOUS_SHM_FILE_H_
21 #define MIR_GRAPHICS_MESA_ANONYMOUS_SHM_FILE_H_
22 
23 #include "shm_file.h"
24 #include "mir/fd.h"
25 
26 namespace mir
27 {
28 namespace graphics
29 {
30 namespace mesa
31 {
32 
33 namespace detail
34 {
35 class MapHandle
36 {
37 public:
38  MapHandle(int fd, size_t size);
39  ~MapHandle() noexcept;
40 
41  operator void*() const;
42 
43 private:
44  MapHandle(MapHandle const&) = delete;
45  MapHandle& operator=(MapHandle const&) = delete;
46  size_t const size;
47  void* const mapping;
48 };
49 }
50 
51 class AnonymousShmFile : public ShmFile
52 {
53 public:
54  AnonymousShmFile(size_t size);
55 
56  void* base_ptr() const;
57  int fd() const;
58 
59 private:
60  Fd const fd_;
61  detail::MapHandle const mapping;
62 };
63 
64 }
65 }
66 }
67 
68 #endif /* MIR_GRAPHICS_MESA_ANONYMOUS_SHM_FILE_H_ */
All things Mir.
Definition: atomic_callback.h:25
Definition: fd.h:33
Definition: anonymous_shm_file.h:51
Definition: anonymous_shm_file.h:35
Definition: shm_file.h:32
int const size
Definition: make_socket_rpc_channel.cpp:51

Copyright © 2012-2015 Canonical Ltd.
Generated on Wed Mar 30 00:29:56 UTC 2016