Skip to content

Commit

Permalink
.github/workflows/build.yml: run 'make tests'
Browse files Browse the repository at this point in the history
This enables SHA tests to check if different compilers produce the same
results.

Definitions in string.h were moved outside of __STDC_HOSTED__ to avoid
compiler warnings (promoted to errors because of -Werror) due to
incompatible implicit declaration of built-in functions.

Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
  • Loading branch information
krystian-hebel committed Apr 15, 2024
1 parent 4304942 commit 90540fe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ jobs:
run: |
make CC=${{matrix.compiler}} BITS=${{matrix.bits}} ${{matrix.lto}}
./extend_skl_only.sh
- name: make tests
run: |
make CC=${{matrix.compiler}} BITS=64 ${{matrix.lto}} tests
23 changes: 14 additions & 9 deletions include/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,31 @@

#if __STDC_HOSTED__

#include <string.h> /* memcpy, memset */
#include <string.h> /* memcpy, memset, memcmp */

/* Used in tests only */
#define memcmp(l, r, n) __builtin_memcmp(l, r, n)

#else

/* Local declaration of bits of libc */

void *memset(void *s, int c, size_t n);

void *memcpy(void *dst, const void *src, size_t n);

size_t strlen(const char *s);

#endif /* __STDC_HOSTED__ */

/*
* Local declaration of bits of libc
*
* Use __builtin_???() wherever possible to allow the compiler to perform
* optimisations (e.g. constant folding) where possible. Calls to ???() will
* be emitted as needed.
*/

void *memset(void *s, int c, size_t n);
#define memset(d, c, n) __builtin_memset(d, c, n)

void *memcpy(void *dst, const void *src, size_t n);
#define memcpy(d, s, n) __builtin_memcpy(d, s, n)

size_t strlen(const char *s);
#define strlen(s) __builtin_strlen(s)

#endif /* __STDC_HOSTED__ */
#endif /* __STRINGS_H__ */

0 comments on commit 90540fe

Please sign in to comment.