summaryrefslogtreecommitdiff
path: root/nuttx/include
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-09-28 14:47:49 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-09-28 14:47:49 -0600
commitb2bb7e626fd9d3ca2a0a53a179712a30f6f2ab3a (patch)
tree40f60dd2d410a5f0d7b6af5d1e736f59187eabdf /nuttx/include
parent7d1166b886638aab648cf27450454ea3b76bfd18 (diff)
downloadpx4-nuttx-b2bb7e626fd9d3ca2a0a53a179712a30f6f2ab3a.tar.gz
px4-nuttx-b2bb7e626fd9d3ca2a0a53a179712a30f6f2ab3a.tar.bz2
px4-nuttx-b2bb7e626fd9d3ca2a0a53a179712a30f6f2ab3a.zip
Optimized sendfile() from Max Holtzberg
Diffstat (limited to 'nuttx/include')
-rw-r--r--nuttx/include/nuttx/fs/fs.h45
-rw-r--r--nuttx/include/nuttx/net/net.h8
-rw-r--r--nuttx/include/sys/sendfile.h2
-rw-r--r--nuttx/include/sys/syscall.h11
4 files changed, 62 insertions, 4 deletions
diff --git a/nuttx/include/nuttx/fs/fs.h b/nuttx/include/nuttx/fs/fs.h
index c11084dee..a1678b603 100644
--- a/nuttx/include/nuttx/fs/fs.h
+++ b/nuttx/include/nuttx/fs/fs.h
@@ -594,7 +594,7 @@ struct tcb_s; /* Forward reference */
FAR struct file_struct *fs_fdopen(int fd, int oflags, FAR struct tcb_s *tcb);
#endif
-/* lib/stdio/lib_fflush.c **************************************************/
+/* libc/stdio/lib_fflush.c *************************************************/
/****************************************************************************
* Name: lib_flushall
*
@@ -608,6 +608,49 @@ FAR struct file_struct *fs_fdopen(int fd, int oflags, FAR struct tcb_s *tcb);
int lib_flushall(FAR struct streamlist *list);
#endif
+/* libc/misc/lib_sendfile.c *************************************************/
+/****************************************************************************
+ * Name: lib_sendfile
+ *
+ * Description:
+ * Transfer a file
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_SENDFILE
+ssize_t lib_sendfile(int outfd, int infd, off_t *offset, size_t count);
+#endif
+
+/* fs/fs_fileread.c *********************************************************/
+/****************************************************************************
+ * Name: file_read
+ *
+ * Description:
+ * Equivalent to the standard read() function except that is accepts a
+ * struct file instance instead of a file descriptor. Currently used
+ * only by net_sendfile()
+ *
+ ****************************************************************************/
+
+#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_NET_SENDFILE)
+ssize_t file_read(FAR struct file *filep, FAR void *buf, size_t nbytes);
+#endif
+
+/* fs/fs_fileread.c *********************************************************/
+/****************************************************************************
+ * Name: file_seek
+ *
+ * Description:
+ * Equivalent to the standard lseek() function except that is accepts a
+ * struct file instance instead of a file descriptor. Currently used
+ * only by net_sendfile()
+ *
+ ****************************************************************************/
+
+#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_NET_SENDFILE)
+off_t file_seek(FAR struct file *filep, off_t offset, int whence);
+#endif
+
/* drivers/dev_null.c *******************************************************/
/****************************************************************************
* Name: devnull_register
diff --git a/nuttx/include/nuttx/net/net.h b/nuttx/include/nuttx/net/net.h
index d9ba5b9f4..402be5d5f 100644
--- a/nuttx/include/nuttx/net/net.h
+++ b/nuttx/include/nuttx/net/net.h
@@ -261,6 +261,14 @@ int net_dup2(int sockfd1, int sockfd2);
int net_clone(FAR struct socket *psock1, FAR struct socket *psock2);
+/* net_sendfile.c ************************************************************/
+/* Send files via a TCP connections */
+
+#ifdef CONFIG_NET_SENDFILE
+struct file;
+ssize_t net_sendfile(int outfd, struct file *infile, off_t *offset, size_t count);
+#endif
+
/* net_vfcntl.c **************************************************************/
/* Performs fcntl operations on socket */
diff --git a/nuttx/include/sys/sendfile.h b/nuttx/include/sys/sendfile.h
index 0f3c05444..831c7b3d5 100644
--- a/nuttx/include/sys/sendfile.h
+++ b/nuttx/include/sys/sendfile.h
@@ -113,7 +113,7 @@ extern "C" {
*
************************************************************************/
-EXTERN ssize_t sendfile (int outfd, int infd, FAR off_t *offset, size_t count);
+ssize_t sendfile(int outfd, int infd, FAR off_t *offset, size_t count);
#undef EXTERN
#if defined(__cplusplus)
diff --git a/nuttx/include/sys/syscall.h b/nuttx/include/sys/syscall.h
index e6d458eae..24743679a 100644
--- a/nuttx/include/sys/syscall.h
+++ b/nuttx/include/sys/syscall.h
@@ -245,9 +245,16 @@
# if CONFIG_NFILE_STREAMS > 0
# define SYS_fs_fdopen (__SYS_filedesc+16)
# define SYS_sched_getstreams (__SYS_filedesc+17)
-# define __SYS_mountpoint (__SYS_filedesc+18)
+# define __SYS_sendfile (__SYS_filedesc+18)
# else
-# define __SYS_mountpoint (__SYS_filedesc+16)
+# define __SYS_sendfile (__SYS_filedesc+16)
+# endif
+
+# if defined(CONFIG_NET_SENDFILE)
+# define SYS_sendfile, __SYS_sendfile
+# define __SYS_mountpoint (__SYS_sendfile+1)
+# else
+# define __SYS_mountpoint __SYS_sendfile
# endif
# if !defined(CONFIG_DISABLE_MOUNTPOINT)