From d07870f698e314a516939ca91de3d7307c9bade7 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 5 Apr 2011 20:37:29 -0700 Subject: usb: mark libusb callbacks with LIBUSB_CALL to ensure correct calling convention --- host/lib/transport/libusb1_zero_copy.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/host/lib/transport/libusb1_zero_copy.cpp b/host/lib/transport/libusb1_zero_copy.cpp index fe6936c7e..e42cab1d1 100644 --- a/host/lib/transport/libusb1_zero_copy.cpp +++ b/host/lib/transport/libusb1_zero_copy.cpp @@ -34,13 +34,23 @@ using namespace uhd::transport; static const size_t DEFAULT_NUM_XFERS = 16; //num xfers static const size_t DEFAULT_XFER_SIZE = 32*512; //bytes +//! Define LIBUSB_CALL when its missing (non-windows) +#ifndef LIBUSB_CALL + #define LIBUSB_CALL +#endif /*LIBUSB_CALL*/ + +/*! + * All libusb callback functions should be marked with the LIBUSB_CALL macro + * to ensure that they are compiled with the same calling convention as libusb. + */ + //! helper function: handles all async callbacks -static void libusb_async_cb(libusb_transfer *lut){ +static void LIBUSB_CALL libusb_async_cb(libusb_transfer *lut){ (*static_cast *>(lut->user_data))(); } //! callback to free transfer upon cancellation -static void cancel_transfer_cb(libusb_transfer *lut){ +static void LIBUSB_CALL cancel_transfer_cb(libusb_transfer *lut){ if (lut->status == LIBUSB_TRANSFER_CANCELLED) libusb_free_transfer(lut); else std::cout << "libusb cancel_transfer unexpected status " << lut->status << std::endl; } -- cgit v1.2.3