~ubuntu-branches/debian/jessie/btrfs-tools/jessie

« back to all changes in this revision

Viewing changes to kerncompat.h

  • Committer: Package Import Robot
  • Author(s): Dimitri John Ledkov
  • Date: 2014-10-23 22:04:07 UTC
  • mfrom: (1.2.15) (6.1.40 sid)
  • Revision ID: package-import@ubuntu.com-20141023220407-skt9hy0ft4oim95o
Tags: 3.17-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#include <stddef.h>
30
30
#include <linux/types.h>
31
31
#include <stdint.h>
 
32
#ifndef BTRFS_DISABLE_BACKTRACE
32
33
#include <execinfo.h>
 
34
#endif
33
35
 
34
36
#define ptr_to_u64(x)   ((u64)(uintptr_t)x)
35
37
#define u64_to_ptr(x)   ((void *)(uintptr_t)x)
55
57
#define ULONG_MAX       (~0UL)
56
58
#endif
57
59
 
 
60
#ifndef BTRFS_DISABLE_BACKTRACE
58
61
#define MAX_BACKTRACE   16
59
62
static inline void print_trace(void)
60
63
{
81
84
}
82
85
 
83
86
#define BUG() assert_trace(NULL, __FILE__, __func__, __LINE__, 0)
 
87
#else
 
88
#define BUG() assert(0)
 
89
#endif
84
90
 
85
91
#ifdef __CHECKER__
86
92
#define __force    __attribute__((force))
102
108
typedef __u64 u64;
103
109
typedef __u16 u16;
104
110
typedef __u8 u8;
 
111
typedef __s64 s64;
 
112
typedef __s32 s32;
 
113
 
105
114
/*
106
115
 * Continuing to define __KERNEL__ breaks others parts of the code, so
107
116
 * we can just undefine it now that we have the correct headers...
113
122
typedef unsigned long long u64;
114
123
typedef unsigned char u8;
115
124
typedef unsigned short u16;
 
125
typedef long long s64;
 
126
typedef int s32
116
127
#endif
117
128
 
118
129
 
263
274
#define kzalloc(x, y) calloc(1, x)
264
275
#define kstrdup(x, y) strdup(x)
265
276
#define kfree(x) free(x)
 
277
#define vmalloc(x) malloc(x)
 
278
#define vfree(x) free(x)
266
279
 
 
280
#ifndef BTRFS_DISABLE_BACKTRACE
267
281
#define BUG_ON(c) assert_trace(#c, __FILE__, __func__, __LINE__, !(c))
 
282
#else
 
283
#define BUG_ON(c) assert(!(c))
 
284
#endif
268
285
 
269
286
#define WARN_ON(c) BUG_ON(c)
 
287
 
 
288
#ifndef BTRFS_DISABLE_BACKTRACE
270
289
#define ASSERT(c) assert_trace(#c, __FILE__, __func__, __LINE__, (c))
 
290
#else
 
291
#define ASSERT(c) assert(c)
 
292
#endif
271
293
 
272
294
#define container_of(ptr, type, member) ({                      \
273
295
        const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
323
345
#define put_unaligned_le64(val,p) (((struct __una_u64 *)(p))->x = cpu_to_le64(val))
324
346
#endif
325
347
 
 
348
#ifndef true
 
349
#define true 1
 
350
#define false 0
 
351
#endif
 
352
 
326
353
#ifndef noinline
327
354
#define noinline
328
355
#endif