diff options
author | Georgios Pinitas <georgios.pinitas@arm.com> | 2017-10-12 17:34:20 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:35:24 +0000 |
commit | 7d3d1b923b7793f1cf5e29c78bfda2582522cf25 (patch) | |
tree | 7a924958ee7f4c9b7e6245170513862dcc016b87 /support/ToolchainSupport.h | |
parent | 3756186e54d77639564e999082f4bbd1ceec5a2f (diff) | |
download | ComputeLibrary-7d3d1b923b7793f1cf5e29c78bfda2582522cf25.tar.gz |
COMPMID-619: Logging interface
Change-Id: I73d1433ee7a682aeabb7540aa2ea1f6564f90aae
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/91775
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'support/ToolchainSupport.h')
-rw-r--r-- | support/ToolchainSupport.h | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/support/ToolchainSupport.h b/support/ToolchainSupport.h index b9d9103652..ab2a9fe80f 100644 --- a/support/ToolchainSupport.h +++ b/support/ToolchainSupport.h @@ -144,8 +144,8 @@ inline T trunc(T value) * @note This function implements the same behaviour as std::copysign except that it doesn't * support Integral type. The latter is not in the namespace std in some Android toolchains. * - * @param[in] x value that contains the magnitued to be used in constructing the result. - * @param[in] y value that contains the sign to be used in constructin the result. + * @param[in] x value that contains the magnitude to be used in constructing the result. + * @param[in] y value that contains the sign to be used in construct in the result. * * @return Floating-point value with magnitude of @p x and sign of @p y. */ @@ -154,6 +154,23 @@ inline T copysign(T x, T y) { return ::copysign(x, y); } + +/** Loads the data from the given location, converts them to character string equivalents + * and writes the result to a character string buffer. + * + * @param[in] s Pointer to a character string to write to + * @param[in] n Up to buf_size - 1 characters may be written, plus the null terminator + * @param[in] fmt Pointer to a null-terminated multibyte string specifying how to interpret the data. + * @param[in] args Arguments forwarded to snprintf. + * + * @return Number of characters that would have been written for a sufficiently large buffer + * if successful (not including the terminating null character), or a negative value if an error occurred. + */ +template <typename... Ts> +inline int snprintf(char *s, size_t n, const char *fmt, Ts &&... args) +{ + return ::snprintf(s, n, fmt, std::forward<Ts>(args)...); +} #else /* (__ANDROID__ || BARE_METAL) */ /** Convert integer and float values to string. * @@ -250,8 +267,8 @@ inline T trunc(T value) * @note This function implements the same behaviour as std::copysign except that it doesn't * support Integral type. The latter is not in the namespace std in some Android toolchains. * - * @param[in] x value that contains the magnitued to be used in constructing the result. - * @param[in] y value that contains the sign to be used in constructin the result. + * @param[in] x value that contains the magnitude to be used in constructing the result. + * @param[in] y value that contains the sign to be used in construct in the result. * * @return Floating-point value with magnitude of @p x and sign of @p y. */ @@ -260,6 +277,23 @@ inline T copysign(T x, T y) { return std::copysign(x, y); } + +/** Loads the data from the given location, converts them to character string equivalents + * and writes the result to a character string buffer. + * + * @param[in] s Pointer to a character string to write to + * @param[in] n Up to buf_size - 1 characters may be written, plus the null terminator + * @param[in] fmt Pointer to a null-terminated multibyte string specifying how to interpret the data. + * @param[in] args Arguments forwarded to std::snprintf. + * + * @return Number of characters that would have been written for a sufficiently large buffer + * if successful (not including the terminating null character), or a negative value if an error occurred. + */ +template <typename... Ts> +inline int snprintf(char *s, std::size_t n, const char *fmt, Ts &&... args) +{ + return std::snprintf(s, n, fmt, std::forward<Ts>(args)...); +} #endif /* (__ANDROID__ || BARE_METAL) */ inline std::string to_string(bool value) |