-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b2e9861
commit 3cb0d50
Showing
13 changed files
with
97 additions
and
4 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include <stdio.h> | ||
#include <unistd.h> | ||
#include <sys/types.h> | ||
#include <sys/sysctl.h> | ||
#include <mach/mach_time.h> | ||
#include "osfreq.c" | ||
|
||
#define timebase mach_absolute_time | ||
|
||
static int tbmib[2] = { CTL_HW, HW_TB_FREQ } ; | ||
|
||
static long myround(double u) | ||
{ | ||
long result = u; | ||
while (result + 0.5 < u) result += 1; | ||
while (result - 0.5 > u) result -= 1; | ||
return result; | ||
} | ||
|
||
static long long cpufrequency = 0; | ||
static long tbcycles = 0; | ||
|
||
static void init(void) | ||
{ | ||
unsigned int tbfrequency = 0; size_t tbfrequencylen = sizeof(unsigned int); | ||
cpufrequency = osfreq(); | ||
sysctl(tbmib,2,&tbfrequency,&tbfrequencylen,0,0); | ||
if (tbfrequency > 0) | ||
tbcycles = myround(64 * (double) (unsigned long long) cpufrequency | ||
/ (double) (unsigned long long) tbfrequency); | ||
} | ||
|
||
long long cpucycles_apple(void) | ||
{ | ||
if (!cpufrequency) init(); | ||
return (timebase() * tbcycles) >> 6; | ||
} | ||
|
||
long long cpucycles_apple_persecond(void) | ||
{ | ||
if (!cpufrequency) init(); | ||
return cpufrequency; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
cpucycles apple.h version 20110616 | ||
D. J. Bernstein | ||
Public domain. | ||
*/ | ||
|
||
#ifndef CPUCYCLES_apple_h | ||
#define CPUCYCLES_apple_h | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
extern long long cpucycles_apple(void); | ||
extern long long cpucycles_apple_persecond(void); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#ifndef cpucycles_implementation | ||
#define cpucycles_implementation "apple" | ||
#define cpucycles cpucycles_apple | ||
#define cpucycles_persecond cpucycles_apple_persecond | ||
#endif | ||
|
||
#endif |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fugue with 384-bit output |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Charanjit Jutla | ||
Shai Halevi | ||
Eric Hall |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Thomas Pornin |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Thomas Pornin |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Thomas Pornin |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Thomas Pornin |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
20110609 | ||
20110617 |