summaryrefslogtreecommitdiff
path: root/nuttx/lib
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-03-09 15:27:47 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-03-09 15:27:47 +0000
commitcb4bc1a2f49306879ecee08f0644300f0037d92c (patch)
treec299739a5089f9fb3cbc902726f66fdc7a9c708a /nuttx/lib
parent3551ee48a7f52425e953d4a3ea7bc2fd3b2a62ff (diff)
downloadpx4-nuttx-cb4bc1a2f49306879ecee08f0644300f0037d92c.tar.gz
px4-nuttx-cb4bc1a2f49306879ecee08f0644300f0037d92c.tar.bz2
px4-nuttx-cb4bc1a2f49306879ecee08f0644300f0037d92c.zip
Debug instrumentation
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@47 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/lib')
-rw-r--r--nuttx/lib/lib_fflush.c7
-rw-r--r--nuttx/lib/lib_init.c2
2 files changed, 8 insertions, 1 deletions
diff --git a/nuttx/lib/lib_fflush.c b/nuttx/lib/lib_fflush.c
index d0f74bd2b..e7f4e6960 100644
--- a/nuttx/lib/lib_fflush.c
+++ b/nuttx/lib/lib_fflush.c
@@ -91,6 +91,7 @@
void lib_flushall(FAR struct streamlist *list)
{
/* Make sure that there are streams associated with this thread */
+
if (list)
{
int i;
@@ -131,6 +132,10 @@ int fflush(FILE *stream)
return ERROR;
}
+ /* Make sure that we have exclusive access to the stream */
+
+ lib_take_semaphore(stream);
+
/* How many bytes are used in the buffer now */
nbuffer = stream->fs_bufpos - stream->fs_bufstart;
@@ -141,6 +146,7 @@ int fflush(FILE *stream)
bytes_written = write(stream->fs_filedes, src, nbuffer);
if (bytes_written < 0)
{
+ lib_give_semaphore(stream);
return bytes_written;
}
@@ -166,6 +172,7 @@ int fflush(FILE *stream)
/* Return the number of bytes remaining in the buffer */
+ lib_give_semaphore(stream);
return stream->fs_bufpos - stream->fs_bufstart;
#else
return 0;
diff --git a/nuttx/lib/lib_init.c b/nuttx/lib/lib_init.c
index 90ccc358b..d6eb5f0a4 100644
--- a/nuttx/lib/lib_init.c
+++ b/nuttx/lib/lib_init.c
@@ -166,7 +166,7 @@ void lib_releaselist(FAR struct streamlist *list)
/* Decrement the reference count */
_lib_semtake(list);
- crefs = --list->sl_crefs;
+ crefs = --(list->sl_crefs);
_lib_semgive(list);
/* If the count decrements to zero, then there is no reference