summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xnuttx/Documentation/README.html6
-rwxr-xr-xnuttx/README.txt4
-rw-r--r--nuttx/fs/Makefile11
-rw-r--r--nuttx/include/sched.h2
-rw-r--r--nuttx/include/sys/syscall.h119
-rw-r--r--nuttx/lib/Makefile10
-rw-r--r--nuttx/lib/README.txt47
-rw-r--r--nuttx/lib/misc/Make.defs4
-rw-r--r--nuttx/lib/misc/lib_filesem.c2
-rw-r--r--nuttx/lib/misc/lib_readdirr.c (renamed from nuttx/fs/fs_readdirr.c)12
-rw-r--r--nuttx/lib/misc/lib_streamsem.c2
-rw-r--r--nuttx/lib/misc/lib_telldir.c (renamed from nuttx/fs/fs_telldir.c)2
-rw-r--r--nuttx/lib/semaphore/sem_getvalue.c2
-rw-r--r--nuttx/lib/semaphore/sem_init.c2
-rw-r--r--nuttx/lib/signal/Make.defs40
-rw-r--r--nuttx/lib/signal/sig_addset.c (renamed from nuttx/sched/sig_addset.c)5
-rw-r--r--nuttx/lib/signal/sig_delset.c (renamed from nuttx/sched/sig_delset.c)5
-rw-r--r--nuttx/lib/signal/sig_emptyset.c (renamed from nuttx/sched/sig_emptyset.c)5
-rw-r--r--nuttx/lib/signal/sig_fillset.c (renamed from nuttx/sched/sig_fillset.c)7
-rw-r--r--nuttx/lib/signal/sig_ismember.c (renamed from nuttx/sched/sig_ismember.c)5
-rw-r--r--nuttx/lib/stdio/lib_fgetpos.c2
-rw-r--r--nuttx/lib/stdio/lib_fileno.c2
-rw-r--r--nuttx/lib/stdio/lib_fopen.c2
-rw-r--r--nuttx/lib/stdio/lib_fputs.c2
-rw-r--r--nuttx/lib/stdio/lib_fseek.c2
-rw-r--r--nuttx/lib/stdio/lib_fsetpos.c2
-rw-r--r--nuttx/lib/stdio/lib_ftell.c2
-rw-r--r--nuttx/lib/stdio/lib_libfflush.c2
-rw-r--r--nuttx/lib/stdio/lib_libflushall.c7
-rw-r--r--nuttx/lib/stdio/lib_libfread.c2
-rw-r--r--nuttx/lib/stdio/lib_libfwrite.c2
-rw-r--r--nuttx/lib/stdio/lib_rawinstream.c2
-rw-r--r--nuttx/lib/stdio/lib_rawoutstream.c2
-rw-r--r--nuttx/lib/stdio/lib_rdflush.c2
-rw-r--r--nuttx/lib/stdio/lib_ungetc.c4
-rwxr-xr-xnuttx/lib/string/lib_strtod.c15
-rw-r--r--nuttx/lib/unistd/lib_chdir.c2
-rw-r--r--nuttx/lib/unistd/lib_getcwd.c6
-rw-r--r--nuttx/sched/Makefile18
-rw-r--r--nuttx/sched/errno_get.c84
-rw-r--r--nuttx/sched/errno_getptr.c (renamed from nuttx/sched/get_errno_ptr.c)8
-rw-r--r--nuttx/sched/errno_set.c83
-rw-r--r--nuttx/sched/sched_lockcount.c16
-rw-r--r--nuttx/syscall/Makefile2
-rw-r--r--nuttx/syscall/README.txt20
-rw-r--r--nuttx/syscall/syscall.csv17
-rw-r--r--nuttx/tools/mksyscall.c86
47 files changed, 523 insertions, 163 deletions
diff --git a/nuttx/Documentation/README.html b/nuttx/Documentation/README.html
index eff38044d..1b7304e94 100755
--- a/nuttx/Documentation/README.html
+++ b/nuttx/Documentation/README.html
@@ -9,7 +9,7 @@
<tr align="center" bgcolor="#e4e4e4">
<td>
<h1><big><font color="#3c34ec"><i>NuttX README Files</i></font></big></h1>
- <p>Last Updated: March 19, 2010</p>
+ <p>Last Updated: April 2, 2010</p>
</td>
</tr>
</table>
@@ -167,8 +167,12 @@
| | `- <a href="nuttx/drivers/README.txt?view=log"><b><i>README.txt</i></b></a>
| |- graphics/
| | `- <a href="nuttx/graphics/README.txt?view=log"><b><i>README.txt</i></b></a>
+ | |- lib/
+ | | `- <a href="nuttx/lib/README.txt?view=log"><b><i>README.txt</i></b></a>
| |- libxx/
| | `- <a href="nuttx/libxx/README.txt?view=log"><b><i>README.txt</i></b></a>
+ | |- syscall/
+ | | `- <a href="nuttx/syscall/README.txt?view=log"><b><i>README.txt</i></b></a>
| `- tools/
| `- <a href="nuttx/tols/README.txt?view=log"><b><i>README.txt</i></b></a>
`- apps/
diff --git a/nuttx/README.txt b/nuttx/README.txt
index 1c6f93582..7b149a06f 100755
--- a/nuttx/README.txt
+++ b/nuttx/README.txt
@@ -382,7 +382,11 @@ Below is a guide to the available README files in the NuttX source tree:
| `- README.txt
|- graphics/
| `- README.txt
+ |- lib/
+ | `- README.txt
|- libxx/
| `- README.txt
+ |- syscall/
+ | `- README.txt
`- tools/
`- README.txt
diff --git a/nuttx/fs/Makefile b/nuttx/fs/Makefile
index d6301ab99..3926cac2e 100644
--- a/nuttx/fs/Makefile
+++ b/nuttx/fs/Makefile
@@ -1,7 +1,7 @@
############################################################################
# fs/Makefile
#
-# Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
+# Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
#
# Redistribution and use in source and binary forms, with or without
@@ -47,11 +47,10 @@ else
CSRCS += fs_open.c fs_close.c fs_read.c fs_write.c fs_ioctl.c \
fs_poll.c fs_select.c fs_lseek.c fs_dup.c fs_filedup.c \
fs_dup2.c fs_fcntl.c fs_filedup2.c fs_mmap.c fs_opendir.c \
- fs_closedir.c fs_stat.c fs_readdir.c fs_readdirr.c \
- fs_seekdir.c fs_telldir.c fs_rewinddir.c fs_files.c fs_inode.c \
- fs_inodefind.c fs_inodereserve.c fs_statfs.c fs_inoderemove.c \
- fs_registerdriver.c fs_unregisterdriver.c fs_inodeaddref.c \
- fs_inoderelease.c
+ fs_closedir.c fs_stat.c fs_readdir.c fs_seekdir.c \
+ fs_rewinddir.c fs_files.c fs_inode.c fs_inodefind.c fs_inodereserve.c \
+ fs_statfs.c fs_inoderemove.c fs_registerdriver.c fs_unregisterdriver.c \
+ fs_inodeaddref.c fs_inoderelease.c
CSRCS += fs_registerblockdriver.c fs_unregisterblockdriver.c \
fs_findblockdriver.c fs_openblockdriver.c fs_closeblockdriver.c
ifneq ($(CONFIG_DISABLE_MOUNTPOINT),y)
diff --git a/nuttx/include/sched.h b/nuttx/include/sched.h
index f7ebd9c82..72c860f0d 100644
--- a/nuttx/include/sched.h
+++ b/nuttx/include/sched.h
@@ -139,7 +139,7 @@ EXTERN int sched_rr_get_interval(pid_t pid, struct timespec *interval);
EXTERN int sched_lock(void);
EXTERN int sched_unlock(void);
-EXTERN int32_t sched_lockcount(void);
+EXTERN int sched_lockcount(void);
/* If instrumentation of the scheduler is enabled, then some outboard logic
* must provide the following interfaces.
diff --git a/nuttx/include/sys/syscall.h b/nuttx/include/sys/syscall.h
index f44587b3c..77aff0530 100644
--- a/nuttx/include/sys/syscall.h
+++ b/nuttx/include/sys/syscall.h
@@ -57,15 +57,15 @@
#define SYS__exit (CONFIG_SYS_RESERVED+0)
#define SYS_accept (CONFIG_SYS_RESERVED+1)
-#define SYS_bind (CONFIG_SYS_RESERVED+2)
-#define SYS_clearenv (CONFIG_SYS_RESERVED+3)
-#define SYS_clock_getres (CONFIG_SYS_RESERVED+4)
-#define SYS_clock_gettime (CONFIG_SYS_RESERVED+5)
-#define SYS_clock_settime (CONFIG_SYS_RESERVED+6)
-#define SYS_close (CONFIG_SYS_RESERVED+7)
-#define SYS_closedir (CONFIG_SYS_RESERVED+8)
-#define SYS_connect (CONFIG_SYS_RESERVED+9)
-#define SYS_creat (CONFIG_SYS_RESERVED+10)
+#define SYS_atexit (CONFIG_SYS_RESERVED+2)
+#define SYS_bind (CONFIG_SYS_RESERVED+3)
+#define SYS_clearenv (CONFIG_SYS_RESERVED+4)
+#define SYS_clock_getres (CONFIG_SYS_RESERVED+5)
+#define SYS_clock_gettime (CONFIG_SYS_RESERVED+6)
+#define SYS_clock_settime (CONFIG_SYS_RESERVED+7)
+#define SYS_close (CONFIG_SYS_RESERVED+8)
+#define SYS_closedir (CONFIG_SYS_RESERVED+9)
+#define SYS_connect (CONFIG_SYS_RESERVED+10)
#define SYS_dup (CONFIG_SYS_RESERVED+11)
#define SYS_dup2 (CONFIG_SYS_RESERVED+12)
#define SYS_exit (CONFIG_SYS_RESERVED+13)
@@ -86,9 +86,9 @@
#define SYS_mkfifo (CONFIG_SYS_RESERVED+28)
#define SYS_mmap (CONFIG_SYS_RESERVED+29)
#define SYS_mount (CONFIG_SYS_RESERVED+30)
-#define SYS_mq_notify (CONFIG_SYS_RESERVED+31)
-#define SYS_mq_open (CONFIG_SYS_RESERVED+32)
-#define SYS_mq_close (CONFIG_SYS_RESERVED+33)
+#define SYS_mq_close (CONFIG_SYS_RESERVED+31)
+#define SYS_mq_notify (CONFIG_SYS_RESERVED+32)
+#define SYS_mq_open (CONFIG_SYS_RESERVED+33)
#define SYS_mq_receive (CONFIG_SYS_RESERVED+34)
#define SYS_mq_send (CONFIG_SYS_RESERVED+35)
#define SYS_mq_timedreceive (CONFIG_SYS_RESERVED+36)
@@ -133,45 +133,66 @@
#define SYS_putenv (CONFIG_SYS_RESERVED+75)
#define SYS_read (CONFIG_SYS_RESERVED+76)
#define SYS_readdir (CONFIG_SYS_RESERVED+77)
-#define SYS_reboot (CONFIG_SYS_RESERVED+78)
+#define SYS_recv (CONFIG_SYS_RESERVED+78)
#define SYS_recvfrom (CONFIG_SYS_RESERVED+79)
#define SYS_rename (CONFIG_SYS_RESERVED+80)
-#define SYS_rmdir (CONFIG_SYS_RESERVED+81)
-#define SYS_sched_getparam (CONFIG_SYS_RESERVED+82)
-#define SYS_sched_get_priority_max (CONFIG_SYS_RESERVED+83)
-#define SYS_sched_get_priority_min (CONFIG_SYS_RESERVED+84)
-#define SYS_sched_getscheduler (CONFIG_SYS_RESERVED+85)
-#define SYS_sched_rr_get_interval (CONFIG_SYS_RESERVED+86)
-#define SYS_sched_setparam (CONFIG_SYS_RESERVED+87)
-#define SYS_sched_setscheduler (CONFIG_SYS_RESERVED+88)
-#define SYS_sched_yield (CONFIG_SYS_RESERVED+89)
-#define SYS_select (CONFIG_SYS_RESERVED+90)
-#define SYS_sendto (CONFIG_SYS_RESERVED+91)
-#define SYS_set_errno (CONFIG_SYS_RESERVED+92)
-#define SYS_setenv (CONFIG_SYS_RESERVED+93)
-#define SYS_setsockopt (CONFIG_SYS_RESERVED+94)
-#define SYS_sigaction (CONFIG_SYS_RESERVED+95)
-#define SYS_signal (CONFIG_SYS_RESERVED+96)
-#define SYS_sigpending (CONFIG_SYS_RESERVED+97)
-#define SYS_sigprocmask (CONFIG_SYS_RESERVED+98)
-#define SYS_sigsuspend (CONFIG_SYS_RESERVED+99)
-#define SYS_socket (CONFIG_SYS_RESERVED+100)
-#define SYS_stat (CONFIG_SYS_RESERVED+101)
-#define SYS_statfs (CONFIG_SYS_RESERVED+102)
-#define SYS_task_create (CONFIG_SYS_RESERVED+103)
-#define SYS_task_delete (CONFIG_SYS_RESERVED+104)
-#define SYS_task_init (CONFIG_SYS_RESERVED+105)
-#define SYS_task_restart (CONFIG_SYS_RESERVED+106)
-#define SYS_timer_create (CONFIG_SYS_RESERVED+107)
-#define SYS_timer_delete (CONFIG_SYS_RESERVED+108)
-#define SYS_timer_getoverrun (CONFIG_SYS_RESERVED+109)
-#define SYS_timer_gettime (CONFIG_SYS_RESERVED+110)
-#define SYS_timer_settime (CONFIG_SYS_RESERVED+111)
-#define SYS_umount (CONFIG_SYS_RESERVED+112)
-#define SYS_unlink (CONFIG_SYS_RESERVED+113)
-#define SYS_waitid (CONFIG_SYS_RESERVED+114)
-#define SYS_waitpid (CONFIG_SYS_RESERVED+115)
-#define SYS_write (CONFIG_SYS_RESERVED+116)
+#define SYS_rewinddir (CONFIG_SYS_RESERVED+81)
+#define SYS_rmdir (CONFIG_SYS_RESERVED+82)
+#define SYS_sched_getparam (CONFIG_SYS_RESERVED+83)
+#define SYS_sched_getscheduler (CONFIG_SYS_RESERVED+84)
+#define SYS_sched_lock (CONFIG_SYS_RESERVED+85)
+#define SYS_sched_lockcount (CONFIG_SYS_RESERVED+86)
+#define SYS_sched_rr_get_interval (CONFIG_SYS_RESERVED+87)
+#define SYS_sched_setparam (CONFIG_SYS_RESERVED+88)
+#define SYS_sched_setscheduler (CONFIG_SYS_RESERVED+89)
+#define SYS_sched_unlock (CONFIG_SYS_RESERVED+90)
+#define SYS_sched_yield (CONFIG_SYS_RESERVED+91)
+#define SYS_seekdir (CONFIG_SYS_RESERVED+92)
+#define SYS_select (CONFIG_SYS_RESERVED+93)
+#define SYS_sem_close (CONFIG_SYS_RESERVED+94)
+#define SYS_sem_destroy (CONFIG_SYS_RESERVED+95)
+#define SYS_sem_open (CONFIG_SYS_RESERVED+96)
+#define SYS_sem_post (CONFIG_SYS_RESERVED+97)
+#define SYS_sem_trywait (CONFIG_SYS_RESERVED+98)
+#define SYS_sem_unlink (CONFIG_SYS_RESERVED+99)
+#define SYS_sem_wait (CONFIG_SYS_RESERVED+100)
+#define SYS_sem_close (CONFIG_SYS_RESERVED+101)
+#define SYS_sem_close (CONFIG_SYS_RESERVED+102)
+#define SYS_sem_close (CONFIG_SYS_RESERVED+103)
+#define SYS_sem_close (CONFIG_SYS_RESERVED+104)
+#define SYS_send (CONFIG_SYS_RESERVED+105)
+#define SYS_sendto (CONFIG_SYS_RESERVED+106)
+#define SYS_set_errno (CONFIG_SYS_RESERVED+107)
+#define SYS_setenv (CONFIG_SYS_RESERVED+108)
+#define SYS_setsockopt (CONFIG_SYS_RESERVED+109)
+#define SYS_sigaction (CONFIG_SYS_RESERVED+110)
+#define SYS_sigpending (CONFIG_SYS_RESERVED+111)
+#define SYS_sigprocmask (CONFIG_SYS_RESERVED+112)
+#define SYS_sigqueue (CONFIG_SYS_RESERVED+113)
+#define SYS_sigsuspend (CONFIG_SYS_RESERVED+114)
+#define SYS_sigtimedwait (CONFIG_SYS_RESERVED+115)
+#define SYS_sigwaitinfo (CONFIG_SYS_RESERVED+116)
+#define SYS_sleep (CONFIG_SYS_RESERVED+117)
+#define SYS_socket (CONFIG_SYS_RESERVED+118)
+#define SYS_stat (CONFIG_SYS_RESERVED+119)
+#define SYS_statfs (CONFIG_SYS_RESERVED+120)
+#define SYS_task_create (CONFIG_SYS_RESERVED+121)
+#define SYS_task_delete (CONFIG_SYS_RESERVED+122)
+#define SYS_task_restart (CONFIG_SYS_RESERVED+123)
+#define SYS_telldir (CONFIG_SYS_RESERVED+124)
+#define SYS_timer_create (CONFIG_SYS_RESERVED+125)
+#define SYS_timer_delete (CONFIG_SYS_RESERVED+126)
+#define SYS_timer_getoverrun (CONFIG_SYS_RESERVED+127)
+#define SYS_timer_gettime (CONFIG_SYS_RESERVED+128)
+#define SYS_timer_settime (CONFIG_SYS_RESERVED+129)
+#define SYS_umount (CONFIG_SYS_RESERVED+130)
+#define SYS_unlink (CONFIG_SYS_RESERVED+131)
+#define SYS_unsetenv (CONFIG_SYS_RESERVED+132)
+#define SYS_up_assert (CONFIG_SYS_RESERVED+133)
+#define SYS_up_assert_code (CONFIG_SYS_RESERVED+134)
+#define SYS_usleep (CONFIG_SYS_RESERVED+135)
+#define SYS_waitpid (CONFIG_SYS_RESERVED+136)
+#define SYS_write (CONFIG_SYS_RESERVED+137)
/****************************************************************************
* Public Type Definitions
diff --git a/nuttx/lib/Makefile b/nuttx/lib/Makefile
index df7a9240f..54ba764ff 100644
--- a/nuttx/lib/Makefile
+++ b/nuttx/lib/Makefile
@@ -41,6 +41,7 @@ include sched/Make.defs
include string/Make.defs
include pthread/Make.defs
include semaphore/Make.defs
+include signal/Make.defs
include mqueue/Make.defs
include math/Make.defs
include net/Make.defs
@@ -53,7 +54,7 @@ ASRCS =
AOBJS = $(ASRCS:.S=$(OBJEXT))
CSRCS = $(STDIO_SRCS) $(STDLIB_SRCS) $(UNISTD_SRCS) $(SCHED_SRCS) \
- $(STRING_SRCS) $(PTHREAD_SRCS) $(SEM_SRCS) $(MQUEUE_SRCS) \
+ $(STRING_SRCS) $(PTHREAD_SRCS) $(SEM_SRCS) $(SIG_SRCS) $(MQUEUE_SRCS) \
$(MATH_SRCS) $(NET_SRCS) $(TIME_SRCS) $(LIBGEN_SRCS) \
$(QUEUE_SRCS) $(MISC_SRCS) $(REGEX_SRCS) $(CRC_SRCS) $(DBG_SRCS)
COBJS = $(CSRCS:.c=$(OBJEXT))
@@ -69,6 +70,7 @@ SCHEDDEPPATH = --dep-path sched
STRINGDEPPATH = --dep-path string
PTHREADDEPPATH = --dep-path pthread
SEMDEPPATH = --dep-path semaphore
+SIGDEPPATH = --dep-path signal
MQDEPPATH = --dep-path mqueue
MATHDEPPATH = --dep-path math
NETDEPPATH = --dep-path net
@@ -76,7 +78,7 @@ TIMEDEPPATH = --dep-path time
LIBGENDEPPATH = --dep-path libgen
QUEUEDEPPATH = --dep-path queue
MISCDEPPATH = --dep-path misc
-VPATH = stdio:stdlib:unistd:sched:string:pthread:semaphore:mqueue:math:net:time:libgen:queue:misc
+VPATH = stdio:stdlib:unistd:sched:string:pthread:semaphore:signal:mqueue:math:net:time:libgen:queue:misc
BIN = liblib$(LIBEXT)
@@ -96,8 +98,8 @@ $(BIN): $(OBJS)
.depend: Makefile $(SRCS)
@$(MKDEP) $(ROOTDEPPATH) $(STDIODEPPATH) $(STDLIBDEPPATH) \
$(UNISTDDEPPATH) $(SCHEDDEPPATH) $(STRINGDEPPATH) $(PTHREADDEPPATH) \
- $(SEMDEPPATH) $(MQDEPPATH) $(MATHDEPPATH) $(NETDEPPATH) $(TIMEDEPPATH) \
- $(LIBGENDEPPATH) $(QUEUEDEPPATH) $(MISCDEPPATH) \
+ $(SEMDEPPATH) $(SIGDEPPATH) $(MQDEPPATH) $(MATHDEPPATH) $(NETDEPPATH) \
+ $(TIMEDEPPATH) $(LIBGENDEPPATH) $(QUEUEDEPPATH) $(MISCDEPPATH) \
$(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
@touch $@
diff --git a/nuttx/lib/README.txt b/nuttx/lib/README.txt
new file mode 100644
index 000000000..62e2fcce2
--- /dev/null
+++ b/nuttx/lib/README.txt
@@ -0,0 +1,47 @@
+lib
+===
+
+This directory contains numerous, small functions typically associated with
+what you would expect to find in a standard C library. The sub-directories
+in this directory contain standard interface that can be executed by user-
+mode programs.
+
+Normally, NuttX is built with no protection and all threads running in kerne-
+mode. In that model, there is no real architectural distinction between
+what is a kernel-mode program and what is a user-mode program; the system is
+more like on multi-threaded program that all runs in kernel-mode.
+
+But if the CONFIG_NUTTX_KERNEL option is selected, NuttX will be built into
+distinct user-mode and kernel-mode sections. In that case, most of the
+code in the nuttx/ directory will run in kernel-mode with with exceptions
+of (1) the user-mode "proxies" found in syscall/proxies, and (2) the
+standard C library functions found in this directory. In this build model,
+it is critical to separate the user-mode OS interfaces in this way.
+
+Sub-Directories
+===============
+
+The files in the lib/ directory are organized (mostly) according which file
+in the include/ directory provides the prototype for library functions. So
+we have:
+
+ libgen - libgen.h
+ math - math.h and fixedmath.h
+ mqueue - pthread.h
+ net - Various network-related header files: netinet/ether.h, arpa/inet.h
+ pthread - pthread.h
+ queue - queue.h
+ sched - sched.h
+ semaphore - semaphore.h
+ stdio - stdio.h
+ stdlib - stdlib.h
+ string - string.h
+ time - time.h
+ unistd - unistd.h
+
+There is also a misc/ subdirectory that contains various internal functions
+and interfaces from header files that are too few to warrant their own sub-
+directory:
+
+ misc - Nonstandard "glue" logic, debug.h, crc32.h, dirent.h
+
diff --git a/nuttx/lib/misc/Make.defs b/nuttx/lib/misc/Make.defs
index 680180a95..62443c338 100644
--- a/nuttx/lib/misc/Make.defs
+++ b/nuttx/lib/misc/Make.defs
@@ -34,9 +34,13 @@
############################################################################
MISC_SRCS = lib_init.c lib_filesem.c
+
+ifneq ($(CONFIG_NFILE_DESCRIPTORS),0)
+MISC_SRCS += lib_readdirr.c lib_telldir.c
ifneq ($(CONFIG_NFILE_STREAMS),0)
MISC_SRCS += lib_streamsem.c
endif
+endif
REGEX_SRCS = lib_match.c
diff --git a/nuttx/lib/misc/lib_filesem.c b/nuttx/lib/misc/lib_filesem.c
index 1f2f80b3c..e6a3fdb67 100644
--- a/nuttx/lib/misc/lib_filesem.c
+++ b/nuttx/lib/misc/lib_filesem.c
@@ -103,7 +103,7 @@ void lib_take_semaphore(FAR struct file_struct *stream)
* the wait was awakened by a signal.
*/
- ASSERT(*get_errno_ptr() == EINTR);
+ ASSERT(get_errno() == EINTR);
}
/* We have it. Claim the stak and return */
diff --git a/nuttx/fs/fs_readdirr.c b/nuttx/lib/misc/lib_readdirr.c
index 953b43d5a..6a9af9068 100644
--- a/nuttx/fs/fs_readdirr.c
+++ b/nuttx/lib/misc/lib_readdirr.c
@@ -1,7 +1,7 @@
/****************************************************************************
- * fs/fs_readdirr.c
+ * lib/misc/lib_readdirr.c
*
- * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -42,8 +42,8 @@
#include <string.h>
#include <dirent.h>
#include <errno.h>
+
#include <nuttx/fs.h>
-#include "fs_internal.h"
/****************************************************************************
* Private Functions
@@ -87,11 +87,13 @@ int readdir_r(FAR DIR *dirp, FAR struct dirent *entry,
{
struct dirent *tmp;
- *get_errno_ptr() = 0;
+ /* NOTE: The following use or errno is *not* thread-safe */
+
+ set_errno(0);
tmp = readdir(dirp);
if (!tmp)
{
- int error = *get_errno_ptr();
+ int error = get_errno();
if (!error)
{
if (result)
diff --git a/nuttx/lib/misc/lib_streamsem.c b/nuttx/lib/misc/lib_streamsem.c
index 5ab4135bb..a8610382e 100644
--- a/nuttx/lib/misc/lib_streamsem.c
+++ b/nuttx/lib/misc/lib_streamsem.c
@@ -78,7 +78,7 @@ void stream_semtake(FAR struct streamlist *list)
* the wait was awakened by a signal.
*/
- ASSERT(*get_errno_ptr() == EINTR);
+ ASSERT(get_errno() == EINTR);
}
}
diff --git a/nuttx/fs/fs_telldir.c b/nuttx/lib/misc/lib_telldir.c
index f8fd3b92c..2fc5384bb 100644
--- a/nuttx/fs/fs_telldir.c
+++ b/nuttx/lib/misc/lib_telldir.c
@@ -46,8 +46,6 @@
#include <nuttx/fs.h>
#include <nuttx/dirent.h>
-#include "fs_internal.h"
-
/****************************************************************************
* Private Functions
****************************************************************************/
diff --git a/nuttx/lib/semaphore/sem_getvalue.c b/nuttx/lib/semaphore/sem_getvalue.c
index bc9971b20..137eb9001 100644
--- a/nuttx/lib/semaphore/sem_getvalue.c
+++ b/nuttx/lib/semaphore/sem_getvalue.c
@@ -102,7 +102,7 @@ int sem_getvalue(FAR sem_t *sem, FAR int *sval)
}
else
{
- errno = -EINVAL;
+ set_errno(EINVAL);
return ERROR;
}
}
diff --git a/nuttx/lib/semaphore/sem_init.c b/nuttx/lib/semaphore/sem_init.c
index f4c9a0d8b..f90cc5470 100644
--- a/nuttx/lib/semaphore/sem_init.c
+++ b/nuttx/lib/semaphore/sem_init.c
@@ -109,7 +109,7 @@ int sem_init (FAR sem_t *sem, int pshared, unsigned int value)
}
else
{
- errno = -EINVAL;
+ set_errno(EINVAL);
return ERROR;
}
}
diff --git a/nuttx/lib/signal/Make.defs b/nuttx/lib/signal/Make.defs
new file mode 100644
index 000000000..0c66efa73
--- /dev/null
+++ b/nuttx/lib/signal/Make.defs
@@ -0,0 +1,40 @@
+############################################################################
+# lib/signal/Make.defs
+#
+# Copyright (C) 2011 Gregory Nutt. All rights reserved.
+# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# 3. Neither the name NuttX nor the names of its contributors may be
+# used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+############################################################################
+
+ifneq ($(CONFIG_DISABLE_SIGNALS),y)
+SIG_SRCS = sig_emptyset.c sig_fillset.c sig_addset.c sig_delset.c sig_ismember.c
+endif
+
+
diff --git a/nuttx/sched/sig_addset.c b/nuttx/lib/signal/sig_addset.c
index 678a7fcaf..af9463aac 100644
--- a/nuttx/sched/sig_addset.c
+++ b/nuttx/lib/signal/sig_addset.c
@@ -1,7 +1,7 @@
/****************************************************************************
- * sched/sig_addset.c
+ * lib/signal/sig_addset.c
*
- * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -97,3 +97,4 @@ int sigaddset(FAR sigset_t *set, int signo)
return ret;
}
+
diff --git a/nuttx/sched/sig_delset.c b/nuttx/lib/signal/sig_delset.c
index 78f8dc177..489c59afa 100644
--- a/nuttx/sched/sig_delset.c
+++ b/nuttx/lib/signal/sig_delset.c
@@ -1,7 +1,7 @@
/****************************************************************************
- * sched/sig_delset.c
+ * lib/signal/sig_delset.c
*
- * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -97,3 +97,4 @@ int sigdelset(FAR sigset_t *set, int signo)
return ret;
}
+
diff --git a/nuttx/sched/sig_emptyset.c b/nuttx/lib/signal/sig_emptyset.c
index c8fc4ef40..bfee58832 100644
--- a/nuttx/sched/sig_emptyset.c
+++ b/nuttx/lib/signal/sig_emptyset.c
@@ -1,7 +1,7 @@
/****************************************************************************
- * sched/sig_emptyset.c
+ * lib/signal/sig_emptyset.c
*
- * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -85,3 +85,4 @@ int sigemptyset(FAR sigset_t *set)
*set = NULL_SIGNAL_SET;
return OK;
}
+
diff --git a/nuttx/sched/sig_fillset.c b/nuttx/lib/signal/sig_fillset.c
index d315c0d63..c660da0ad 100644
--- a/nuttx/sched/sig_fillset.c
+++ b/nuttx/lib/signal/sig_fillset.c
@@ -1,7 +1,7 @@
/****************************************************************************
- * sched/sig_fillset.c
+ * lib/signal/sig_fillset.c
*
- * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -60,7 +60,7 @@
****************************************************************************/
/****************************************************************************
- * Publics Functioins
+ * Publics Functions
****************************************************************************/
/****************************************************************************
@@ -85,3 +85,4 @@ int sigfillset(FAR sigset_t *set)
*set = ALL_SIGNAL_SET;
return OK;
}
+
diff --git a/nuttx/sched/sig_ismember.c b/nuttx/lib/signal/sig_ismember.c
index 670ef7bd2..88dc8d819 100644
--- a/nuttx/sched/sig_ismember.c
+++ b/nuttx/lib/signal/sig_ismember.c
@@ -1,7 +1,7 @@
/****************************************************************************
- * sched/sig_ismember.c
+ * lib/signal/sig_ismember.c
*
- * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -98,3 +98,4 @@ int sigismember(FAR const sigset_t *set, int signo)
return ret;
}
+
diff --git a/nuttx/lib/stdio/lib_fgetpos.c b/nuttx/lib/stdio/lib_fgetpos.c
index a641db481..af07f7387 100644
--- a/nuttx/lib/stdio/lib_fgetpos.c
+++ b/nuttx/lib/stdio/lib_fgetpos.c
@@ -107,7 +107,7 @@ int fgetpos(FAR FILE *stream, FAR fpos_t *pos)
#if CONFIG_DEBUG
if (!stream || !pos)
{
- errno = EINVAL;
+ set_errno(EINVAL);
return ERROR;
}
#endif
diff --git a/nuttx/lib/stdio/lib_fileno.c b/nuttx/lib/stdio/lib_fileno.c
index 2fe3d9c99..7366194ba 100644
--- a/nuttx/lib/stdio/lib_fileno.c
+++ b/nuttx/lib/stdio/lib_fileno.c
@@ -60,7 +60,7 @@ int fileno(FAR FILE *stream)
if (ret < 0)
{
- errno = EBADF;
+ set_errno(EBADF);
return ERROR;
}
return ret;
diff --git a/nuttx/lib/stdio/lib_fopen.c b/nuttx/lib/stdio/lib_fopen.c
index 07437161c..42ac19d1b 100644
--- a/nuttx/lib/stdio/lib_fopen.c
+++ b/nuttx/lib/stdio/lib_fopen.c
@@ -230,7 +230,7 @@ errout_with_sem:
stream_semgive(slist);
errout:
- *get_errno_ptr() = err;
+ set_errno(err);
return NULL;
}
diff --git a/nuttx/lib/stdio/lib_fputs.c b/nuttx/lib/stdio/lib_fputs.c
index 870c5c42e..54801ca50 100644
--- a/nuttx/lib/stdio/lib_fputs.c
+++ b/nuttx/lib/stdio/lib_fputs.c
@@ -100,7 +100,7 @@ int fputs(FAR const char *s, FAR FILE *stream)
if (!s)
{
- *get_errno_ptr() = EINVAL;
+ set_errno(EINVAL);
}
else
{
diff --git a/nuttx/lib/stdio/lib_fseek.c b/nuttx/lib/stdio/lib_fseek.c
index e56645ab6..a68de79fe 100644
--- a/nuttx/lib/stdio/lib_fseek.c
+++ b/nuttx/lib/stdio/lib_fseek.c
@@ -119,7 +119,7 @@ int fseek(FAR FILE *stream, long int offset, int whence)
if (!stream)
{
- errno = EBADF;
+ set_errno(EBADF);
return ERROR;
}
#endif
diff --git a/nuttx/lib/stdio/lib_fsetpos.c b/nuttx/lib/stdio/lib_fsetpos.c
index 637c627b5..ad3e67230 100644
--- a/nuttx/lib/stdio/lib_fsetpos.c
+++ b/nuttx/lib/stdio/lib_fsetpos.c
@@ -107,7 +107,7 @@ int fsetpos(FAR FILE *stream, FAR fpos_t *pos)
#if CONFIG_DEBUG
if (!stream || !pos)
{
- errno = EINVAL;
+ set_errno(EINVAL);
return ERROR;
}
#endif
diff --git a/nuttx/lib/stdio/lib_ftell.c b/nuttx/lib/stdio/lib_ftell.c
index b0b0a78e5..cd0e48368 100644
--- a/nuttx/lib/stdio/lib_ftell.c
+++ b/nuttx/lib/stdio/lib_ftell.c
@@ -107,7 +107,7 @@ long ftell(FAR FILE *stream)
if (!stream)
{
- errno = EBADF;
+ set_errno(EBADF);
return ERROR;
}
diff --git a/nuttx/lib/stdio/lib_libfflush.c b/nuttx/lib/stdio/lib_libfflush.c
index 68a1bc39f..3e9de538a 100644
--- a/nuttx/lib/stdio/lib_libfflush.c
+++ b/nuttx/lib/stdio/lib_libfflush.c
@@ -114,7 +114,7 @@ ssize_t lib_fflush(FAR FILE *stream, bool bforce)
if (stream->fs_filedes < 0 || (stream->fs_oflags & O_WROK) == 0)
{
- *get_errno_ptr() = EBADF;
+ set_errno(EBADF);
return ERROR;
}
diff --git a/nuttx/lib/stdio/lib_libflushall.c b/nuttx/lib/stdio/lib_libflushall.c
index de2853df8..0b95fc22d 100644
--- a/nuttx/lib/stdio/lib_libflushall.c
+++ b/nuttx/lib/stdio/lib_libflushall.c
@@ -121,7 +121,7 @@ int lib_flushall(FAR struct streamlist *list)
* to flush all of the buffered write data. Return EOF on failure.
*/
- lasterrno = *get_errno_ptr();
+ lasterrno = get_errno();
ret = ERROR;
}
}
@@ -131,6 +131,9 @@ int lib_flushall(FAR struct streamlist *list)
/* If any flush failed, return that last failed flush */
- *get_errno_ptr() = lasterrno;
+ if (ret != OK)
+ {
+ set_errno(lasterrno);
+ }
return ret;
}
diff --git a/nuttx/lib/stdio/lib_libfread.c b/nuttx/lib/stdio/lib_libfread.c
index abeb34deb..4d402a42b 100644
--- a/nuttx/lib/stdio/lib_libfread.c
+++ b/nuttx/lib/stdio/lib_libfread.c
@@ -93,7 +93,7 @@ ssize_t lib_fread(FAR void *ptr, size_t count, FAR FILE *stream)
if (!stream || (stream->fs_oflags & O_RDOK) == 0)
{
- *get_errno_ptr() = EBADF;
+ set_errno(EBADF);
bytes_read = -1;
}
else
diff --git a/nuttx/lib/stdio/lib_libfwrite.c b/nuttx/lib/stdio/lib_libfwrite.c
index 3b7253cdd..e2c35e3e9 100644
--- a/nuttx/lib/stdio/lib_libfwrite.c
+++ b/nuttx/lib/stdio/lib_libfwrite.c
@@ -96,7 +96,7 @@ ssize_t lib_fwrite(FAR const void *ptr, size_t count, FAR FILE *stream)
if (!stream || (stream->fs_oflags & O_WROK) == 0)
{
- *get_errno_ptr() = EBADF;
+ set_errno(EBADF);
goto errout;
}
diff --git a/nuttx/lib/stdio/lib_rawinstream.c b/nuttx/lib/stdio/lib_rawinstream.c
index b54305ce6..ead3116b4 100644
--- a/nuttx/lib/stdio/lib_rawinstream.c
+++ b/nuttx/lib/stdio/lib_rawinstream.c
@@ -66,7 +66,7 @@ static int rawinstream_getc(FAR struct lib_instream_s *this)
return ch;
}
}
- while (nwritten < 0 && errno == EINTR);
+ while (nwritten < 0 && get_errno() == EINTR);
}
return EOF;
diff --git a/nuttx/lib/stdio/lib_rawoutstream.c b/nuttx/lib/stdio/lib_rawoutstream.c
index bf9a68206..05cb5853f 100644
--- a/nuttx/lib/stdio/lib_rawoutstream.c
+++ b/nuttx/lib/stdio/lib_rawoutstream.c
@@ -64,7 +64,7 @@ static void rawoutstream_putc(FAR struct lib_outstream_s *this, int ch)
this->nput++;
}
}
- while (nwritten < 0 && *get_errno_ptr() == EINTR);
+ while (nwritten < 0 && get_errno() == EINTR);
}
}
diff --git a/nuttx/lib/stdio/lib_rdflush.c b/nuttx/lib/stdio/lib_rdflush.c
index 592cc4183..948dcce5d 100644
--- a/nuttx/lib/stdio/lib_rdflush.c
+++ b/nuttx/lib/stdio/lib_rdflush.c
@@ -96,7 +96,7 @@ int lib_rdflush(FAR FILE *stream)
{
if (!stream)
{
- *get_errno_ptr() = EBADF;
+ set_errno(EBADF);
return ERROR;
}
diff --git a/nuttx/lib/stdio/lib_ungetc.c b/nuttx/lib/stdio/lib_ungetc.c
index 9ad72b394..e27428fa4 100644
--- a/nuttx/lib/stdio/lib_ungetc.c
+++ b/nuttx/lib/stdio/lib_ungetc.c
@@ -99,7 +99,7 @@ int ungetc(int c, FAR FILE *stream)
if ((stream && stream->fs_filedes < 0) ||
((stream->fs_oflags & O_RDOK) == 0))
{
- errno = EBADF;
+ set_errno(EBADF);
return EOF;
}
@@ -114,7 +114,7 @@ int ungetc(int c, FAR FILE *stream)
else
#endif
{
- errno = ENOMEM;
+ set_errno(ENOMEM);
return EOF;
}
}
diff --git a/nuttx/lib/string/lib_strtod.c b/nuttx/lib/string/lib_strtod.c
index 26480f925..86719c510 100755
--- a/nuttx/lib/string/lib_strtod.c
+++ b/nuttx/lib/string/lib_strtod.c
@@ -145,7 +145,7 @@ double_t strtod(const char *str, char **endptr)
if (num_digits == 0)
{
- errno = ERANGE;
+ set_errno(ERANGE);
return 0.0;
}
@@ -193,7 +193,7 @@ double_t strtod(const char *str, char **endptr)
if (exponent < __DBL_MIN_EXP__ ||
exponent > __DBL_MAX_EXP__)
{
- errno = ERANGE;
+ set_errno(ERANGE);
return infinite;
}
@@ -219,8 +219,15 @@ double_t strtod(const char *str, char **endptr)
p10 *= p10;
}
- if (!is_real(number)) errno = ERANGE;
- if (endptr) *endptr = p;
+ if (!is_real(number))
+ {
+ set_errno(ERANGE);
+ }
+
+ if (endptr)
+ {
+ *endptr = p;
+ }
return number;
}
diff --git a/nuttx/lib/unistd/lib_chdir.c b/nuttx/lib/unistd/lib_chdir.c
index 15dc64383..c054f2b23 100644
--- a/nuttx/lib/unistd/lib_chdir.c
+++ b/nuttx/lib/unistd/lib_chdir.c
@@ -173,7 +173,7 @@ int chdir(FAR const char *path)
return OK;
errout:
- errno = err;
+ set_errno(err);
return ERROR;
}
#endif /* CONFIG_NFILE_DESCRIPTORS && !CONFIG_DISABLE_ENVIRON */
diff --git a/nuttx/lib/unistd/lib_getcwd.c b/nuttx/lib/unistd/lib_getcwd.c
index 6888470ac..9bfa102fb 100644
--- a/nuttx/lib/unistd/lib_getcwd.c
+++ b/nuttx/lib/unistd/lib_getcwd.c
@@ -99,11 +99,13 @@ FAR char *getcwd(FAR char *buf, size_t size)
/* Verify input parameters */
+#ifdef CONFIG_DEBUG
if (!buf || !size)
{
- errno = EINVAL;
+ set_errno(EINVAL);
return NULL;
}
+#endif
/* If no working directory is defined, then default to the home directory */
@@ -117,7 +119,7 @@ FAR char *getcwd(FAR char *buf, size_t size)
if (strlen(pwd) + 1 > size)
{
- errno = ERANGE;
+ set_errno(ERANGE);
return NULL;
}
diff --git a/nuttx/sched/Makefile b/nuttx/sched/Makefile
index 8b8b33a58..86e7c0b76 100644
--- a/nuttx/sched/Makefile
+++ b/nuttx/sched/Makefile
@@ -38,10 +38,10 @@
ASRCS =
AOBJS = $(ASRCS:.S=$(OBJEXT))
-MISC_SRCS = os_start.c os_bringup.c get_errno_ptr.c sched_garbage.c \
- sched_setupstreams.c sched_getfiles.c sched_getsockets.c sched_getstreams.c \
- sched_setupidlefiles.c sched_setuptaskfiles.c sched_setuppthreadfiles.c \
- sched_releasefiles.c
+MISC_SRCS = os_start.c os_bringup.c errno_getptr.c errno_get.c errno_set.c \
+ sched_garbage.c sched_setupstreams.c sched_getfiles.c sched_getsockets.c \
+ sched_getstreams.c sched_setupidlefiles.c sched_setuptaskfiles.c \
+ sched_setuppthreadfiles.c sched_releasefiles.c
TSK_SRCS = task_create.c task_init.c task_setup.c task_activate.c \
task_start.c task_delete.c task_deletecurrent.c task_restart.c \
@@ -80,12 +80,10 @@ CLOCK_SRCS = clock_initialize.c clock_settime.c clock_gettime.c clock_getres.c \
SIGNAL_SRCS = sig_initialize.c \
sig_action.c sig_procmask.c sig_pending.c sig_suspend.c \
sig_kill.c sig_queue.c sig_waitinfo.c sig_timedwait.c \
- sig_emptyset.c sig_fillset.c sig_addset.c sig_delset.c \
- sig_ismember.c sig_findaction.c \
- sig_allocatependingsigaction.c sig_releasependingsigaction.c \
- sig_unmaskpendingsignal.c sig_removependingsignal.c \
- sig_releasependingsignal.c sig_lowest.c sig_mqnotempty.c \
- sig_cleanup.c sig_received.c sig_deliver.c
+ sig_findaction.c sig_allocatependingsigaction.c \
+ sig_releasependingsigaction.c sig_unmaskpendingsignal.c \
+ sig_removependingsignal.c sig_releasependingsignal.c sig_lowest.c \
+ sig_mqnotempty.c sig_cleanup.c sig_received.c sig_deliver.c
MQUEUE_SRCS = mq_open.c mq_close.c mq_unlink.c mq_send.c mq_timedsend.c\
mq_sndinternal.c mq_receive.c mq_timedreceive.c mq_rcvinternal.c \
diff --git a/nuttx/sched/errno_get.c b/nuttx/sched/errno_get.c
new file mode 100644
index 000000000..7461a42c7
--- /dev/null
+++ b/nuttx/sched/errno_get.c
@@ -0,0 +1,84 @@
+/****************************************************************************
+ * sched/errno_get.c
+ *
+ * Copyright (C) 2011 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <errno.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#undef get_errno_ptr
+#undef get_errno
+#undef errno
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Function: get_errno
+ *
+ * Description:
+ * Return the value of the thread specific errno. This function is only
+ * intended to provide a mechanism for user-mode programs to get the
+ * thread-specific errno value. It is #define'd to the symbol errno in
+ * include/errno.h.
+ *
+ * Parameters:
+ * None
+ *
+ * Return Value:
+ * The current value of the thread specific errno.
+ *
+ * Assumptions:
+ *
+ ****************************************************************************/
+
+int get_errno(void)
+{
+ return *get_errno_ptr();
+}
+
+
diff --git a/nuttx/sched/get_errno_ptr.c b/nuttx/sched/errno_getptr.c
index ebf2e105c..8daf5b2cc 100644
--- a/nuttx/sched/get_errno_ptr.c
+++ b/nuttx/sched/errno_getptr.c
@@ -1,7 +1,7 @@
/****************************************************************************
- * sched/get_errno_ptr.c
+ * sched/errno_getptr.c
*
- * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -43,6 +43,10 @@
#include <nuttx/arch.h>
#include "os_internal.h"
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
#undef get_errno_ptr
#undef errno
diff --git a/nuttx/sched/errno_set.c b/nuttx/sched/errno_set.c
new file mode 100644
index 000000000..2bf01d9b1
--- /dev/null
+++ b/nuttx/sched/errno_set.c
@@ -0,0 +1,83 @@
+/****************************************************************************
+ * sched/errno_set.c
+ *
+ * Copyright (C) 2011 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <errno.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#undef get_errno_ptr
+#undef set_errno
+#undef errno
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Function: set_errno
+ *
+ * Description:
+ * Set the value of the thread specific errno. This function is only
+ * intended to provide a mechanism for user-mode programs to set the
+ * thread-specific errno value.
+ *
+ * Parameters:
+ * errcode - The thread specific errno will be set to this error code value.
+ *
+ * Return Value:
+ * None
+ *
+ * Assumptions:
+ *
+ ****************************************************************************/
+
+void set_errno(int errcode)
+{
+ *get_errno_ptr() = errcode;
+}
+
+
diff --git a/nuttx/sched/sched_lockcount.c b/nuttx/sched/sched_lockcount.c
index 21998f6b3..6ac3a9dee 100644
--- a/nuttx/sched/sched_lockcount.c
+++ b/nuttx/sched/sched_lockcount.c
@@ -1,7 +1,7 @@
/************************************************************************
* sched/sched_lockcount.c
*
- * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -75,10 +75,11 @@
* Name: sched_lockcount
*
* Description:
- * This function returns the current value of the lockcount.
- * If zero, preemption is enabled; if non-zero, this value
- * indicates the number of times that osTask() has been
- * called on this thread of execution.
+ * This function returns the current value of the lockcount. If zero,
+ * pre-emption is enabled; if non-zero, this value indicates the number
+ * of times that sched_lock() has been called on this thread of
+ * execution. sched_unlock() will have to called that many times from
+ * this thread in order to re-enable pre-emption.
*
* Inputs:
* None
@@ -88,8 +89,9 @@
*
************************************************************************/
-int32_t sched_lockcount(void)
+int sched_lockcount(void)
{
_TCB *rtcb = (_TCB*)g_readytorun.head;
- return (int32_t)rtcb->lockcount;
+ return (int)rtcb->lockcount;
}
+
diff --git a/nuttx/syscall/Makefile b/nuttx/syscall/Makefile
index b38518bfb..89d079e5c 100644
--- a/nuttx/syscall/Makefile
+++ b/nuttx/syscall/Makefile
@@ -97,7 +97,7 @@ context: .context
clean:
@rm -f $(BIN1) $(BIN2) *~ .*.swp
-ifneq ($(OBJECT),)
+ifneq ($(OBJEXT),)
@rm -f proxies/*$(OBJEXT) stubs/*$(OBJEXT)
endif
$(call CLEAN)
diff --git a/nuttx/syscall/README.txt b/nuttx/syscall/README.txt
index 08d041346..7c45207f8 100644
--- a/nuttx/syscall/README.txt
+++ b/nuttx/syscall/README.txt
@@ -90,7 +90,23 @@ The format of the CVS file for each line is:
Field 2: The header file that contains the function prototype
Field 3: Condition for compilation
Field 4: The type of function return value.
- Field 5 - N+5: The type of each of the N formal parameters of the function
+ Field 5 - N+5: The type of each of the N formal parameters of the function
+
+Each type field has a format as follows:
+
+ type name:
+ For all simpler types
+ formal type | actual type:
+ For array types where the form of the formal (eg. int parm[2])
+ differs from the type of actual passed parameter (eg. int*). This
+ is necessary because you cannot do simple casts to array types.
+ formal type | union member actual type | union member fieldname:
+ A similar situation exists for unions. For example, the formal
+ parameter type union sigval -- You cannot cast a uintptr_t to
+ a union sigval, but you can cast to the type of one of the union
+ member types when passing the actua paramter. Similarly, we
+ cannot cast a union sigval to a uinptr_t either. Rather, we need
+ to cast a specific union member fieldname to uintptr_t.
Auto-Generated Files
====================
@@ -104,7 +120,7 @@ database. Here the following definition is used:
call into a syscall, marshalling all of the system call parameters
as necessary.
- STUB - Another tiny bit of code that executes within the NuttX kernel
+ Stub - Another tiny bit of code that executes within the NuttX kernel
that is used to map a software interrupt received by the kernel to
a kernel function call. The stubs receive the marshalled system
call data, and perform the actually kernel function call (in
diff --git a/nuttx/syscall/syscall.csv b/nuttx/syscall/syscall.csv
index d0cf3eb16..44920d015 100644
--- a/nuttx/syscall/syscall.csv
+++ b/nuttx/syscall/syscall.csv
@@ -9,7 +9,6 @@
"close","unistd.h","CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0","int","int"
"closedir","dirent.h","CONFIG_NFILE_DESCRIPTORS > 0","int","FAR DIR*"
"connect","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","int","int","FAR const struct sockaddr*","socklen_t"
-"creat","fcntl.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","int","const char*","mode_t"
"dup","unistd.h","CONFIG_NFILE_DESCRIPTORS > 0","int","int"
"dup2","unistd.h","CONFIG_NFILE_DESCRIPTORS > 0","int","int","int"
"exit","stdlib.h","","void","int"
@@ -79,7 +78,6 @@
"putenv","stdlib.h","!defined(CONFIG_DISABLE_ENVIRON)","int","FAR const char*"
"read","unistd.h","CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0","ssize_t","int","FAR void*","size_t"
"readdir","dirent.h","CONFIG_NFILE_DESCRIPTORS > 0","FAR struct dirent*","FAR DIR*"
-"readdir_r","dirent.h","CONFIG_NFILE_DESCRIPTORS > 0","int","FAR DIR*","FAR struct dirent*","FAR struct dirent**"
"recv","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","ssize_t","int","FAR void*","size_t","int"
"recvfrom","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","ssize_t","int","FAR void*","size_t","int","FAR struct sockaddr*","FAR socklen_t*"
"rename","stdio.h","CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT)","int","FAR const char*","FAR const char*"
@@ -89,9 +87,6 @@
"sched_getscheduler","sched.h","","int","pid_t"
"sched_lock","sched.h","","int"
"sched_lockcount","sched.h","","int32_t"
-"sched_note_start","sched.h","","void","FAR _TCB* "
-"sched_note_stop","sched.h","","void","FAR _TCB* "
-"sched_note_switch","sched.h","","void","FAR _TCB*","FAR _TCB*"
"sched_rr_get_interval","sched.h","","int","pid_t","struct timespec*"
"sched_setparam","sched.h","","int","pid_t","const struct sched_param*"
"sched_setscheduler","sched.h","","int","pid_t","int","const struct sched_param*"
@@ -112,30 +107,20 @@
"setenv","stdlib.h","","int","const char*","const char*","int"
"setsockopt","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","int","int","int","int","FAR const void*","socklen_t"
"sigaction","signal.h","!defined(CONFIG_DISABLE_SIGNALS)","int","int","FAR const struct sigaction*","FAR struct sigaction*"
-"sigaddset","signal.h","!defined(CONFIG_DISABLE_SIGNALS)","int","FAR sigset_t*","int"
-"sigdelset","signal.h","!defined(CONFIG_DISABLE_SIGNALS)","int","FAR sigset_t*","int"
-"sigemptyset","signal.h","!defined(CONFIG_DISABLE_SIGNALS)","int","FAR sigset_t*"
-"sigfillset","signal.h","!defined(CONFIG_DISABLE_SIGNALS)","int","FAR sigset_t*"
-"sigismember","signal.h","!defined(CONFIG_DISABLE_SIGNALS)","int","FAR const sigset_t*","int"
"sigpending","signal.h","!defined(CONFIG_DISABLE_SIGNALS)","int","FAR sigset_t*"
"sigprocmask","signal.h","!defined(CONFIG_DISABLE_SIGNALS)","int","int","FAR const sigset_t*","FAR sigset_t*"
-"sigqueue","signal.h","!defined(CONFIG_DISABLE_SIGNALS)","int","int","int","FAR void*"
-"sigqueue","signal.h","!defined(CONFIG_DISABLE_SIGNALS)","int","int","int","union sigval|FAR void *"
+"sigqueue","signal.h","!defined(CONFIG_DISABLE_SIGNALS)","int","int","int","union sigval|FAR void *|sival_ptr"
"sigsuspend","signal.h","!defined(CONFIG_DISABLE_SIGNALS)","int","FAR const sigset_t*"
"sigtimedwait","signal.h","!defined(CONFIG_DISABLE_SIGNALS)","int","FAR const sigset_t*","FAR struct siginfo*","FAR const struct timespec*"
"sigwaitinfo","signal.h","!defined(CONFIG_DISABLE_SIGNALS)","int","FAR const sigset_t*","FAR struct siginfo*"
"sleep","unistd.h","!defined(CONFIG_DISABLE_SIGNALS)","unsigned int","unsigned int"
-"snprintf","stdio.h","","int","FAR char*","size_t","const char*","..."
"socket","sys/socket.h","","int","int","int","int"
"stat","sys/stat.h","CONFIG_NFILE_DESCRIPTORS > 0","int","const char*","FAR struct stat*"
#"statfs","stdio.h","","int","FAR const char*","FAR struct statfs*"
"statfs","sys/statfs.h","CONFIG_NFILE_DESCRIPTORS > 0","int","const char*","struct statfs*"
-"task_activate","sched.h","","int","FAR _TCB*"
"task_create","sched.h","","int","const char*","int","int","main_t","const char* []|const char**"
#"task_create","sched.h","","int","const char*","int","main_t","const char* []|const char**"
"task_delete","sched.h","","int","pid_t"
-"task_init","sched.h","","int","FAR _TCB*","const char*","int","FAR uint32_t*","uint32_t","main_t","const char* []|const char**"
-#"task_init","sched.h","","int","FAR _TCB*","const char*","int","main_t","const char* []|const char**"
"task_restart","sched.h","","int","pid_t"
"telldir","dirent.h","CONFIG_NFILE_DESCRIPTORS > 0","off_t","FAR DIR*"
"timer_create","time.h","!defined(CONFIG_DISABLE_POSIX_TIMERS)","int","clockid_t","FAR struct sigevent*","FAR timer_t*"
diff --git a/nuttx/tools/mksyscall.c b/nuttx/tools/mksyscall.c
index f65a4f489..a8f2cf99b 100644
--- a/nuttx/tools/mksyscall.c
+++ b/nuttx/tools/mksyscall.c
@@ -274,35 +274,69 @@ static void print_formalparm(FILE *stream, const char *argtype, int parmno)
static void get_formalparmtype(const char *arg, char *formal)
{
- char *ptr = strchr(arg,'|');
- if (ptr)
- {
- /* The formal parm type is a pointer to everything up to the '|' */
+ /* The formal parm type is a pointer to everything up to the first'|' (or
+ * the end of the string if there is no '|' in the type description).
+ */
- while (*arg != '|')
- {
- *formal++ = *arg++;
- }
- *formal = '\0';
- }
- else
+ while (*arg != '|' && *arg != '\0')
{
- strncpy(formal, arg, MAX_PARMSIZE);
+ *formal++ = *arg++;
}
+ *formal = '\0';
}
static void get_actualparmtype(const char *arg, char *actual)
{
- char *ptr = strchr(arg,'|');
- if (ptr)
+ const char *pstart = strchr(arg,'|');
+ if (pstart)
{
- ptr++;
- strncpy(actual, ptr, MAX_PARMSIZE);
+ /* The actual parameter type starts after the '|' */
+
+ pstart++;
}
else
{
- strncpy(actual, arg, MAX_PARMSIZE);
+ /* The actual parameter is the same as the formal parameter
+ * at starts at the beginning of the type string.
+ */
+
+ pstart = arg;
}
+
+ /* The actual parm type is a pointer to everything up to the next '|' (or
+ * the end of the string if there is no '|' in the type description).
+ */
+
+ while (*pstart != '|' && *pstart != '\0')
+ {
+ *actual++ = *pstart++;
+ }
+ *actual = '\0';
+}
+
+static void get_fieldname(const char *arg, char *fieldname)
+{
+ char *pactual = strchr(arg,'|');
+ char *pstart;
+
+ if (pactual)
+ {
+ /* The actual parameter type starts after the '|' */
+
+ pactual++;
+ pstart = strchr(pactual,'|');
+ if (pstart)
+ {
+ /* The fieldname is everything past the second '|' to the end of the string */
+
+ pstart++;
+ strncpy(fieldname, pstart, MAX_PARMSIZE);
+ return;
+ }
+ }
+
+ fprintf(stderr, "%d: Missing union fieldname: %s\n", g_lineno, arg);
+ exit(15);
}
static FILE *open_proxy(void)
@@ -326,6 +360,7 @@ static void generate_proxy(int nparms)
{
FILE *stream = open_proxy();
char formal[MAX_PARMSIZE];
+ char fieldname[MAX_PARMSIZE];
bool bvarargs = false;
int nformal;
int nactual;
@@ -444,7 +479,22 @@ static void generate_proxy(int nparms)
for (i = 0; i < nactual; i++)
{
- fprintf(stream, ", (uintptr_t)parm%d", i+1);
+ /* Is the parameter a union member */
+
+ if (i < nparms && is_union(g_parm[PARM1_INDEX+i]))
+ {
+ /* Then we will have to pick a field name that can be cast to a
+ * uintptr_t. There probably should be some error handling here
+ * to catch the case where the fieldname was not supplied.
+ */
+
+ get_fieldname(g_parm[PARM1_INDEX+i], fieldname);
+ fprintf(stream, ", (uintptr_t)parm%d.%s", i+1, fieldname);
+ }
+ else
+ {
+ fprintf(stream, ", (uintptr_t)parm%d", i+1);
+ }
}
/* Handle the tail end of the function. */