Skip to content

Commit a04cbaf

Browse files
author
Laurence Lundblade
committed
Float and build documentation update
1 parent feb6b57 commit a04cbaf

File tree

4 files changed

+220
-284
lines changed

4 files changed

+220
-284
lines changed

doc/Building.md

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ the full test suite.
2828

2929
### Building with CMake
3030

31-
A modern cmake configuration is provided in CMakeLists.txt that can
32-
build, test and install QCBOR. The installation includes cmake package
33-
files for easy installation, use of the QCBOR library by cmake-based
34-
and non-cmake-based dependents and integration into a larger
35-
cmake-based project.
31+
A modern CMake configuration is provided in CMakeLists.txt that can
32+
build, test, and install QCBOR. The installation includes CMake package
33+
files for easy installation, use of the QCBOR library by CMake-based
34+
and non-CMake-based dependents, and integration into a larger
35+
CMake-based project.
3636

3737
Generally, no configuration is needed, but there are a few build
3838
options:
@@ -43,7 +43,7 @@ options:
4343
| `-DBUILD_QCBOR_WARN=ON` | Compiler warnings are off by default; this turns on the warnins used in QCBOR continuous integration.
4444
| `-DBUILD_QCBOR_TEST=APP` | Builds the tests as an executable. Tests are off by default.
4545
| `-DBUILD_QCBOR_TEST=LIB` | Builds the tests as a library.
46-
| `-DQCBOR_DISABLE_XXX=ON` | Disables feature XXX to reduce code size. See descriptions below. The name of the cmake option is the same as the #define.
46+
| `-DQCBOR_DISABLE_XXX=ON` | Disables feature XXX to reduce code size. See descriptions below. The name of the CMake option is the same as the `#define`.
4747

4848
Building the QCBOR library:
4949

@@ -72,6 +72,8 @@ cmake --build <build_folder>
7272
@anchor CodeSize
7373
## Code Size
7474

75+
TODO: The sizes in this section need to be updated for QCBOR v2.
76+
7577
These are approximate sizes on a 64-bit x86 CPU with the -Os optimization.
7678
All `QCBOR_DISABLE_XXX` are set and compiler stack frame checking is disabled
7779
for smallest but not for largest. Smallest is the library functions for a
@@ -128,7 +130,7 @@ and standard tag types.
128130
The primary control over the amount of QCBOR code that is linked into
129131
an application is in which functions are actually used. When linking
130132
against a library, or when dead-code stripping is enabled, any code
131-
that is not explicitly referenced will not be linked. For, example
133+
that is not explicitly referenced will not be linked. For example,
132134
never calling number conversion functions will result in less linked
133135
code.
134136

@@ -143,7 +145,7 @@ depend on factors such as the target CPU, compiler, compiler options,
143145
build configuration, and the specific QCBOR functions used.
144146

145147

146-
| #define | Saves |
148+
| `#define` | Saves |
147149
| ------------------------------------------| -------|
148150
| `QCBOR_DISABLE_ENCODE_USAGE_GUARDS` | TODO |
149151
| `QCBOR_DISABLE_INDEFINITE_LENGTH_STRINGS` | TODO |
@@ -164,34 +166,34 @@ implementation is complete and correct.
164166

165167
Indefinite lengths are a feature of CBOR that makes encoding simpler
166168
and the decoding more complex. They allow the encoder to not have to
167-
know the length of a string, map or array when they start encoding
169+
know the length of a string, map, or array when they start encoding
168170
it. Their main use is when encoding has to be done on a very
169-
constrained device. Conversely when decoding on a very constrained
171+
constrained device. Conversely, when decoding on a very constrained
170172
device, it is good to prohibit use of indefinite lengths so the
171173
decoder can be smaller.
172174

173175
The QCBOR decode API processes both definite and indefinite lengths
174-
with the same API, except to decode indefinite-length strings a
176+
with the same API, except that to decode indefinite-length strings, a
175177
storage allocator must be configured.
176178

177-
To reduce the size of the decoder define
178-
`QCBOR_DISABLE_INDEFINITE_LENGTH_STRINGS` particularly if you are not
179+
To reduce the size of the decoder, define
180+
`QCBOR_DISABLE_INDEFINITE_LENGTH_STRINGS`, particularly if you are not
179181
configuring a storage allocator.
180182

181-
Further reduction can be by defining
182-
`QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS` which will result in an error
183+
Further reduction can be acheived by defining
184+
`QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS`, which will result in an error
183185
when an indefinite-length map or array arrives for decoding.
184186

185187
`QCBOR_DISABLE_UNCOMMON_TAGS` is removed from QCBOR v2. It didn't save
186-
very much and you can get the same effect by not installing
188+
very much, and you can get the same effect by not installing
187189
the tag content handlers.
188190

189191
`QCBOR_DISABLE_EXP_AND_MANTISSA` disables the decoding of decimal
190192
fractions and big floats.
191193

192194
The options for disabling floating-point are detailed in the section
193195
on @ref Floating-Point. In short, `QCBOR_DISABLE_PREFERRED_FLOAT`
194-
eliminates a lot of floating-point related code, particularly
196+
eliminates a lot of floating-point-related code, particularly
195197
half-precision support, `QCBOR_DISABLE_FLOAT_HW_USE` eliminates
196198
dependency on the math library and `<math.h>`, and
197199
`USEFULBUF_DISABLE_ALL_FLOAT` eliminates all float-point dependency,
@@ -226,22 +228,22 @@ deterministic of dCBOR.
226228

227229
### Size of spiffy decode
228230

229-
When creating a decode implementation, there is a choice of whether or
230-
not to use spiffy decode features or to just use
231-
QCBORDecode_GetNext().
232-
233-
The implementation using spiffy decode will be simpler resulting in
234-
the calling code being smaller, but the amount of code brought in from
235-
the QCBOR library will be larger. Basic use of spiffy decode brings in
236-
about 2KB of object code. If object code size is not a concern, then
237-
it is probably better to use spiffy decode because it is less work,
238-
there is less complexity and less testing to worry about.
239-
240-
If code size is a concern, then use of QCBORDecode_GetNext() will
241-
probably result in smaller overall code size for simpler CBOR
242-
protocols. However, if the CBOR protocol is complex then use of spiffy
243-
decode may reduce overall code size. An example of a complex protocol
244-
is one that involves decoding a lot of maps or maps that have many
245-
data items in them. The overall code may be smaller because the
246-
general purpose spiffy decode map processor is the one used for all
247-
the maps.
231+
When implementing a protocol decoder, you can choose between using the
232+
spiffy decode features or using the lower-level API,
233+
QCBORDecode_VGetNext() API.
234+
235+
Using spiffy decode generally results in a simpler implementation. The
236+
calling code is smaller and easier to write, understand, and test. The
237+
tradeoff is that more code from the QCBOR library is linked in: basic
238+
use of spiffy decode adds approximately 2 KB of object code. If object
239+
code size is not a concern, spiffy decode is usually the better choice
240+
due to reduced development effort, lower complexity, and simpler
241+
testing.
242+
243+
If code size is a concern, using QCBORDecode_VGetNext() will often
244+
produce a smaller overall binary for simple CBOR protocols. However,
245+
for more complex protocols, spiffy decode may actually reduce total
246+
code size. This is especially true for protocols that decode many
247+
maps, or maps with many entries, where the shared, general-purpose
248+
spiffy decode map processing logic replaces repeated hand-written
249+
decoding code.

0 commit comments

Comments
 (0)