You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/headers/ti/sprintf.rst
+12-7Lines changed: 12 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,27 +1,30 @@
1
-
.. _boot_sprintf:
1
+
.. _sprintf_h:
2
2
3
-
boot_sprintf
3
+
ti/sprintf.h
4
4
======================
5
5
6
6
.. code-block:: c
7
7
8
-
#include <boot_sprintf.h>
8
+
#include <ti/sprintf.h>
9
9
10
10
The OS comes with an implementation of ANSI C89 `sprintf`, which can reduce the size of a program by ~8 KiB. However, it is very limited in functionality. It does not support width specifiers, and it won't accept :code:`long` or :code:`float` arguments.
11
11
12
-
The following type specifiers are supported :code:`%s %c %d %i %u %o %x %X %p %n`, alongside the flags :code:`-+ #0*` in addition to the width field.
12
+
boot_sprintf
13
+
----------------------------
14
+
15
+
The following type specifiers are supported :code:`%s %c %d %i %u %o %x %X %p %n`, alongside the flags :code:`-+#0*` in addition to the space flag and width field.
13
16
14
17
All length modifiers :code:`hh h l ll j z t L` and floating point specifiers :code:`%f %g %e %a` are **not** supported.
15
18
16
19
Additionally, each individual argument will write no more than 255 characters each. This means that any strings written with :code:`%s` will be truncated after 255 characters.
17
20
18
-
The :code:`<boot_sprintf.h>` header provides `boot_sprintf`. `boot_snprintf` and `boot_asprintf` are also provided as macros
21
+
The :code:`<ti/sprintf.h>` provides `boot_sprintf`, in addition to `boot_snprintf` and `boot_asprintf` as macros.
19
22
20
23
.. code-block:: c
21
24
22
25
int boot_sprintf(char *restrict buffer, const char *restrict format, ...)
23
26
24
-
int boot_snprintf(char *buffer, size_t count, const char *restrict format, ...)
27
+
int boot_snprintf(char *restrict buffer, size_t count, const char *restrict format, ...)
25
28
26
29
int boot_asprintf(char **restrict p_buffer, const char *restrict format, ...)
27
30
@@ -30,7 +33,7 @@ Because the OS does not provide `vsprintf`, `boot_snprintf` and `boot_asprintf`
30
33
replacing printf functions
31
34
----------------------------
32
35
33
-
To disable all other printf functions with `boot_sprintf`, `boot_snprintf`, and `boot_asprintf`, add the following line to the Makefile. More information `here <https://ce-programming.github.io/toolchain/static/printf.html>`
36
+
To disable all other printf functions with `boot_sprintf`, `boot_snprintf`, and `boot_asprintf`, add the following line to the Makefile. More information :ref:`here <printf>`.
34
37
35
38
.. code-block:: makefile
36
39
@@ -53,6 +56,7 @@ boot_snprintf
53
56
The truncating behavior of C99 `snprintf` can be replicated with `boot_asprintf`
54
57
55
58
.. code-block:: c
59
+
56
60
char buf[20];
57
61
char* temp;
58
62
boot_asprintf(&temp, format, ...);
@@ -67,6 +71,7 @@ printf and fprintf
67
71
`printf` and `fprintf` can be replicated by using `boot_asprintf` and `fputs`
Copy file name to clipboardExpand all lines: docs/static/printf.rst
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ However, they contribute around 8 KiB to the resultant program.
11
11
It is highly recommended to not use `printf` and related functions at all because of this.
12
12
If you insist on using these functions, this page details how to do so in the next section.
13
13
14
-
Alternatively, a limited `sprintf` (no `long` or `float` support) implementation is baked into the OS which doesn't add any extra size to the resultant program. See the dedicated page for more information `<boot_sprintf.h> <https://ce-programming.github.io/toolchain/headers/boot_sprintf.html>`_.
14
+
Alternatively, a limited `sprintf` (no `long` or `float` support) implementation is baked into the OS which doesn't add any extra size to the resultant program. See the dedicated page for more information :ref:`ti/sprintf.h <sprintf_h>`.
15
15
To disable all other printf functions and use this `sprintf` implementation, add the following line to the Makefile:
0 commit comments