mirror of
https://github.com/apache/nuttx.git
synced 2026-08-20 13:08:26 +00:00
net/local: extern local_generate_instance_id() interface
Change-Id: I14273d11b1fe4d6bdc15b14e32da609cc7883713 Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
parent
a66e18bc53
commit
37c2bc18db
2 changed files with 34 additions and 20 deletions
|
|
@ -662,6 +662,16 @@ int local_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds);
|
|||
int local_pollteardown(FAR struct socket *psock, FAR struct pollfd *fds);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: local_generate_instance_id
|
||||
*
|
||||
* Description:
|
||||
* Generate instance ID for stream
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int32_t local_generate_instance_id(void);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,26 +45,6 @@
|
|||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: local_generate_instance_id
|
||||
****************************************************************************/
|
||||
|
||||
static int32_t local_generate_instance_id(void)
|
||||
{
|
||||
static int32_t g_next_instance_id = 0;
|
||||
int32_t id;
|
||||
|
||||
/* Called from local_connect with net_lock held. */
|
||||
|
||||
id = g_next_instance_id++;
|
||||
if (g_next_instance_id < 0)
|
||||
{
|
||||
g_next_instance_id = 0;
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: _local_semtake() and _local_semgive()
|
||||
*
|
||||
|
|
@ -216,6 +196,30 @@ errout_with_fifos:
|
|||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: local_generate_instance_id
|
||||
*
|
||||
* Description:
|
||||
* Generate instance ID for stream
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int32_t local_generate_instance_id(void)
|
||||
{
|
||||
static int32_t g_next_instance_id = 0;
|
||||
int32_t id;
|
||||
|
||||
/* Called from local_connect with net_lock held. */
|
||||
|
||||
id = g_next_instance_id++;
|
||||
if (g_next_instance_id < 0)
|
||||
{
|
||||
g_next_instance_id = 0;
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: psock_local_connect
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue