Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jboockmann/850dc0b677ee3148a4dd2dfff586fa09 to your computer and use it in GitHub Desktop.
Save jboockmann/850dc0b677ee3148a4dd2dfff586fa09 to your computer and use it in GitHub Desktop.
Function pointer example from the 'Towards Safe Enclaves' paper
/*
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