diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-09-01 18:06:15 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-09-01 18:06:15 +0000 |
commit | 5d303ec17efc511d8cfe0919a790b44e24a8aad9 (patch) | |
tree | 76c519b5903e6d1e2880f7fb0d403838f7acddac /nuttx/sched/sched_setupidlefiles.c | |
parent | 0cab5d84f146c0f6105192db5593aa4019edcdcf (diff) | |
download | px4-nuttx-5d303ec17efc511d8cfe0919a790b44e24a8aad9.tar.gz px4-nuttx-5d303ec17efc511d8cfe0919a790b44e24a8aad9.tar.bz2 px4-nuttx-5d303ec17efc511d8cfe0919a790b44e24a8aad9.zip |
Added support for socket descriptors
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@318 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched/sched_setupidlefiles.c')
-rw-r--r-- | nuttx/sched/sched_setupidlefiles.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/nuttx/sched/sched_setupidlefiles.c b/nuttx/sched/sched_setupidlefiles.c index 78d8d60ad..4949779af 100644 --- a/nuttx/sched/sched_setupidlefiles.c +++ b/nuttx/sched/sched_setupidlefiles.c @@ -38,11 +38,17 @@ ************************************************************/ #include <nuttx/config.h> +#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NSOCKET_DESCRIPTORS > 0 + #include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <sched.h> #include <errno.h> + +#include <nuttx/fs.h> +#include <nuttx/net.h> + #include "os_internal.h" /************************************************************ @@ -69,12 +75,11 @@ * ************************************************************/ -#if CONFIG_NFILE_DESCRIPTORS > 0 - int sched_setupidlefiles(FAR _TCB *tcb) { int fd; +#if CONFIG_NFILE_DESCRIPTORS > 0 /* Allocate file descriptors for the TCB */ tcb->filelist = files_alloclist(); @@ -83,8 +88,20 @@ int sched_setupidlefiles(FAR _TCB *tcb) *get_errno_ptr() = ENOMEM; return ERROR; } +#endif /* CONFIG_NFILE_DESCRIPTORS */ + +#if CONFIG_NSOCKET_DESCRIPTORS > 0 + /* Allocate socket descriptors for the TCB */ + + tcb->sockets = net_alloclist(); + if (!tcb->sockets) + { + *get_errno_ptr() = ENOMEM; + return ERROR; + } +#endif /* CONFIG_NSOCKET_DESCRIPTORS */ -#ifdef CONFIG_DEV_CONSOLE +#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_DEV_CONSOLE) /* Open stdin, dup to get stdout and stderr. */ fd = open("/dev/console", O_RDWR); @@ -107,7 +124,7 @@ int sched_setupidlefiles(FAR _TCB *tcb) #else return OK; #endif /* CONFIG_NFILE_STREAMS */ -#endif /* CONFIG_DEV_CONSOLE */ +#endif /* CONFIG_NFILE_DESCRIPTORS && CONFIG_DEV_CONSOLE */ } -#endif /* CONFIG_NFILE_DESCRIPTORS */ +#endif /* CONFIG_NFILE_DESCRIPTORS || CONFIG_NSOCKET_DESCRIPTORS */ |