Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
tg
Commits
22c1a411
Commit
22c1a411
authored
Jan 15, 2014
by
antma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve portability by removing rdtsc calls
https://github.com/vysheng/tg/issues/8
parent
4b6870f0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
14 deletions
+7
-14
mtproto-client.c
mtproto-client.c
+1
-2
mtproto-common.c
mtproto-common.c
+6
-6
mtproto-common.h
mtproto-common.h
+0
-6
No files found.
mtproto-client.c
View file @
22c1a411
...
...
@@ -90,14 +90,13 @@ struct connection_methods auth_methods = {
};
long
long
precise_time
;
long
long
precise_time_rdtsc
;
double
get_utime
(
int
clock_id
)
{
struct
timespec
T
;
my_clock_gettime
(
clock_id
,
&
T
);
double
res
=
T
.
tv_sec
+
(
double
)
T
.
tv_nsec
*
1e-9
;
if
(
clock_id
==
CLOCK_REALTIME
)
{
precise_time
=
(
long
long
)
(
res
*
(
1LL
<<
32
));
precise_time_rdtsc
=
rdtsc
();
}
return
res
;
}
...
...
mtproto-common.c
View file @
22c1a411
...
...
@@ -67,6 +67,9 @@ int get_random_bytes (unsigned char *buf, int n) {
}
}
close
(
h
);
if
(
r
<
0
)
{
r
=
0
;
}
}
if
(
r
<
n
)
{
...
...
@@ -105,18 +108,15 @@ void my_clock_gettime (int clock_id UU, struct timespec *T) {
#endif
}
void
prng_seed
(
const
char
*
password_filename
,
int
password_length
)
{
unsigned
char
*
a
=
talloc0
(
64
+
password_length
);
long
long
r
=
rdtsc
();
struct
timespec
T
;
my_clock_gettime
(
CLOCK_REALTIME
,
&
T
);
memcpy
(
a
,
&
T
.
tv_sec
,
4
);
memcpy
(
a
+
4
,
&
T
.
tv_nsec
,
4
);
memcpy
(
a
+
8
,
&
r
,
8
);
memcpy
(
a
+
4
,
&
T
.
tv_nsec
,
4
);
unsigned
short
p
=
getpid
();
memcpy
(
a
+
16
,
&
p
,
2
);
int
s
=
get_random_bytes
(
a
+
1
8
,
32
)
+
18
;
memcpy
(
a
+
8
,
&
p
,
2
);
int
s
=
get_random_bytes
(
a
+
1
0
,
32
)
+
10
;
if
(
password_filename
)
{
int
fd
=
open
(
password_filename
,
O_RDONLY
);
if
(
fd
<
0
)
{
...
...
mtproto-common.h
View file @
22c1a411
...
...
@@ -375,12 +375,6 @@ static inline void fetch_skip_str (void) {
fetch_str
(
l
);
}
static
__inline__
unsigned
long
long
rdtsc
(
void
)
{
unsigned
hi
,
lo
;
__asm__
__volatile__
(
"rdtsc"
:
"=a"
(
lo
),
"=d"
(
hi
));
return
(
(
unsigned
long
long
)
lo
)
|
(
((
unsigned
long
long
)
hi
)
<<
32
);
}
static
inline
long
have_prefetch_ints
(
void
)
{
return
in_end
-
in_ptr
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment