-int read_single_number_file(const char *filename, unsigned long long *result) {
- char buffer[1024 + 1];
-
- int fd = open(filename, O_RDONLY, 0666);
- if(unlikely(fd == -1)) return 1;
-
- ssize_t r = read(fd, buffer, 1024);
- if(unlikely(r == -1)) {
- close(fd);
- return 2;
- }
-
- close(fd);
- *result = strtoull(buffer, NULL, 0);
- return 0;
+/*
+// poor man cycle counting
+static unsigned long tsc;
+void begin_tsc(void) {
+ unsigned long a, d;
+ asm volatile ("cpuid\nrdtsc" : "=a" (a), "=d" (d) : "0" (0) : "ebx", "ecx");
+ tsc = ((unsigned long)d << 32) | (unsigned long)a;