mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 16:50:55 +08:00
fs/streams: Move the file streams from the group structure into TLS
This is preparation for flushing streams from user space, like it should
be done.
- Move tg_streamlist (group, kernel space) ->
ta_streamlist (TLS, user space)
- Access stream list via tg_info in kernel
- Access stream list via TLS in user space
- Remove / rename nxsched_get_streams -> lib_getstreams
- Remove system call for nxsched_get_streams
This commit is contained in:
@@ -45,6 +45,7 @@ CSRCS += lib_fputs.c lib_ungetc.c lib_fprintf.c lib_vfprintf.c
|
||||
CSRCS += lib_feof.c lib_ferror.c lib_rewind.c lib_clearerr.c
|
||||
CSRCS += lib_scanf.c lib_vscanf.c lib_fscanf.c lib_vfscanf.c lib_tmpfile.c
|
||||
CSRCS += lib_setbuf.c lib_setvbuf.c lib_libstream.c lib_libfilelock.c
|
||||
CSRCS += lib_libgetstreams.c
|
||||
endif
|
||||
|
||||
# Add the stdio directory to the build
|
||||
|
||||
@@ -84,7 +84,7 @@ int fclose(FAR FILE *stream)
|
||||
|
||||
/* Remove FILE structure from the stream list */
|
||||
|
||||
slist = nxsched_get_streams();
|
||||
slist = lib_get_streams();
|
||||
nxmutex_lock(&slist->sl_lock);
|
||||
|
||||
for (next = slist->sl_head; next; prev = next, next = next->fs_next)
|
||||
|
||||
@@ -62,7 +62,7 @@ int fflush(FAR FILE *stream)
|
||||
{
|
||||
/* Yes... then this is a request to flush all streams */
|
||||
|
||||
ret = lib_flushall(nxsched_get_streams());
|
||||
ret = lib_flushall(lib_get_streams());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/****************************************************************************
|
||||
* libs/libc/stdio/lib_libgetstreams.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <nuttx/tls.h>
|
||||
|
||||
#ifdef CONFIG_FILE_STREAM
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: lib_get_streams
|
||||
*
|
||||
* Description:
|
||||
* Return a pointer to the streams list for this thread
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* A pointer to the errno.
|
||||
*
|
||||
* Assumptions:
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct streamlist *lib_get_streams(void)
|
||||
{
|
||||
FAR struct task_info_s *info;
|
||||
|
||||
info = task_get_info();
|
||||
return &info->ta_streamlist;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_FILE_STREAM */
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <nuttx/sched.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/lib/lib.h>
|
||||
#include <nuttx/tls.h>
|
||||
|
||||
#include "libc.h"
|
||||
|
||||
@@ -56,13 +57,8 @@ void lib_stream_initialize(FAR struct task_group_s *group)
|
||||
{
|
||||
FAR struct streamlist *list;
|
||||
|
||||
#ifdef CONFIG_MM_KERNEL_HEAP
|
||||
DEBUGASSERT(group && group->tg_streamlist);
|
||||
list = group->tg_streamlist;
|
||||
#else
|
||||
DEBUGASSERT(group);
|
||||
list = &group->tg_streamlist;
|
||||
#endif
|
||||
DEBUGASSERT(group && group->tg_info);
|
||||
list = &group->tg_info->ta_streamlist;
|
||||
|
||||
/* Initialize the list access mutex */
|
||||
|
||||
@@ -94,13 +90,8 @@ void lib_stream_release(FAR struct task_group_s *group)
|
||||
{
|
||||
FAR struct streamlist *list;
|
||||
|
||||
#ifdef CONFIG_MM_KERNEL_HEAP
|
||||
DEBUGASSERT(group && group->tg_streamlist);
|
||||
list = group->tg_streamlist;
|
||||
#else
|
||||
DEBUGASSERT(group);
|
||||
list = &group->tg_streamlist;
|
||||
#endif
|
||||
DEBUGASSERT(group && group->tg_info);
|
||||
list = &group->tg_info->ta_streamlist;
|
||||
|
||||
/* Destroy the mutex and release the filelist */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user