summaryrefslogtreecommitdiff
path: root/lwrapper.h
blob: 2d7b5aa75b4f70e98a7abd04605c9d30751e94f3 (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
/*
 * Copyright © 2010 Jerome Glisse <glisse@freedesktop.org>
 *
 * This file is free software; you can redistribute it and/or modify
 * it under the terms of version 2 of the GNU General Public License
 * as published by the Free Software Foundation.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 */
#ifndef LWRAPPER_H
#define LWRAPPER_H

#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "xf86drm.h"
#include "radeon_bo.h"
#include "radeon_drm.h"

typedef uint8_t		u8;
typedef uint32_t	u32;
typedef uint64_t	u64;
#define GFP_KERNEL  0
#define kmalloc(s, gfp) malloc(s)
#define kfree(p) free(p)

struct idr {
	u32	cid;
};

struct mutex {
	int	lock;
};

#define mutex_init(ptr)
#define mutex_lock(ptr)
#define mutex_unlock(ptr)

extern int idr_pre_get(struct idr *idp, int gfp_mask);
extern int idr_get_new(struct idr *idp, void *ptr, int *id);
extern void idr_destroy(struct idr *idp);
extern void idr_init(struct idr *idp);

#include "list.h"
#define dev_err(d, p, args...) fprintf(stderr, p, ##args)

struct kref {
	int refcount;
};

void kref_set(struct kref *kref, int num);
void kref_init(struct kref *kref);
void kref_get(struct kref *kref);
int kref_put(struct kref *kref, void (*release) (struct kref *kref));
/**
 * container_of - cast a member of a structure out to the containing structure
 * @ptr:	the pointer to the member.
 * @type:	the type of the container struct this is embedded in.
 * @member:	the name of the member within the struct.
 *
 */
#define container_of(ptr, type, member) ({			\
	const typeof( ((type *)0)->member ) *__mptr = (ptr);	\
	(type *)( (char *)__mptr - offsetof(type,member) );})

#endif