Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NuttX RTOS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
f4grx
NuttX RTOS
Commits
38eb8bb1
Commit
38eb8bb1
authored
9 years ago
by
Andrew Tridgell
Committed by
Gregory Nutt
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
pipes: support FIONREAD and FIONWRITE ioctl on pipes; use semaphores for pipecommon_ioctl().
parent
03a77c1d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
arch
+1
-1
1 addition, 1 deletion
arch
drivers/pipes/fifo.c
+0
-16
0 additions, 16 deletions
drivers/pipes/fifo.c
drivers/pipes/pipe_common.c
+72
-21
72 additions, 21 deletions
drivers/pipes/pipe_common.c
drivers/pipes/pipe_common.h
+1
-1
1 addition, 1 deletion
drivers/pipes/pipe_common.h
with
74 additions
and
39 deletions
arch
@
2a3c9628
Subproject commit 2
c6b85793f26fb265e88ff2fc3d4e71707f9ab2b
Subproject commit 2
a3c96286af41c261411d9cdd17e98e2ee18dc2e
This diff is collapsed.
Click to expand it.
drivers/pipes/fifo.c
+
0
−
16
View file @
38eb8bb1
...
...
@@ -50,18 +50,6 @@
#if CONFIG_DEV_PIPE_SIZE > 0
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
...
...
@@ -82,10 +70,6 @@ static const struct file_operations fifo_fops =
#endif
};
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
...
...
This diff is collapsed.
Click to expand it.
drivers/pipes/pipe_common.c
+
72
−
21
View file @
38eb8bb1
...
...
@@ -55,6 +55,7 @@
#include
<nuttx/kmalloc.h>
#include
<nuttx/fs/fs.h>
#include
<nuttx/fs/ioctl.h>
#ifdef CONFIG_DEBUG
# include <nuttx/arch.h>
#endif
...
...
@@ -77,20 +78,12 @@
# define pipe_dumpbuffer(m,a,n)
#endif
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
static
void
pipecommon_semtake
(
sem_t
*
sem
);
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
...
...
@@ -746,32 +739,90 @@ errout:
}
#endif
/****************************************************************************
/****************************************************************************
********
* Name: pipecommon_ioctl
****************************************************************************/
****************************************************************************
********
/
int
pipecommon_ioctl
(
FAR
struct
file
*
filep
,
int
cmd
,
unsigned
long
arg
)
int
pipecommon_ioctl
(
FAR
struct
file
*
filep
,
int
cmd
,
unsigned
long
arg
)
{
FAR
struct
inode
*
inode
=
filep
->
f_inode
;
FAR
struct
pipe_dev_s
*
dev
=
inode
->
i_private
;
FAR
struct
inode
*
inode
=
filep
->
f_inode
;
struct
pipe_dev_s
*
dev
=
inode
->
i_private
;
int
ret
=
-
EINVAL
;
/* Only one command supported */
#ifdef CONFIG_DEBUG
/* Some sanity checking */
if
(
cmd
==
PIPEIOC_POLICY
)
if
(
dev
==
NULL
)
{
if
(
arg
!=
0
)
return
-
EBADF
;
}
#endif
pipecommon_semtake
(
&
dev
->
d_bfsem
);
switch
(
cmd
)
{
case
PIPEIOC_POLICY
:
{
PIPE_POLICY_1
(
dev
->
d_flags
);
if
(
arg
!=
0
)
{
PIPE_POLICY_1
(
dev
->
d_flags
);
}
else
{
PIPE_POLICY_0
(
dev
->
d_flags
);
}
ret
=
OK
;
}
else
break
;
case
FIONREAD
:
{
int
count
;
/* Determine the number of bytes available in the buffer */
if
(
dev
->
d_wrndx
<
dev
->
d_rdndx
)
{
count
=
(
CONFIG_DEV_PIPE_SIZE
-
dev
->
d_rdndx
)
+
dev
->
d_wrndx
;
}
else
{
count
=
dev
->
d_wrndx
-
dev
->
d_rdndx
;
}
*
(
int
*
)
arg
=
count
;
ret
=
0
;
}
break
;
case
FIONWRITE
:
{
PIPE_POLICY_0
(
dev
->
d_flags
);
int
count
;
/* Determine the number of bytes free in the buffer */
if
(
dev
->
d_wrndx
<
dev
->
d_rdndx
)
{
count
=
(
dev
->
d_rdndx
-
dev
->
d_wrndx
)
-
1
;
}
else
{
count
=
((
CONFIG_DEV_PIPE_SIZE
-
dev
->
d_wrndx
)
+
dev
->
d_rdndx
)
-
1
;
}
*
(
int
*
)
arg
=
count
;
ret
=
0
;
}
break
;
return
OK
;
default:
break
;
}
return
-
ENOTTY
;
sem_post
(
&
dev
->
d_bfsem
);
return
ret
;
}
/****************************************************************************
...
...
This diff is collapsed.
Click to expand it.
drivers/pipes/pipe_common.h
+
1
−
1
View file @
38eb8bb1
/****************************************************************************
* drivers/pipe/pipe_common.h
*
* Copyright (C) 2008-2009, 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2008-2009, 2015
=2016
Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment