~tblue/+junk/biosim

« back to all changes in this revision

Viewing changes to src/util.h

  • Committer: Tilman Blumenbach
  • Date: 2010-02-23 17:20:30 UTC
  • Revision ID: tilman@ax86.net-20100223172030-9s951z97trfik0fs
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * @file  util.h
 
3
 * @brief Prototypes for utility functions.
 
4
 */
 
5
/* biosim - A simulator for the predator-prey relationship of aphids and
 
6
 *          ladybugs.
 
7
 *
 
8
 * Copyright (c) 2010, Tilman Blumenbach <tilman@ax86.net>
 
9
 * All rights reserved.
 
10
 *
 
11
 * Redistribution and use in source and binary forms, with or without
 
12
 * modification, are permitted provided that the following conditions are
 
13
 * met:
 
14
 *  - Redistributions of source code must retain the above copyright notice,
 
15
 *    this list of conditions and the following disclaimer.
 
16
 *  - Redistributions in binary form must reproduce the above copyright
 
17
 *    notice, this list of conditions and the following disclaimer in the
 
18
 *    documentation and/or other materials provided with the distribution.
 
19
 *
 
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 
21
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 
22
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 
23
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
 
24
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
27
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
 
28
 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
29
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 
30
 * THE POSSIBILITY OF SUCH DAMAGE.
 
31
 */
 
32
 
 
33
#ifndef UTIL_H
 
34
#define UTIL_H
 
35
 
 
36
#ifdef _WIN32
 
37
/**
 
38
 * @brief Initialize the random number generator (RNG).
 
39
 *
 
40
 * This function MUST be called on Windows before calling rand_get().
 
41
 */
 
42
int rand_init( void );
 
43
 
 
44
/**
 
45
 * @brief De-initialize / destroy the random number generator.
 
46
 *
 
47
 * This function should be called on Windows when rand_get() is not needed
 
48
 * anymore.
 
49
 */
 
50
void rand_destroy( void );
 
51
#endif
 
52
 
 
53
/**
 
54
 * @brief Get a (pseudo) random number between \c min and \c max inclusive.
 
55
 * @param min The smallest integer to return (lower limit).
 
56
 * @param max The biggest integer to return (upper limit).
 
57
 * @return A random number between \c min and \c max inclusive.
 
58
 */
 
59
int rand_get( unsigned int min, unsigned int max );
 
60
 
 
61
#endif /* ifndef UTIL_H */