aboutsummaryrefslogtreecommitdiff
path: root/include/libcasio/misc.h
blob: fcfd0a22eaba5f8b43da0c87217f35b65650b04a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* ****************************************************************************
 * libcasio/misc.h -- libcasio miscallaneous utilities.
 * Copyright (C) 2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
 *
 * This file is part of libcasio.
 * libcasio is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 3.0 of the License,
 * or (at your option) any later version.
 *
 * libcasio is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with libcasio; if not, see <http://www.gnu.org/licenses/>.
 * ************************************************************************* */
#ifndef  LIBCASIO_MISC_H
# define LIBCASIO_MISC_H 2018051601
# include "cdefs.h"
# include "stream.h"
# include "fs.h"

CASIO_BEGIN_NAMESPACE
CASIO_BEGIN_DECLS

/* As there is no portable sleep function, libcasio implements one.
 * It takes a callback, of the following form: */

CASIO_EXTERN int  CASIO_EXPORT casio_sleep
	OF((unsigned long casio__ms));

/* If the default function is not good enough for you, just change it
 * using the following function. */

typedef void casio_sleep_t OF((unsigned long casio__ms));

CASIO_EXTERN void CASIO_EXPORT casio_set_sleep_func
	OF((casio_sleep_t *casio__func));

/* As for time and timeouts management, here are functions to time
 * anything in libcasio. Times are expressed in milliseconds. */

struct casio_timer_s;
typedef struct casio_timer_s casio_timer_t;

CASIO_EXTERN int CASIO_EXPORT casio_get_timer
	OF((casio_timer_t **casio__timer));
CASIO_EXTERN void CASIO_EXPORT casio_free_timer
	OF((casio_timer_t *casio__timer));

CASIO_EXTERN int CASIO_EXPORT casio_get_spent_time
	OF((casio_timer_t *casio__timer, unsigned long *casio__spent));

/* You can change these functions too! */

typedef int CASIO_EXPORT casio_get_timer_t
	OF((casio_timer_t **casio__timer));
typedef void CASIO_EXPORT casio_free_timer_t
	OF((casio_timer_t *casio__timer));
typedef int CASIO_EXPORT casio_get_spent_time_t
	OF((casio_timer_t *casio__timer, unsigned long *casio__spent));

CASIO_EXTERN int CASIO_EXPORT casio_set_timer_funcs
	OF((casio_get_timer_t *casio__get_timer,
		casio_free_timer_t *casio__free_timer,
		casio_get_spent_time_t *casio__get_spent_time));

/* And here are cross-platform allocation functions.
 * They are defined just in case. */

CASIO_EXTERN void* CASIO_EXPORT casio_alloc
	OF((size_t casio__num_elements, size_t casio__element_size));
CASIO_EXTERN void  CASIO_EXPORT casio_free
	OF((void *casio__ptr));

CASIO_END_DECLS
CASIO_END_NAMESPACE

#endif /* LIBCASIO_MISC_H */