mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-06 16:56:45 +08:00
IPC_EXPORT => LIBIPC_EXPORT
This commit is contained in:
parent
1fd07a2dec
commit
09a304161f
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
namespace ipc {
|
namespace ipc {
|
||||||
|
|
||||||
class IPC_EXPORT buffer {
|
class LIBIPC_EXPORT buffer {
|
||||||
public:
|
public:
|
||||||
using destructor_t = void (*)(void*, std::size_t);
|
using destructor_t = void (*)(void*, std::size_t);
|
||||||
|
|
||||||
@ -59,8 +59,8 @@ public:
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
friend IPC_EXPORT bool operator==(buffer const & b1, buffer const & b2);
|
friend LIBIPC_EXPORT bool operator==(buffer const & b1, buffer const & b2);
|
||||||
friend IPC_EXPORT bool operator!=(buffer const & b1, buffer const & b2);
|
friend LIBIPC_EXPORT bool operator!=(buffer const & b1, buffer const & b2);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class buffer_;
|
class buffer_;
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
namespace ipc {
|
namespace ipc {
|
||||||
namespace sync {
|
namespace sync {
|
||||||
|
|
||||||
class IPC_EXPORT condition {
|
class LIBIPC_EXPORT condition {
|
||||||
condition(condition const &) = delete;
|
condition(condition const &) = delete;
|
||||||
condition &operator=(condition const &) = delete;
|
condition &operator=(condition const &) = delete;
|
||||||
|
|
||||||
|
|||||||
@ -19,7 +19,7 @@ namespace ipc {
|
|||||||
* \param dlen The target string length can be 0
|
* \param dlen The target string length can be 0
|
||||||
*/
|
*/
|
||||||
template <typename CharT, typename CharU>
|
template <typename CharT, typename CharU>
|
||||||
IPC_EXPORT std::size_t cvt_cstr(CharT const *src, std::size_t slen, CharU *des, std::size_t dlen) noexcept;
|
LIBIPC_EXPORT std::size_t cvt_cstr(CharT const *src, std::size_t slen, CharU *des, std::size_t dlen) noexcept;
|
||||||
|
|
||||||
template <typename CharT, typename TraitsT, typename AllocT,
|
template <typename CharT, typename TraitsT, typename AllocT,
|
||||||
typename CharU, typename TraitsU, typename AllocU>
|
typename CharU, typename TraitsU, typename AllocU>
|
||||||
|
|||||||
@ -9,37 +9,37 @@
|
|||||||
|
|
||||||
#if defined(Q_DECL_EXPORT) && defined(Q_DECL_IMPORT)
|
#if defined(Q_DECL_EXPORT) && defined(Q_DECL_IMPORT)
|
||||||
|
|
||||||
# define IPC_DECL_EXPORT Q_DECL_EXPORT
|
# define LIBIPC_DECL_EXPORT Q_DECL_EXPORT
|
||||||
# define IPC_DECL_IMPORT Q_DECL_IMPORT
|
# define LIBIPC_DECL_IMPORT Q_DECL_IMPORT
|
||||||
|
|
||||||
#else // defined(Q_DECL_EXPORT) && defined(Q_DECL_IMPORT)
|
#else // defined(Q_DECL_EXPORT) && defined(Q_DECL_IMPORT)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Compiler & system detection for IPC_DECL_EXPORT & IPC_DECL_IMPORT.
|
* \brief Compiler & system detection for LIBIPC_DECL_EXPORT & LIBIPC_DECL_IMPORT.
|
||||||
* Not using QtCore cause it shouldn't depend on Qt.
|
* Not using QtCore cause it shouldn't depend on Qt.
|
||||||
*/
|
*/
|
||||||
# if defined(LIBIPC_CC_MSVC) || defined(LIBIPC_OS_WIN)
|
# if defined(LIBIPC_CC_MSVC) || defined(LIBIPC_OS_WIN)
|
||||||
# define IPC_DECL_EXPORT __declspec(dllexport)
|
# define LIBIPC_DECL_EXPORT __declspec(dllexport)
|
||||||
# define IPC_DECL_IMPORT __declspec(dllimport)
|
# define LIBIPC_DECL_IMPORT __declspec(dllimport)
|
||||||
# elif defined(LIBIPC_OS_ANDROID) || defined(LIBIPC_OS_LINUX) || defined(LIBIPC_CC_GNUC)
|
# elif defined(LIBIPC_OS_ANDROID) || defined(LIBIPC_OS_LINUX) || defined(LIBIPC_CC_GNUC)
|
||||||
# define IPC_DECL_EXPORT __attribute__((visibility("default")))
|
# define LIBIPC_DECL_EXPORT __attribute__((visibility("default")))
|
||||||
# define IPC_DECL_IMPORT __attribute__((visibility("default")))
|
# define LIBIPC_DECL_IMPORT __attribute__((visibility("default")))
|
||||||
# else
|
# else
|
||||||
# define IPC_DECL_EXPORT __attribute__((visibility("default")))
|
# define LIBIPC_DECL_EXPORT __attribute__((visibility("default")))
|
||||||
# define IPC_DECL_IMPORT __attribute__((visibility("default")))
|
# define LIBIPC_DECL_IMPORT __attribute__((visibility("default")))
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#endif // defined(Q_DECL_EXPORT) && defined(Q_DECL_IMPORT)
|
#endif // defined(Q_DECL_EXPORT) && defined(Q_DECL_IMPORT)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Define IPC_EXPORT for exporting function & class.
|
* \brief Define LIBIPC_EXPORT for exporting function & class.
|
||||||
*/
|
*/
|
||||||
#ifndef IPC_EXPORT
|
#ifndef LIBIPC_EXPORT
|
||||||
# if defined(LIBIPC_LIBRARY_SHARED_BUILDING__)
|
# if defined(LIBIPC_LIBRARY_SHARED_BUILDING__)
|
||||||
# define IPC_EXPORT IPC_DECL_EXPORT
|
# define LIBIPC_EXPORT LIBIPC_DECL_EXPORT
|
||||||
# elif defined(LIBIPC_LIBRARY_SHARED_USING__)
|
# elif defined(LIBIPC_LIBRARY_SHARED_USING__)
|
||||||
# define IPC_EXPORT IPC_DECL_IMPORT
|
# define LIBIPC_EXPORT LIBIPC_DECL_IMPORT
|
||||||
# else
|
# else
|
||||||
# define IPC_EXPORT
|
# define LIBIPC_EXPORT
|
||||||
# endif
|
# endif
|
||||||
#endif /*IPC_EXPORT*/
|
#endif /*LIBIPC_EXPORT*/
|
||||||
|
|||||||
@ -65,45 +65,45 @@ LIBIPC_NODISCARD std::string fmt(A &&...args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// \brief String types.
|
/// \brief String types.
|
||||||
IPC_EXPORT bool to_string(fmt_context &ctx, char const * a) noexcept;
|
LIBIPC_EXPORT bool to_string(fmt_context &ctx, char const * a) noexcept;
|
||||||
IPC_EXPORT bool to_string(fmt_context &ctx, std::string const &a) noexcept;
|
LIBIPC_EXPORT bool to_string(fmt_context &ctx, std::string const &a) noexcept;
|
||||||
IPC_EXPORT bool to_string(fmt_context &ctx, char const * a, span<char const> fstr) noexcept;
|
LIBIPC_EXPORT bool to_string(fmt_context &ctx, char const * a, span<char const> fstr) noexcept;
|
||||||
inline bool to_string(fmt_context &ctx, std::string const &a, span<char const> fstr) noexcept { return to_string(ctx, a.c_str(), fstr); }
|
inline bool to_string(fmt_context &ctx, std::string const &a, span<char const> fstr) noexcept { return to_string(ctx, a.c_str(), fstr); }
|
||||||
|
|
||||||
/// \brief Character to string conversion.
|
/// \brief Character to string conversion.
|
||||||
IPC_EXPORT bool to_string(fmt_context &ctx, char a) noexcept;
|
LIBIPC_EXPORT bool to_string(fmt_context &ctx, char a) noexcept;
|
||||||
#if defined(LIBIPC_CPP_20)
|
#if defined(LIBIPC_CPP_20)
|
||||||
inline bool to_string(fmt_context &ctx, char8_t a) noexcept { return to_string(ctx, (char)a); }
|
inline bool to_string(fmt_context &ctx, char8_t a) noexcept { return to_string(ctx, (char)a); }
|
||||||
#endif // defined(LIBIPC_CPP_20)
|
#endif // defined(LIBIPC_CPP_20)
|
||||||
IPC_EXPORT bool to_string(fmt_context &ctx, wchar_t a) noexcept;
|
LIBIPC_EXPORT bool to_string(fmt_context &ctx, wchar_t a) noexcept;
|
||||||
IPC_EXPORT bool to_string(fmt_context &ctx, char16_t a) noexcept;
|
LIBIPC_EXPORT bool to_string(fmt_context &ctx, char16_t a) noexcept;
|
||||||
IPC_EXPORT bool to_string(fmt_context &ctx, char32_t a) noexcept;
|
LIBIPC_EXPORT bool to_string(fmt_context &ctx, char32_t a) noexcept;
|
||||||
|
|
||||||
/// \brief Conversion of numeric types to strings.
|
/// \brief Conversion of numeric types to strings.
|
||||||
IPC_EXPORT bool to_string(fmt_context &ctx, signed short a, span<char const> fstr = {}) noexcept;
|
LIBIPC_EXPORT bool to_string(fmt_context &ctx, signed short a, span<char const> fstr = {}) noexcept;
|
||||||
IPC_EXPORT bool to_string(fmt_context &ctx, unsigned short a, span<char const> fstr = {}) noexcept;
|
LIBIPC_EXPORT bool to_string(fmt_context &ctx, unsigned short a, span<char const> fstr = {}) noexcept;
|
||||||
IPC_EXPORT bool to_string(fmt_context &ctx, signed int a, span<char const> fstr = {}) noexcept;
|
LIBIPC_EXPORT bool to_string(fmt_context &ctx, signed int a, span<char const> fstr = {}) noexcept;
|
||||||
IPC_EXPORT bool to_string(fmt_context &ctx, unsigned int a, span<char const> fstr = {}) noexcept;
|
LIBIPC_EXPORT bool to_string(fmt_context &ctx, unsigned int a, span<char const> fstr = {}) noexcept;
|
||||||
IPC_EXPORT bool to_string(fmt_context &ctx, signed long a, span<char const> fstr = {}) noexcept;
|
LIBIPC_EXPORT bool to_string(fmt_context &ctx, signed long a, span<char const> fstr = {}) noexcept;
|
||||||
IPC_EXPORT bool to_string(fmt_context &ctx, unsigned long a, span<char const> fstr = {}) noexcept;
|
LIBIPC_EXPORT bool to_string(fmt_context &ctx, unsigned long a, span<char const> fstr = {}) noexcept;
|
||||||
IPC_EXPORT bool to_string(fmt_context &ctx, signed long long a, span<char const> fstr = {}) noexcept;
|
LIBIPC_EXPORT bool to_string(fmt_context &ctx, signed long long a, span<char const> fstr = {}) noexcept;
|
||||||
IPC_EXPORT bool to_string(fmt_context &ctx, unsigned long long a, span<char const> fstr = {}) noexcept;
|
LIBIPC_EXPORT bool to_string(fmt_context &ctx, unsigned long long a, span<char const> fstr = {}) noexcept;
|
||||||
inline bool to_string(fmt_context &ctx, signed char a, span<char const> fstr = {}) noexcept { return to_string(ctx, (int)a, fstr); }
|
inline bool to_string(fmt_context &ctx, signed char a, span<char const> fstr = {}) noexcept { return to_string(ctx, (int)a, fstr); }
|
||||||
inline bool to_string(fmt_context &ctx, unsigned char a, span<char const> fstr = {}) noexcept { return to_string(ctx, (unsigned)a, fstr); }
|
inline bool to_string(fmt_context &ctx, unsigned char a, span<char const> fstr = {}) noexcept { return to_string(ctx, (unsigned)a, fstr); }
|
||||||
|
|
||||||
/// \brief Conversion of floating point type to strings.
|
/// \brief Conversion of floating point type to strings.
|
||||||
IPC_EXPORT bool to_string(fmt_context &ctx, double a, span<char const> fstr = {}) noexcept;
|
LIBIPC_EXPORT bool to_string(fmt_context &ctx, double a, span<char const> fstr = {}) noexcept;
|
||||||
IPC_EXPORT bool to_string(fmt_context &ctx, long double a, span<char const> fstr = {}) noexcept;
|
LIBIPC_EXPORT bool to_string(fmt_context &ctx, long double a, span<char const> fstr = {}) noexcept;
|
||||||
inline bool to_string(fmt_context &ctx, float a, span<char const> fstr = {}) noexcept { return to_string(ctx, (double)a, fstr); }
|
inline bool to_string(fmt_context &ctx, float a, span<char const> fstr = {}) noexcept { return to_string(ctx, (double)a, fstr); }
|
||||||
|
|
||||||
/// \brief Pointer.
|
/// \brief Pointer.
|
||||||
IPC_EXPORT bool to_string(fmt_context &ctx, std::nullptr_t) noexcept;
|
LIBIPC_EXPORT bool to_string(fmt_context &ctx, std::nullptr_t) noexcept;
|
||||||
template <typename T,
|
template <typename T,
|
||||||
typename = std::enable_if_t<std::is_same<T, void>::value>>
|
typename = std::enable_if_t<std::is_same<T, void>::value>>
|
||||||
IPC_EXPORT bool to_string(fmt_context &ctx, T const volatile *a) noexcept;
|
LIBIPC_EXPORT bool to_string(fmt_context &ctx, T const volatile *a) noexcept;
|
||||||
|
|
||||||
/// \brief Date and time.
|
/// \brief Date and time.
|
||||||
IPC_EXPORT bool to_string(fmt_context &ctx, std::tm const &a, span<char const> fstr = {}) noexcept;
|
LIBIPC_EXPORT bool to_string(fmt_context &ctx, std::tm const &a, span<char const> fstr = {}) noexcept;
|
||||||
|
|
||||||
namespace detail_fmt {
|
namespace detail_fmt {
|
||||||
|
|
||||||
|
|||||||
@ -17,10 +17,10 @@
|
|||||||
namespace ipc {
|
namespace ipc {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \class class IPC_EXPORT fmt_context
|
* \class class LIBIPC_EXPORT fmt_context
|
||||||
* \brief The context of fmt.
|
* \brief The context of fmt.
|
||||||
*/
|
*/
|
||||||
class IPC_EXPORT fmt_context {
|
class LIBIPC_EXPORT fmt_context {
|
||||||
std::array<char, 2048U> sbuf_; ///< stack buffer
|
std::array<char, 2048U> sbuf_; ///< stack buffer
|
||||||
|
|
||||||
std::string &joined_;
|
std::string &joined_;
|
||||||
|
|||||||
@ -22,7 +22,7 @@ namespace ipc {
|
|||||||
* \param name the mangled name
|
* \param name the mangled name
|
||||||
* \return std::string a human-readable demangled type name
|
* \return std::string a human-readable demangled type name
|
||||||
*/
|
*/
|
||||||
IPC_EXPORT std::string demangle(std::string name) noexcept;
|
LIBIPC_EXPORT std::string demangle(std::string name) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Returns an implementation defined string containing the name of the type.
|
* \brief Returns an implementation defined string containing the name of the type.
|
||||||
|
|||||||
@ -18,7 +18,7 @@ enum : unsigned {
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Flag>
|
template <typename Flag>
|
||||||
struct IPC_EXPORT chan_impl {
|
struct LIBIPC_EXPORT chan_impl {
|
||||||
static ipc::handle_t init_first();
|
static ipc::handle_t init_first();
|
||||||
|
|
||||||
static bool connect (ipc::handle_t * ph, char const * name, unsigned mode);
|
static bool connect (ipc::handle_t * ph, char const * name, unsigned mode);
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
#include "libipc/imp/byte.h"
|
#include "libipc/imp/byte.h"
|
||||||
#include "libipc/imp/detect_plat.h"
|
#include "libipc/imp/detect_plat.h"
|
||||||
|
|
||||||
#include "libipc/export.h"
|
#include "libipc/imp/export.h"
|
||||||
|
|
||||||
namespace ipc {
|
namespace ipc {
|
||||||
namespace mem {
|
namespace mem {
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
namespace ipc {
|
namespace ipc {
|
||||||
namespace sync {
|
namespace sync {
|
||||||
|
|
||||||
class IPC_EXPORT mutex {
|
class LIBIPC_EXPORT mutex {
|
||||||
mutex(mutex const &) = delete;
|
mutex(mutex const &) = delete;
|
||||||
mutex &operator=(mutex const &) = delete;
|
mutex &operator=(mutex const &) = delete;
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
namespace ipc {
|
namespace ipc {
|
||||||
namespace mem {
|
namespace mem {
|
||||||
|
|
||||||
class IPC_EXPORT pool_alloc {
|
class LIBIPC_EXPORT pool_alloc {
|
||||||
public:
|
public:
|
||||||
static void* alloc(std::size_t size) noexcept;
|
static void* alloc(std::size_t size) noexcept;
|
||||||
static void free (void* p, std::size_t size) noexcept;
|
static void free (void* p, std::size_t size) noexcept;
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
namespace ipc {
|
namespace ipc {
|
||||||
namespace sync {
|
namespace sync {
|
||||||
|
|
||||||
class IPC_EXPORT semaphore {
|
class LIBIPC_EXPORT semaphore {
|
||||||
semaphore(semaphore const &) = delete;
|
semaphore(semaphore const &) = delete;
|
||||||
semaphore &operator=(semaphore const &) = delete;
|
semaphore &operator=(semaphore const &) = delete;
|
||||||
|
|
||||||
|
|||||||
@ -15,8 +15,8 @@ enum : unsigned {
|
|||||||
open = 0x02
|
open = 0x02
|
||||||
};
|
};
|
||||||
|
|
||||||
IPC_EXPORT id_t acquire(char const * name, std::size_t size, unsigned mode = create | open);
|
LIBIPC_EXPORT id_t acquire(char const * name, std::size_t size, unsigned mode = create | open);
|
||||||
IPC_EXPORT void * get_mem(id_t id, std::size_t * size);
|
LIBIPC_EXPORT void * get_mem(id_t id, std::size_t * size);
|
||||||
|
|
||||||
// Release shared memory resource and clean up disk file if reference count reaches zero.
|
// Release shared memory resource and clean up disk file if reference count reaches zero.
|
||||||
// This function decrements the reference counter. When the counter reaches zero, it:
|
// This function decrements the reference counter. When the counter reaches zero, it:
|
||||||
@ -25,7 +25,7 @@ IPC_EXPORT void * get_mem(id_t id, std::size_t * size);
|
|||||||
// 3. Frees the id structure
|
// 3. Frees the id structure
|
||||||
// After calling this function, the id becomes invalid and must not be used again.
|
// After calling this function, the id becomes invalid and must not be used again.
|
||||||
// Returns: The reference count before decrement, or -1 on error.
|
// Returns: The reference count before decrement, or -1 on error.
|
||||||
IPC_EXPORT std::int32_t release(id_t id) noexcept;
|
LIBIPC_EXPORT std::int32_t release(id_t id) noexcept;
|
||||||
|
|
||||||
// Release shared memory resource and force cleanup of disk file.
|
// Release shared memory resource and force cleanup of disk file.
|
||||||
// This function calls release(id) internally, then unconditionally attempts to
|
// This function calls release(id) internally, then unconditionally attempts to
|
||||||
@ -34,19 +34,19 @@ IPC_EXPORT std::int32_t release(id_t id) noexcept;
|
|||||||
// not in combination with release().
|
// not in combination with release().
|
||||||
// Typical use case: Force cleanup when you want to ensure the disk file is removed
|
// Typical use case: Force cleanup when you want to ensure the disk file is removed
|
||||||
// regardless of reference count state.
|
// regardless of reference count state.
|
||||||
IPC_EXPORT void remove (id_t id) noexcept;
|
LIBIPC_EXPORT void remove (id_t id) noexcept;
|
||||||
|
|
||||||
// Remove shared memory backing file by name.
|
// Remove shared memory backing file by name.
|
||||||
// This function only removes the disk file and does not affect any active memory
|
// This function only removes the disk file and does not affect any active memory
|
||||||
// mappings or id structures. Use this for cleanup of orphaned files or for explicit
|
// mappings or id structures. Use this for cleanup of orphaned files or for explicit
|
||||||
// file removal without affecting runtime resources.
|
// file removal without affecting runtime resources.
|
||||||
// Safe to call at any time, even if shared memory is still in use elsewhere.
|
// Safe to call at any time, even if shared memory is still in use elsewhere.
|
||||||
IPC_EXPORT void remove (char const * name) noexcept;
|
LIBIPC_EXPORT void remove (char const * name) noexcept;
|
||||||
|
|
||||||
IPC_EXPORT std::int32_t get_ref(id_t id);
|
LIBIPC_EXPORT std::int32_t get_ref(id_t id);
|
||||||
IPC_EXPORT void sub_ref(id_t id);
|
LIBIPC_EXPORT void sub_ref(id_t id);
|
||||||
|
|
||||||
class IPC_EXPORT handle {
|
class LIBIPC_EXPORT handle {
|
||||||
public:
|
public:
|
||||||
handle();
|
handle();
|
||||||
handle(char const * name, std::size_t size, unsigned mode = create | open);
|
handle(char const * name, std::size_t size, unsigned mode = create | open);
|
||||||
@ -83,3 +83,4 @@ private:
|
|||||||
|
|
||||||
} // namespace shm
|
} // namespace shm
|
||||||
} // namespace ipc
|
} // namespace ipc
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user