Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Main
Synchronet
Commits
b01fd14f
Commit
b01fd14f
authored
Apr 06, 2002
by
rswindell
Browse files
xp_random is now built for all compilers (even Borland), now self-seeding.
parent
93e5e01f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
4 deletions
+10
-4
src/xpdev/genwrap.c
src/xpdev/genwrap.c
+10
-4
No files found.
src/xpdev/genwrap.c
View file @
b01fd14f
...
...
@@ -36,8 +36,9 @@
****************************************************************************/
#include <string.h>
/* strlen() */
#include <stdlib.h>
/* RAND_MAX */
#include <fcntl.h>
/* O_NOCTTY */
#include <stdlib.h>
/* RAND_MAX */
#include <fcntl.h>
/* O_NOCTTY */
#include <time.h>
/* clock() */
#if defined(__unix__)
/* KIOCSOUND */
...
...
@@ -45,6 +46,7 @@
#include <sys/kbio.h>
#else
#include <sys/kd.h>
#endif
#endif
/* __unix__ */
#include "genwrap.h"
/* Verify prototypes */
...
...
@@ -113,16 +115,20 @@ void DLLCALL unix_beep(int freq, int dur)
/****************************************************************************/
/* Return random number between 0 and n-1 */
/****************************************************************************/
#if !defined(__BORLANDC__j)
int
DLLCALL
xp_random
(
int
n
)
{
float
f
;
static
BOOL
initialized
;
if
(
!
initialized
)
{
srand
(
time
(
NULL
));
/* seed random number generator */
rand
();
/* throw away first result */
initialized
=
TRUE
;
}
if
(
n
<
2
)
return
(
0
);
f
=
(
float
)
rand
()
/
(
float
)
RAND_MAX
;
return
((
int
)(
n
*
f
));
}
#endif
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