Skip to content

Instantly share code, notes, and snippets.

@haggaie
Created November 17, 2008 22:25
Show Gist options
  • Save haggaie/25935 to your computer and use it in GitHub Desktop.
Save haggaie/25935 to your computer and use it in GitHub Desktop.
Test TM memory allocation
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#ifndef _TM
#error TM not enabled
#endif
int main(int argc, char** argv)
{
printf("%s\n", argv[0]);
if (argc <= 1)
exit(1);
int size = atoi(argv[1]);
void* p;
__tm_atomic {
p = malloc(size);
__tm_retry;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment