aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/interceptor/platform_kernel_mutex.h
blob: 2e9d0806589007eb1535c786a48891e636a54d22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* Netfilter Driver for IPSec VPN Client
 *
 * Copyright(c)   2012 Samsung Electronics
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

/*
 * platform_kernel_mutex.h
 *
 * Linux interceptor specific defines for the kernel mutex API.
 *
 */

#ifndef PLATFORM_KERNEL_MUTEX_H
#define PLATFORM_KERNEL_MUTEX_H 1

/* Sanity check to make sure that optimizations get done correcly
   on a UP machine. The following block can be safely removed. */
#ifndef CONFIG_SMP
#ifdef __ASM_SPINLOCK_H
#error "asm/spinlock.h" should not be included explicitly.
#endif /* __ASM_SPINLOCK_H */
#endif /* !CONFIG_SMP */

#include "linux_params.h"
#include "linux_mutex_internal.h"

/* Directly map linux mutexes to macros. This causes significantly
   less overhead in the non-preemptive UP case, where these macros
   are empty. */
#ifndef KERNEL_MUTEX_USE_FUNCTIONS

/* This code should not be used unless DEBUG_LIGHT is disabled. */

#define ssh_kernel_mutex_lock(a) spin_lock(&((a)->lock))
#define ssh_kernel_mutex_unlock(b) spin_unlock(&((b)->lock))

#else /* KERNEL_MUTEX_USE_FUNCTIONS */

void ssh_kernel_mutex_lock_i(SshKernelMutex mutex);
void ssh_kernel_mutex_unlock_i(SshKernelMutex mutex);

#define ssh_kernel_mutex_lock(a) \
  ssh_kernel_mutex_lock_i((a))
#define ssh_kernel_mutex_unlock(a) \
  ssh_kernel_mutex_unlock_i((a))

#endif /* KERNEL_MUTEX_USE_FUNCTIONS */

#endif /* PLATFORM_KERNEL_MUTEX_H */