summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs/src/jffs2/include/linux/kernel-rtems.h
blob: ed46ce23910d185e68320e46c976c1d6d7f93048 (plain) (blame)
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
/*
 * Copyright (c) 2013 embedded brains GmbH & Co. KG
 *
 * Copyright 2016 Chris Johns <chrisj@rtems.org>
 *
 * The license and distribution terms for this file may be
 * found in the file LICENSE in this distribution or at
 * http://www.rtems.org/license/LICENSE.
 */

#ifndef __LINUX_RTEMS_IMPL_H__
#define __LINUX_RTEMS_IMPL_H__

#include <rtems.h>
#include <rtems/bspIo.h>

static inline char *do_kmemdup(const char *s, size_t n)
{
	char *dup = malloc(n + 1);

	if (dup != 0) {
		dup[n] = '\0';
		dup = memcpy(dup, s, n);
	}

	return dup;
}

/*
 * Provide a private printk to avoid all the formatting warnings in the JFFS2 code.
 */
static inline int jffs2_printk(const char* fmt, ...)
{
	va_list ap;
	int r;
	va_start(ap, fmt);
	r = vprintk(fmt, ap);
	va_end(ap);
	return r;
}

#undef printk
#define printk jffs2_printk

#endif /* __LINUX_RTEMS_IMPL_H__ */