Skip to content

Instantly share code, notes, and snippets.

@arajkumar
Last active July 4, 2016 08:40
Show Gist options
  • Select an option

  • Save arajkumar/d98527d6706ea2089b33 to your computer and use it in GitHub Desktop.

Select an option

Save arajkumar/d98527d6706ea2089b33 to your computer and use it in GitHub Desktop.
#ifdef _MSC_VER
#include <windows.h>
#define gettid() ::GetCurrentThreadId()
#else
#include <stdio.h>
#include <sys/syscall.h>
#include <unistd.h>
#define gettid() syscall(SYS_gettid)
#endif
#include <stdio.h>
#define pri(x, ...) do {\
fprintf(stderr, "|%s:%d:tid(%ld)|", __FUNCTION__, __LINE__, gettid());\
fprintf(stderr, "{");\
fprintf(stderr, x, ## __VA_ARGS__);\
fprintf(stderr, "}\n");\
fflush(stderr);\
} while(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment