Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ai
sso
Commits
6d738803
Commit
6d738803
authored
Nov 11, 2014
by
ale
Browse files
C implementation of the core SSO library, using tweetnacl
parent
366f0ae5
Changes
538
Hide whitespace changes
Inline
Side-by-side
Makefile.defs
View file @
6d738803
# Note: this should match what's in lib/nacl-20110221/do.
short_hostname
:=
$(
shell
hostname
|
sed
's/\..*//'
|
tr
-cd
'[a-z][A-Z][0-9]'
)
NACL_ABI
:=
$(
shell
$(top_srcdir)
/lib/nacl-20110221/printabi.debian
)
NACL_DIR
=
$(top_builddir)
/lib/nacl-20110221/build/
$(short_hostname)
NACL_LIB_DIR
=
$(NACL_DIR)
/lib/
$(NACL_ABI)
AM_CPPFLAGS
=
\
-
I
$(top_srcdir)
/src
\
-I
$(
NACL_DIR)
/include/
$(NACL_ABI)
-
D_GNU_SOURCE
-Wall
-Werror
\
-I
$(
top_srcdir)
/src
AM_LDFLAGS
=
\
-L
$(top_builddir)
/src
\
-L
$(NACL_LIB_DIR)
NACL_LIBS
=
$(NACL_LIB_DIR)
/libnacl.a
$(NACL_LIB_DIR)
/librandombytes.a
SSO_LIBS
=
$(top_builddir)
/src/sso/libsso.la
$(NACL_LIBS)
LDADD
=
$(SSO_LIBS)
-L
$(top_builddir)
/src
configure.ac
View file @
6d738803
AC_INIT([sso], [2.0], [info@autistici.org])
AC_CONFIG_SRCDIR([src/sso/
ticket.c
c])
AC_CONFIG_SRCDIR([src/sso/
sso.
c])
AC_LANG(C++)
AM_INIT_AUTOMAKE([dist-bzip2 foreign])
...
...
@@ -16,10 +16,11 @@ AC_PROG_MAKE_SET
AC_PROG_LIBTOOL
AC_SUBST(LIBTOOL_DEPS)
CFLAGS="$CFLAGS -fPIC -std=c99 -pedantic"
CXXFLAGS="$CXXFLAGS -fPIC"
dnl Checks for libraries.
ACX_PTHREAD([have_pthread=yes], [h
e
ve_pthread=no])
ACX_PTHREAD([have_pthread=yes], [h
a
ve_pthread=no])
CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
...
...
@@ -128,7 +129,6 @@ dnl Final stage
AC_OUTPUT(
Makefile
lib/Makefile
lib/nacl-20110221/Makefile
lib/gtest/Makefile
src/Makefile
src/sso/Makefile
...
...
lib/Makefile.am
View file @
6d738803
SUBDIRS
=
nacl-20110221
gtest
SUBDIRS
=
gtest
lib/nacl-20110221/MACROS
deleted
100644 → 0
View file @
366f0ae5
crypto_verify
crypto_verify_BYTES
crypto_core
crypto_core_OUTPUTBYTES
crypto_core_INPUTBYTES
crypto_core_KEYBYTES
crypto_core_CONSTBYTES
crypto_hashblocks
crypto_hashblocks_STATEBYTES
crypto_hashblocks_BLOCKBYTES
crypto_hash
crypto_hash_BYTES
crypto_stream
crypto_stream_xor
crypto_stream_beforenm
crypto_stream_afternm
crypto_stream_xor_afternm
crypto_stream_KEYBYTES
crypto_stream_NONCEBYTES
crypto_stream_BEFORENMBYTES
crypto_onetimeauth
crypto_onetimeauth_verify
crypto_onetimeauth_BYTES
crypto_onetimeauth_KEYBYTES
crypto_auth
crypto_auth_verify
crypto_auth_BYTES
crypto_auth_KEYBYTES
crypto_secretbox
crypto_secretbox_open
crypto_secretbox_KEYBYTES
crypto_secretbox_NONCEBYTES
crypto_secretbox_ZEROBYTES
crypto_secretbox_BOXZEROBYTES
crypto_scalarmult
crypto_scalarmult_base
crypto_scalarmult_BYTES
crypto_scalarmult_SCALARBYTES
crypto_box
crypto_box_open
crypto_box_keypair
crypto_box_beforenm
crypto_box_afternm
crypto_box_open_afternm
crypto_box_PUBLICKEYBYTES
crypto_box_SECRETKEYBYTES
crypto_box_BEFORENMBYTES
crypto_box_NONCEBYTES
crypto_box_ZEROBYTES
crypto_box_BOXZEROBYTES
crypto_sign
crypto_sign_open
crypto_sign_keypair
crypto_sign_BYTES
crypto_sign_PUBLICKEYBYTES
crypto_sign_SECRETKEYBYTES
lib/nacl-20110221/Makefile.am
deleted
100644 → 0
View file @
366f0ae5
include
$(top_srcdir)/Makefile.defs
all
:
.build-stamp .librandombytes-stamp
.build-stamp
:
$(srcdir)
/do
-
touch
$@
.librandombytes-stamp
:
.build-stamp
$(AR)
cru
$(NACL_LIB_DIR)
/librandombytes.a
\
$(NACL_LIB_DIR)
/randombytes.o
$(RANLIB)
$(NACL_LIB_DIR)
/librandombytes.a
-
touch
$@
clean
:
-
rm
-f
.build-stamp
lib/nacl-20110221/OPERATIONS
deleted
100644 → 0
View file @
366f0ae5
crypto_verify
crypto_core
crypto_hashblocks
crypto_hash
crypto_stream
crypto_onetimeauth
crypto_auth
crypto_secretbox
crypto_scalarmult
crypto_box
crypto_sign
lib/nacl-20110221/PROTOTYPES.c
deleted
100644 → 0
View file @
366f0ae5
extern
int
crypto_verify
(
const
unsigned
char
*
,
const
unsigned
char
*
);
extern
int
crypto_core
(
unsigned
char
*
,
const
unsigned
char
*
,
const
unsigned
char
*
,
const
unsigned
char
*
);
extern
int
crypto_hashblocks
(
unsigned
char
*
,
const
unsigned
char
*
,
unsigned
long
long
);
extern
int
crypto_hash
(
unsigned
char
*
,
const
unsigned
char
*
,
unsigned
long
long
);
extern
int
crypto_stream
(
unsigned
char
*
,
unsigned
long
long
,
const
unsigned
char
*
,
const
unsigned
char
*
);
extern
int
crypto_stream_xor
(
unsigned
char
*
,
const
unsigned
char
*
,
unsigned
long
long
,
const
unsigned
char
*
,
const
unsigned
char
*
);
extern
int
crypto_stream_beforenm
(
unsigned
char
*
,
const
unsigned
char
*
);
extern
int
crypto_stream_afternm
(
unsigned
char
*
,
unsigned
long
long
,
const
unsigned
char
*
,
const
unsigned
char
*
);
extern
int
crypto_stream_xor_afternm
(
unsigned
char
*
,
const
unsigned
char
*
,
unsigned
long
long
,
const
unsigned
char
*
,
const
unsigned
char
*
);
extern
int
crypto_onetimeauth
(
unsigned
char
*
,
const
unsigned
char
*
,
unsigned
long
long
,
const
unsigned
char
*
);
extern
int
crypto_onetimeauth_verify
(
const
unsigned
char
*
,
const
unsigned
char
*
,
unsigned
long
long
,
const
unsigned
char
*
);
extern
int
crypto_auth
(
unsigned
char
*
,
const
unsigned
char
*
,
unsigned
long
long
,
const
unsigned
char
*
);
extern
int
crypto_auth_verify
(
const
unsigned
char
*
,
const
unsigned
char
*
,
unsigned
long
long
,
const
unsigned
char
*
);
extern
int
crypto_secretbox
(
unsigned
char
*
,
const
unsigned
char
*
,
unsigned
long
long
,
const
unsigned
char
*
,
const
unsigned
char
*
);
extern
int
crypto_secretbox_open
(
unsigned
char
*
,
const
unsigned
char
*
,
unsigned
long
long
,
const
unsigned
char
*
,
const
unsigned
char
*
);
extern
int
crypto_scalarmult
(
unsigned
char
*
,
const
unsigned
char
*
,
const
unsigned
char
*
);
extern
int
crypto_scalarmult_base
(
unsigned
char
*
,
const
unsigned
char
*
);
extern
int
crypto_box
(
unsigned
char
*
,
const
unsigned
char
*
,
unsigned
long
long
,
const
unsigned
char
*
,
const
unsigned
char
*
,
const
unsigned
char
*
);
extern
int
crypto_box_open
(
unsigned
char
*
,
const
unsigned
char
*
,
unsigned
long
long
,
const
unsigned
char
*
,
const
unsigned
char
*
,
const
unsigned
char
*
);
extern
int
crypto_box_keypair
(
unsigned
char
*
,
unsigned
char
*
);
extern
int
crypto_box_beforenm
(
unsigned
char
*
,
const
unsigned
char
*
,
const
unsigned
char
*
);
extern
int
crypto_box_afternm
(
unsigned
char
*
,
const
unsigned
char
*
,
unsigned
long
long
,
const
unsigned
char
*
,
const
unsigned
char
*
);
extern
int
crypto_box_open_afternm
(
unsigned
char
*
,
const
unsigned
char
*
,
unsigned
long
long
,
const
unsigned
char
*
,
const
unsigned
char
*
);
extern
int
crypto_sign
(
unsigned
char
*
,
unsigned
long
long
*
,
const
unsigned
char
*
,
unsigned
long
long
,
const
unsigned
char
*
);
extern
int
crypto_sign_open
(
unsigned
char
*
,
unsigned
long
long
*
,
const
unsigned
char
*
,
unsigned
long
long
,
const
unsigned
char
*
);
extern
int
crypto_sign_keypair
(
unsigned
char
*
,
unsigned
char
*
);
lib/nacl-20110221/PROTOTYPES.cpp
deleted
100644 → 0
View file @
366f0ae5
extern
std
::
string
crypto_auth
(
const
std
::
string
&
,
const
std
::
string
&
);
extern
void
crypto_auth_verify
(
const
std
::
string
&
,
const
std
::
string
&
,
const
std
::
string
&
);
extern
std
::
string
crypto_box
(
const
std
::
string
&
,
const
std
::
string
&
,
const
std
::
string
&
,
const
std
::
string
&
);
extern
std
::
string
crypto_box_open
(
const
std
::
string
&
,
const
std
::
string
&
,
const
std
::
string
&
,
const
std
::
string
&
);
extern
std
::
string
crypto_box_keypair
(
std
::
string
*
);
extern
std
::
string
crypto_hash
(
const
std
::
string
&
);
extern
std
::
string
crypto_onetimeauth
(
const
std
::
string
&
,
const
std
::
string
&
);
extern
void
crypto_onetimeauth_verify
(
const
std
::
string
&
,
const
std
::
string
&
,
const
std
::
string
&
);
extern
std
::
string
crypto_scalarmult
(
const
std
::
string
&
,
const
std
::
string
&
);
extern
std
::
string
crypto_scalarmult_base
(
const
std
::
string
&
);
extern
std
::
string
crypto_secretbox
(
const
std
::
string
&
,
const
std
::
string
&
,
const
std
::
string
&
);
extern
std
::
string
crypto_secretbox_open
(
const
std
::
string
&
,
const
std
::
string
&
,
const
std
::
string
&
);
extern
std
::
string
crypto_stream
(
size_t
,
const
std
::
string
&
,
const
std
::
string
&
);
extern
std
::
string
crypto_stream_xor
(
const
std
::
string
&
,
const
std
::
string
&
,
const
std
::
string
&
);
extern
std
::
string
crypto_sign
(
const
std
::
string
&
,
const
std
::
string
&
);
extern
std
::
string
crypto_sign_open
(
const
std
::
string
&
,
const
std
::
string
&
);
extern
std
::
string
crypto_sign_keypair
(
std
::
string
*
);
lib/nacl-20110221/commandline/nacl-sha256.c
deleted
100644 → 0
View file @
366f0ae5
/*
commandline/nacl-sha256.c version 20080713
D. J. Bernstein
Public domain.
*/
#include
<sys/types.h>
#include
<sys/stat.h>
#include
<sys/mman.h>
#include
<unistd.h>
#include
<string.h>
#include
<stdlib.h>
#include
<stdio.h>
#include
"crypto_hash_sha256.h"
unsigned
char
*
input
;
unsigned
long
long
inputalloc
;
unsigned
long
long
inputlen
;
unsigned
char
h
[
crypto_hash_sha256_BYTES
];
void
h_print
(
void
)
{
int
i
;
for
(
i
=
0
;
i
<
crypto_hash_sha256_BYTES
;
++
i
)
printf
(
"%02x"
,
255
&
(
int
)
h
[
i
]);
printf
(
"
\n
"
);
}
int
main
()
{
struct
stat
st
;
int
ch
;
if
(
fstat
(
0
,
&
st
)
==
0
)
{
input
=
mmap
(
0
,
st
.
st_size
,
PROT_READ
,
MAP_SHARED
,
0
,
0
);
if
(
input
!=
MAP_FAILED
)
{
crypto_hash_sha256
(
h
,
input
,
st
.
st_size
);
h_print
();
return
0
;
}
}
input
=
0
;
inputalloc
=
0
;
inputlen
=
0
;
while
((
ch
=
getchar
())
!=
EOF
)
{
if
(
inputlen
>=
inputalloc
)
{
void
*
newinput
;
while
(
inputlen
>=
inputalloc
)
inputalloc
=
inputalloc
*
2
+
1
;
if
(
posix_memalign
(
&
newinput
,
16
,
inputalloc
)
!=
0
)
return
111
;
memcpy
(
newinput
,
input
,
inputlen
);
free
(
input
);
input
=
newinput
;
}
input
[
inputlen
++
]
=
ch
;
}
crypto_hash_sha256
(
h
,
input
,
inputlen
);
h_print
();
return
0
;
}
lib/nacl-20110221/commandline/nacl-sha512.c
deleted
100644 → 0
View file @
366f0ae5
/*
commandline/nacl-sha512.c version 20080713
D. J. Bernstein
Public domain.
*/
#include
<sys/types.h>
#include
<sys/stat.h>
#include
<sys/mman.h>
#include
<unistd.h>
#include
<string.h>
#include
<stdlib.h>
#include
<stdio.h>
#include
"crypto_hash_sha512.h"
unsigned
char
*
input
;
unsigned
long
long
inputalloc
;
unsigned
long
long
inputlen
;
unsigned
char
h
[
crypto_hash_sha512_BYTES
];
void
h_print
(
void
)
{
int
i
;
for
(
i
=
0
;
i
<
crypto_hash_sha512_BYTES
;
++
i
)
printf
(
"%02x"
,
255
&
(
int
)
h
[
i
]);
printf
(
"
\n
"
);
}
int
main
()
{
struct
stat
st
;
int
ch
;
if
(
fstat
(
0
,
&
st
)
==
0
)
{
input
=
mmap
(
0
,
st
.
st_size
,
PROT_READ
,
MAP_SHARED
,
0
,
0
);
if
(
input
!=
MAP_FAILED
)
{
crypto_hash_sha512
(
h
,
input
,
st
.
st_size
);
h_print
();
return
0
;
}
}
input
=
0
;
inputalloc
=
0
;
inputlen
=
0
;
while
((
ch
=
getchar
())
!=
EOF
)
{
if
(
inputlen
>=
inputalloc
)
{
void
*
newinput
;
while
(
inputlen
>=
inputalloc
)
inputalloc
=
inputalloc
*
2
+
1
;
if
(
posix_memalign
(
&
newinput
,
16
,
inputalloc
)
!=
0
)
return
111
;
memcpy
(
newinput
,
input
,
inputlen
);
free
(
input
);
input
=
newinput
;
}
input
[
inputlen
++
]
=
ch
;
}
crypto_hash_sha512
(
h
,
input
,
inputlen
);
h_print
();
return
0
;
}
lib/nacl-20110221/cpucycles/alpha.c
deleted
100644 → 0
View file @
366f0ae5
/*
cpucycles/alpha.c version 20060316
D. J. Bernstein
Public domain.
*/
#include
<time.h>
#include
<unistd.h>
#include
<sys/time.h>
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
rpcc
(
void
)
{
unsigned
long
long
t
;
asm
volatile
(
"rpcc %0"
:
"=r"
(
t
));
return
t
&
0xffffffff
;
}
static
long
long
firstrpcc
;
static
long
long
firsttod
;
static
long
long
lastrpcc
;
static
long
long
lasttod
;
static
double
mhz
=
0
;
static
void
init
(
void
)
{
firstrpcc
=
rpcc
();
firsttod
=
tod
();
do
{
lastrpcc
=
rpcc
();
lasttod
=
tod
();
}
while
(
lasttod
-
firsttod
<
10000
);
lastrpcc
-=
firstrpcc
;
lastrpcc
&=
0xffffffff
;
lasttod
-=
firsttod
;
mhz
=
(
double
)
lastrpcc
/
(
double
)
lasttod
;
}
long
long
cpucycles_alpha
(
void
)
{
double
x
;
long
long
y
;
if
(
!
mhz
)
init
();
lastrpcc
=
rpcc
();
lasttod
=
tod
();
lastrpcc
-=
firstrpcc
;
lastrpcc
&=
0xffffffff
;
lasttod
-=
firsttod
;
/* Number of cycles since firstrpcc is lastrpcc + 2^32 y for unknown y. */
/* Number of microseconds since firsttod is lasttod. */
x
=
(
lasttod
*
mhz
-
lastrpcc
)
*
0
.
000000000232
83064365386962890625
;
y
=
x
;
while
(
x
>
y
+
0
.
5
)
y
+=
1
;
while
(
x
<
y
-
0
.
5
)
y
-=
1
;
y
*=
4294967296ULL
;
lastrpcc
+=
y
;
mhz
=
(
double
)
lastrpcc
/
(
double
)
lasttod
;
return
firstrpcc
+
lastrpcc
;
}
long
long
cpucycles_alpha_persecond
(
void
)
{
if
(
!
mhz
)
init
();
return
1000000
.
0
*
mhz
;
}
lib/nacl-20110221/cpucycles/alpha.h
deleted
100644 → 0
View file @
366f0ae5
/*
cpucycles alpha.h version 20060318
D. J. Bernstein
Public domain.
*/
#ifndef CPUCYCLES_alpha_h
#define CPUCYCLES_alpha_h
#ifdef __cplusplus
extern
"C"
{
#endif
extern
long
long
cpucycles_alpha
(
void
);
extern
long
long
cpucycles_alpha_persecond
(
void
);
#ifdef __cplusplus
}
#endif
#ifndef cpucycles_implementation
#define cpucycles_implementation "alpha"
#define cpucycles cpucycles_alpha
#define cpucycles_persecond cpucycles_alpha_persecond
#endif
#endif
lib/nacl-20110221/cpucycles/amd64cpuinfo.c
deleted
100644 → 0
View file @
366f0ae5
#include
<stdio.h>
#include
<sys/types.h>
#include
"osfreq.c"
long
long
cpucycles_amd64cpuinfo
(
void
)
{
unsigned
long
long
result
;
asm
volatile
(
".byte 15;.byte 49;shlq $32,%%rdx;orq %%rdx,%%rax"
:
"=a"
(
result
)
::
"%rdx"
);
return
result
;
}
long
long
cpucycles_amd64cpuinfo_persecond
(
void
)
{
return
osfreq
();
}
lib/nacl-20110221/cpucycles/amd64cpuinfo.h
deleted
100644 → 0
View file @
366f0ae5
/*
cpucycles amd64cpuinfo.h version 20100803
D. J. Bernstein
Public domain.
*/
#ifndef CPUCYCLES_amd64cpuinfo_h
#define CPUCYCLES_amd64cpuinfo_h
#ifdef __cplusplus
extern
"C"
{
#endif
extern
long
long
cpucycles_amd64cpuinfo
(
void
);
extern
long
long
cpucycles_amd64cpuinfo_persecond
(
void
);
#ifdef __cplusplus
}
#endif
#ifndef cpucycles_implementation
#define cpucycles_implementation "amd64cpuinfo"
#define cpucycles cpucycles_amd64cpuinfo
#define cpucycles_persecond cpucycles_amd64cpuinfo_persecond
#endif
#endif
lib/nacl-20110221/cpucycles/amd64cpuspeed.c
deleted
100644 → 0
View file @
366f0ae5
#include
<stdio.h>
#include
<sys/types.h>
#include
<sys/param.h>
#include
<sys/sysctl.h>
long
long
cpucycles_amd64cpuspeed
(
void
)
{
unsigned
long
long
result
;
asm
volatile
(
".byte 15;.byte 49;shlq $32,%%rdx;orq %%rdx,%%rax"
:
"=a"
(
result
)
::
"%rdx"
);
return
result
;
}
long
long
cpucycles_amd64cpuspeed_persecond
(
void
)
{
int
oid
[
2
];
int
val
;
size_t
size
;
oid
[
0
]
=
CTL_HW
;
oid
[
1
]
=
HW_CPUSPEED
;
size
=
sizeof
val
;
if
(
sysctl
(
oid
,
2
,
&
val
,
&
size
,
0
,
0
)
==
-
1
)
return
0
;
if
(
size
!=
sizeof
val
)
return
0
;
return
val
*
1000000LL
;
}
lib/nacl-20110221/cpucycles/amd64cpuspeed.h
deleted
100644 → 0
View file @
366f0ae5
/*
cpucycles amd64cpuspeed.h version 20090716
Matthew Dempsky
Public domain.
*/
#ifndef CPUCYCLES_amd64cpuspeed_h
#define CPUCYCLES_amd64cpuspeed_h
#ifdef __cplusplus
extern
"C"
{
#endif
extern
long
long
cpucycles_amd64cpuspeed
(
void
);
extern
long
long
cpucycles_amd64cpuspeed_persecond
(
void
);
#ifdef __cplusplus
}
#endif
#ifndef cpucycles_implementation
#define cpucycles_implementation "amd64cpuspeed"
#define cpucycles cpucycles_amd64cpuspeed
#define cpucycles_persecond cpucycles_amd64cpuspeed_persecond
#endif
#endif
lib/nacl-20110221/cpucycles/amd64tscfreq.c
deleted
100644 → 0
View file @
366f0ae5
#include
<stdio.h>
#include
<sys/types.h>
long
long
cpucycles_amd64tscfreq
(
void
)
{
unsigned
long
long
result
;
asm
volatile
(
".byte 15;.byte 49;shlq $32,%%rdx;orq %%rdx,%%rax"
:
"=a"
(
result
)
::
"%rdx"
);
return
result
;
}
long
long
cpucycles_amd64tscfreq_persecond
(
void
)
{
long
result
=
0
;
size_t
resultlen
=
sizeof
(
long
);
sysctlbyname
(
"machdep.tsc_freq"
,
&
result
,
&
resultlen
,
0
,
0
);
return
result
;
}
lib/nacl-20110221/cpucycles/amd64tscfreq.h
deleted
100644 → 0
View file @
366f0ae5
/*
cpucycles amd64tscfreq.h version 20060318
D. J. Bernstein
Public domain.
*/
#ifndef CPUCYCLES_amd64tscfreq_h
#define CPUCYCLES_amd64tscfreq_h
#ifdef __cplusplus
extern
"C"
{
#endif
extern
long
long
cpucycles_amd64tscfreq
(
void
);
extern
long
long
cpucycles_amd64tscfreq_persecond
(
void
);
#ifdef __cplusplus
}
#endif
#ifndef cpucycles_implementation
#define cpucycles_implementation "amd64tscfreq"
#define cpucycles cpucycles_amd64tscfreq
#define cpucycles_persecond cpucycles_amd64tscfreq_persecond
#endif
#endif
lib/nacl-20110221/cpucycles/celllinux.c
deleted
100644 → 0
View file @
366f0ae5
#include
<time.h>
#include
<stdio.h>
#include
<unistd.h>
#include
<sys/time.h>
#include
<sys/types.h>
#include
<spu_mfcio.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
long
result
;
result
=
-
spu_read_decrementer
();