llvm-mos-sdk
util.h
Go to the documentation of this file.
1 // Copyright 2022 LLVM-MOS Project
2 // Licensed under the Apache License, Version 2.0 with LLVM Exceptions.
3 // See https://github.com/llvm-mos/llvm-mos-sdk/blob/main/LICENSE for license
4 // information.
5 
6 // Utilities shared between disparate parts of the libc.
7 
8 #ifndef _UTIL_H
9 #define _UTIL_H
10 
11 #include <stdarg.h>
12 #include <stddef.h>
13 #include <stdint.h>
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 // State of a formatted input/output operation.
20 struct Status {
21  signed char base; // base to which the value shall be converted
22  uint16_t flags; // flags and length modifiers
23  size_t n; // print: maximum characters to be written
24  // scan: number matched conversion specifiers
25  size_t i; // number of characters read/written
26  size_t current; // number of characters read in current conversion
27  char *s; // *sprintf(): target buffer
28  // *sscanf(): source string
29  size_t width; // specified field width
30  int prec; // specified field precision
31  va_list arg; // argument stack
32 };
33 
34 // Return the digit for a character in the given base or -1 if invalid.
35 signed char __parse_digit(char c, char base);
36 
37 // A simple base-10 only strtoui. Overflows are undefined behavior. If there are
38 // no digits, it returns zero.
39 unsigned __simple_strtoui(const char *__restrict__ nptr,
40  char **__restrict endptr);
41 
42 #ifdef __cplusplus
43 }
44 #endif
45 
46 #endif // _UTIL_H
std::uint16_t
::uint16_t uint16_t
Definition: cstdint:22
Status::i
size_t i
Definition: util.h:25
Status::prec
int prec
Definition: util.h:30
Status::current
size_t current
Definition: util.h:26
Status::arg
va_list arg
Definition: util.h:31
Status::base
signed char base
Definition: util.h:21
Status::s
char * s
Definition: util.h:27
Status
Definition: util.h:20
Status::n
size_t n
Definition: util.h:23
Status::width
size_t width
Definition: util.h:29
Status::flags
uint16_t flags
Definition: util.h:22
c
byte byte c
Definition: api.h:59