diff options
author | John Levon <john.levon@nutanix.com> | 2021-05-28 18:47:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-28 18:47:07 +0100 |
commit | 950a9847fee01cc80f749bf0ba2636a407c0e7c8 (patch) | |
tree | 8f1924d9e70983f2114773e512352dcdafdc8f33 | |
parent | ad88ffd9acdf4deec83cb3f5fdae4fd62ec30efe (diff) | |
download | libvfio-user-950a9847fee01cc80f749bf0ba2636a407c0e7c8.zip libvfio-user-950a9847fee01cc80f749bf0ba2636a407c0e7c8.tar.gz libvfio-user-950a9847fee01cc80f749bf0ba2636a407c0e7c8.tar.bz2 |
hide non-ABI symbols (#538)
Default to hidden visibility to remove non-public symbols from API users (and
improve performance a little). Every public function gets an EXPORT annotation.
Signed-off-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | lib/common.h | 1 | ||||
-rw-r--r-- | lib/irq.c | 2 | ||||
-rw-r--r-- | lib/libvfio-user.c | 38 | ||||
-rw-r--r-- | lib/migration.c | 2 | ||||
-rw-r--r-- | lib/pci.c | 8 | ||||
-rw-r--r-- | lib/pci_caps.c | 6 |
7 files changed, 31 insertions, 28 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 10086ba..742ecf2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,8 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE -Wall -Werror -Wextra") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-field-initializers -Wmissing-declarations") +set(CMAKE_C_FLAGS + "${CMAKE_C_FLAGS} -fvisibility=hidden") # public headers add_subdirectory(include) diff --git a/lib/common.h b/lib/common.h index d15017a..970e5d4 100644 --- a/lib/common.h +++ b/lib/common.h @@ -40,6 +40,7 @@ #include <stdint.h> #define UNUSED __attribute__((unused)) +#define EXPORT __attribute__((visibility("default"))) #define PAGE_SIZE (size_t)sysconf(_SC_PAGE_SIZE) #define PAGE_ALIGNED(x) (((x) & ((typeof(x))(PAGE_SIZE) - 1)) == 0) @@ -390,7 +390,7 @@ validate_irq_subindex(vfu_ctx_t *vfu_ctx, uint32_t subindex) return true; } -int +EXPORT int vfu_irq_trigger(vfu_ctx_t *vfu_ctx, uint32_t subindex) { eventfd_t val = 1; diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c index 99a115d..6be9a92 100644 --- a/lib/libvfio-user.c +++ b/lib/libvfio-user.c @@ -58,7 +58,7 @@ static void vfu_reset_ctx(vfu_ctx_t *vfu_ctx, const char *reason); -void +EXPORT void vfu_log(vfu_ctx_t *vfu_ctx, int level, const char *fmt, ...) { va_list ap; @@ -1058,7 +1058,7 @@ out: return ret; } -int +EXPORT int vfu_realize_ctx(vfu_ctx_t *vfu_ctx) { vfu_reg_info_t *cfg_reg; @@ -1136,7 +1136,7 @@ vfu_realize_ctx(vfu_ctx_t *vfu_ctx) return 0; } -int +EXPORT int vfu_run_ctx(vfu_ctx_t *vfu_ctx) { int err; @@ -1189,7 +1189,7 @@ vfu_reset_ctx(vfu_ctx_t *vfu_ctx, const char *reason) } } -void +EXPORT void vfu_destroy_ctx(vfu_ctx_t *vfu_ctx) { @@ -1216,7 +1216,7 @@ vfu_destroy_ctx(vfu_ctx_t *vfu_ctx) free(vfu_ctx); } -void * +EXPORT void * vfu_get_private(vfu_ctx_t *vfu_ctx) { assert(vfu_ctx != NULL); @@ -1224,7 +1224,7 @@ vfu_get_private(vfu_ctx_t *vfu_ctx) return vfu_ctx->pvt; } -vfu_ctx_t * +EXPORT vfu_ctx_t * vfu_create_ctx(vfu_trans_t trans, const char *path, int flags, void *pvt, vfu_dev_type_t dev_type) { @@ -1300,7 +1300,7 @@ err_out: return ERROR_PTR(err); } -int +EXPORT int vfu_attach_ctx(vfu_ctx_t *vfu_ctx) { @@ -1309,7 +1309,7 @@ vfu_attach_ctx(vfu_ctx_t *vfu_ctx) return vfu_ctx->tran->attach(vfu_ctx); } -int +EXPORT int vfu_get_poll_fd(vfu_ctx_t *vfu_ctx) { @@ -1318,7 +1318,7 @@ vfu_get_poll_fd(vfu_ctx_t *vfu_ctx) return vfu_ctx->tran->get_poll_fd(vfu_ctx); } -int +EXPORT int vfu_setup_log(vfu_ctx_t *vfu_ctx, vfu_log_fn_t *log, int log_level) { @@ -1386,7 +1386,7 @@ validate_sparse_mmaps_for_migr_reg(vfu_reg_info_t *reg) return true; } -int +EXPORT int vfu_setup_region(vfu_ctx_t *vfu_ctx, int region_idx, size_t size, vfu_region_access_cb_t *cb, int flags, struct iovec *mmap_areas, uint32_t nr_mmap_areas, @@ -1470,7 +1470,7 @@ err: return ERROR_INT(ret); } -int +EXPORT int vfu_setup_device_reset_cb(vfu_ctx_t *vfu_ctx, vfu_reset_cb_t *reset) { assert(vfu_ctx != NULL); @@ -1478,7 +1478,7 @@ vfu_setup_device_reset_cb(vfu_ctx_t *vfu_ctx, vfu_reset_cb_t *reset) return 0; } -int +EXPORT int vfu_setup_device_dma(vfu_ctx_t *vfu_ctx, vfu_dma_register_cb_t *dma_register, vfu_dma_unregister_cb_t *dma_unregister) { @@ -1497,7 +1497,7 @@ vfu_setup_device_dma(vfu_ctx_t *vfu_ctx, vfu_dma_register_cb_t *dma_register, return 0; } -int +EXPORT int vfu_setup_device_nr_irqs(vfu_ctx_t *vfu_ctx, enum vfu_dev_irq_type type, uint32_t count) { @@ -1514,7 +1514,7 @@ vfu_setup_device_nr_irqs(vfu_ctx_t *vfu_ctx, enum vfu_dev_irq_type type, return 0; } -int +EXPORT int vfu_setup_device_migration_callbacks(vfu_ctx_t *vfu_ctx, const vfu_migration_callbacks_t *callbacks, uint64_t data_offset) @@ -1544,7 +1544,7 @@ vfu_setup_device_migration_callbacks(vfu_ctx_t *vfu_ctx, return 0; } -int +EXPORT int vfu_addr_to_sg(vfu_ctx_t *vfu_ctx, vfu_dma_addr_t dma_addr, size_t len, dma_sg_t *sg, int max_sg, int prot) { @@ -1557,7 +1557,7 @@ vfu_addr_to_sg(vfu_ctx_t *vfu_ctx, vfu_dma_addr_t dma_addr, return dma_addr_to_sg(vfu_ctx->dma, dma_addr, len, sg, max_sg, prot); } -int +EXPORT int vfu_map_sg(vfu_ctx_t *vfu_ctx, const dma_sg_t *sg, struct iovec *iov, int cnt) { @@ -1575,7 +1575,7 @@ vfu_map_sg(vfu_ctx_t *vfu_ctx, const dma_sg_t *sg, return 0; } -void +EXPORT void vfu_unmap_sg(vfu_ctx_t *vfu_ctx, const dma_sg_t *sg, struct iovec *iov, int cnt) { if (unlikely(vfu_ctx->dma_unregister == NULL)) { @@ -1584,7 +1584,7 @@ vfu_unmap_sg(vfu_ctx_t *vfu_ctx, const dma_sg_t *sg, struct iovec *iov, int cnt) return dma_unmap_sg(vfu_ctx->dma, sg, iov, cnt); } -int +EXPORT int vfu_dma_read(vfu_ctx_t *vfu_ctx, dma_sg_t *sg, void *data) { struct vfio_user_dma_region_access *dma_recv; @@ -1626,7 +1626,7 @@ vfu_dma_read(vfu_ctx_t *vfu_ctx, dma_sg_t *sg, void *data) return ret; } -int +EXPORT int vfu_dma_write(vfu_ctx_t *vfu_ctx, dma_sg_t *sg, void *data) { struct vfio_user_dma_region_access *dma_send, dma_recv; diff --git a/lib/migration.c b/lib/migration.c index 8f0706a..f690959 100644 --- a/lib/migration.c +++ b/lib/migration.c @@ -45,7 +45,7 @@ MOCK_DEFINE(vfio_migr_state_transition_is_valid)(uint32_t from, uint32_t to) return migr_states[from].state & (1 << to); } -size_t +EXPORT size_t vfu_get_migr_register_area_size(void) { return ROUND_UP(sizeof(struct vfio_device_migration_info), @@ -398,7 +398,7 @@ pci_config_space_access(vfu_ctx_t *vfu_ctx, char *buf, size_t count, return offset - start; } -int +EXPORT int vfu_pci_init(vfu_ctx_t *vfu_ctx, vfu_pci_type_t pci_type, int hdr_type, int revision UNUSED) { @@ -449,7 +449,7 @@ vfu_pci_init(vfu_ctx_t *vfu_ctx, vfu_pci_type_t pci_type, return 0; } -void +EXPORT void vfu_pci_set_id(vfu_ctx_t *vfu_ctx, uint16_t vid, uint16_t did, uint16_t ssvid, uint16_t ssid) { @@ -459,7 +459,7 @@ vfu_pci_set_id(vfu_ctx_t *vfu_ctx, uint16_t vid, uint16_t did, vfu_ctx->pci.config_space->hdr.ss.sid = ssid; } -void +EXPORT void vfu_pci_set_class(vfu_ctx_t *vfu_ctx, uint8_t base, uint8_t sub, uint8_t pi) { vfu_ctx->pci.config_space->hdr.cc.bcc = base; @@ -467,7 +467,7 @@ vfu_pci_set_class(vfu_ctx_t *vfu_ctx, uint8_t base, uint8_t sub, uint8_t pi) vfu_ctx->pci.config_space->hdr.cc.pi = pi; } -vfu_pci_config_space_t * +EXPORT vfu_pci_config_space_t * vfu_pci_get_config_space(vfu_ctx_t *vfu_ctx) { assert(vfu_ctx != NULL); diff --git a/lib/pci_caps.c b/lib/pci_caps.c index b00b9b8..f6a3abc 100644 --- a/lib/pci_caps.c +++ b/lib/pci_caps.c @@ -548,7 +548,7 @@ ext_cap_place(vfu_ctx_t *vfu_ctx, struct pci_cap *cap, void *data) return 0; } -ssize_t +EXPORT ssize_t vfu_pci_add_capability(vfu_ctx_t *vfu_ctx, size_t pos, int flags, void *data) { bool extended = (flags & VFU_CAP_FLAG_EXTENDED); @@ -710,7 +710,7 @@ vfu_pci_find_next_ext_capability(vfu_ctx_t *vfu_ctx, size_t offset, int cap_id) return 0; } -size_t +EXPORT size_t vfu_pci_find_next_capability(vfu_ctx_t *vfu_ctx, bool extended, size_t offset, int cap_id) { @@ -762,7 +762,7 @@ vfu_pci_find_next_capability(vfu_ctx_t *vfu_ctx, bool extended, } } -size_t +EXPORT size_t vfu_pci_find_capability(vfu_ctx_t *vfu_ctx, bool extended, int cap_id) { return vfu_pci_find_next_capability(vfu_ctx, extended, 0, cap_id); |