All done except 1
authorMart Lubbers <mart@martlubbers.net>
Tue, 24 Feb 2015 15:34:52 +0000 (16:34 +0100)
committerMart Lubbers <mart@martlubbers.net>
Tue, 24 Feb 2015 15:34:52 +0000 (16:34 +0100)
- Updated pdf(now with warnings for compiler flags).
- Added the optional assignment 2.e.
- Removed the unworking code for exercise 1.

ass3/assignment3v1.pdf [new file with mode: 0644]
ass3/mart/sws1-assignment3-s4109503-s4202015/exercise1.c
ass3/mart/sws1-assignment3-s4109503-s4202015/exercise2.c
ass3/mart/sws1-assignment3-s4109503-s4202015/mf.c [deleted file]

diff --git a/ass3/assignment3v1.pdf b/ass3/assignment3v1.pdf
new file mode 100644 (file)
index 0000000..7e03b59
Binary files /dev/null and b/ass3/assignment3v1.pdf differ
index 8f94702..beb6c5a 100644 (file)
@@ -1,14 +1,7 @@
 #include <stdio.h>
-#include <stdlib.h>
-
 
 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;
 }
index 30ab2a4..c5f22bb 100644 (file)
@@ -1,12 +1,14 @@
 #include <stdlib.h>
+#include <stdio.h>
+#include <stdbool.h>
 
 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 (file)
index a8be370..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <stdio.h>
-
-void magic_function()
-{
-       char a = 0;
-       a = a+1;
-}