nidas  v1.2-1520
ver_macros.h
Go to the documentation of this file.
1 /* -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8; -*- */
2 /* vim: set shiftwidth=8 softtabstop=8 expandtab: */
3 /*
4  ********************************************************************
5  ** NIDAS: NCAR In-situ Data Acquistion Software
6  **
7  ** 2007, Copyright University Corporation for Atmospheric Research
8  **
9  ** This program is free software; you can redistribute it and/or modify
10  ** it under the terms of the GNU General Public License as published by
11  ** the Free Software Foundation; either version 2 of the License, or
12  ** (at your option) any later version.
13  **
14  ** This program is distributed in the hope that it will be useful,
15  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  ** GNU General Public License for more details.
18  **
19  ** The LICENSE.txt file accompanying this software contains
20  ** a copy of the GNU General Public License. If it is not found,
21  ** write to the Free Software Foundation, Inc.,
22  ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  **
24  ********************************************************************
25 */
26 /*
27  macros for use across different version of Linux.
28 
29  Original Author: Gordon Maclean
30 
31 */
32 
33 #ifndef NIDAS_LINUX_NIDAS_VER_MACROS_H
34 #define NIDAS_LINUX_NIDAS_VER_MACROS_H
35 
36 #if defined(__KERNEL__)
37 
38 #include <linux/version.h>
39 
40 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
41 #define mutex_init(x) init_MUTEX(x)
42 #define mutex_lock_interruptible(x) ( down_interruptible(x) ? -ERESTARTSYS : 0)
43 #define mutex_unlock(x) up(x)
44 #endif
45 
50 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
51  #define device_create_x(a, b, c, d, ...) device_create(a, b, c, NULL, d, ##__VA_ARGS__)
52 #else
53  #define device_create_x(a, b, c, d, ...) device_create(a, b, c, d, ##__VA_ARGS__)
54 #endif
55 
61 #ifdef RHEL_RELEASE_CODE
62 # if RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(8,1)
63 # define portable_access_ok(mode, userptr, len) access_ok(mode, userptr, len)
64 # else
65 # define portable_access_ok(mode, userptr, len) access_ok(userptr, len)
66 # endif
67 #elif LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0)
68 # define portable_access_ok(mode, userptr, len) access_ok(mode, userptr, len)
69 #else
70 # define portable_access_ok(mode, userptr, len) access_ok(userptr, len)
71 #endif
72 
73 #endif
74 #endif