错误: 隐式声明函数‘init_MUTEX’ [-Werror=implicit-function-declaration]
2012-07-23 21:33
411 查看
在新版本的linux内核中,init_mutex已经被废除了,新版本使用sema_init函数。查了一下早期版本的定义:平台:X86 32位内核:2.6.30定义:Linux/include/linux/semaphore.h
1 /*
2 * Copyright (c) 2008 Intel Corporation
3 * Author: Matthew Wilcox <willy@linux.intel.com>
4 *
5 * Distributed under the terms of the GNU GPL, version 2
6 *
7 * Please see kernel/semaphore.c for documentation of these functions
8 */
9 #ifndef __LINUX_SEMAPHORE_H
10 #define __LINUX_SEMAPHORE_H
11
12 #include <linux/list.h>
13 #include <linux/spinlock.h>
14
15 /* Please don't access any members of this structure directly */
16 struct semaphore {
17 spinlock_t lock;
18 unsigned int count;
19 struct list_head wait_list;
20 };
21
22 #define __SEMAPHORE_INITIALIZER(name, n) \
23 { \
24 .lock = __SPIN_LOCK_UNLOCKED((name).lock), \
25 .count = n, \
26 .wait_list = LIST_HEAD_INIT((name).wait_list), \
27 }
28
29 #define DECLARE_MUTEX(name) \
30 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
31
32 static inline void sema_init(struct semaphore *sem, int val)
33 {
34 static struct lock_class_key __key;
35 *sem = (struct semaphore) __SEMAPHORE_INITIALIZER(*sem, val);
36 lockdep_init_map(&sem->lock.dep_map, "semaphore->lock", &__key, 0);
37 }
38
39 #define init_MUTEX(sem) sema_init(sem, 1)//在最新的版本中没有这两个宏定义了
40 #define init_MUTEX_LOCKED(sem) sema_init(sem, 0)
41
42 extern void down(struct semaphore *sem);
43 extern int __must_check down_interruptible(struct semaphore *sem);
44 extern int __must_check down_killable(struct semaphore *sem);
45 extern int __must_check down_trylock(struct semaphore *sem);
46 extern int __must_check down_timeout(struct semaphore *sem, long jiffies);
47 extern void up(struct semaphore *sem);
48
49 #endif /* __LINUX_SEMAPHORE_H */
50
说明:Init_MUTEX()函数初始化信号量为互斥量。 互斥量为信号量的特例,它可以防止数据被两个不同系统调用读写。sema_init (sem, 1) 定义为:平台:X86 32位内核:3.0.xx定义:Linux/include/linux/semaphore.h
1 /*
2 * Copyright (c) 2008 Intel Corporation
3 * Author: Matthew Wilcox <willy@linux.intel.com>
4 *
5 * Distributed under the terms of the GNU GPL, version 2
6 *
7 * Please see kernel/semaphore.c for documentation of these functions
8 */
9 #ifndef __LINUX_SEMAPHORE_H
10 #define __LINUX_SEMAPHORE_H
11
12 #include <linux/list.h>
13 #include <linux/spinlock.h>
14
15 /* Please don't access any members of this structure directly */
16 struct semaphore {
17 spinlock_t lock;
18 unsigned int count;
19 struct list_head wait_list;
20 };
21
22 #define __SEMAPHORE_INITIALIZER(name, n) \
23 { \
24 .lock = __SPIN_LOCK_UNLOCKED((name).lock), \
25 .count = n, \
26 .wait_list = LIST_HEAD_INIT((name).wait_list), \
27 }
28
29 #define DEFINE_SEMAPHORE(name) \
30 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
31
32 static inline void sema_init(struct semaphore *sem, int val)
33 {
34 static struct lock_class_key __key;
35 *sem = (struct semaphore) __SEMAPHORE_INITIALIZER(*sem, val);
36 lockdep_init_map(&sem->lock.dep_map, "semaphore->lock", &__key, 0);
37 }
38
39 extern void down(struct semaphore *sem);
40 extern int __must_check down_interruptible(struct semaphore *sem);
41 extern int __must_check down_killable(struct semaphore *sem);
42 extern int __must_check down_trylock(struct semaphore *sem);
43 extern int __must_check down_timeout(struct semaphore *sem, long jiffies);
44 extern void up(struct semaphore *sem);
45
46 #endif /* __LINUX_SEMAPHORE_H */
47
1 /*
2 * Copyright (c) 2008 Intel Corporation
3 * Author: Matthew Wilcox <willy@linux.intel.com>
4 *
5 * Distributed under the terms of the GNU GPL, version 2
6 *
7 * Please see kernel/semaphore.c for documentation of these functions
8 */
9 #ifndef __LINUX_SEMAPHORE_H
10 #define __LINUX_SEMAPHORE_H
11
12 #include <linux/list.h>
13 #include <linux/spinlock.h>
14
15 /* Please don't access any members of this structure directly */
16 struct semaphore {
17 spinlock_t lock;
18 unsigned int count;
19 struct list_head wait_list;
20 };
21
22 #define __SEMAPHORE_INITIALIZER(name, n) \
23 { \
24 .lock = __SPIN_LOCK_UNLOCKED((name).lock), \
25 .count = n, \
26 .wait_list = LIST_HEAD_INIT((name).wait_list), \
27 }
28
29 #define DECLARE_MUTEX(name) \
30 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
31
32 static inline void sema_init(struct semaphore *sem, int val)
33 {
34 static struct lock_class_key __key;
35 *sem = (struct semaphore) __SEMAPHORE_INITIALIZER(*sem, val);
36 lockdep_init_map(&sem->lock.dep_map, "semaphore->lock", &__key, 0);
37 }
38
39 #define init_MUTEX(sem) sema_init(sem, 1)//在最新的版本中没有这两个宏定义了
40 #define init_MUTEX_LOCKED(sem) sema_init(sem, 0)
41
42 extern void down(struct semaphore *sem);
43 extern int __must_check down_interruptible(struct semaphore *sem);
44 extern int __must_check down_killable(struct semaphore *sem);
45 extern int __must_check down_trylock(struct semaphore *sem);
46 extern int __must_check down_timeout(struct semaphore *sem, long jiffies);
47 extern void up(struct semaphore *sem);
48
49 #endif /* __LINUX_SEMAPHORE_H */
50
说明:Init_MUTEX()函数初始化信号量为互斥量。 互斥量为信号量的特例,它可以防止数据被两个不同系统调用读写。sema_init (sem, 1) 定义为:平台:X86 32位内核:3.0.xx定义:Linux/include/linux/semaphore.h
1 /*
2 * Copyright (c) 2008 Intel Corporation
3 * Author: Matthew Wilcox <willy@linux.intel.com>
4 *
5 * Distributed under the terms of the GNU GPL, version 2
6 *
7 * Please see kernel/semaphore.c for documentation of these functions
8 */
9 #ifndef __LINUX_SEMAPHORE_H
10 #define __LINUX_SEMAPHORE_H
11
12 #include <linux/list.h>
13 #include <linux/spinlock.h>
14
15 /* Please don't access any members of this structure directly */
16 struct semaphore {
17 spinlock_t lock;
18 unsigned int count;
19 struct list_head wait_list;
20 };
21
22 #define __SEMAPHORE_INITIALIZER(name, n) \
23 { \
24 .lock = __SPIN_LOCK_UNLOCKED((name).lock), \
25 .count = n, \
26 .wait_list = LIST_HEAD_INIT((name).wait_list), \
27 }
28
29 #define DEFINE_SEMAPHORE(name) \
30 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
31
32 static inline void sema_init(struct semaphore *sem, int val)
33 {
34 static struct lock_class_key __key;
35 *sem = (struct semaphore) __SEMAPHORE_INITIALIZER(*sem, val);
36 lockdep_init_map(&sem->lock.dep_map, "semaphore->lock", &__key, 0);
37 }
38
39 extern void down(struct semaphore *sem);
40 extern int __must_check down_interruptible(struct semaphore *sem);
41 extern int __must_check down_killable(struct semaphore *sem);
42 extern int __must_check down_trylock(struct semaphore *sem);
43 extern int __must_check down_timeout(struct semaphore *sem, long jiffies);
44 extern void up(struct semaphore *sem);
45
46 #endif /* __LINUX_SEMAPHORE_H */
47
相关文章推荐
- 错误: 隐式声明函数‘init_MUTEX’ [-Werror=implicit-function-declaration]
- 错误: 隐式声明函数‘kmalloc’ [-Werror=implicit-function-declaration]
- globalmem.c:193:2: 错误:隐式声明函数‘kmalloc’ [-Werror=implicit-function-declaration]
- /home/lufee/mydiraver//globalmem.c:193:2: 错误:隐式声明函数‘kmalloc’ [-Werror=implicit-function-declaration]
- implicit declaration of function 'init_MUTEX'
- 关于编译时报implicit-function-declaration(隐式声明)错误的解决方法
- C 语言 implicit declaration of function 错误原因
- 编译错误处理: warning: implicit declaration of function ‘close’ [-Wimplicit-function-declaration]
- 出现implicit declaration of function 'h1940_latch_control错误的解决方法
- init_MUTEX被废除(解决error: implicit declaration of function ‘init_MUTEX’)
- 编译错误解决:implicit declaration of function 'close' is invalid in C99
- iOS错误汇总 Implicit declaration of function - C99 完美解决
- IOS Implicit declaration of function 'xxxxxx ' is invalid in C99 错误
- error: implicit declaration of function 'acquire_console_sem'错误解决方法
- error: implicit declaration of function 'posix_memalign' [-Werror=implicit-function-declaration]
- implicit declaration of function 'KBUILD_STR' 错误
- xcode9报 Implicit declaration of function 'require' is invalid in c99 的错误
- 编译海思3520内核时候报错drivers/mfd/ezx-pcap.c:205:2: error: implicit declaration of function 'irq_to_gpio' [-
- linux c之出现warning: implicit declaration of function ‘exit’ [-Wimplicit-function-declaration]这个问题
- warning: function declared implicitly错误原因