Detailed gem5 analysis of how data races happen

And pass niters as a thread argument to all threading implementations...
otherwise every loop has to do a memory load from the global!
This commit is contained in:
Ciro Santilli 六四事件 法轮功
2020-06-05 06:00:05 +00:00
parent 619fef4b04
commit 0d5c7f5c4c
6 changed files with 162 additions and 19 deletions

View File

@@ -39,14 +39,18 @@ int main(void) {
/* Less common case where string does not fit. Error handling would
* normally follow in a real program. */
{
int in = 1234;
char out[6];
/* The return here is the same as before.
*
* Because it is >= than the imposed limit of 6, we know that
* the write failed to fully complete. */
#if 0
/* GCC 8.3.0 with -O3 actually detects this and breaks the build.
* error: cd directive output truncated writing 2 bytes into a region of size 0 [-Werror=format-truncation=] */
int in = 1234;
char out[6];
assert(snprintf(out, sizeof(out), "ab%dcd", in) == 8);
assert(strcmp(out, "ab123") == 0);
#endif
}
#endif
return EXIT_SUCCESS;