]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/interprocess/include/boost/interprocess/xsi_key.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / interprocess / include / boost / interprocess / xsi_key.hpp
CommitLineData
7c673cae
FG
1//////////////////////////////////////////////////////////////////////////////
2//
3// (C) Copyright Ion Gaztanaga 2009. Distributed under the Boost
4// Software License, Version 1.0. (See accompanying file
5// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6//
7// See http://www.boost.org/libs/interprocess for documentation.
8//
9//////////////////////////////////////////////////////////////////////////////
10
11#ifndef BOOST_INTERPROCESS_XSI_KEY_HPP
12#define BOOST_INTERPROCESS_XSI_KEY_HPP
13
14#ifndef BOOST_CONFIG_HPP
15# include <boost/config.hpp>
16#endif
17#
18#if defined(BOOST_HAS_PRAGMA_ONCE)
19# pragma once
20#endif
21
22#include <boost/interprocess/detail/config_begin.hpp>
23#include <boost/interprocess/detail/workaround.hpp>
24#include <boost/detail/workaround.hpp>
25
26#if !defined(BOOST_INTERPROCESS_XSI_SHARED_MEMORY_OBJECTS)
27#error "This header can't be used in operating systems without XSI (System V) shared memory support"
28#endif
29
30#include <boost/interprocess/creation_tags.hpp>
31#include <boost/interprocess/exceptions.hpp>
32#include <boost/interprocess/detail/utilities.hpp>
33#include <boost/move/utility_core.hpp>
34#include <boost/interprocess/detail/os_file_functions.hpp>
35#include <boost/interprocess/interprocess_fwd.hpp>
36#include <boost/interprocess/exceptions.hpp>
37#include <sys/types.h>
38#include <sys/ipc.h>
39#include <cstddef>
40#include <boost/cstdint.hpp>
41
42//!\file
43//!Describes a class representing a xsi key type.
44
45namespace boost {
46namespace interprocess {
47
48//!A class that wraps XSI (System V) key_t type.
49//!This type calculates key_t from path and id using ftok
50//!or sets key to IPC_PRIVATE using the default constructor.
51class xsi_key
52{
53 public:
54
55 //!Default constructor.
56 //!Represents a private xsi_key.
57 xsi_key()
58 : m_key(IPC_PRIVATE)
59 {}
60
61 //!Creates a new XSI shared memory with a key obtained from a call to ftok (with path
62 //!"path" and id "id"), of size "size" and permissions "perm".
63 //!If the shared memory previously exists, throws an error.
64 xsi_key(const char *path, boost::uint8_t id)
65 {
66 key_t key;
67 if(path){
68 key = ::ftok(path, id);
69 if(((key_t)-1) == key){
70 error_info err = system_error_code();
71 throw interprocess_exception(err);
72 }
73 }
74 else{
75 key = IPC_PRIVATE;
76 }
77 m_key = key;
78 }
79
80 //!Returns the internal key_t value
81 key_t get_key() const
82 { return m_key; }
83
84 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
85 private:
86 key_t m_key;
87 #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
88};
89
90} //namespace interprocess {
91} //namespace boost {
92
93#include <boost/interprocess/detail/config_end.hpp>
94
95#endif //BOOST_INTERPROCESS_XSI_KEY_HPP