summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/tinycbor/src
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/tinycbor/src')
-rw-r--r--src/3rdparty/tinycbor/src/cbor.h4
-rw-r--r--src/3rdparty/tinycbor/src/cborencoder.c24
-rw-r--r--src/3rdparty/tinycbor/src/cborparser.c2
-rw-r--r--src/3rdparty/tinycbor/src/compilersupport_p.h2
4 files changed, 23 insertions, 9 deletions
diff --git a/src/3rdparty/tinycbor/src/cbor.h b/src/3rdparty/tinycbor/src/cbor.h
index 5c7ba74e39..3672bd0d98 100644
--- a/src/3rdparty/tinycbor/src/cbor.h
+++ b/src/3rdparty/tinycbor/src/cbor.h
@@ -257,6 +257,7 @@ CBOR_INLINE_API CborError cbor_encode_undefined(CborEncoder *encoder)
CBOR_INLINE_API CborError cbor_encode_half_float(CborEncoder *encoder, const void *value)
{ return cbor_encode_floating_point(encoder, CborHalfFloatType, value); }
+CBOR_API CborError cbor_encode_float_as_half_float(CborEncoder *encoder, float value);
CBOR_INLINE_API CborError cbor_encode_float(CborEncoder *encoder, float value)
{ return cbor_encode_floating_point(encoder, CborFloatType, &value); }
CBOR_INLINE_API CborError cbor_encode_double(CborEncoder *encoder, double value)
@@ -593,12 +594,13 @@ CBOR_API CborError cbor_value_map_find_value(const CborValue *map, const char *s
/* Floating point */
CBOR_INLINE_API bool cbor_value_is_half_float(const CborValue *value)
{ return value->type == CborHalfFloatType; }
+CBOR_API CborError cbor_value_get_half_float_as_float(const CborValue *value, float *result);
CBOR_INLINE_API CborError cbor_value_get_half_float(const CborValue *value, void *result)
{
assert(cbor_value_is_half_float(value));
assert((value->flags & CborIteratorFlag_IntegerValueTooLarge) == 0);
- /* size has been computed already */
+ /* size has already been computed */
memcpy(result, &value->extra, sizeof(value->extra));
return CborNoError;
}
diff --git a/src/3rdparty/tinycbor/src/cborencoder.c b/src/3rdparty/tinycbor/src/cborencoder.c
index 52a4025be1..38804cfa6f 100644
--- a/src/3rdparty/tinycbor/src/cborencoder.c
+++ b/src/3rdparty/tinycbor/src/cborencoder.c
@@ -76,7 +76,7 @@
* \code
* uint8_t buf[16];
* CborEncoder encoder, mapEncoder;
- * cbor_encoder_init(&encoder, &buf, sizeof(buf), 0);
+ * cbor_encoder_init(&encoder, buf, sizeof(buf), 0);
* cbor_encoder_create_map(&encoder, &mapEncoder, 1);
* cbor_encode_text_stringz(&mapEncoder, "foo");
* cbor_encode_boolean(&mapEncoder, some_value);
@@ -115,7 +115,7 @@
* uint8_t buf[16];
* CborError err;
* CborEncoder encoder, mapEncoder;
- * cbor_encoder_init(&encoder, &buf, sizeof(buf), 0);
+ * cbor_encoder_init(&encoder, buf, sizeof(buf), 0);
* err = cbor_encoder_create_map(&encoder, &mapEncoder, 1);
* if (!err)
* return err;
@@ -155,7 +155,7 @@
* goto error;
* buf = nbuf;
*
- * cbor_encoder_init(&encoder, &buf, size, 0);
+ * cbor_encoder_init(&encoder, buf, size, 0);
* err = cbor_encoder_create_array(&encoder, &arrayEncoder, n);
* cbor_assert(err); // can't fail, the buffer is always big enough
*
@@ -411,7 +411,7 @@ CborError cbor_encode_simple_value(CborEncoder *encoder, uint8_t value)
* This function is useful for code that needs to pass through floating point
* values but does not wish to have the actual floating-point code.
*
- * \sa cbor_encode_half_float, cbor_encode_float, cbor_encode_double
+ * \sa cbor_encode_half_float, cbor_encode_float_as_half_float, cbor_encode_float, cbor_encode_double
*/
CborError cbor_encode_floating_point(CborEncoder *encoder, CborType fpType, const void *value)
{
@@ -622,12 +622,24 @@ CborError cbor_encoder_close_container(CborEncoder *encoder, const CborEncoder *
*/
/**
+ * \fn CborError cbor_encode_float_as_half_float(CborEncoder *encoder, float value)
+ *
+ * Convert the IEEE 754 single-precision (32-bit) floating point value \a value
+ * to the IEEE 754 half-precision (16-bit) floating point value and append it
+ * to the CBOR stream provided by \a encoder.
+ * The \a value should be in the range of the IEEE 754 half-precision floating point type,
+ * INFINITY, -INFINITY, or NAN, otherwise the behavior of this function is undefined.
+ *
+ * \sa cbor_encode_floating_point(), cbor_encode_float(), cbor_encode_double()
+ */
+
+/**
* \fn CborError cbor_encode_float(CborEncoder *encoder, float value)
*
* Appends the IEEE 754 single-precision (32-bit) floating point value \a value
* to the CBOR stream provided by \a encoder.
*
- * \sa cbor_encode_floating_point(), cbor_encode_half_float(), cbor_encode_double()
+ * \sa cbor_encode_floating_point(), cbor_encode_half_float(), cbor_encode_float_as_half_float(), cbor_encode_double()
*/
/**
@@ -636,7 +648,7 @@ CborError cbor_encoder_close_container(CborEncoder *encoder, const CborEncoder *
* Appends the IEEE 754 double-precision (64-bit) floating point value \a value
* to the CBOR stream provided by \a encoder.
*
- * \sa cbor_encode_floating_point(), cbor_encode_half_float(), cbor_encode_float()
+ * \sa cbor_encode_floating_point(), cbor_encode_half_float(), cbor_encode_float_as_half_float(), cbor_encode_float()
*/
/**
diff --git a/src/3rdparty/tinycbor/src/cborparser.c b/src/3rdparty/tinycbor/src/cborparser.c
index 971230ea61..90a7d2ced6 100644
--- a/src/3rdparty/tinycbor/src/cborparser.c
+++ b/src/3rdparty/tinycbor/src/cborparser.c
@@ -1520,7 +1520,7 @@ error:
* floating point, this function takes a \c{void *} as a parameter for the
* storage area, which must be at least 16 bits wide.
*
- * \sa cbor_value_get_type(), cbor_value_is_valid(), cbor_value_is_half_float(), cbor_value_get_float()
+ * \sa cbor_value_get_type(), cbor_value_is_valid(), cbor_value_is_half_float(), cbor_value_get_half_float_as_float(), cbor_value_get_float()
*/
/** @} */
diff --git a/src/3rdparty/tinycbor/src/compilersupport_p.h b/src/3rdparty/tinycbor/src/compilersupport_p.h
index 2b9491d34d..bd10efc9c7 100644
--- a/src/3rdparty/tinycbor/src/compilersupport_p.h
+++ b/src/3rdparty/tinycbor/src/compilersupport_p.h
@@ -106,7 +106,7 @@
# define cbor_ntohs __builtin_bswap16
# define cbor_htons __builtin_bswap16
# else
-# define cbor_ntohs(x) (((uint16_t)x >> 8) | ((uint16_t)x << 8))
+# define cbor_ntohs(x) (((uint16_t)(x) >> 8) | ((uint16_t)(x) << 8))
# define cbor_htons cbor_ntohs
# endif
# else