This is #defined as empty at the moment, but it allows the Windows
port to define this __declspec(dllexport), which is necessary for
symbols to be exported in DLLs.
---
include/nbdkit-common.h | 86 ++++++++++++++++++++++++-----------------
include/nbdkit-filter.h | 42 +++++++++++++-------
include/nbdkit-plugin.h | 6 +--
server/main.c | 2 +
4 files changed, 83 insertions(+), 53 deletions(-)
diff --git a/include/nbdkit-common.h b/include/nbdkit-common.h
index d38b37d2..8684b95a 100644
--- a/include/nbdkit-common.h
+++ b/include/nbdkit-common.h
@@ -55,6 +55,8 @@ extern "C" {
#define ATTRIBUTE_FORMAT_PRINTF(fmtpos, argpos)
#endif
+#define NBDKIT_DLLEXPORT
+
#define NBDKIT_THREAD_MODEL_SERIALIZE_CONNECTIONS 0
#define NBDKIT_THREAD_MODEL_SERIALIZE_ALL_REQUESTS 1
#define NBDKIT_THREAD_MODEL_SERIALIZE_REQUESTS 2
@@ -76,49 +78,63 @@ extern "C" {
#define NBDKIT_EXTENT_HOLE (1<<0) /* Same as NBD_STATE_HOLE */
#define NBDKIT_EXTENT_ZERO (1<<1) /* Same as NBD_STATE_ZERO */
-extern void nbdkit_error (const char *msg, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2);
-extern void nbdkit_verror (const char *msg, va_list args)
+extern NBDKIT_DLLEXPORT void nbdkit_error (const char *msg, ...)
+ ATTRIBUTE_FORMAT_PRINTF (1, 2);
+extern NBDKIT_DLLEXPORT void nbdkit_verror (const char *msg, va_list args)
ATTRIBUTE_FORMAT_PRINTF (1, 0);
-extern void nbdkit_debug (const char *msg, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2);
-extern void nbdkit_vdebug (const char *msg, va_list args)
+extern NBDKIT_DLLEXPORT void nbdkit_debug (const char *msg, ...)
+ ATTRIBUTE_FORMAT_PRINTF (1, 2);
+extern NBDKIT_DLLEXPORT void nbdkit_vdebug (const char *msg, va_list args)
ATTRIBUTE_FORMAT_PRINTF (1, 0);
-extern char *nbdkit_absolute_path (const char *path);
-extern int64_t nbdkit_parse_size (const char *str);
-extern int nbdkit_parse_bool (const char *str);
-extern int nbdkit_parse_int (const char *what, const char *str,
- int *r);
-extern int nbdkit_parse_unsigned (const char *what, const char *str,
- unsigned *r);
-extern int nbdkit_parse_int8_t (const char *what, const char *str,
- int8_t *r);
-extern int nbdkit_parse_uint8_t (const char *what, const char *str,
- uint8_t *r);
-extern int nbdkit_parse_int16_t (const char *what, const char *str,
- int16_t *r);
-extern int nbdkit_parse_uint16_t (const char *what, const char *str,
- uint16_t *r);
-extern int nbdkit_parse_int32_t (const char *what, const char *str,
- int32_t *r);
-extern int nbdkit_parse_uint32_t (const char *what, const char *str,
- uint32_t *r);
-extern int nbdkit_parse_int64_t (const char *what, const char *str,
- int64_t *r);
-extern int nbdkit_parse_uint64_t (const char *what, const char *str,
- uint64_t *r);
-extern int nbdkit_stdio_safe (void);
-extern int nbdkit_read_password (const char *value, char **password);
-extern char *nbdkit_realpath (const char *path);
-extern int nbdkit_nanosleep (unsigned sec, unsigned nsec);
-extern int nbdkit_peer_name (struct sockaddr *addr, socklen_t *addrlen);
-extern void nbdkit_shutdown (void);
+extern NBDKIT_DLLEXPORT char *nbdkit_absolute_path (const char *path);
+extern NBDKIT_DLLEXPORT int64_t nbdkit_parse_size (const char *str);
+extern NBDKIT_DLLEXPORT int nbdkit_parse_bool (const char *str);
+extern NBDKIT_DLLEXPORT int nbdkit_parse_int (const char *what,
+ const char *str,
+ int *r);
+extern NBDKIT_DLLEXPORT int nbdkit_parse_unsigned (const char *what,
+ const char *str,
+ unsigned *r);
+extern NBDKIT_DLLEXPORT int nbdkit_parse_int8_t (const char *what,
+ const char *str,
+ int8_t *r);
+extern NBDKIT_DLLEXPORT int nbdkit_parse_uint8_t (const char *what,
+ const char *str,
+ uint8_t *r);
+extern NBDKIT_DLLEXPORT int nbdkit_parse_int16_t (const char *what,
+ const char *str,
+ int16_t *r);
+extern NBDKIT_DLLEXPORT int nbdkit_parse_uint16_t (const char *what,
+ const char *str,
+ uint16_t *r);
+extern NBDKIT_DLLEXPORT int nbdkit_parse_int32_t (const char *what,
+ const char *str,
+ int32_t *r);
+extern NBDKIT_DLLEXPORT int nbdkit_parse_uint32_t (const char *what,
+ const char *str,
+ uint32_t *r);
+extern NBDKIT_DLLEXPORT int nbdkit_parse_int64_t (const char *what,
+ const char *str,
+ int64_t *r);
+extern NBDKIT_DLLEXPORT int nbdkit_parse_uint64_t (const char *what,
+ const char *str,
+ uint64_t *r);
+extern NBDKIT_DLLEXPORT int nbdkit_stdio_safe (void);
+extern NBDKIT_DLLEXPORT int nbdkit_read_password (const char *value,
+ char **password);
+extern NBDKIT_DLLEXPORT char *nbdkit_realpath (const char *path);
+extern NBDKIT_DLLEXPORT int nbdkit_nanosleep (unsigned sec, unsigned nsec);
+extern NBDKIT_DLLEXPORT int nbdkit_peer_name (struct sockaddr *addr,
+ socklen_t *addrlen);
+extern NBDKIT_DLLEXPORT void nbdkit_shutdown (void);
struct nbdkit_extents;
-extern int nbdkit_add_extent (struct nbdkit_extents *,
+extern NBDKIT_DLLEXPORT int nbdkit_add_extent (struct nbdkit_extents *,
uint64_t offset, uint64_t length, uint32_t type);
struct nbdkit_exports;
-extern int nbdkit_add_export (struct nbdkit_exports *,
+extern NBDKIT_DLLEXPORT int nbdkit_add_export (struct nbdkit_exports *,
const char *name, const char *description);
/* A static non-NULL pointer which can be used when you don't need a
diff --git a/include/nbdkit-filter.h b/include/nbdkit-filter.h
index 6aba1aec..bd0d5425 100644
--- a/include/nbdkit-filter.h
+++ b/include/nbdkit-filter.h
@@ -115,16 +115,24 @@ struct nbdkit_extent {
uint32_t type;
};
-extern struct nbdkit_extents *nbdkit_extents_new (uint64_t start, uint64_t end);
-extern void nbdkit_extents_free (struct nbdkit_extents *);
-extern size_t nbdkit_extents_count (const struct nbdkit_extents *);
-extern struct nbdkit_extent nbdkit_get_extent (const struct nbdkit_extents *,
- size_t);
-extern int nbdkit_extents_aligned (struct nbdkit_next_ops *next_ops,
- nbdkit_backend *nxdata,
- uint32_t count, uint64_t offset,
- uint32_t flags, uint32_t align,
- struct nbdkit_extents *extents, int *err);
+extern NBDKIT_DLLEXPORT
+struct nbdkit_extents *nbdkit_extents_new (uint64_t start, uint64_t end);
+extern NBDKIT_DLLEXPORT
+void nbdkit_extents_free (struct nbdkit_extents *);
+extern NBDKIT_DLLEXPORT
+size_t nbdkit_extents_count (const struct nbdkit_extents *);
+extern NBDKIT_DLLEXPORT
+struct nbdkit_extent nbdkit_get_extent (const struct nbdkit_extents *,
+ size_t);
+extern NBDKIT_DLLEXPORT
+int nbdkit_extents_aligned (struct nbdkit_next_ops *next_ops,
+ nbdkit_backend *nxdata,
+ uint32_t count,
+ uint64_t offset,
+ uint32_t flags,
+ uint32_t align,
+ struct nbdkit_extents *extents,
+ int *err);
/* Export functions. */
struct nbdkit_export {
@@ -132,11 +140,15 @@ struct nbdkit_export {
char *description;
};
-extern struct nbdkit_exports *nbdkit_exports_new (int default_only);
-extern void nbdkit_exports_free (struct nbdkit_exports *);
-extern size_t nbdkit_exports_count (const struct nbdkit_exports *);
-extern const struct nbdkit_export nbdkit_get_export (const struct nbdkit_exports *,
- size_t);
+extern NBDKIT_DLLEXPORT
+struct nbdkit_exports *nbdkit_exports_new (int default_only);
+extern NBDKIT_DLLEXPORT
+void nbdkit_exports_free (struct nbdkit_exports *);
+extern NBDKIT_DLLEXPORT
+size_t nbdkit_exports_count (const struct nbdkit_exports *);
+extern NBDKIT_DLLEXPORT
+const struct nbdkit_export nbdkit_get_export (const struct nbdkit_exports *,
+ size_t);
/* Filter struct. */
struct nbdkit_filter {
diff --git a/include/nbdkit-plugin.h b/include/nbdkit-plugin.h
index e20391b8..23b44ef8 100644
--- a/include/nbdkit-plugin.h
+++ b/include/nbdkit-plugin.h
@@ -144,9 +144,9 @@ struct nbdkit_plugin {
struct nbdkit_exports *exports);
};
-extern void nbdkit_set_error (int err);
-extern const char *nbdkit_export_name (void);
-extern int nbdkit_is_tls (void);
+extern NBDKIT_DLLEXPORT void nbdkit_set_error (int err);
+extern NBDKIT_DLLEXPORT const char *nbdkit_export_name (void);
+extern NBDKIT_DLLEXPORT int nbdkit_is_tls (void);
#define NBDKIT_REGISTER_PLUGIN(plugin) \
NBDKIT_CXX_LANG_C \
diff --git a/server/main.c b/server/main.c
index a96ac88b..f6ffd9b2 100644
--- a/server/main.c
+++ b/server/main.c
@@ -171,6 +171,8 @@ dump_config (void)
#endif
}
+extern NBDKIT_DLLEXPORT int nbdkit_main (int argc, char *argv[]);
+
int
nbdkit_main (int argc, char *argv[])
{
--
2.27.0