IPC_EXPORT => LIBIPC_EXPORT

This commit is contained in:
mutouyun 2025-01-07 20:14:43 +08:00 committed by 木头云
parent 1fd07a2dec
commit 09a304161f
13 changed files with 59 additions and 58 deletions

View File

@ -10,7 +10,7 @@
namespace ipc {
class IPC_EXPORT buffer {
class LIBIPC_EXPORT buffer {
public:
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 IPC_EXPORT bool operator!=(buffer const & b1, buffer const & b2);
friend LIBIPC_EXPORT bool operator==(buffer const & b1, buffer const & b2);
friend LIBIPC_EXPORT bool operator!=(buffer const & b1, buffer const & b2);
private:
class buffer_;

View File

@ -9,7 +9,7 @@
namespace ipc {
namespace sync {
class IPC_EXPORT condition {
class LIBIPC_EXPORT condition {
condition(condition const &) = delete;
condition &operator=(condition const &) = delete;

View File

@ -19,7 +19,7 @@ namespace ipc {
* \param dlen The target string length can be 0
*/
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,
typename CharU, typename TraitsU, typename AllocU>

View File

@ -9,37 +9,37 @@
#if defined(Q_DECL_EXPORT) && defined(Q_DECL_IMPORT)
# define IPC_DECL_EXPORT Q_DECL_EXPORT
# define IPC_DECL_IMPORT Q_DECL_IMPORT
# define LIBIPC_DECL_EXPORT Q_DECL_EXPORT
# define LIBIPC_DECL_IMPORT 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.
*/
# if defined(LIBIPC_CC_MSVC) || defined(LIBIPC_OS_WIN)
# define IPC_DECL_EXPORT __declspec(dllexport)
# define IPC_DECL_IMPORT __declspec(dllimport)
# define LIBIPC_DECL_EXPORT __declspec(dllexport)
# define LIBIPC_DECL_IMPORT __declspec(dllimport)
# elif defined(LIBIPC_OS_ANDROID) || defined(LIBIPC_OS_LINUX) || defined(LIBIPC_CC_GNUC)
# define IPC_DECL_EXPORT __attribute__((visibility("default")))
# define IPC_DECL_IMPORT __attribute__((visibility("default")))
# define LIBIPC_DECL_EXPORT __attribute__((visibility("default")))
# define LIBIPC_DECL_IMPORT __attribute__((visibility("default")))
# else
# define IPC_DECL_EXPORT __attribute__((visibility("default")))
# define IPC_DECL_IMPORT __attribute__((visibility("default")))
# define LIBIPC_DECL_EXPORT __attribute__((visibility("default")))
# define LIBIPC_DECL_IMPORT __attribute__((visibility("default")))
# endif
#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__)
# define IPC_EXPORT IPC_DECL_EXPORT
# define LIBIPC_EXPORT LIBIPC_DECL_EXPORT
# elif defined(LIBIPC_LIBRARY_SHARED_USING__)
# define IPC_EXPORT IPC_DECL_IMPORT
# define LIBIPC_EXPORT LIBIPC_DECL_IMPORT
# else
# define IPC_EXPORT
# define LIBIPC_EXPORT
# endif
#endif /*IPC_EXPORT*/
#endif /*LIBIPC_EXPORT*/

View File

@ -65,45 +65,45 @@ LIBIPC_NODISCARD std::string fmt(A &&...args) {
}
/// \brief String types.
IPC_EXPORT bool to_string(fmt_context &ctx, char const * a) noexcept;
IPC_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) noexcept;
LIBIPC_EXPORT bool to_string(fmt_context &ctx, std::string const &a) 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); }
/// \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)
inline bool to_string(fmt_context &ctx, char8_t a) noexcept { return to_string(ctx, (char)a); }
#endif // defined(LIBIPC_CPP_20)
IPC_EXPORT bool to_string(fmt_context &ctx, wchar_t a) noexcept;
IPC_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, wchar_t a) noexcept;
LIBIPC_EXPORT bool to_string(fmt_context &ctx, char16_t a) noexcept;
LIBIPC_EXPORT bool to_string(fmt_context &ctx, char32_t a) noexcept;
/// \brief Conversion of numeric types to strings.
IPC_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;
IPC_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;
IPC_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;
IPC_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, signed short a, span<char const> fstr = {}) noexcept;
LIBIPC_EXPORT bool to_string(fmt_context &ctx, unsigned short a, span<char const> fstr = {}) noexcept;
LIBIPC_EXPORT bool to_string(fmt_context &ctx, signed int a, span<char const> fstr = {}) noexcept;
LIBIPC_EXPORT bool to_string(fmt_context &ctx, unsigned int a, span<char const> fstr = {}) noexcept;
LIBIPC_EXPORT bool to_string(fmt_context &ctx, signed long a, span<char const> fstr = {}) noexcept;
LIBIPC_EXPORT bool to_string(fmt_context &ctx, unsigned long a, span<char const> fstr = {}) noexcept;
LIBIPC_EXPORT bool to_string(fmt_context &ctx, signed 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, unsigned char a, span<char const> fstr = {}) noexcept { return to_string(ctx, (unsigned)a, fstr); }
/// \brief Conversion of floating point type to strings.
IPC_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, 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); }
/// \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,
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.
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 {

View File

@ -17,10 +17,10 @@
namespace ipc {
/**
* \class class IPC_EXPORT fmt_context
* \class class LIBIPC_EXPORT fmt_context
* \brief The context of fmt.
*/
class IPC_EXPORT fmt_context {
class LIBIPC_EXPORT fmt_context {
std::array<char, 2048U> sbuf_; ///< stack buffer
std::string &joined_;

View File

@ -22,7 +22,7 @@ namespace ipc {
* \param name the mangled 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.

View File

@ -18,7 +18,7 @@ enum : unsigned {
};
template <typename Flag>
struct IPC_EXPORT chan_impl {
struct LIBIPC_EXPORT chan_impl {
static ipc::handle_t init_first();
static bool connect (ipc::handle_t * ph, char const * name, unsigned mode);

View File

@ -14,7 +14,7 @@
#include "libipc/imp/byte.h"
#include "libipc/imp/detect_plat.h"
#include "libipc/export.h"
#include "libipc/imp/export.h"
namespace ipc {
namespace mem {

View File

@ -9,7 +9,7 @@
namespace ipc {
namespace sync {
class IPC_EXPORT mutex {
class LIBIPC_EXPORT mutex {
mutex(mutex const &) = delete;
mutex &operator=(mutex const &) = delete;

View File

@ -9,7 +9,7 @@
namespace ipc {
namespace mem {
class IPC_EXPORT pool_alloc {
class LIBIPC_EXPORT pool_alloc {
public:
static void* alloc(std::size_t size) noexcept;
static void free (void* p, std::size_t size) noexcept;

View File

@ -8,7 +8,7 @@
namespace ipc {
namespace sync {
class IPC_EXPORT semaphore {
class LIBIPC_EXPORT semaphore {
semaphore(semaphore const &) = delete;
semaphore &operator=(semaphore const &) = delete;

View File

@ -15,8 +15,8 @@ enum : unsigned {
open = 0x02
};
IPC_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 id_t acquire(char const * name, std::size_t size, unsigned mode = create | open);
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.
// 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
// After calling this function, the id becomes invalid and must not be used again.
// 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.
// 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().
// Typical use case: Force cleanup when you want to ensure the disk file is removed
// 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.
// 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
// file removal without affecting runtime resources.
// 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);
IPC_EXPORT void sub_ref(id_t id);
LIBIPC_EXPORT std::int32_t get_ref(id_t id);
LIBIPC_EXPORT void sub_ref(id_t id);
class IPC_EXPORT handle {
class LIBIPC_EXPORT handle {
public:
handle();
handle(char const * name, std::size_t size, unsigned mode = create | open);
@ -83,3 +83,4 @@ private:
} // namespace shm
} // namespace ipc