4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2011, 2013, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
33 #define DEBUG_SUBSYSTEM S_LNET
34 #include <linux/module.h>
35 #include <linux/kernel.h>
36 #include <linux/fs_struct.h>
37 #include <linux/sched.h>
39 #include <libcfs/libcfs.h>
41 #if defined(CONFIG_KGDB)
45 #ifndef HAVE_KTIME_GET_TS64
46 void ktime_get_ts64(struct timespec64 *ts)
51 *ts = timespec_to_timespec64(now);
53 EXPORT_SYMBOL(ktime_get_ts64);
54 #endif /* HAVE_KTIME_GET_TS64 */
56 #ifndef HAVE_KTIME_GET_REAL_TS64
57 void ktime_get_real_ts64(struct timespec64 *ts)
62 *ts = timespec_to_timespec64(now);
64 EXPORT_SYMBOL(ktime_get_real_ts64);
65 #endif /* HAVE_KTIME_GET_REAL_TS64 */
67 #ifndef HAVE_KTIME_GET_REAL_SECONDS
69 * Get the seconds portion of CLOCK_REALTIME (wall clock).
70 * This is the clock that can be altered by NTP and is
71 * independent of a reboot.
73 time64_t ktime_get_real_seconds(void)
75 return (time64_t)get_seconds();
77 EXPORT_SYMBOL(ktime_get_real_seconds);
78 #endif /* HAVE_KTIME_GET_REAL_SECONDS */
80 #ifndef HAVE_KTIME_GET_SECONDS
82 * Get the seconds portion of CLOCK_MONOTONIC
83 * This clock is immutable and is reset across
84 * reboots. For older platforms this is a
85 * wrapper around get_seconds which is valid
86 * until 2038. By that time this will be gone
89 time64_t ktime_get_seconds(void)
91 struct timespec64 now;
96 EXPORT_SYMBOL(ktime_get_seconds);
97 #endif /* HAVE_KTIME_GET_SECONDS */
100 cfs_block_allsigs(void)
105 spin_lock_irqsave(¤t->sighand->siglock, flags);
106 old = current->blocked;
107 sigfillset(¤t->blocked);
109 spin_unlock_irqrestore(¤t->sighand->siglock, flags);
112 EXPORT_SYMBOL(cfs_block_allsigs);
114 sigset_t cfs_block_sigs(unsigned long sigs)
119 spin_lock_irqsave(¤t->sighand->siglock, flags);
120 old = current->blocked;
121 sigaddsetmask(¤t->blocked, sigs);
123 spin_unlock_irqrestore(¤t->sighand->siglock, flags);
126 EXPORT_SYMBOL(cfs_block_sigs);
128 /* Block all signals except for the @sigs */
129 sigset_t cfs_block_sigsinv(unsigned long sigs)
134 spin_lock_irqsave(¤t->sighand->siglock, flags);
135 old = current->blocked;
136 sigaddsetmask(¤t->blocked, ~sigs);
138 spin_unlock_irqrestore(¤t->sighand->siglock, flags);
141 EXPORT_SYMBOL(cfs_block_sigsinv);
144 cfs_restore_sigs(sigset_t old)
148 spin_lock_irqsave(¤t->sighand->siglock, flags);
149 current->blocked = old;
151 spin_unlock_irqrestore(¤t->sighand->siglock, flags);
153 EXPORT_SYMBOL(cfs_restore_sigs);
156 cfs_clear_sigpending(void)
160 spin_lock_irqsave(¤t->sighand->siglock, flags);
161 clear_tsk_thread_flag(current, TIF_SIGPENDING);
162 spin_unlock_irqrestore(¤t->sighand->siglock, flags);
164 EXPORT_SYMBOL(cfs_clear_sigpending);