OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [include/] [net/] [sctp/] [compat.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/* SCTP kernel reference Implementation
2
 *
3
 * (C) Copyright IBM Corp. 2004
4
 * Copyright (c) 2003 Hewlett-Packard Company
5
 *
6
 * This file is part of the SCTP kernel reference Implementation
7
 *
8
 * This header represents the structures and constants needed to backport
9
 * lksctp from Linux kernel 2.5 to 2.4 This file also has some code that
10
 * has been taken from the source base of Linux kernel 2.5
11
 *
12
 * The SCTP reference implementation is free software;
13
 * you can redistribute it and/or modify it under the terms of
14
 * the GNU General Public License as published by
15
 * the Free Software Foundation; either version 2, or (at your option)
16
 * any later version.
17
 *
18
 * The SCTP reference implementation is distributed in the hope that it
19
 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
20
 *                 ************************
21
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22
 * See the GNU General Public License for more details.
23
 *
24
 * You should have received a copy of the GNU General Public License
25
 * along with GNU CC; see the file COPYING.  If not, write to
26
 * the Free Software Foundation, 59 Temple Place - Suite 330,
27
 * Boston, MA 02111-1307, USA.
28
 *
29
 */
30
 
31
#ifndef __net_sctp_compat_h__
32
#define __net_sctp_compat_h__
33
 
34
#include <linux/version.h>
35
#include <linux/module.h>
36
#include <linux/poll.h>
37
#include <linux/seq_file.h>
38
 
39
/*
40
 * The following defines are for compatibility with 2.6
41
 */
42
/*
43
 * container_of - cast a member of a structure out to the containing structure
44
 * @ptr:        the pointer to the member.
45
 * @type:       the type of the container struct this is embedded in.
46
 * @member:     the name of the member within the struct.
47
 */
48
#define container_of(ptr, type, member) ({                      \
49
        const typeof( ((type *)0)->member ) *__mptr = (ptr);     \
50
        (type *)( (char *)__mptr - offsetof(type,member) );})
51
 
52
#define DEFINE_SNMP_STAT(type, name)    \
53
        type name[NR_CPUS * 2]
54
#define DECLARE_SNMP_STAT(type, name)   \
55
        extern type name[]
56
#define SNMP_DEC_STATS(mib, field) ((mib)[2*smp_processor_id()+!in_softirq()].field--)
57
 
58
#define inet_sk(__sk) (&(((struct sock *)__sk)->protinfo.af_inet))
59
#define inet6_sk(__sk) (&(((struct sock *)__sk)->net_pinfo.af_inet6))
60
 
61
#define virt_addr_valid(x)      VALID_PAGE(virt_to_page((x)))
62
#define sock_owned_by_user(sk)  ((sk)->lock.users)
63
#define sk_set_owner(x, y)
64
#define __unsafe(x) MOD_INC_USE_COUNT
65
#define dst_pmtu(x) ((x)->pmtu)
66
 
67
#define sk_family family
68
#define sk_state state
69
#define sk_type type
70
#define sk_socket socket
71
#define sk_prot prot
72
#define sk_rcvbuf rcvbuf
73
#define sk_sndbuf sndbuf
74
#define sk_ack_backlog ack_backlog
75
#define sk_max_ack_backlog max_ack_backlog
76
#define sk_write_space write_space
77
#define sk_use_write_queue use_write_queue
78
#define sk_err err
79
#define sk_err_soft err_soft
80
#define sk_error_report error_report
81
#define sk_error_queue error_queue
82
#define sk_shutdown shutdown
83
#define sk_state_change state_change
84
#define sk_receive_queue receive_queue
85
#define sk_data_ready data_ready
86
#define sk_no_check no_check
87
#define sk_reuse reuse
88
#define sk_destruct destruct
89
#define sk_zapped zapped
90
#define sk_protocol protocol
91
#define sk_backlog_rcv backlog_rcv
92
#define sk_allocation allocation
93
#define sk_lingertime lingertime
94
#define sk_sleep sleep
95
#define sk_wmem_queued wmem_queued
96
#define sk_bound_dev_if bound_dev_if
97
 
98
/*
99
 * find last bit set.
100
 */
101
static __inline__ int fls(int x)
102
{
103
        int r = 32;
104
 
105
        if (!x)
106
                return 0;
107
        if (!(x & 0xffff0000u)) {
108
                x <<= 16;
109
                r -= 16;
110
        }
111
        if (!(x & 0xff000000u)) {
112
                x <<= 8;
113
                r -= 8;
114
        }
115
        if (!(x & 0xf0000000u)) {
116
                x <<= 4;
117
                r -= 4;
118
        }
119
        if (!(x & 0xc0000000u)) {
120
                x <<= 2;
121
                r -= 2;
122
        }
123
        if (!(x & 0x80000000u)) {
124
                x <<= 1;
125
                r -= 1;
126
        }
127
        return r;
128
}
129
 
130
#endif /* __net_sctp_compat_h__ */

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.