/*
* Abstractions between different versions of Linux
* Currently only tested amonst the latest versions of 2.0 and 2.2
* Copyright (C) 2026 Javier S. Pedro
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
* 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, see .
*/
#ifdef MODVERSIONS
#include
#endif
#include
#define MAKE_VERSION_CODE(vers, rel, seq) ( (vers)<<16 | (rel)<<8 | (seq) )
#include
#include
// Module entry point abstraction
#if LINUX_VERSION_CODE < MAKE_VERSION_CODE(2,1,36)
#define __init /**/
#define module_init(x) int init_module(void) { return x(); }
#define module_exit(x) void cleanup_module(void) { x(); }
#else
#include
#endif
// Module params
#if LINUX_VERSION_CODE < MAKE_VERSION_CODE(2,1,26)
#define MODULE_PARM(var, type) /**/
#define MODULE_PARM_DESC(var, s) /**/
#define MODULE_DESCRIPTION(s) /**/
#endif
#if LINUX_VERSION_CODE < MAKE_VERSION_CODE(2,4,0)
#define MODULE_LICENSE(s) /**/
#endif
#include
#include
#include
#include
#include
#include
#if LINUX_VERSION_CODE < MAKE_VERSION_CODE(2,1,0)
#define invalidate_inodes_dev(devno) invalidate_inodes(devno)
#else
static inline void invalidate_inodes_dev(kdev_t devno) {
struct super_block *sb = get_super(devno);
if (sb) invalidate_inodes(sb);
}
#endif
#include
// time before/after
#if LINUX_VERSION_CODE < MAKE_VERSION_CODE(2,1,95)
#define time_after(a,b) ((long)(b) - (long)(a) < 0)
#define time_before(a,b) time_after(b,a)
#endif
// mdelay
#if LINUX_VERSION_CODE < MAKE_VERSION_CODE(2,1,0)
static inline void mdelay(int milliseconds)
{
int i;
for(i=0; i
#endif
// capabilities
#if LINUX_VERSION_CODE < MAKE_VERSION_CODE(2,1,0)
#define is_sys_admin() suser()
#else
#define is_sys_admin() capable(CAP_SYS_ADMIN)
#endif
// stdtypes
#if LINUX_VERSION_CODE < MAKE_VERSION_CODE(2,1,0)
typedef __s8 int8_t;
typedef __s16 int16_t;
typedef __s32 int32_t;
typedef __u8 uint8_t;
typedef __u16 uint16_t;
typedef __u32 uint32_t;
#endif
#include