CSDN |
GitHub |
Init_mutex was abolished Resolve Error:implicit declaration of function ' Init_mutex ' |
Ldd/problem/port/init_mutex |
This work uses the Knowledge sharing signature-non-commercial use-the same way Shares 4.0 international License Agreement to authorize, reprint please indicate the source
1 Questions
The following error was prompted during the recent migration drive
Error:implicit declaration of function ' Init_mutex ' [-werror=implicit-function-declaration] 2 causal analysis
In the Linux kernel after 2.6.37, Init_mutex has been abolished and the new version uses the Sema_init function
Check out the definition of an earlier version, see Include/linux/semaphore.h, Version 2.6.36.4, line 42
static inline void Sema_init (struct semaphore *sem, int val)
{
static struct lock_class_key;
*sem = (struct semaphore) __semaphore_initializer (*sem, Val);
Lockdep_init_map (&sem->lock.dep_map, "Semaphore->lock", &__key, 0);
}
#define INIT_MUTEX (SEM) sema_init (SEM, 1)
#define INIT_MUTEX_LOCKED (SEM) sema_init (SEM, 0)
3 Solutions
Modify the Init_mutex to Sema_init, or you can define Init_mutex modifications in the drive Init_mutex for Sema_init
#if linux_version_code > Kernel_version (2, 6,) &&!defined (Init_mutex)
sema_init (&sem, 1);
#else
Init_mutex (&sem);
#endif
Define Init_mutex as Sema_init
#if linux_version_code > Kernel_version (2, 6) &&!defined (Init_mutex)
#define INIT_MUTEX (SEM) sema_init (SEM, 1)
#endif
In fact, in the early kernel, the definition of sema_init, so you can not need to add #if #endif macros, directly modify Init_mutex for Sema_init is not a problem.
This work/Bowen (aderstep-Purple night-Blue Ling Xiang Cao copyright©2013-2017), by Chengjian (gatieme) creation,
Use of knowledge-sharing signatures-non-commercial use-Share 4.0 International license agreements in the same way. Welcome to reprint, use, republish, but be sure to keep the article signed Chengjian Gatieme (including Links: http://blog.csdn.net/gatieme/article/details/71598127), not for commercial purposes,
Based on the modified works of this article must be issued with the same license. If you have any questions, please contact me.