Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

supercop-20100803

  • Loading branch information...
commit e46797a2d81b1f22f14d8f6f2f8ffa79bd771978 1 parent d144f05
Daniel J. Bernstein authored committed
Showing with 5,958 additions and 1,860 deletions.
  1. +2 −16 cpucycles/amd64cpuinfo.c
  2. +1 −1  cpucycles/amd64cpuinfo.h
  3. +2 −14 cpucycles/celllinux.c
  4. +0 −27 cpucycles/clockmonotonic.h
  5. +0 −29 cpucycles/cpucycles-impl.c
  6. +0 −81 cpucycles/dev4.c
  7. +0 −27 cpucycles/dev4.h
  8. +62 −0 cpucycles/dev4ns.c
  9. +27 −0 cpucycles/dev4ns.h
  10. +0 −58 cpucycles/dev8.c
  11. +0 −27 cpucycles/dev8.h
  12. +14 −15 cpucycles/do
  13. +3 −26 cpucycles/gettimeofday.c
  14. +2 −16 cpucycles/ia64cpuinfo.c
  15. +1 −1  cpucycles/ia64cpuinfo.h
  16. +42 −53 cpucycles/mips.c
  17. +2 −2 cpucycles/{clockmonotonic.c → monotonic.c}
  18. +27 −0 cpucycles/monotonic.h
  19. +33 −0 cpucycles/monotonicos.c
  20. +27 −0 cpucycles/monotonicos.h
  21. +53 −0 cpucycles/osfreq.c
  22. +0 −94 cpucycles/powerpcaix.c
  23. +0 −27 cpucycles/powerpcaix.h
  24. +4 −16 cpucycles/{powerpclinux.c → powerpccpuinfo.c}
  25. +27 −0 cpucycles/powerpccpuinfo.h
  26. +0 −27 cpucycles/powerpclinux.h
  27. +64 −0 cpucycles/sparc32.c
  28. +27 −0 cpucycles/sparc32.h
  29. +0 −34 cpucycles/sparc32psrinfo.c
  30. +0 −27 cpucycles/sparc32psrinfo.h
  31. +15 −0 cpucycles/sparccpuinfo.c
  32. +27 −0 cpucycles/sparccpuinfo.h
  33. +0 −29 cpucycles/sparcpsrinfo.c
  34. +0 −27 cpucycles/sparcpsrinfo.h
  35. +2 −16 cpucycles/x86cpuinfo.c
  36. +1 −1  cpucycles/x86cpuinfo.h
  37. +1 −0  crypto_hash/cubehash1632/mips32/api.h
  38. +827 −0 crypto_hash/cubehash1632/mips32/hash.q
  39. +3,421 −0 crypto_hash/cubehash1632/mips32/hash.s
  40. +66 −92 crypto_hash/cubehash1632/ppc32/hash.q
  41. +601 −601 crypto_hash/cubehash1632/ppc32/hash.s
  42. +38 −56 crypto_hash/shavite3256/aes-instruct/SHA3api_ref.h
  43. +1 −1  crypto_hash/shavite3256/aes-instruct/api.h
  44. +324 −217 crypto_hash/shavite3256/aes-instruct/compress.h
  45. +36 −49 crypto_hash/shavite3512/aes-instruct/SHA3api_ref.h
  46. +1 −1  crypto_hash/shavite3512/aes-instruct/api.h
  47. +144 −136 crypto_hash/shavite3512/aes-instruct/compress.h
  48. +31 −15 okcompilers/abiname.c
  49. +1 −0  sinceepoch/time.c
  50. +1 −1  version
View
18 cpucycles/amd64cpuinfo.c
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <sys/types.h>
+#include "osfreq.c"
long long cpucycles_amd64cpuinfo(void)
{
@@ -11,20 +12,5 @@ long long cpucycles_amd64cpuinfo(void)
long long cpucycles_amd64cpuinfo_persecond(void)
{
- FILE *f;
- double result;
- int s;
-
- f = fopen("/proc/cpuinfo","r");
- if (!f) return 0;
-
- for (;;) {
- s = fscanf(f,"cpu MHz : %lf",&result);
- if (s > 0) break;
- if (s == 0) s = fscanf(f,"%*[^\n]\n");
- if (s < 0) { result = 0; break; }
- }
-
- fclose(f);
- return 1000000.0 * result;
+ return osfreq();
}
View
2  cpucycles/amd64cpuinfo.h
@@ -1,5 +1,5 @@
/*
-cpucycles amd64cpuinfo.h version 20060318
+cpucycles amd64cpuinfo.h version 20100803
D. J. Bernstein
Public domain.
*/
View
16 cpucycles/celllinux.c
@@ -4,6 +4,7 @@
#include <sys/time.h>
#include <sys/types.h>
#include <spu_mfcio.h>
+#include "osfreq.c"
static long myround(double u)
{
@@ -49,27 +50,14 @@ static double guesstbcycles(void)
static void init(void)
{
- FILE *f;
- int s;
int loop;
double guess1;
double guess2;
spu_write_decrementer(0xffffffff);
- f = fopen("/proc/cpuinfo","r");
- if (!f) return;
-
- for (;;) {
- s = fscanf(f," clock : %lf MHz",&cpufrequency);
- if (s > 0) break;
- if (s == 0) s = fscanf(f,"%*[^\n]\n");
- if (s < 0) { cpufrequency = 0; break; }
- }
-
- fclose(f);
+ cpufrequency = osfreq();
if (!cpufrequency) return;
- cpufrequency *= 1000000.0;
for (loop = 0;loop < 100;++loop) {
guess1 = guesstbcycles();
View
27 cpucycles/clockmonotonic.h
@@ -1,27 +0,0 @@
-/*
-cpucycles clockmonotonic.h version 20060318
-D. J. Bernstein
-Public domain.
-*/
-
-#ifndef CPUCYCLES_clockmonotonic_h
-#define CPUCYCLES_clockmonotonic_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern long long cpucycles_clockmonotonic(void);
-extern long long cpucycles_clockmonotonic_persecond(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#ifndef cpucycles_implementation
-#define cpucycles_implementation "clockmonotonic"
-#define cpucycles cpucycles_clockmonotonic
-#define cpucycles_persecond cpucycles_clockmonotonic_persecond
-#endif
-
-#endif
View
29 cpucycles/cpucycles-impl.c
@@ -1,29 +0,0 @@
-#include <stdio.h>
-#include <sys/types.h>
-
-long long cpucycles_x86cpuinfo(void)
-{
- long long result;
- asm volatile(".byte 15;.byte 49" : "=A" (result));
- return result;
-}
-
-long long cpucycles_x86cpuinfo_persecond(void)
-{
- FILE *f;
- double result;
- int s;
-
- f = fopen("/proc/cpuinfo","r");
- if (!f) return 0;
-
- for (;;) {
- s = fscanf(f,"cpu MHz : %lf",&result);
- if (s > 0) break;
- if (s == 0) s = fscanf(f,"%*[^\n]\n");
- if (s < 0) { result = 0; break; }
- }
-
- fclose(f);
- return 1000000.0 * result;
-}
View
81 cpucycles/dev4.c
@@ -1,81 +0,0 @@
-#include <sys/types.h>
-#include <fcntl.h>
-#include <time.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/time.h>
-
-static int fddev = -1;
-
-static long long tod(void)
-{
- struct timeval t;
- gettimeofday(&t,(struct timezone *) 0);
- return t.tv_sec * (long long) 1000000 + t.tv_usec;
-}
-
-static long long cycles32(void)
-{
- unsigned int result;
- if (read(fddev,&result,4) == 4) return 0xffffffff & (unsigned long long) result;
- return 0;
-}
-
-static long long firstcycles32;
-static long long firsttod;
-static long long lastcycles32;
-static long long lasttod;
-static double mhz = 0;
-
-static void init(void)
-{
- if (fddev == -1) fddev = open("/dev/cpucycles4",O_RDONLY);
-
- firstcycles32 = cycles32();
- firsttod = tod();
-
- do {
- lastcycles32 = cycles32();
- lasttod = tod();
- } while (lasttod - firsttod < 10000);
-
- lastcycles32 -= firstcycles32; lastcycles32 &= 0xffffffff;
- lasttod -= firsttod;
-
- mhz = (double) lastcycles32 / (double) lasttod;
-}
-
-long long cpucycles_dev4(void)
-{
- double x;
- long long y;
-
- if (!mhz) init();
-
- lastcycles32 = cycles32();
- lasttod = tod();
-
- lastcycles32 -= firstcycles32; lastcycles32 &= 0xffffffff;
- lasttod -= firsttod;
-
- /* Number of cycles since firstcycles32 is lastcycles32 + 2^32 y for unknown y. */
- /* Number of microseconds since firsttod is lasttod. */
-
- x = (lasttod * mhz - lastcycles32) * 0.00000000023283064365386962890625;
- y = x;
- while (x > y + 0.5) y += 1;
- while (x < y - 0.5) y -= 1;
-
- y *= 4294967296ULL;
- lastcycles32 += y;
-
- mhz = (double) lastcycles32 / (double) lasttod;
-
- return firstcycles32 + lastcycles32;
-}
-
-long long cpucycles_dev4_persecond(void)
-{
- if (!mhz) init();
- return 1000000.0 * mhz;
-}
View
27 cpucycles/dev4.h
@@ -1,27 +0,0 @@
-/*
-cpucycles dev4.h version 20100712
-D. J. Bernstein
-Public domain.
-*/
-
-#ifndef CPUCYCLES_dev4_h
-#define CPUCYCLES_dev4_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern long long cpucycles_dev4(void);
-extern long long cpucycles_dev4_persecond(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#ifndef cpucycles_implementation
-#define cpucycles_implementation "dev4"
-#define cpucycles cpucycles_dev4
-#define cpucycles_persecond cpucycles_dev4_persecond
-#endif
-
-#endif
View
62 cpucycles/dev4ns.c
@@ -0,0 +1,62 @@
+#include <sys/types.h>
+#include <fcntl.h>
+#include <time.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+static int fddev = -1;
+static int prev[3];
+static unsigned long long prevcycles = 0;
+static int now[3];
+static long long cyclespersec = 0;
+
+static void readdev(unsigned int *result)
+{
+ if (read(fddev,result,12) == 12) return;
+ result[0] = result[1] = result[2] = 0;
+}
+
+long long cpucycles_dev4ns(void)
+{
+ unsigned long long delta4;
+ int deltan;
+ int deltas;
+ unsigned long long guesscycles;
+
+ if (fddev == -1) {
+ fddev = open("/dev/cpucycles4ns",O_RDONLY);
+ readdev(prev);
+ }
+
+ readdev(now);
+ delta4 = (unsigned int) (now[0] - prev[0]); /* unsigned change in number of cycles mod 2^32 */
+ deltan = now[1] - prev[1]; /* signed change in number of nanoseconds mod 10^9 */
+ deltas = now[2] - prev[2]; /* signed change in number of seconds */
+ if ((deltas == 0 && deltan < 200000000) || (deltas == 1 && deltan < -800000000))
+ return prevcycles + delta4;
+
+ prev[0] = now[0];
+ prev[1] = now[1];
+ prev[2] = now[2];
+
+ if ((deltas == 0 && deltan < 300000000) || (deltas == 1 && deltan < -700000000)) {
+ // actual number of cycles cannot have increased by 2^32 in <0.3ms
+ cyclespersec = 1000000000 * (unsigned long long) delta4;
+ cyclespersec /= deltan + 1000000000 * (long long) deltas;
+ } else {
+ guesscycles = deltas * cyclespersec;
+ guesscycles += (deltan * cyclespersec) / 1000000000;
+ while (delta4 + 2147483648ULL < guesscycles) delta4 += 4294967296ULL;
+ /* XXX: could do longer-term extrapolation here */
+ }
+
+ prevcycles += delta4;
+ return prevcycles;
+}
+
+long long cpucycles_dev4ns_persecond(void)
+{
+ while (!cyclespersec) cpucycles_dev4ns();
+ return cyclespersec;
+}
View
27 cpucycles/dev4ns.h
@@ -0,0 +1,27 @@
+/*
+cpucycles dev4ns.h version 20100803
+D. J. Bernstein
+Public domain.
+*/
+
+#ifndef CPUCYCLES_dev4ns_h
+#define CPUCYCLES_dev4ns_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern long long cpucycles_dev4ns(void);
+extern long long cpucycles_dev4ns_persecond(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifndef cpucycles_implementation
+#define cpucycles_implementation "dev4ns"
+#define cpucycles cpucycles_dev4ns
+#define cpucycles_persecond cpucycles_dev4ns_persecond
+#endif
+
+#endif
View
58 cpucycles/dev8.c
@@ -1,58 +0,0 @@
-#include <sys/types.h>
-#include <fcntl.h>
-#include <time.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/time.h>
-
-static int fddev = -1;
-
-static long long cycles(void)
-{
- unsigned long long result;
- if (read(fddev,&result,8) == 8) return result;
- return 0;
-}
-
-long long cpucycles_dev8(void)
-{
- if (fddev == -1) fddev = open("/dev/cpucycles8",O_RDONLY);
- return cycles();
-}
-
-static long long tod(void)
-{
- struct timeval t;
- gettimeofday(&t,(struct timezone *) 0);
- return t.tv_sec * (long long) 1000000 + t.tv_usec;
-}
-
-static long long persecond = 0;
-static long long firstcycles;
-static long long lastcycles;
-static long long firsttod;
-static long long lasttod;
-
-static void init(void)
-{
- if (fddev == -1) fddev = open("/dev/cpucycles8",O_RDONLY);
-
- firstcycles = cycles();
- firsttod = tod();
-
- do {
- lastcycles = cycles();
- lasttod = tod();
- } while (lasttod - firsttod < 100000);
-
- lastcycles -= firstcycles;
- lasttod -= firsttod;
-
- persecond = (1000000 * lastcycles) / lasttod;
-}
-
-long long cpucycles_dev8_persecond(void)
-{
- if (!persecond) init();
- return persecond;
-}
View
27 cpucycles/dev8.h
@@ -1,27 +0,0 @@
-/*
-cpucycles dev8.h version 20100801
-D. J. Bernstein
-Public domain.
-*/
-
-#ifndef CPUCYCLES_dev8_h
-#define CPUCYCLES_dev8_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern long long cpucycles_dev8(void);
-extern long long cpucycles_dev8_persecond(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#ifndef cpucycles_implementation
-#define cpucycles_implementation "dev8"
-#define cpucycles cpucycles_dev8
-#define cpucycles_persecond cpucycles_dev8_persecond
-#endif
-
-#endif
View
29 cpucycles/do
@@ -9,9 +9,8 @@ okabi | (
(
case "$abi" in
ppc*)
- echo powerpclinux
+ echo powerpccpuinfo
echo powerpcmacos
- echo powerpcaix
;;
amd64*)
echo amd64tscfreq
@@ -28,8 +27,11 @@ okabi | (
echo celllinux
;;
sparc*)
- echo sparcpsrinfo
- echo sparc32psrinfo
+ echo sparccpuinfo
+ echo sparc32
+ ;;
+ mips*)
+ echo mips
;;
hppa*)
echo hppapstat
@@ -40,8 +42,8 @@ okabi | (
sgi*)
echo sgi
;;
- mips*)
- echo mips
+ arm*)
+ echo dev4ns
;;
esac
@@ -53,21 +55,18 @@ okabi | (
echo x86cpuspeed
echo x86estimate
echo ia64cpuinfo
- echo powerpclinux
+ echo powerpccpuinfo
echo powerpcmacos
- echo powerpcaix
echo celllinux
- echo sparcpsrinfo
- echo sparc32psrinfo
+ echo sparccpuinfo
+ echo sparc32
echo mips
echo hppapstat
echo alpha
echo sgi
-
- echo dev8
- echo dev4
-
- echo clockmonotonic
+ echo dev4ns
+ echo monotoniccpuinfo
+ echo monotonic
echo gettimeofday
) | (
while read n
View
29 cpucycles/gettimeofday.c
@@ -2,37 +2,14 @@
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
+#include <sys/types.h>
+#include "osfreq.c"
static double cpufrequency = 0;
static void init(void)
{
- FILE *f;
- double result;
- int s;
-
- f = fopen("/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq", "r");
- if (f) {
- s = fscanf(f,"%lf",&result);
- fclose(f);
- if (s > 0) {
- cpufrequency = 1000.0 * result;
- return;
- }
- }
-
- f = fopen("/proc/cpuinfo","r");
- if (!f) return;
-
- for (;;) {
- s = fscanf(f,"cpu MHz : %lf",&result);
- if (s > 0) break;
- if (s == 0) s = fscanf(f,"%*[^\n]\n");
- if (s < 0) { result = 0; break; }
- }
- fclose(f);
-
- cpufrequency = 1000000.0 * result;
+ cpufrequency = osfreq();
}
long long cpucycles_gettimeofday(void)
View
18 cpucycles/ia64cpuinfo.c
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <sys/types.h>
+#include "osfreq.c"
long long cpucycles_ia64cpuinfo(void)
{
@@ -10,20 +11,5 @@ long long cpucycles_ia64cpuinfo(void)
long long cpucycles_ia64cpuinfo_persecond(void)
{
- FILE *f;
- double result;
- int s;
-
- f = fopen("/proc/cpuinfo","r");
- if (!f) return 0;
-
- for (;;) {
- s = fscanf(f,"cpu MHz : %lf",&result);
- if (s > 0) break;
- if (s == 0) s = fscanf(f,"%*[^\n]\n");
- if (s < 0) { result = 0; break; }
- }
-
- fclose(f);
- return 1000000.0 * result;
+ return osfreq();
}
View
2  cpucycles/ia64cpuinfo.h
@@ -1,5 +1,5 @@
/*
-cpucycles ia64cpuinfo.h version 20070118
+cpucycles ia64cpuinfo.h version 20100803
D. J. Bernstein
Public domain.
*/
View
95 cpucycles/mips.c
@@ -1,5 +1,5 @@
/*
-cpucycles/mips.c version 20100802
+cpucycles/mips.c version 20100803
D. J. Bernstein
Public domain.
*/
@@ -9,68 +9,57 @@ Public domain.
#include <unistd.h>
#include <sys/time.h>
-static unsigned long long tod(void)
-{
- struct timeval t;
- gettimeofday(&t,(struct timezone *) 0);
- return t.tv_sec * (long long) 1000 + t.tv_usec / 1000;
-}
+static int prev[3];
+static unsigned long long prevcycles = 0;
+static int now[3];
+static long long cyclespersec = 0;
-static unsigned int mfc(void)
+static void readticks(unsigned int *result)
{
+ struct timeval t;
unsigned int cc;
asm volatile(".byte 59; .byte 16; .byte 2; .byte 124; move %0,$2" : "=r"(cc) : : "$2");
- return cc;
-}
-
-static unsigned int firstmfc;
-static unsigned long long firsttod;
-static unsigned int lastmfc;
-static unsigned long long lasttod;
-static unsigned long long khz = 0;
-
-static void init(void)
-{
- firstmfc = mfc();
- firsttod = tod();
-
- do {
- lastmfc = mfc();
- lasttod = tod() - firsttod;
- } while (lasttod < 100);
- lastmfc -= firstmfc;
-
- khz = lastmfc / lasttod;
+ gettimeofday(&t,(struct timezone *) 0);
+ result[0] = cc;
+ result[1] = t.tv_usec;
+ result[2] = t.tv_sec;
}
long long cpucycles_mips(void)
{
- long long x;
- long long y;
-
- if (!khz) init();
-
- lastmfc = mfc();
- lasttod = tod();
-
- lastmfc -= firstmfc;
- lasttod -= firsttod;
-
- x = lasttod * khz;
-
- y = x - lastmfc;
- y += 2147483648ULL;
- y >>= 32;
- y <<= 32;
- y += lastmfc;
-
- khz = y / lasttod;
-
- return (y + firstmfc) * SCALE;
+ unsigned long long delta4;
+ int deltan;
+ int deltas;
+ unsigned long long guesscycles;
+
+ readticks(now);
+ delta4 = (unsigned int) (now[0] - prev[0]); /* unsigned change in number of cycles mod 2^32 */
+ deltan = now[1] - prev[1]; /* signed change in number of nanoseconds mod 10^9 */
+ deltas = now[2] - prev[2]; /* signed change in number of seconds */
+ if ((deltas == 0 && deltan < 200000) || (deltas == 1 && deltan < -800000))
+ return (prevcycles + delta4) * SCALE;
+
+ prev[0] = now[0];
+ prev[1] = now[1];
+ prev[2] = now[2];
+
+ if ((deltas == 0 && deltan < 300000) || (deltas == 1 && deltan < -700000)) {
+ // actual number of cycles cannot have increased by 2^32 in <0.3ms
+ cyclespersec = 1000000 * (unsigned long long) delta4;
+ cyclespersec /= deltan + 1000000 * (long long) deltas;
+ } else {
+ guesscycles = deltas * cyclespersec;
+ guesscycles += (deltan * cyclespersec) / 1000000;
+ while (delta4 + 2147483648ULL < guesscycles) delta4 += 4294967296ULL;
+ /* XXX: could do longer-term extrapolation here */
+ }
+
+ prevcycles += delta4;
+ return prevcycles * SCALE;
}
long long cpucycles_mips_persecond(void)
{
- if (!khz) init();
- return SCALE * 1000 * khz;
+ while (!cyclespersec) cpucycles_mips();
+ return cyclespersec * SCALE;
}
View
4 cpucycles/clockmonotonic.c → cpucycles/monotonic.c
@@ -14,7 +14,7 @@ static void init(void)
cpufrequency = result;
}
-long long cpucycles_clockmonotonic(void)
+long long cpucycles_monotonic(void)
{
double result;
struct timespec t;
@@ -27,7 +27,7 @@ long long cpucycles_clockmonotonic(void)
return result;
}
-long long cpucycles_clockmonotonic_persecond(void)
+long long cpucycles_monotonic_persecond(void)
{
if (!cpufrequency) init();
return cpufrequency;
View
27 cpucycles/monotonic.h
@@ -0,0 +1,27 @@
+/*
+cpucycles monotonic.h version 20100803
+D. J. Bernstein
+Public domain.
+*/
+
+#ifndef CPUCYCLES_monotonic_h
+#define CPUCYCLES_monotonic_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern long long cpucycles_monotonic(void);
+extern long long cpucycles_monotonic_persecond(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifndef cpucycles_implementation
+#define cpucycles_implementation "monotonic"
+#define cpucycles cpucycles_monotonic
+#define cpucycles_persecond cpucycles_monotonic_persecond
+#endif
+
+#endif
View
33 cpucycles/monotonicos.c
@@ -0,0 +1,33 @@
+#include <time.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#include "osfreq.c"
+
+static double cpufrequency = 0;
+
+static void init(void)
+{
+ cpufrequency = osfreq();
+}
+
+long long cpucycles_monotonicos(void)
+{
+ double result;
+ struct timespec t;
+ if (!cpufrequency) init();
+ clock_gettime(CLOCK_MONOTONIC,&t);
+ result = t.tv_nsec;
+ result *= 0.000000001;
+ result += (double) t.tv_sec;
+ result *= cpufrequency;
+ return result;
+}
+
+long long cpucycles_monotonicos_persecond(void)
+{
+ if (!cpufrequency) init();
+ return cpufrequency;
+}
View
27 cpucycles/monotonicos.h
@@ -0,0 +1,27 @@
+/*
+cpucycles monotonicos.h version 20100803
+D. J. Bernstein
+Public domain.
+*/
+
+#ifndef CPUCYCLES_monotonicos_h
+#define CPUCYCLES_monotonicos_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern long long cpucycles_monotonicos(void);
+extern long long cpucycles_monotonicos_persecond(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifndef cpucycles_implementation
+#define cpucycles_implementation "monotonicos"
+#define cpucycles cpucycles_monotonicos
+#define cpucycles_persecond cpucycles_monotonicos_persecond
+#endif
+
+#endif
View
53 cpucycles/osfreq.c
@@ -0,0 +1,53 @@
+static double osfreq(void)
+{
+ FILE *f;
+ double result;
+ int s;
+
+ f = fopen("/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq", "r");
+ if (f) {
+ s = fscanf(f,"%lf",&result);
+ fclose(f);
+ if (s > 0) return 1000.0 * result;
+ }
+
+ f = fopen("/sys/devices/system/cpu/cpu0/clock_tick", "r");
+ if (f) {
+ s = fscanf(f,"%lf",&result);
+ fclose(f);
+ if (s > 0) return result;
+ }
+
+ f = fopen("/proc/cpuinfo","r");
+ if (f) {
+ for (;;) {
+ s = fscanf(f,"cpu MHz : %lf",&result);
+ if (s > 0) break;
+ if (s == 0) s = fscanf(f,"%*[^\n]\n");
+ if (s < 0) { result = 0; break; }
+ }
+ fclose(f);
+ if (result) return 1000000.0 * result;
+ }
+
+ f = popen("/usr/sbin/lsattr -E -l proc0 -a frequency 2>/dev/null","r");
+ if (f) {
+ s = fscanf(f,"frequency %lf",&result);
+ pclose(f);
+ if (s > 0) return result;
+ }
+
+ f = popen("/usr/sbin/psrinfo -v 2>/dev/null","r");
+ if (f) {
+ for (;;) {
+ s = fscanf(f," The %*s processor operates at %lf MHz",&result);
+ if (s > 0) break;
+ if (s == 0) s = fscanf(f,"%*[^\n]\n");
+ if (s < 0) { result = 0; break; }
+ }
+ pclose(f);
+ if (result) return 1000000.0 * result;
+ }
+
+ return 0;
+}
View
94 cpucycles/powerpcaix.c
@@ -1,94 +0,0 @@
-#include <time.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <sys/types.h>
-
-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 microseconds(void)
-{
- struct timeval t;
- gettimeofday(&t,(struct timezone *) 0);
- return t.tv_sec * (long long) 1000000 + t.tv_usec;
-}
-
-static long long timebase(void)
-{
- unsigned long high;
- unsigned long low;
- unsigned long newhigh;
- unsigned long long result;
- asm volatile(
- "7:mftbu %0;mftb %1;mftbu %2;cmpw %0,%2;bne 7b"
- : "=r" (high), "=r" (low), "=r" (newhigh)
- );
- result = high;
- result <<= 32;
- result |= low;
- return result;
-}
-
-static double cpufrequency = 0;
-static long tbcycles = 0;
-
-static double guesstbcycles(void)
-{
- long long tb0; long long us0;
- long long tb1; long long us1;
-
- tb0 = timebase();
- us0 = microseconds();
- do {
- tb1 = timebase();
- us1 = microseconds();
- } while (us1 - us0 < 10000 || tb1 - tb0 < 1000);
- if (tb1 <= tb0) return 0;
- tb1 -= tb0;
- us1 -= us0;
- return (cpufrequency * 0.000001 * (double) us1) / (double) tb1;
-}
-
-static void init(void)
-{
- FILE *f;
- int loop;
- double guess1;
- double guess2;
-
- f = popen("/usr/sbin/lsattr -E -l proc0 -a frequency","r");
- if (!f) return;
- if (fscanf(f,"frequency %lf",&cpufrequency) < 1) cpufrequency = 0;
- pclose(f);
- if (!cpufrequency) return;
-
- for (loop = 0;loop < 100;++loop) {
- guess1 = guesstbcycles();
- guess2 = guesstbcycles();
- tbcycles = myround(guess1);
- if (guess1 - tbcycles > 0.1) continue;
- if (tbcycles - guess1 > 0.1) continue;
- if (guess2 - tbcycles > 0.1) continue;
- if (tbcycles - guess2 > 0.1) continue;
- return;
- }
- tbcycles = 0;
-}
-
-long long cpucycles_powerpcaix(void)
-{
- if (!tbcycles) init();
- return timebase() * tbcycles;
-}
-
-long long cpucycles_powerpcaix_persecond(void)
-{
- if (!tbcycles) init();
- return cpufrequency;
-}
View
27 cpucycles/powerpcaix.h
@@ -1,27 +0,0 @@
-/*
-cpucycles powerpcaix.h version 20060318
-D. J. Bernstein
-Public domain.
-*/
-
-#ifndef CPUCYCLES_powerpcaix_h
-#define CPUCYCLES_powerpcaix_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern long long cpucycles_powerpcaix(void);
-extern long long cpucycles_powerpcaix_persecond(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#ifndef cpucycles_implementation
-#define cpucycles_implementation "powerpcaix"
-#define cpucycles cpucycles_powerpcaix
-#define cpucycles_persecond cpucycles_powerpcaix_persecond
-#endif
-
-#endif
View
20 cpucycles/powerpclinux.c → cpucycles/powerpccpuinfo.c
@@ -3,6 +3,7 @@
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
+#include "osfreq.c"
static long myround(double u)
{
@@ -59,25 +60,12 @@ static double guesstbcycles(void)
static void init(void)
{
- FILE *f;
- int s;
int loop;
double guess1;
double guess2;
- f = fopen("/proc/cpuinfo","r");
- if (!f) return;
-
- for (;;) {
- s = fscanf(f," clock : %lf MHz",&cpufrequency);
- if (s > 0) break;
- if (s == 0) s = fscanf(f,"%*[^\n]\n");
- if (s < 0) { cpufrequency = 0; break; }
- }
-
- fclose(f);
+ cpufrequency = osfreq();
if (!cpufrequency) return;
- cpufrequency *= 1000000.0;
for (tbshift = 0;tbshift < 10;++tbshift) {
for (loop = 0;loop < 100;++loop) {
@@ -94,13 +82,13 @@ static void init(void)
tbcycles = 0;
}
-long long cpucycles_powerpclinux(void)
+long long cpucycles_powerpccpuinfo(void)
{
if (!tbcycles) init();
return timebase() * tbcycles;
}
-long long cpucycles_powerpclinux_persecond(void)
+long long cpucycles_powerpccpuinfo_persecond(void)
{
if (!tbcycles) init();
return cpufrequency;
View
27 cpucycles/powerpccpuinfo.h
@@ -0,0 +1,27 @@
+/*
+cpucycles powerpccpuinfo.h version 20100803
+D. J. Bernstein
+Public domain.
+*/
+
+#ifndef CPUCYCLES_powerpccpuinfo_h
+#define CPUCYCLES_powerpccpuinfo_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern long long cpucycles_powerpccpuinfo(void);
+extern long long cpucycles_powerpccpuinfo_persecond(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifndef cpucycles_implementation
+#define cpucycles_implementation "powerpccpuinfo"
+#define cpucycles cpucycles_powerpccpuinfo
+#define cpucycles_persecond cpucycles_powerpccpuinfo_persecond
+#endif
+
+#endif
View
27 cpucycles/powerpclinux.h
@@ -1,27 +0,0 @@
-/*
-cpucycles powerpclinux.h version 20060319
-D. J. Bernstein
-Public domain.
-*/
-
-#ifndef CPUCYCLES_powerpclinux_h
-#define CPUCYCLES_powerpclinux_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern long long cpucycles_powerpclinux(void);
-extern long long cpucycles_powerpclinux_persecond(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#ifndef cpucycles_implementation
-#define cpucycles_implementation "powerpclinux"
-#define cpucycles cpucycles_powerpclinux
-#define cpucycles_persecond cpucycles_powerpclinux_persecond
-#endif
-
-#endif
View
64 cpucycles/sparc32.c
@@ -0,0 +1,64 @@
+/*
+cpucycles/sparc32.c version 20100803
+D. J. Bernstein
+Public domain.
+*/
+
+#include <time.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+static int prev[3];
+static unsigned long long prevcycles = 0;
+static int now[3];
+static long long cyclespersec = 0;
+
+static void readticks(unsigned int *result)
+{
+ struct timeval t;
+ unsigned int cc;
+ asm volatile(".word 0x93410000;.word 0x91327020;mov %%g0,%0" : "=r" (cc) : : "%g0");
+ gettimeofday(&t,(struct timezone *) 0);
+ result[0] = cc;
+ result[1] = t.tv_usec;
+ result[2] = t.tv_sec;
+}
+
+long long cpucycles_sparc32(void)
+{
+ unsigned long long delta4;
+ int deltan;
+ int deltas;
+ unsigned long long guesscycles;
+
+ readticks(now);
+ delta4 = (unsigned int) (now[0] - prev[0]); /* unsigned change in number of cycles mod 2^32 */
+ deltan = now[1] - prev[1]; /* signed change in number of nanoseconds mod 10^9 */
+ deltas = now[2] - prev[2]; /* signed change in number of seconds */
+ if ((deltas == 0 && deltan < 200000) || (deltas == 1 && deltan < -800000))
+ return prevcycles + delta4;
+
+ prev[0] = now[0];
+ prev[1] = now[1];
+ prev[2] = now[2];
+
+ if ((deltas == 0 && deltan < 300000) || (deltas == 1 && deltan < -700000)) {
+ // actual number of cycles cannot have increased by 2^32 in <0.3ms
+ cyclespersec = 1000000 * (unsigned long long) delta4;
+ cyclespersec /= deltan + 1000000 * (long long) deltas;
+ } else {
+ guesscycles = deltas * cyclespersec;
+ guesscycles += (deltan * cyclespersec) / 1000000;
+ while (delta4 + 2147483648ULL < guesscycles) delta4 += 4294967296ULL;
+ /* XXX: could do longer-term extrapolation here */
+ }
+
+ prevcycles += delta4;
+ return prevcycles;
+}
+
+long long cpucycles_sparc32_persecond(void)
+{
+ while (!cyclespersec) cpucycles_sparc32();
+ return cyclespersec;
+}
View
27 cpucycles/sparc32.h
@@ -0,0 +1,27 @@
+/*
+cpucycles sparc32.h version 20100803
+D. J. Bernstein
+Public domain.
+*/
+
+#ifndef CPUCYCLES_sparc32_h
+#define CPUCYCLES_sparc32_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern long long cpucycles_sparc32(void);
+extern long long cpucycles_sparc32_persecond(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifndef cpucycles_implementation
+#define cpucycles_implementation "sparc32"
+#define cpucycles cpucycles_sparc32
+#define cpucycles_persecond cpucycles_sparc32_persecond
+#endif
+
+#endif
View
34 cpucycles/sparc32psrinfo.c
@@ -1,34 +0,0 @@
-#include <stdio.h>
-#include <sys/types.h>
-
-long long cpucycles_sparc32psrinfo(void)
-{
- long long result;
- asm volatile(
- ".word 0x93410000;.word 0x91327020;mov %%g0,%0"
- : "=r" (result)
- :
- : "%g0"
- );
- return result;
-}
-
-long long cpucycles_sparc32psrinfo_persecond(void)
-{
- FILE *f;
- double result;
- int s;
-
- f = popen("/usr/sbin/psrinfo -v","r");
- if (!f) return 0;
-
- for (;;) {
- s = fscanf(f," The %*s processor operates at %lf MHz",&result);
- if (s > 0) break;
- if (s == 0) s = fscanf(f,"%*[^\n]\n");
- if (s < 0) { result = 0; break; }
- }
-
- pclose(f);
- return 1000000.0 * result;
-}
View
27 cpucycles/sparc32psrinfo.h
@@ -1,27 +0,0 @@
-/*
-cpucycles sparc32psrinfo.h version 20060319
-D. J. Bernstein
-Public domain.
-*/
-
-#ifndef CPUCYCLES_sparc32psrinfo_h
-#define CPUCYCLES_sparc32psrinfo_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern long long cpucycles_sparc32psrinfo(void);
-extern long long cpucycles_sparc32psrinfo_persecond(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#ifndef cpucycles_implementation
-#define cpucycles_implementation "sparc32psrinfo"
-#define cpucycles cpucycles_sparc32psrinfo
-#define cpucycles_persecond cpucycles_sparc32psrinfo_persecond
-#endif
-
-#endif
View
15 cpucycles/sparccpuinfo.c
@@ -0,0 +1,15 @@
+#include <stdio.h>
+#include <sys/types.h>
+#include "osfreq.c"
+
+long long cpucycles_sparccpuinfo(void)
+{
+ long long result;
+ asm volatile("rd %%tick,%0" : "=r" (result));
+ return result;
+}
+
+long long cpucycles_sparccpuinfo_persecond(void)
+{
+ return osfreq();
+}
View
27 cpucycles/sparccpuinfo.h
@@ -0,0 +1,27 @@
+/*
+cpucycles sparccpuinfo.h version 20100803
+D. J. Bernstein
+Public domain.
+*/
+
+#ifndef CPUCYCLES_sparccpuinfo_h
+#define CPUCYCLES_sparccpuinfo_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern long long cpucycles_sparccpuinfo(void);
+extern long long cpucycles_sparccpuinfo_persecond(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifndef cpucycles_implementation
+#define cpucycles_implementation "sparccpuinfo"
+#define cpucycles cpucycles_sparccpuinfo
+#define cpucycles_persecond cpucycles_sparccpuinfo_persecond
+#endif
+
+#endif
View
29 cpucycles/sparcpsrinfo.c
@@ -1,29 +0,0 @@
-#include <stdio.h>
-#include <sys/types.h>
-
-long long cpucycles_sparcpsrinfo(void)
-{
- long long result;
- asm volatile("rd %%tick,%0" : "=r" (result));
- return result;
-}
-
-long long cpucycles_sparcpsrinfo_persecond(void)
-{
- FILE *f;
- double result;
- int s;
-
- f = popen("/usr/sbin/psrinfo -v","r");
- if (!f) return 0;
-
- for (;;) {
- s = fscanf(f," The %*s processor operates at %lf MHz",&result);
- if (s > 0) break;
- if (s == 0) s = fscanf(f,"%*[^\n]\n");
- if (s < 0) { result = 0; break; }
- }
-
- pclose(f);
- return 1000000.0 * result;
-}
View
27 cpucycles/sparcpsrinfo.h
@@ -1,27 +0,0 @@
-/*
-cpucycles sparcpsrinfo.h version 20060318
-D. J. Bernstein
-Public domain.
-*/
-
-#ifndef CPUCYCLES_sparcpsrinfo_h
-#define CPUCYCLES_sparcpsrinfo_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern long long cpucycles_sparcpsrinfo(void);
-extern long long cpucycles_sparcpsrinfo_persecond(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#ifndef cpucycles_implementation
-#define cpucycles_implementation "sparcpsrinfo"
-#define cpucycles cpucycles_sparcpsrinfo
-#define cpucycles_persecond cpucycles_sparcpsrinfo_persecond
-#endif
-
-#endif
View
18 cpucycles/x86cpuinfo.c
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <sys/types.h>
+#include "osfreq.c"
long long cpucycles_x86cpuinfo(void)
{
@@ -10,20 +11,5 @@ long long cpucycles_x86cpuinfo(void)
long long cpucycles_x86cpuinfo_persecond(void)
{
- FILE *f;
- double result;
- int s;
-
- f = fopen("/proc/cpuinfo","r");
- if (!f) return 0;
-
- for (;;) {
- s = fscanf(f,"cpu MHz : %lf",&result);
- if (s > 0) break;
- if (s == 0) s = fscanf(f,"%*[^\n]\n");
- if (s < 0) { result = 0; break; }
- }
-
- fclose(f);
- return 1000000.0 * result;
+ return osfreq();
}
View
2  cpucycles/x86cpuinfo.h
@@ -1,5 +1,5 @@
/*
-cpucycles x86cpuinfo.h version 20060318
+cpucycles x86cpuinfo.h version 20100803
D. J. Bernstein
Public domain.
*/
View
1  crypto_hash/cubehash1632/mips32/api.h
@@ -0,0 +1 @@
+#define CRYPTO_BYTES 64
View
827 crypto_hash/cubehash1632/mips32/hash.q
@@ -0,0 +1,827 @@
+int32 out
+int32 in
+int32 inlenlow
+int32 inlenhigh
+int32 result
+
+input out
+input in
+input inlenlow
+input inlenhigh
+output result
+
+int32 x00
+int32 x01
+int32 x02
+int32 x03
+int32 x04
+int32 x05
+int32 x06
+int32 x07
+int32 x08
+int32 x09
+int32 x0a
+int32 x0b
+int32 x0c
+int32 x0d
+int32 x0e
+int32 x0f
+int32 x10
+int32 x11
+int32 x12
+int32 x13
+int32 x14
+int32 x15
+int32 x16
+int32 x17
+int32 x18
+int32 x19
+int32 x1a
+int32 x1b
+int32 x1c
+int32 x1d
+int32 x1e
+int32 x1f
+
+int32 s00
+int32 s01
+int32 s02
+int32 s03
+int32 s04
+int32 s05
+int32 s06
+int32 s07
+int32 s08
+int32 s09
+int32 s0a
+int32 s0b
+int32 s0c
+int32 s0d
+int32 s0e
+int32 s0f
+
+int32 y00
+int32 y01
+int32 y02
+int32 y03
+int32 y04
+int32 y05
+int32 y06
+int32 y07
+
+int32 r
+int32 i
+int32 finalization
+stack256 tmp
+int32 z
+
+int32 check
+int32 carry
+
+stack32 out_stack
+stack32 in_stack
+stack32 inlenlow_stack
+stack32 inlenhigh_stack
+stack32 finalization_stack
+stack32 r_stack
+
+stack32 x02_stack
+stack32 x0a_stack
+stack32 x0b_stack
+stack32 x0c_stack
+stack32 x0d_stack
+stack32 x0e_stack
+stack32 x0f_stack
+stack32 x14_stack
+stack32 x15_stack
+stack32 x16_stack
+stack32 x17_stack
+stack32 x1c_stack
+stack32 x1d_stack
+stack32 x1e_stack
+stack32 x1f_stack
+
+int32 i16
+int32 i17
+int32 i18
+int32 i19
+int32 i20
+int32 i21
+int32 i22
+int32 i23
+int32 i30
+int32 i31
+
+caller i16
+caller i17
+caller i18
+caller i19
+caller i20
+caller i21
+caller i22
+caller i23
+caller i30
+caller i31
+
+stack32 i16_stack
+stack32 i17_stack
+stack32 i18_stack
+stack32 i19_stack
+stack32 i20_stack
+stack32 i21_stack
+stack32 i22_stack
+stack32 i23_stack
+stack32 i30_stack
+stack32 i31_stack
+
+enter crypto_hash_cubehash1632_mips32
+
+ i16_stack = i16
+ i17_stack = i17
+ i18_stack = i18
+ i19_stack = i19
+ i20_stack = i20
+ i21_stack = i21
+ i22_stack = i22
+ i23_stack = i23
+ i30_stack = i30
+ i31_stack = i31
+
+ out_stack = out
+
+ x08 = 0x4d420000
+ x08 |= 0xc787
+ x09 = 0xa6470000
+ x09 |= 0xa8b3
+ x0a = 0x97cf0000
+ x0a |= 0x0bef
+ x0b = 0x825b0000
+ x0b |= 0x4537
+ x0c = 0xeef80000
+ x0c |= 0x64d2
+ x0d = 0xf2200000
+ x0d |= 0x90c4
+ x0e = 0xd0e50000
+ x0e |= 0xcd33
+ x0f = 0xa2390000
+ x0f |= 0x11ae
+
+ x0b_stack = x0b
+ x0c_stack = x0c
+ x0d_stack = x0d
+ x0e_stack = x0e
+ x0f_stack = x0f
+
+ x10 = 0xfcd30000
+ x10 |= 0x98d9
+ x11 = 0x148f0000
+ x11 |= 0xe485
+ x12 = 0x1b010000
+ x12 |= 0x7bef
+ x13 = 0xb6440000
+ x13 |= 0x4532
+ x14 = 0x6a530000
+ x14 |= 0x6159
+ x15 = 0x2ff50000
+ x15 |= 0x781c
+ x16 = 0x91fa0000
+ x16 |= 0x7934
+ x17 = 0x0dba0000
+ x17 |= 0xdea9
+
+ x14_stack = x14
+ x15_stack = x15
+ x16_stack = x16
+ x17_stack = x17
+
+ x18 = 0xd65c0000
+ x18 |= 0x8a2b
+ x19 = 0xa5a70000
+ x19 |= 0x0e75
+ x1a = 0xb1c60000
+ x1a |= 0x2456
+ x1b = 0xbc790000
+ x1b |= 0x6576
+ x1c = 0x19210000
+ x1c |= 0xc8f7
+ x1d = 0xe7980000
+ x1d |= 0x9af1
+ x1e = 0x77950000
+ x1e |= 0xd246
+ x1f = 0xd43e0000
+ x1f |= 0x3b44
+
+ x1c_stack = x1c
+ x1d_stack = x1d
+ x1e_stack = x1e
+ x1f_stack = x1f
+
+ x00 = 0x2aea0000
+ x00 |= 0x2a61
+ x01 = 0x50f40000
+ x01 |= 0x94d4
+ x02 = 0x2d530000
+ x02 |= 0x8b8b
+ x03 = 0x41670000
+ x03 |= 0xd83e
+ x04 = 0x3fee0000
+ x04 |= 0x2313
+ x05 = 0xc7010000
+ x05 |= 0xcf8c
+ x06 = 0xcc390000
+ x06 |= 0x968e
+ x07 = 0x50ac0000
+ x07 |= 0x5695
+
+ finalization = 0
+
+checkinlen:
+ carry = (uint32) inlenlow < 32
+goto mainloop if carry == 0
+goto inlenbelow32 if inlenhigh == 0
+
+mainloop:
+
+ inlenlow -= 32
+ inlenhigh -= carry
+ r = 16
+
+ finalization_stack = finalization
+ inlenlow_stack = inlenlow
+ inlenhigh_stack = inlenhigh
+
+ new y00
+ new y01
+ new y02
+ new y03
+
+ y00 left = *(unaligned uint32 *) (in + 0)
+ y00 right = *(unaligned uint32 *) (in + 0)
+ y01 left = *(unaligned uint32 *) (in + 4)
+ y01 right = *(unaligned uint32 *) (in + 4)
+ y02 left = *(unaligned uint32 *) (in + 8)
+ y02 right = *(unaligned uint32 *) (in + 8)
+ y03 left = *(unaligned uint32 *) (in + 12)
+ y03 right = *(unaligned uint32 *) (in + 12)
+ x00 ^= y00
+ x01 ^= y01
+ x02 ^= y02
+ x03 ^= y03
+
+ new y04
+ new y05
+ new y06
+ new y07
+
+ y04 left = *(unaligned uint32 *) (in + 16)
+ y04 right = *(unaligned uint32 *) (in + 16)
+ y05 left = *(unaligned uint32 *) (in + 20)
+ y05 right = *(unaligned uint32 *) (in + 20)
+ x04 ^= y04
+ x05 ^= y05
+
+ y06 left = *(unaligned uint32 *) (in + 24)
+ y06 right = *(unaligned uint32 *) (in + 24)
+ y07 left = *(unaligned uint32 *) (in + 28)
+ y07 right = *(unaligned uint32 *) (in + 28)
+ x06 ^= y06
+ x07 ^= y07
+
+ in += 32
+ in_stack = in
+
+morerounds:
+
+r_stack = r
+
+ x10 += x00
+ x12 += x02
+ x18 += x08
+ x1a += x0a
+ s00 = x00 << 7
+ (uint32) x00 >>= 25
+ x00 |= s00
+ s02 = x02 << 7
+ (uint32) x02 >>= 25
+ x02 |= s02
+ s08 = x08 << 7
+ (uint32) x08 >>= 25
+ x08 |= s08
+ s0a = x0a << 7
+ (uint32) x0a >>= 25
+ x0a |= s0a
+ x00 ^= x18
+ x02 ^= x1a
+ x08 ^= x10
+ x0a ^= x12
+ x02_stack = x02
+ x1a += x00
+ x0a_stack = x0a
+ x18 += x02
+ x14 = x14_stack
+ x12 += x08
+ x16 = x16_stack
+ x10 += x0a
+ x1c = x1c_stack
+ x14 += x04
+ x1e = x1e_stack
+ x0c = x0c_stack
+ x0e = x0e_stack
+ x16 += x06
+ x1c += x0c
+ x1e += x0e
+ s04 = x04 << 7
+ (uint32) x04 >>= 25
+ x04 |= s04
+ s06 = x06 << 7
+ (uint32) x06 >>= 25
+ x06 |= s06
+ s0c = x0c << 7
+ (uint32) x0c >>= 25
+ x0c |= s0c
+ s0e = x0e << 7
+ (uint32) x0e >>= 25
+ x0e |= s0e
+ x04 ^= x1c
+ x06 ^= x1e
+ x0c ^= x14
+ x0e ^= x16
+ x0b = x0b_stack
+ x1e += x04
+ x1c += x06
+ x16 += x0c
+ x14 += x0e
+ x1e_stack = x1e
+ x11 += x01
+ x1c_stack = x1c
+ x13 += x03
+ x16_stack = x16
+ x19 += x09
+ x14_stack = x14
+ x0c_stack = x0c
+ x0e_stack = x0e
+ x1b += x0b
+ s01 = x01 << 7
+ (uint32) x01 >>= 25
+ x01 |= s01
+ s03 = x03 << 7
+ (uint32) x03 >>= 25
+ x03 |= s03
+ s09 = x09 << 7
+ (uint32) x09 >>= 25
+ x09 |= s09
+ s0b = x0b << 7
+ (uint32) x0b >>= 25
+ x0b |= s0b
+ x01 ^= x19
+ x03 ^= x1b
+ x09 ^= x11
+ x0b ^= x13
+ x15 = x15_stack
+ x1b += x01
+ x17 = x17_stack
+ x19 += x03
+ x1d = x1d_stack
+ x13 += x09
+ x1f = x1f_stack
+ x11 += x0b
+ x0b_stack = x0b
+ x0d_stack = x0d
+ x0f_stack = x0f
+ x15 += x05
+ x17 += x07
+ x1d += x0d
+ x1f += x0f
+ s05 = x05 << 7
+ (uint32) x05 >>= 25
+ x05 |= s05
+ s07 = x07 << 7
+ (uint32) x07 >>= 25
+ x07 |= s07
+ s0d = x0d << 7
+ (uint32) x0d >>= 25
+ x0d |= s0d
+ s0f = x0f << 7
+ (uint32) x0f >>= 25
+ x0f |= s0f
+ x05 ^= x1d
+ x07 ^= x1f
+ x0d ^= x15
+ x0f ^= x17
+ x1f += x05
+ x1d += x07
+ x17 += x0d
+ x15 += x0f
+ x1e = x1e_stack
+ x0d_stack = x0d
+ x0f_stack = x0f
+ s00 = x00 << 11
+ (uint32) x00 >>= 21
+ x00 |= s00
+ x16 = x16_stack
+ s01 = x01 << 11
+ (uint32) x01 >>= 21
+ x01 |= s01
+ x15_stack = x15
+ s08 = x08 << 11
+ (uint32) x08 >>= 21
+ x08 |= s08
+ x1d_stack = x1d
+ s09 = x09 << 11
+ (uint32) x09 >>= 21
+ x09 |= s09
+ x00 ^= x1e
+ x01 ^= x1f
+ x08 ^= x16
+ x09 ^= x17
+ x1f += x00
+ x1e += x01
+ x17 += x08
+ x16 += x09
+ s00 = x00 << 7
+ (uint32) x00 >>= 25
+ x00 |= s00
+ x1f_stack = x1f
+ s01 = x01 << 7
+ (uint32) x01 >>= 25
+ x01 |= s01
+ x1e_stack = x1e
+ s08 = x08 << 7
+ (uint32) x08 >>= 25
+ x08 |= s08
+ x17_stack = x17
+ s09 = x09 << 7
+ (uint32) x09 >>= 25
+ x09 |= s09
+ x16_stack = x16
+ x00 ^= x17
+ x02 = x02_stack
+ x01 ^= x16
+ x0a = x0a_stack
+ x08 ^= x1f
+ x0b = x0b_stack
+ x09 ^= x1e
+ x1c = x1c_stack
+ s02 = x02 << 11
+ (uint32) x02 >>= 21
+ x02 |= s02
+ x1d = x1d_stack
+ s03 = x03 << 11
+ (uint32) x03 >>= 21
+ x03 |= s03
+ x14 = x14_stack
+ s0a = x0a << 11
+ (uint32) x0a >>= 21
+ x0a |= s0a
+ x15 = x15_stack
+ s0b = x0b << 11
+ (uint32) x0b >>= 21
+ x0b |= s0b
+ x02 ^= x1c
+ x03 ^= x1d
+ x0a ^= x14
+ x0b ^= x15
+ x1d += x02
+ x1c += x03
+ x15 += x0a
+ x14 += x0b
+ x1d_stack = x1d
+ s02 = x02 << 7
+ (uint32) x02 >>= 25
+ x02 |= s02
+ x1c_stack = x1c
+ s03 = x03 << 7
+ (uint32) x03 >>= 25
+ x03 |= s03
+ x15_stack = x15
+ s0a = x0a << 7
+ (uint32) x0a >>= 25
+ x0a |= s0a
+ x14_stack = x14
+ s0b = x0b << 7
+ (uint32) x0b >>= 25
+ x0b |= s0b
+ x02 ^= x15
+ x03 ^= x14
+ x0a ^= x1d
+ x0c = x0c_stack
+ x0d = x0d_stack
+ x0b ^= x1c
+ x02_stack = x02
+ s04 = x04 << 11
+ (uint32) x04 >>= 21
+ x04 |= s04
+ x0a_stack = x0a
+ s05 = x05 << 11
+ (uint32) x05 >>= 21
+ x05 |= s05
+ x0b_stack = x0b
+ s0c = x0c << 11
+ (uint32) x0c >>= 21
+ x0c |= s0c
+ s0d = x0d << 11
+ (uint32) x0d >>= 21
+ x0d |= s0d
+ x04 ^= x1a
+ x05 ^= x1b
+ x0c ^= x12
+ x0d ^= x13
+ x1b += x04
+ x1a += x05
+ x13 += x0c
+ x12 += x0d
+ s04 = x04 << 7
+ (uint32) x04 >>= 25
+ x04 |= s04
+ s05 = x05 << 7
+ (uint32) x05 >>= 25
+ x05 |= s05
+ s0c = x0c << 7
+ (uint32) x0c >>= 25
+ x0c |= s0c
+ s0d = x0d << 7
+ (uint32) x0d >>= 25
+ x0d |= s0d
+ x04 ^= x13
+ x05 ^= x12
+ x0c ^= x1b
+ x0d ^= x1a
+ x0c_stack = x0c
+ x0d_stack = x0d
+ x0e = x0e_stack
+ x0f = x0f_stack
+
+ s06 = x06 << 11
+ (uint32) x06 >>= 21
+ x06 |= s06
+ s07 = x07 << 11
+ (uint32) x07 >>= 21
+ x07 |= s07
+ s0e = x0e << 11
+ (uint32) x0e >>= 21
+ x0e |= s0e
+ s0f = x0f << 11
+ (uint32) x0f >>= 21
+ x0f |= s0f
+ x06 ^= x18
+ x07 ^= x19
+ x0e ^= x10
+ x0f ^= x11
+ x19 += x06
+ x18 += x07
+ x11 += x0e
+ x10 += x0f
+ s06 = x06 << 7
+ (uint32) x06 >>= 25
+ x06 |= s06
+ s07 = x07 << 7
+ (uint32) x07 >>= 25
+ x07 |= s07
+ s0e = x0e << 7
+ (uint32) x0e >>= 25
+ x0e |= s0e
+ s0f = x0f << 7
+ (uint32) x0f >>= 25
+ x0f |= s0f
+ x06 ^= x11
+ x15 = x15_stack
+ x07 ^= x10
+ x14 = x14_stack
+ x0e ^= x19
+ x1d = x1d_stack
+ x0f ^= x18
+ x1c = x1c_stack
+
+ x0e_stack = x0e
+ x0f_stack = x0f
+ x0c = x0c_stack
+ x0d = x0d_stack
+
+ x11 += x04
+ x10 += x05
+ x19 += x0c
+ x18 += x0d
+
+
+ x15 += x00
+ x14 += x01
+ x1d += x08
+ x1c += x09
+
+ s04 = x04 << 11
+ (uint32) x04 >>= 21
+ x04 |= s04
+ x15_stack = x15
+ s05 = x05 << 11
+ (uint32) x05 >>= 21
+ x05 |= s05
+ x14_stack = x14
+ s0c = x0c << 11
+ (uint32) x0c >>= 21
+ x0c |= s0c
+ x1d_stack = x1d
+ s0d = x0d << 11
+ (uint32) x0d >>= 21
+ x0d |= s0d
+ x1c_stack = x1c
+ x04 ^= x15
+ x05 ^= x14
+ x0c ^= x1d
+ x0d ^= x1c
+ x0c_stack = x0c
+ x0d_stack = x0d
+ x0e = x0e_stack
+ x0f = x0f_stack
+ s00 = x00 << 11
+ (uint32) x00 >>= 21
+ x00 |= s00
+ s01 = x01 << 11
+ (uint32) x01 >>= 21
+ x01 |= s01
+ s08 = x08 << 11
+ (uint32) x08 >>= 21
+ x08 |= s08
+ s09 = x09 << 11
+ (uint32) x09 >>= 21
+ x09 |= s09
+ x00 ^= x11
+ x01 ^= x10
+ x17 = x17_stack
+ x08 ^= x19
+ x02 = x02_stack
+ x09 ^= x18
+ x16 = x16_stack
+ x13 += x06
+ x1f = x1f_stack
+ x12 += x07
+ x0a = x0a_stack
+ x1b += x0e
+ x1e = x1e_stack
+ x1a += x0f
+ x0b = x0b_stack
+ x17 += x02
+ x16 += x03
+ x1f += x0a
+ x1e += x0b
+ s06 = x06 << 11
+ (uint32) x06 >>= 21
+ x06 |= s06
+ x17_stack = x17
+ s07 = x07 << 11
+ (uint32) x07 >>= 21
+ x07 |= s07
+ x16_stack = x16
+ s0e = x0e << 11
+ (uint32) x0e >>= 21
+ x0e |= s0e
+ x1f_stack = x1f
+ s0f = x0f << 11
+ (uint32) x0f >>= 21
+ x0f |= s0f
+ x1e_stack = x1e
+ x06 ^= x17
+ x07 ^= x16
+ x0e ^= x1f
+ x0f ^= x1e
+ x0e_stack = x0e
+ x0f_stack = x0f
+
+ s0b = x0b << 11
+ (uint32) x0b >>= 21
+ x0b |= s0b
+ s0a = x0a << 11
+ (uint32) x0a >>= 21
+ x0a |= s0a
+ s03 = x03 << 11
+ (uint32) x03 >>= 21
+ x03 |= s03
+ s02 = x02 << 11
+ (uint32) x02 >>= 21
+ x02 |= s02
+ r = r_stack
+ x0b ^= x1a
+ x0a ^= x1b
+ r -= 2
+ x03 ^= x12
+ x02 ^= x13
+ x0b_stack = x0b
+
+goto morerounds if r > 0
+
+ finalization = finalization_stack
+ in = in_stack
+ inlenlow = inlenlow_stack
+ inlenhigh = inlenhigh_stack
+
+goto checkinlen
+
+inlenbelow32:
+
+ check = 1
+goto finalization1 if finalization == check
+ check = 2
+goto finalization2 if finalization == check
+
+ new tmp
+ y00 = 0
+ z = &tmp
+
+ *(uint32 *) (z + 0) = y00
+ *(uint32 *) (z + 4) = y00
+ *(uint32 *) (z + 8) = y00
+ *(uint32 *) (z + 12) = y00
+ *(uint32 *) (z + 16) = y00
+ *(uint32 *) (z + 20) = y00
+ *(uint32 *) (z + 24) = y00
+ *(uint32 *) (z + 28) = y00
+
+goto copydone if inlenlow <= 0
+ copyloop:
+ y00 = *(uint8 *) (in + 0)
+ in += 1
+ *(uint8 *) (z + 0) = y00
+ z += 1
+
+ inlenlow -= 1
+goto copyloop if inlenlow > 0
+copydone:
+
+ y00 = 128
+ *(uint8 *) (z + 0) = y00
+
+ in = &tmp
+ finalization = 1
+ inlenlow = 32
+ carry = 0
+ goto mainloop
+
+finalization1:
+ x1f = x1f_stack
+ x1f ^= 1
+ x1f_stack = x1f
+ r = 160
+ finalization = 2
+ finalization_stack = finalization
+ in_stack = in
+ inlenlow_stack = inlenlow
+ inlenhigh_stack = inlenhigh
+goto morerounds
+
+finalization2:
+
+ out = out_stack
+
+ *(unaligned uint32 *) (out + 0) left = x00
+ *(unaligned uint32 *) (out + 0) right = x00
+ *(unaligned uint32 *) (out + 4) left = x01
+ *(unaligned uint32 *) (out + 4) right = x01
+ *(unaligned uint32 *) (out + 8) left = x02
+ *(unaligned uint32 *) (out + 8) right = x02
+ *(unaligned uint32 *) (out + 12) left = x03
+ *(unaligned uint32 *) (out + 12) right = x03
+ *(unaligned uint32 *) (out + 16) left = x04
+ *(unaligned uint32 *) (out + 16) right = x04
+ *(unaligned uint32 *) (out + 20) left = x05
+ *(unaligned uint32 *) (out + 20) right = x05
+ *(unaligned uint32 *) (out + 24) left = x06
+ *(unaligned uint32 *) (out + 24) right = x06
+ *(unaligned uint32 *) (out + 28) left = x07
+ *(unaligned uint32 *) (out + 28) right = x07
+
+ x0b = x0b_stack
+ x0c = x0c_stack
+ x0d = x0d_stack
+ x0e = x0e_stack
+ x0f = x0f_stack
+
+ *(unaligned uint32 *) (out + 32) left = x08
+ *(unaligned uint32 *) (out + 32) right = x08
+ *(unaligned uint32 *) (out + 36) left = x09
+ *(unaligned uint32 *) (out + 36) right = x09
+ *(unaligned uint32 *) (out + 40) left = x0a
+ *(unaligned uint32 *) (out + 40) right = x0a
+ *(unaligned uint32 *) (out + 44) left = x0b
+ *(unaligned uint32 *) (out + 44) right = x0b
+ *(unaligned uint32 *) (out + 48) left = x0c
+ *(unaligned uint32 *) (out + 48) right = x0c
+ *(unaligned uint32 *) (out + 52) left = x0d
+ *(unaligned uint32 *) (out + 52) right = x0d
+ *(unaligned uint32 *) (out + 56) left = x0e
+ *(unaligned uint32 *) (out + 56) right = x0e
+ *(unaligned uint32 *) (out + 60) left = x0f
+ *(unaligned uint32 *) (out + 60) right = x0f
+
+ result = 0
+
+ i16 = i16_stack
+ i17 = i17_stack
+ i18 = i18_stack
+ i19 = i19_stack
+ i20 = i20_stack
+ i21 = i21_stack
+ i22 = i22_stack
+ i23 = i23_stack
+ i30 = i30_stack
+ i31 = i31_stack
+
+leave
View
3,421 crypto_hash/cubehash1632/mips32/hash.s
@@ -0,0 +1,3421 @@
+
+# qhasm: int32 out
+
+# qhasm: int32 in
+
+# qhasm: int32 inlenlow
+
+# qhasm: int32 inlenhigh
+
+# qhasm: int32 result
+
+# qhasm: input out
+
+# qhasm: input in
+
+# qhasm: input inlenlow
+
+# qhasm: input inlenhigh
+
+# qhasm: output result
+
+# qhasm: int32 x00
+
+# qhasm: int32 x01
+
+# qhasm: int32 x02
+
+# qhasm: int32 x03
+
+# qhasm: int32 x04
+
+# qhasm: int32 x05
+
+# qhasm: int32 x06
+
+# qhasm: int32 x07
+
+# qhasm: int32 x08
+
+# qhasm: int32 x09
+
+# qhasm: int32 x0a
+
+# qhasm: int32 x0b
+
+# qhasm: int32 x0c
+
+# qhasm: int32 x0d
+
+# qhasm: int32 x0e
+
+# qhasm: int32 x0f
+
+# qhasm: int32 x10
+
+# qhasm: int32 x11
+
+# qhasm: int32 x12
+
+# qhasm: int32 x13
+
+# qhasm: int32 x14
+
+# qhasm: int32 x15
+
+# qhasm: int32 x16
+
+# qhasm: int32 x17
+
+# qhasm: int32 x18
+
+# qhasm: int32 x19
+
+# qhasm: int32 x1a
+
+# qhasm: int32 x1b
+
+# qhasm: int32 x1c
+
+# qhasm: int32 x1d
+
+# qhasm: int32 x1e
+
+# qhasm: int32 x1f
+
+# qhasm: int32 s00
+
+# qhasm: int32 s01
+
+# qhasm: int32 s02
+
+# qhasm: int32 s03
+
+# qhasm: int32 s04
+
+# qhasm: int32 s05
+
+# qhasm: int32 s06
+
+# qhasm: int32 s07
+
+# qhasm: int32 s08
+
+# qhasm: int32 s09
+
+# qhasm: int32 s0a
+
+# qhasm: int32 s0b
+
+# qhasm: int32 s0c
+
+# qhasm: int32 s0d
+
+# qhasm: int32 s0e
+
+# qhasm: int32 s0f
+
+# qhasm: int32 y00
+
+# qhasm: int32 y01
+
+# qhasm: int32 y02
+
+# qhasm: int32 y03
+
+# qhasm: int32 y04
+
+# qhasm: int32 y05
+
+# qhasm: int32 y06
+
+# qhasm: int32 y07
+
+# qhasm: int32 r
+
+# qhasm: int32 i
+
+# qhasm: int32 finalization
+
+# qhasm: stack256 tmp
+
+# qhasm: int32 z
+
+# qhasm: int32 check
+
+# qhasm: int32 carry
+
+# qhasm: stack32 out_stack
+
+# qhasm: stack32 in_stack
+
+# qhasm: stack32 inlenlow_stack
+
+# qhasm: stack32 inlenhigh_stack
+
+# qhasm: stack32 finalization_stack
+
+# qhasm: stack32 r_stack
+
+# qhasm: stack32 x02_stack
+
+# qhasm: stack32 x0a_stack
+
+# qhasm: stack32 x0b_stack
+
+# qhasm: stack32 x0c_stack
+
+# qhasm: stack32 x0d_stack
+
+# qhasm: stack32 x0e_stack
+
+# qhasm: stack32 x0f_stack
+
+# qhasm: stack32 x14_stack
+
+# qhasm: stack32 x15_stack
+
+# qhasm: stack32 x16_stack
+
+# qhasm: stack32 x17_stack
+
+# qhasm: stack32 x1c_stack
+
+# qhasm: stack32 x1d_stack
+
+# qhasm: stack32 x1e_stack
+
+# qhasm: stack32 x1f_stack
+
+# qhasm: int32 i16
+
+# qhasm: int32 i17
+
+# qhasm: int32 i18
+
+# qhasm: int32 i19
+
+# qhasm: int32 i20
+
+# qhasm: int32 i21
+
+# qhasm: int32 i22
+
+# qhasm: int32 i23
+
+# qhasm: int32 i30
+
+# qhasm: int32 i31
+
+# qhasm: caller i16
+
+# qhasm: caller i17
+
+# qhasm: caller i18
+
+# qhasm: caller i19
+
+# qhasm: caller i20
+
+# qhasm: caller i21
+
+# qhasm: caller i22
+
+# qhasm: caller i23
+
+# qhasm: caller i30
+
+# qhasm: caller i31
+
+# qhasm: stack32 i16_stack