15 Commits
Author SHA1 Message Date
Thiago Macieira 7b607eb5e8 Remove the old Makefile and qmake buildsystem files
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-18 17:14:19 -07:00
Thiago Macieira ff33012d13 CMake: enable building the tools
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-18 16:43:48 -07:00
Thiago Macieira 2fc4c35f9d json2cbor: don't use the buffer variable after realloc()
There's a discussion in the C and C++ communities whether you're allowed
to use the values of pointers that have been deallocated, if you don't
dereference them. Some argue that it is Undefined Behaviour in spite of
the numeric value stored in the variable not having changed.

Instead of arguing, let's just make sure we don't use the pointers after
they have become dangling. We only needed the offset of how far we've
written into the buffer to restore the state and we have a function that
returns exactly that.

Seen while debugging #259.

Drive-by keep the `buffersize` global variable unchanged until after
`realloc()` has returned with success.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-11 18:24:45 -07:00
Kal Conley 3cba6b11aa Use _Float16 for half conversions if available
Implement support for half-precision floating-point conversions using
`_Float16` introduced in C11 extension ISO/IEC TS 18661-3.
2023-02-23 17:13:37 -08:00
Khyber Sen 590c28a004 Removed #define _POSIX_C_SOURCEs where #define _GNU_SOURCE was also defined, as _GNU_SOURCE implicitly defines _POSIX_C_SOURCE, but on BSD/macOS, _POSIX_C_SOURCE prevents non-POSIX extensions from being defined. 2022-06-28 09:49:22 -07:00
Fabrice Fontaine d072f461e9 fix undefined encode_half in json2cbor
encode_half has been moved from compilersupport_p.h to cborinternal_p.h
in commit bfc40dcf90 so include this file
in json2cbor to avoid the following build failure:

/home/buildroot/autobuild/run/instance-0/output/host/bin/microblazeel-linux-gcc -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I./src -std=gnu99 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Os    -c -o tools/json2cbor/json2cbor.o tools/json2cbor/json2cbor.c
tools/json2cbor/json2cbor.c: In function 'decode_json_with_metadata':
tools/json2cbor/json2cbor.c:295:50: warning: implicit declaration of function 'encode_half' [-Wimplicit-function-declaration]
                                          (half = encode_half(v), cbor_encode_half_float(encoder, &half));
                                                  ^~~~~~~~~~~
/home/buildroot/autobuild/run/instance-0/output/host/bin/microblazeel-linux-gcc -o bin/json2cbor  tools/json2cbor/json2cbor.o lib/libtinycbor.so -lcjson -lm
tools/json2cbor/json2cbor.o: In function `decode_json_with_metadata':
(.text+0xe54): undefined reference to `encode_half'
collect2: error: ld returned 1 exit status
Makefile:151: recipe for target 'bin/json2cbor' failed

Fixes:
 - http://autobuild.buildroot.net/results/afd8d24f2a4e501264abff618cf421d4bd088ebf

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2018-09-21 09:43:08 -07:00
Thiago Macieira f5a172b976 Docs and comments updates
Many thanks to Edward Welbourne for pointing them all out.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-02-05 18:02:52 -08:00
Thiago Macieira cd4430ece7 json2cbor: Minor update for clarity
Avoids a magic constant in the code.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-02-05 18:02:52 -08:00
Thiago Macieira 7a09e63fa0 json2cbor: don't crash if realloc() returns false
perror() doesn't exist. It's not like Perl's die().

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-02-05 15:07:12 -08:00
Philippe Coval f9457017aa json2cbor: Initialize index before "for scope"
Observed issue on earlier version:

  json2cbor.c:157:5: error: for loop initial declarations are only allowed in C99 mode

Note, it's not mandatory for current master branch
since build script already sets the c99 flag,
but it won't cause any harm.

Signed-off-by: Philippe Coval <philippe.coval@osg.samsung.com>
2017-11-13 19:13:06 -08:00
Fabrice Fontaine 8ba8e2030e Update cjson include path
Since cjson-v1.0.0 (https://github.com/DaveGamble/cJSON/releases),
cJSON.h is installed into cjson/cJSON.h and library has been renamed
from cJSON to cjson

Signed-off-by: Fabrice Fontaine <fabrice.fontaine@orange.com>
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-01-18 15:47:32 -08:00
Thiago Macieira ede7f1431a Revert "Revert "Give a name to unnamed union in CborEncoder""
This reverts commit 4628a110b7 and thus
brings 0e1440ab92 back.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-30 23:09:56 -07:00
Thiago Macieira 57bcf4fec4 Add support for IEEE 754 half-precision floating point
The CBOR spec has support for them, but we didn't take them into account
in the CBOR and JSON dumpers nor the JSON parser.

See: https://en.wikipedia.org/wiki/Half-precision_floating-point_format

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2015-09-29 18:50:27 -07:00
Thiago Macieira 78632b3e5c json2cbor: Implement parsing of metadata
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2015-09-29 18:50:27 -07:00
Thiago Macieira d4c9ecb91f json2cbor: Add the tool to convert from JSON to CBOR
Conversion works without metadata interpretation yet. That's coming
next.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2015-09-29 18:50:27 -07:00