~n-muench/ubuntu/quantal/open-vm-tools/open-vm-tools.may2.sid-sync

« back to all changes in this revision

Viewing changes to modules/linux/vmxnet3/compat_slab.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-05-30 09:48:43 UTC
  • mfrom: (1.1.5 upstream) (2.4.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090530094843-gdpza57r5iqsf124
Tags: 2009.05.22-167859-1
MergingĀ upstreamĀ versionĀ 2009.05.22-167859.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*********************************************************
2
 
 * Copyright (C) 2005 VMware, Inc. All rights reserved.
3
 
 *
4
 
 * This program is free software; you can redistribute it and/or modify it
5
 
 * under the terms of the GNU General Public License as published by the
6
 
 * Free Software Foundation version 2 and no later version.
7
 
 *
8
 
 * This program is distributed in the hope that it will be useful, but
9
 
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10
 
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
11
 
 * for more details.
12
 
 *
13
 
 * You should have received a copy of the GNU General Public License along
14
 
 * with this program; if not, write to the Free Software Foundation, Inc.,
15
 
 * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
16
 
 *
17
 
 *********************************************************/
18
 
 
19
 
#ifndef __COMPAT_SLAB_H__
20
 
#   define __COMPAT_SLAB_H__
21
 
 
22
 
 
23
 
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 2, 0)
24
 
#   include <linux/slab.h>
25
 
#else
26
 
#   include <linux/malloc.h>
27
 
#endif
28
 
 
29
 
/*
30
 
 * Before 2.6.20, kmem_cache_t was the accepted way to refer to a kmem_cache
31
 
 * structure.  Prior to 2.6.15, this structure was called kmem_cache_s, and
32
 
 * afterwards it was renamed to kmem_cache.  Here we keep things simple and use
33
 
 * the accepted typedef until it became deprecated, at which point we switch
34
 
 * over to the kmem_cache name.
35
 
 */
36
 
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
37
 
#   define compat_kmem_cache struct kmem_cache
38
 
#else
39
 
#   define compat_kmem_cache kmem_cache_t
40
 
#endif
41
 
 
42
 
/*
43
 
 * Up to 2.6.22 kmem_cache_create has 6 arguments - name, size, alignment, flags,
44
 
 * constructor, and destructor.  Then for some time kernel was asserting that
45
 
 * destructor is NULL, and since 2.6.23-pre1 kmem_cache_create takes only 5
46
 
 * arguments - destructor is gone.
47
 
 */
48
 
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22) || defined(VMW_KMEMCR_HAS_DTOR)
49
 
#define compat_kmem_cache_create(name, size, align, flags, ctor) \
50
 
                kmem_cache_create(name, size, align, flags, ctor, NULL)
51
 
#else
52
 
#define compat_kmem_cache_create(name, size, align, flags, ctor) \
53
 
                kmem_cache_create(name, size, align, flags, ctor)
54
 
#endif
55
 
 
56
 
/*
57
 
 * Up to 2.6.23 kmem_cache constructor has three arguments - pointer to block to
58
 
 * prepare (aka "this"), from which cache it came, and some unused flags.  After
59
 
 * 2.6.23 flags were removed, and order of "this" and cache parameters was swapped...
60
 
 * Since 2.6.27-rc2 everything is different again, and ctor has only one argument.
61
 
 *
62
 
 * HAS_3_ARGS has precedence over HAS_2_ARGS if both are defined.
63
 
 */
64
 
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23) && !defined(VMW_KMEMCR_CTOR_HAS_3_ARGS)
65
 
#  define VMW_KMEMCR_CTOR_HAS_3_ARGS
66
 
#endif
67
 
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26) && !defined(VMW_KMEMCR_CTOR_HAS_2_ARGS)
68
 
#  define VMW_KMEMCR_CTOR_HAS_2_ARGS
69
 
#endif
70
 
 
71
 
#if defined(VMW_KMEMCR_CTOR_HAS_3_ARGS)
72
 
typedef void compat_kmem_cache_ctor(void *, compat_kmem_cache *, unsigned long);
73
 
#define COMPAT_KMEM_CACHE_CTOR_ARGS(arg) void *arg, \
74
 
                                         compat_kmem_cache *cache, \
75
 
                                         unsigned long flags
76
 
#elif defined(VMW_KMEMCR_CTOR_HAS_2_ARGS)
77
 
typedef void compat_kmem_cache_ctor(compat_kmem_cache *, void *);
78
 
#define COMPAT_KMEM_CACHE_CTOR_ARGS(arg) compat_kmem_cache *cache, \
79
 
                                         void *arg
80
 
#else
81
 
typedef void compat_kmem_cache_ctor(void *);
82
 
#define COMPAT_KMEM_CACHE_CTOR_ARGS(arg) void *arg
83
 
#endif
84
 
 
85
 
#endif /* __COMPAT_SLAB_H__ */