staging: lustre: remove top level ccflags variable
[linux-2.6-block.git] / drivers / staging / lustre / lustre / libcfs / linux / linux-prim.c
CommitLineData
d7e09d03
PT
1/*
2 * GPL HEADER START
3 *
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
19 *
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
22 * have any questions.
23 *
24 * GPL HEADER END
25 */
26/*
27 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
29 *
30 * Copyright (c) 2011, 2012, Intel Corporation.
31 */
32/*
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
35 */
36
37#define DEBUG_SUBSYSTEM S_LNET
38#include <linux/module.h>
39#include <linux/kernel.h>
40#include <linux/fs_struct.h>
41#include <linux/sched.h>
42
9fdaf8c0 43#include "../../../include/linux/libcfs/libcfs.h"
d7e09d03
PT
44
45#if defined(CONFIG_KGDB)
46#include <asm/kgdb.h>
47#endif
48
d7e09d03
PT
49/**
50 * wait_queue_t of Linux (version < 2.6.34) is a FIFO list for exclusively
51 * waiting threads, which is not always desirable because all threads will
52 * be waken up again and again, even user only needs a few of them to be
53 * active most time. This is not good for performance because cache can
54 * be polluted by different threads.
55 *
56 * LIFO list can resolve this problem because we always wakeup the most
57 * recent active thread by default.
58 *
59 * NB: please don't call non-exclusive & exclusive wait on the same
60 * waitq if add_wait_queue_exclusive_head is used.
61 */
62void
63add_wait_queue_exclusive_head(wait_queue_head_t *waitq, wait_queue_t *link)
64{
65 unsigned long flags;
66
4ed296ef
PG
67 spin_lock_irqsave(&waitq->lock, flags);
68 __add_wait_queue_exclusive(waitq, link);
69 spin_unlock_irqrestore(&waitq->lock, flags);
d7e09d03
PT
70}
71EXPORT_SYMBOL(add_wait_queue_exclusive_head);
72
54319351 73void cfs_init_timer(struct timer_list *t)
d7e09d03
PT
74{
75 init_timer(t);
76}
77EXPORT_SYMBOL(cfs_init_timer);
78
54319351 79void cfs_timer_init(struct timer_list *t, cfs_timer_func_t *func, void *arg)
d7e09d03
PT
80{
81 init_timer(t);
82 t->function = func;
83 t->data = (unsigned long)arg;
84}
85EXPORT_SYMBOL(cfs_timer_init);
86
54319351 87void cfs_timer_done(struct timer_list *t)
d7e09d03
PT
88{
89 return;
90}
91EXPORT_SYMBOL(cfs_timer_done);
92
54319351 93void cfs_timer_arm(struct timer_list *t, cfs_time_t deadline)
d7e09d03
PT
94{
95 mod_timer(t, deadline);
96}
97EXPORT_SYMBOL(cfs_timer_arm);
98
54319351 99void cfs_timer_disarm(struct timer_list *t)
d7e09d03
PT
100{
101 del_timer(t);
102}
103EXPORT_SYMBOL(cfs_timer_disarm);
104
54319351 105int cfs_timer_is_armed(struct timer_list *t)
d7e09d03
PT
106{
107 return timer_pending(t);
108}
109EXPORT_SYMBOL(cfs_timer_is_armed);
110
54319351 111cfs_time_t cfs_timer_deadline(struct timer_list *t)
d7e09d03
PT
112{
113 return t->expires;
114}
115EXPORT_SYMBOL(cfs_timer_deadline);
116
117void cfs_enter_debugger(void)
118{
119#if defined(CONFIG_KGDB)
120// BREAKPOINT();
121#else
122 /* nothing */
123#endif
124}
125
126
127sigset_t
128cfs_block_allsigs(void)
129{
130 unsigned long flags;
131 sigset_t old;
132
133 SIGNAL_MASK_LOCK(current, flags);
134 old = current->blocked;
135 sigfillset(&current->blocked);
136 recalc_sigpending();
137 SIGNAL_MASK_UNLOCK(current, flags);
138
139 return old;
140}
141
142sigset_t cfs_block_sigs(unsigned long sigs)
143{
144 unsigned long flags;
145 sigset_t old;
146
147 SIGNAL_MASK_LOCK(current, flags);
148 old = current->blocked;
149 sigaddsetmask(&current->blocked, sigs);
150 recalc_sigpending();
151 SIGNAL_MASK_UNLOCK(current, flags);
152 return old;
153}
154
155/* Block all signals except for the @sigs */
156sigset_t cfs_block_sigsinv(unsigned long sigs)
157{
158 unsigned long flags;
159 sigset_t old;
160
161 SIGNAL_MASK_LOCK(current, flags);
162 old = current->blocked;
163 sigaddsetmask(&current->blocked, ~sigs);
164 recalc_sigpending();
165 SIGNAL_MASK_UNLOCK(current, flags);
166
167 return old;
168}
169
170void
171cfs_restore_sigs (sigset_t old)
172{
173 unsigned long flags;
174
175 SIGNAL_MASK_LOCK(current, flags);
176 current->blocked = old;
177 recalc_sigpending();
178 SIGNAL_MASK_UNLOCK(current, flags);
179}
180
181int
182cfs_signal_pending(void)
183{
184 return signal_pending(current);
185}
186
187void
188cfs_clear_sigpending(void)
189{
190 unsigned long flags;
191
192 SIGNAL_MASK_LOCK(current, flags);
193 clear_tsk_thread_flag(current, TIF_SIGPENDING);
194 SIGNAL_MASK_UNLOCK(current, flags);
195}
196
197int
198libcfs_arch_init(void)
199{
200 return 0;
201}
202
203void
204libcfs_arch_cleanup(void)
205{
206 return;
207}
208
209EXPORT_SYMBOL(libcfs_arch_init);
210EXPORT_SYMBOL(libcfs_arch_cleanup);
211EXPORT_SYMBOL(cfs_enter_debugger);
212EXPORT_SYMBOL(cfs_block_allsigs);
213EXPORT_SYMBOL(cfs_block_sigs);
214EXPORT_SYMBOL(cfs_block_sigsinv);
215EXPORT_SYMBOL(cfs_restore_sigs);
216EXPORT_SYMBOL(cfs_signal_pending);
217EXPORT_SYMBOL(cfs_clear_sigpending);