mirror of
https://github.com/apache/nuttx.git
synced 2026-05-22 05:42:05 +08:00
conn_lock: inline conn_lock/conn_dev_lock
modify functions that are simple but frequently called into inline functions, thereby reducing CPU loading without significantly changing the code size. Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
committed by
Alan C. Assis
parent
5ca6581353
commit
b8850e4eb3
@@ -395,43 +395,3 @@ FAR struct iob_s *net_ioballoc(bool throttled)
|
||||
return net_iobtimedalloc(throttled, UINT_MAX);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: conn_lock, conn_unlock, conn_dev_lock, conn_dev_unlock
|
||||
*
|
||||
* Description:
|
||||
* Lock and unlock the connection and device.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void conn_lock(FAR struct socket_conn_s *sconn)
|
||||
{
|
||||
nxrmutex_lock(&sconn->s_lock);
|
||||
}
|
||||
|
||||
void conn_unlock(FAR struct socket_conn_s *sconn)
|
||||
{
|
||||
nxrmutex_unlock(&sconn->s_lock);
|
||||
}
|
||||
|
||||
void conn_dev_lock(FAR struct socket_conn_s *sconn,
|
||||
FAR struct net_driver_s *dev)
|
||||
{
|
||||
if (dev != NULL)
|
||||
{
|
||||
netdev_lock(dev);
|
||||
}
|
||||
|
||||
nxrmutex_lock(&sconn->s_lock);
|
||||
}
|
||||
|
||||
void conn_dev_unlock(FAR struct socket_conn_s *sconn,
|
||||
FAR struct net_driver_s *dev)
|
||||
{
|
||||
nxrmutex_unlock(&sconn->s_lock);
|
||||
|
||||
if (dev != NULL)
|
||||
{
|
||||
netdev_unlock(dev);
|
||||
}
|
||||
}
|
||||
|
||||
+30
-6
@@ -32,6 +32,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <nuttx/mutex.h>
|
||||
#include <nuttx/net/net.h>
|
||||
#include <nuttx/net/ip.h>
|
||||
#include <nuttx/net/netdev.h>
|
||||
@@ -614,14 +615,37 @@ FAR void *cmsg_append(FAR struct msghdr *msg, int level, int type,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void conn_lock(FAR struct socket_conn_s *sconn);
|
||||
void conn_unlock(FAR struct socket_conn_s *sconn);
|
||||
static inline_function void conn_lock(FAR struct socket_conn_s *sconn)
|
||||
{
|
||||
nxrmutex_lock(&sconn->s_lock);
|
||||
}
|
||||
|
||||
void conn_dev_lock(FAR struct socket_conn_s *sconn,
|
||||
FAR struct net_driver_s *dev);
|
||||
static inline_function void conn_unlock(FAR struct socket_conn_s *sconn)
|
||||
{
|
||||
nxrmutex_unlock(&sconn->s_lock);
|
||||
}
|
||||
|
||||
void conn_dev_unlock(FAR struct socket_conn_s *sconn,
|
||||
FAR struct net_driver_s *dev);
|
||||
static inline_function void conn_dev_lock(FAR struct socket_conn_s *sconn,
|
||||
FAR struct net_driver_s *dev)
|
||||
{
|
||||
if (dev != NULL)
|
||||
{
|
||||
netdev_lock(dev);
|
||||
}
|
||||
|
||||
nxrmutex_lock(&sconn->s_lock);
|
||||
}
|
||||
|
||||
static inline_function void conn_dev_unlock(FAR struct socket_conn_s *sconn,
|
||||
FAR struct net_driver_s *dev)
|
||||
{
|
||||
nxrmutex_unlock(&sconn->s_lock);
|
||||
|
||||
if (dev != NULL)
|
||||
{
|
||||
netdev_unlock(dev);
|
||||
}
|
||||
}
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user