aboutsummaryrefslogtreecommitdiff
path: root/src/android_stubs.h
blob: 320263597219c8a63b453d6bc8a07ec67c1d15c5 (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
#include <linux/ethtool.h>
#include <sys/socket.h>
#include <string>

/* Android doesn't provide locale support int its C and C++
 * runtime. Handled at higher level in application stack.
 * So define stubs for gettext funtions used.
 */
#define PACKAGE			0
#define LOCALEDIR		0
#define bindtextdomain(x, y)
#define textdomain(x)
#define gettext(x)		(x)

#ifndef _LIBCPP_VERSION
/* STLport C++ new operator does not throw exception on failure */
#define set_new_handler(x)
#endif

/* define stubs for C++ exception handling */
#define try     	if (true)
#define catch(x) 	if (false)

/* Define __NR_perf_event_open if not already defined */
#if __arm__
#ifndef __NR_perf_event_open
#define __NR_perf_event_open    364
#endif
#endif

/* Implement missing functions */
static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep,
						__u32 speed)
{

	ep->speed = (__u16)speed;
	ep->speed_hi = (__u16)(speed >> 16);
}

static inline __u32 ethtool_cmd_speed(struct ethtool_cmd *ep)
{
	return (ep->speed_hi << 16) | ep->speed;
}

static inline char *strchrnul(const char *s, int c)
{
	while (*s && (*s != c))
		s++;
	return (char *)s;
}