summaryrefslogtreecommitdiff
path: root/include/util.h
diff options
context:
space:
mode:
authorCraig Hesling <hesling@chromium.org>2019-07-29 11:12:49 -0700
committerCommit Bot <commit-bot@chromium.org>2019-07-30 23:58:20 +0000
commitd754f92d3beb9b1d7d19ec081c39dd87b964473f (patch)
tree42624cf2e36022e2e0b3bca75d69c0a648ae9493 /include/util.h
parentaed16e293cb4bd17b301ac9f1508402bcb233bb1 (diff)
downloadchrome-ec-d754f92d3beb9b1d7d19ec081c39dd87b964473f.tar.gz
util: Move __stdlib_compat to function definitions
Putting a visibility-hidden attribute in the header file is ambiguous. The compiler cannot determine which definition should be hidden (our implementation or stdlib). This serves as a slight correction to the work in crrev.com/c/1180401 . In particular, this fixes test/fuzz builds with code coverage enabled: make runtests TEST_COVERAGE=1 -j Before this fix, enabling coverage would trigger build errors, like the following: In file included from common/test_util.c:19: include/util.h:82:1: error: attribute declaration must precede definition [-Werror,-Wignored-attributes] __stdlib_compat int atoi(const char *nptr); ^ include/common.h:267:40: note: expanded from macro '__stdlib_compat' #define __stdlib_compat __attribute__((visibility("hidden"))) ^ /usr/include/stdlib.h:361:8: note: previous definition is here __NTH (atoi (const char *__nptr)) Note that enabling sanitizer on some unit tests is still broken (as it was before this CL). For example, these unit tests fail when compiling with sanitizers: make host-charge_manager_drp_charging TEST_ASAN=1 make host-charge_manager_drp_charging TEST_MSAN=1 BRANCH=none BUG=none TEST=make runtests TEST_COVERAGE=1 -j TEST=make buildall -j Change-Id: I74462c964c0ff9d3ee131450e6826cbbd6c89319 Signed-off-by: Craig Hesling <hesling@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1724936 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'include/util.h')
-rw-r--r--include/util.h44
1 files changed, 22 insertions, 22 deletions
diff --git a/include/util.h b/include/util.h
index 690b4cc1d9..04acffd988 100644
--- a/include/util.h
+++ b/include/util.h
@@ -79,30 +79,30 @@ extern "C" {
#ifndef HIDE_EC_STDLIB
/* Standard library functions */
-__stdlib_compat int atoi(const char *nptr);
-__stdlib_compat int isdigit(int c);
-__stdlib_compat int isspace(int c);
-__stdlib_compat int isalpha(int c);
-__stdlib_compat int isupper(int c);
-__stdlib_compat int isprint(int c);
-__stdlib_compat int memcmp(const void *s1, const void *s2, size_t len);
-__stdlib_compat void *memcpy(void *dest, const void *src, size_t len);
-__stdlib_compat __visible void *memset(void *dest, int c, size_t len);
-__stdlib_compat void *memmove(void *dest, const void *src, size_t len);
-__stdlib_compat void *memchr(const void *buffer, int c, size_t n);
-__stdlib_compat int strcasecmp(const char *s1, const char *s2);
-__stdlib_compat int strncasecmp(const char *s1, const char *s2, size_t size);
-__stdlib_compat size_t strlen(const char *s);
-__stdlib_compat size_t strnlen(const char *s, size_t maxlen);
-__stdlib_compat char *strncpy(char *dest, const char *src, size_t n);
-__stdlib_compat int strncmp(const char *s1, const char *s2, size_t n);
+int atoi(const char *nptr);
+int isdigit(int c);
+int isspace(int c);
+int isalpha(int c);
+int isupper(int c);
+int isprint(int c);
+int memcmp(const void *s1, const void *s2, size_t len);
+void *memcpy(void *dest, const void *src, size_t len);
+void *memset(void *dest, int c, size_t len);
+void *memmove(void *dest, const void *src, size_t len);
+void *memchr(const void *buffer, int c, size_t n);
+int strcasecmp(const char *s1, const char *s2);
+int strncasecmp(const char *s1, const char *s2, size_t size);
+size_t strlen(const char *s);
+size_t strnlen(const char *s, size_t maxlen);
+char *strncpy(char *dest, const char *src, size_t n);
+int strncmp(const char *s1, const char *s2, size_t n);
/* Like strtol(), but for integers. */
-__stdlib_compat int strtoi(const char *nptr, char **endptr, int base);
-__stdlib_compat uint64_t strtoul(const char *nptr, char **endptr, int base);
+int strtoi(const char *nptr, char **endptr, int base);
+uint64_t strtoul(const char *nptr, char **endptr, int base);
/* Like strncpy(), but guarantees null termination. */
-__stdlib_compat char *strzcpy(char *dest, const char *src, int len);
+char *strzcpy(char *dest, const char *src, int len);
/**
* Parses a boolean option from a string.
@@ -121,9 +121,9 @@ __stdlib_compat char *strzcpy(char *dest, const char *src, int len);
*
* Other strings return 0 and leave *dest unchanged.
*/
-__stdlib_compat int parse_bool(const char *s, int *dest);
+int parse_bool(const char *s, int *dest);
-__stdlib_compat int tolower(int c);
+int tolower(int c);
#endif /* !HIDE_EC_STDLIB */
/**