Home | History | Annotate | Download | only in module
      1 /**
      2  * @file compat.h
      3  * This file is intended to be up-to-date with the last linux version and
      4  * provide work-arounds for missing features in previous kernel version
      5  *
      6  * @remark Copyright 2002 OProfile authors
      7  * @remark Read the file COPYING
      8  *
      9  * @author John Levon
     10  * @author Philippe Elie
     11  */
     12 
     13 
     14 #ifndef COMPAT_H
     15 #define COMPAT_H
     16 
     17 #include <linux/version.h>
     18 #include <linux/module.h>
     19 #ifdef HAVE_LINUX_SPINLOCK_HEADER
     20 /* FIXME do we need this still ? */
     21 #include <linux/spinlock.h>
     22 #endif
     23 
     24 #define V_BEFORE(a, b, c) (LINUX_VERSION_CODE < KERNEL_VERSION(a, b, c))
     25 #define V_AT_LEAST(a, b, c) (LINUX_VERSION_CODE >= KERNEL_VERSION(a, b, c))
     26 
     27 #if V_BEFORE(2, 4, 0)
     28 	#include "compat22.h"
     29 #else
     30 	#include "compat24.h"
     31 #endif
     32 
     33 #include "op_cache.h"
     34 
     35 /* Things that cannot rely on a particular linux version or are needed between
     36  * major release */
     37 
     38 #ifndef BUG_ON
     39 #define BUG_ON(p) do { if (p) BUG(); } while (0)
     40 #endif
     41 
     42 #ifndef MODULE_LICENSE
     43 #define MODULE_LICENSE(x)
     44 #endif
     45 
     46 /* Compiler work-around */
     47 
     48 /* branch prediction */
     49 #ifndef likely
     50 	#ifdef EXPECT_OK
     51 		#define likely(a) __builtin_expect((a), 1)
     52 	#else
     53 		#define likely(a) (a)
     54 	#endif
     55 #endif
     56 #ifndef unlikely
     57 	#ifdef EXPECT_OK
     58 		#define unlikely(a) __builtin_expect((a), 0)
     59 	#else
     60 		#define unlikely(a) (a)
     61 	#endif
     62 #endif
     63 
     64 #ifndef CONFIG_X86_64
     65 #define VMALLOC_32(sz) vmalloc_32(sz)
     66 #else /* CONFIG_X86_64 */
     67 #define VMALLOC_32(sz) vmalloc(sz)
     68 #endif /* CONFIG_X86_64 */
     69 
     70 #endif /* COMPAT_H */
     71