Created
September 2, 2018 11:28
-
-
Save jboockmann/850dc0b677ee3148a4dd2dfff586fa09 to your computer and use it in GitHub Desktop.
Function pointer example from the 'Towards Safe Enclaves' paper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Neline van Ginkel, Raoul Strackx, Jan Tobias Mühlberg, Frank Piessens | |
"Towards safe enclaves." | |
4th Workshop on Hot Issues in Security Principles and Trust (HotSpot 2016). | |
2016. | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
int count = 0; | |
void (*obs)(int); | |
void set_observer(void o(int)) { | |
obs = o; | |
} | |
void inc() { | |
count = count + 1; | |
obs(count); | |
} | |
int getcount() { | |
return count; | |
} | |
void printMe(int i) { | |
printf("%d\n", i); | |
} | |
int main(void) { | |
void (*fun_ptr)(int) = printMe; | |
set_observer(fun_ptr); | |
inc(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment