Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
821388c9
Commit
821388c9
authored
19 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Fix xp_randomize() build for *nix.
parent
5d6bde3a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/xpdev/genwrap.c
+11
-3
11 additions, 3 deletions
src/xpdev/genwrap.c
src/xpdev/genwrap.h
+5
-0
5 additions, 0 deletions
src/xpdev/genwrap.h
with
16 additions
and
3 deletions
src/xpdev/genwrap.c
+
11
−
3
View file @
821388c9
...
...
@@ -236,9 +236,7 @@ char* strrev(char* str)
/****************************************************************************/
unsigned
DLLCALL
xp_randomize
(
void
)
{
unsigned
thread_id
=
(
unsigned
)
GetCurrentThreadId
();
unsigned
process_id
=
(
unsigned
)
GetCurrentProcessId
();
unsigned
seed
=
time
(
NULL
)
^
BYTE_SWAP_INT
(
thread_id
)
^
process_id
;
unsigned
seed
=~
0
;
#if defined(HAS_DEV_RANDOM) && defined(RANDOM_DEV)
int
rf
;
...
...
@@ -247,6 +245,16 @@ unsigned DLLCALL xp_randomize(void)
read
(
rf
,
&
seed
,
sizeof
(
seed
));
close
(
rf
);
}
#else
unsigned
curtime
=
(
unsigned
)
time
(
NULL
);
unsigned
process_id
=
(
unsigned
)
GetCurrentProcessId
();
seed
=
curtime
^
BYTE_SWAP_INT
(
process_id
);
#if defined(_WIN32) || defined(GetCurrentThreadId)
seed
^=
(
unsigned
)
GetCurrentThreadId
();
#endif
#endif
srand
(
seed
);
...
...
This diff is collapsed.
Click to expand it.
src/xpdev/genwrap.h
+
5
−
0
View file @
821388c9
...
...
@@ -48,11 +48,16 @@
#include
<sys/time.h>
/* struct timeval */
#include
<strings.h>
/* strcasecmp() */
#include
<unistd.h>
/* usleep */
/* Simple Win32 function equivalents */
#define GetCurrentProcessId() getpid()
#ifdef _THREAD_SAFE
#include
<pthread.h>
/* Check for GNU PTH libs */
#ifdef _PTH_PTHREAD_H_
#include
<pth.h>
#endif
#define GetCurrentThreadId() pthread_self()
#endif
#elif defined(_WIN32)
#include
<process.h>
/* getpid() */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment