From: Mart Lubbers Date: Tue, 24 Feb 2015 15:34:52 +0000 (+0100) Subject: All done except 1 X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=c1d0478a9b9cf24970ddd4d77835935c083723d2;p=sws1-1415.git All done except 1 - Updated pdf(now with warnings for compiler flags). - Added the optional assignment 2.e. - Removed the unworking code for exercise 1. --- diff --git a/ass3/assignment3v1.pdf b/ass3/assignment3v1.pdf new file mode 100644 index 0000000..7e03b59 Binary files /dev/null and b/ass3/assignment3v1.pdf differ diff --git a/ass3/mart/sws1-assignment3-s4109503-s4202015/exercise1.c b/ass3/mart/sws1-assignment3-s4109503-s4202015/exercise1.c index 8f94702..beb6c5a 100644 --- a/ass3/mart/sws1-assignment3-s4109503-s4202015/exercise1.c +++ b/ass3/mart/sws1-assignment3-s4109503-s4202015/exercise1.c @@ -1,14 +1,7 @@ #include -#include - int main(void) { - char a = 0; - magic_function(); - char b = 0; - printf("%p\n", &a); - printf("%p\n", &b); - + printf("Ik snap hier nog even niks van...\n"); return 0; } diff --git a/ass3/mart/sws1-assignment3-s4109503-s4202015/exercise2.c b/ass3/mart/sws1-assignment3-s4109503-s4202015/exercise2.c index 30ab2a4..c5f22bb 100644 --- a/ass3/mart/sws1-assignment3-s4109503-s4202015/exercise2.c +++ b/ass3/mart/sws1-assignment3-s4109503-s4202015/exercise2.c @@ -1,12 +1,14 @@ #include +#include +#include typedef unsigned char uc; typedef unsigned __int128 uint128; void addvector(int *r, const int *a, const int *b, size_t len) { - for(int *r2 = r; r2 < r + len;r2++, a++, b++) - *r2 = *a + *b; + for(int *r2 = r; r2 < r + len; r2++) + *r2 = *a++ + *b++; } int memcmp(const void *s1, const void *s2, size_t n) @@ -35,3 +37,12 @@ int memcmp_fast(const void *s1, const void *s2, size_t n) return memcmp(s3, s4, sizeof(uint128)); return memcmp(s3, s4, n % sizeof(uint128)); } + +int memcmp_consttime(const void *s1, const void *s2, size_t n) +{ + int returnvalue = 0; + for(uc *s3 = (uc*)s1, *s4 = (uc*)s2; s3 < (uc*)s1 + n; s3++, s4++) + if(*s3 != *s4 && returnvalue == 0) + returnvalue = *s3 - *s4; + return returnvalue; +} diff --git a/ass3/mart/sws1-assignment3-s4109503-s4202015/mf.c b/ass3/mart/sws1-assignment3-s4109503-s4202015/mf.c deleted file mode 100644 index a8be370..0000000 --- a/ass3/mart/sws1-assignment3-s4109503-s4202015/mf.c +++ /dev/null @@ -1,7 +0,0 @@ -#include - -void magic_function() -{ - char a = 0; - a = a+1; -}