-
Notifications
You must be signed in to change notification settings - Fork 9
/
mce-lib.h
78 lines (64 loc) · 2.86 KB
/
mce-lib.h
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
/**
* @file mce-lib.h
* Headers for various helper functions
* for the Mode Control Entity
* <p>
* Copyright © 2004-2011 Nokia Corporation and/or its subsidiary(-ies).
* Copyright (C) 2014-2019 Jolla Ltd.
* <p>
* @author David Weinehall <[email protected]>
* @author Tapio Rantala <[email protected]>
* @author Santtu Lakkala <[email protected]>
* @author Simo Piiroinen <[email protected]>
*
* mce is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* mce 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 mce. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _MCE_LIB_H_
#define _MCE_LIB_H_
#include <stdint.h>
#include <glib.h>
/** Find the number of bits of a type */
#define bitsize_of(__x) (guint)(sizeof (__x) * 8)
/** translation structure */
typedef struct {
const gint number; /**< Number representation */
const gchar *const string; /**< String representation */
} mce_translation_t;
void set_bit(guint bit, gulong **bitfield);
void clear_bit(guint bit, gulong **bitfield);
gboolean test_bit(guint bit, const gulong *bitfield);
gboolean string_to_bitfield(const gchar *string,
gulong **bitfield, gsize bitfieldsize);
char *bitfield_to_string(const gulong *bitfield, gsize bitfieldsize);
const gchar *bin_to_string(guint bin);
const gchar *mce_translate_int_to_string_with_default(const mce_translation_t translation[], gint number, const gchar *default_string);
const gchar *mce_translate_int_to_string(const mce_translation_t translation[],
gint number);
gint mce_translate_string_to_int_with_default(const mce_translation_t translation[], const gchar *const string, gint default_number);
gint mce_translate_string_to_int(const mce_translation_t translation[],
const gchar *const string);
gchar *strstr_delim(const gchar *const haystack, const char *needle,
const char *const delimiter);
gboolean strmemcmp(guint8 *mem, const gchar *str, gulong len);
int64_t mce_lib_get_boot_tick(void);
int64_t mce_lib_get_mono_tick(void);
int64_t mce_lib_get_real_tick(void);
guint mce_wakelocked_timeout_add_full(gint priority, guint interval,
GSourceFunc function,
gpointer data, GDestroyNotify notify);
guint mce_wakelocked_timeout_add(guint interval, GSourceFunc function,
gpointer data);
guint mce_wakelocked_idle_add(GSourceFunc function, gpointer data);
char *mce_strip_string(char *str);
char *mce_slice_token(char *pos, char **ppos, const char *sep);
#endif /* _MCE_LIB_H_ */