From: Gerhard Sittig Date: Fri, 6 Sep 2019 15:43:05 +0000 (+0200) Subject: bt: drop bt_put_le16() dependency (not universally available) X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=3b13990f7d193e8276eb7da27ab9a1fb8f01ee95 bt: drop bt_put_le16() dependency (not universally available) Eliminate the dependency on the non-portable bt_put_le16() routine. It isn't available in all supported BlueZ versions, and won't be available in other platform backends. Prefer write_u16le() which is available on all sigrok supported platforms. --- diff --git a/configure.ac b/configure.ac index 159cf117..a8cb4f70 100644 --- a/configure.ac +++ b/configure.ac @@ -201,15 +201,6 @@ AM_CONDITIONAL([NEED_RPC], [test "x$sr_cv_have_rpc" = xyes]) # Check for compiler support of 128 bit integers AC_CHECK_TYPES([__int128_t, __uint128_t], [], [], []) -# Availability of bt_put_le16() depends on the bluez library version. -AC_CACHE_CHECK([for bt_put_le16], [sr_cv_have_btputle16], - [AC_LINK_IFELSE([AC_LANG_PROGRAM( - [[#include ]], - [[bt_put_le16(0, (void *)0);]])], - [sr_cv_have_btputle16=yes], [sr_cv_have_btputle16=no])]) -AS_IF([test "x$sr_cv_have_btputle16" = xyes], - [AC_DEFINE([HAVE_BT_PUT_LE16], [1], [Specifies whether we have bt_put_le16().])]) - ######################## ## Hardware drivers ## ######################## diff --git a/src/bt/bt_bluez.c b/src/bt/bt_bluez.c index 52567f9e..d0a3b7c8 100644 --- a/src/bt/bt_bluez.c +++ b/src/bt/bt_bluez.c @@ -106,14 +106,6 @@ * the header doesn't. */ -#if !defined HAVE_BT_PUT_LE16 -static inline void bt_put_le16(uint16_t v, uint8_t *p) -{ - p[0] = (v >> 0) & 0xff; - p[1] = (v >> 8) & 0xff; -} -#endif - /* }}} compat decls */ /* {{{ Linux socket specific decls */ @@ -898,7 +890,7 @@ SR_PRIV int sr_bt_start_notify(struct sr_bt_desc *desc) if (sr_bt_check_socket_usable(desc) < 0) return -2; - bt_put_le16(desc->cccd_value, buf); + write_u16le(buf, desc->cccd_value); wrlen = sr_bt_char_write_req(desc, desc->cccd_handle, buf, sizeof(buf)); if (wrlen != sizeof(buf)) return -2; @@ -1048,7 +1040,7 @@ static ssize_t sr_bt_write_type_handle_bytes(struct sr_bt_desc *desc, return -2; header[0] = type; - bt_put_le16(handle, &header[1]); + write_u16le(&header[1], handle); if (data && len) wrlen = writev(desc->fd, iov, ARRAY_SIZE(iov));