summaryrefslogtreecommitdiff
path: root/nuttx/lib
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-04-02 15:25:22 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-04-02 15:25:22 +0000
commit68551d0cf274eacbf5c6de959e7bf812a6ee7eba (patch)
treea26751e5f0991b18a587dbc2d37c6ee7c3ce847d /nuttx/lib
parent158978359318cb94de9e08900af4300bdfa5f651 (diff)
downloadpx4-nuttx-68551d0cf274eacbf5c6de959e7bf812a6ee7eba.tar.gz
px4-nuttx-68551d0cf274eacbf5c6de959e7bf812a6ee7eba.tar.bz2
px4-nuttx-68551d0cf274eacbf5c6de959e7bf812a6ee7eba.zip
Kernel build mostly successful
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3454 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/lib')
-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.c122
-rw-r--r--nuttx/lib/misc/lib_streamsem.c2
-rw-r--r--nuttx/lib/misc/lib_telldir.c91
-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.c100
-rw-r--r--nuttx/lib/signal/sig_delset.c100
-rw-r--r--nuttx/lib/signal/sig_emptyset.c88
-rw-r--r--nuttx/lib/signal/sig_fillset.c88
-rw-r--r--nuttx/lib/signal/sig_ismember.c101
-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
33 files changed, 827 insertions, 32 deletions
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/lib/misc/lib_readdirr.c b/nuttx/lib/misc/lib_readdirr.c
new file mode 100644
index 000000000..6a9af9068
--- /dev/null
+++ b/nuttx/lib/misc/lib_readdirr.c
@@ -0,0 +1,122 @@
+/****************************************************************************
+ * lib/misc/lib_readdirr.c
+ *
+ * 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
+ * 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 <string.h>
+#include <dirent.h>
+#include <errno.h>
+
+#include <nuttx/fs.h>
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: readdir_r
+ *
+ * Description:
+ * The readdir() function returns a pointer to a dirent
+ * structure representing the next directory entry in the
+ * directory stream pointed to by dir. It returns NULL on
+ * reaching the end-of-file or if an error occurred.
+ *
+ * Inputs:
+ * dirp -- An instance of type DIR created by a previous
+ * call to opendir();
+ * entry -- The storage pointed to by entry must be large
+ * enough for a dirent with an array of char d_name
+ * members containing at least {NAME_MAX}+1 elements.
+ * result -- Upon successful return, the pointer returned
+ * at *result shall have the same value as the
+ * argument entry. Upon reaching the end of the directory
+ * stream, this pointer shall have the value NULL.
+ *
+ * Return:
+ * If successful, the readdir_r() function return s zero;
+ * otherwise, an error number is returned to indicate the
+ * error.
+ *
+ * EBADF - Invalid directory stream descriptor dir
+ *
+ ****************************************************************************/
+
+int readdir_r(FAR DIR *dirp, FAR struct dirent *entry,
+ FAR struct dirent **result)
+{
+ struct dirent *tmp;
+
+ /* NOTE: The following use or errno is *not* thread-safe */
+
+ set_errno(0);
+ tmp = readdir(dirp);
+ if (!tmp)
+ {
+ int error = get_errno();
+ if (!error)
+ {
+ if (result)
+ {
+ *result = NULL;
+ }
+ return 0;
+ }
+ else
+ {
+ return error;
+ }
+ }
+
+ if (entry)
+ {
+ memcpy(entry, tmp, sizeof(struct dirent));
+ }
+
+ if (result)
+ {
+ *result = entry;
+ }
+ return 0;
+}
+
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/lib/misc/lib_telldir.c b/nuttx/lib/misc/lib_telldir.c
new file mode 100644
index 000000000..2fc5384bb
--- /dev/null
+++ b/nuttx/lib/misc/lib_telldir.c
@@ -0,0 +1,91 @@
+/****************************************************************************
+ * fs/fs_telldir.c
+ *
+ * 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
+ * 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 <sys/types.h>
+#include <dirent.h>
+#include <errno.h>
+
+#include <nuttx/fs.h>
+#include <nuttx/dirent.h>
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: telldir
+ *
+ * Description:
+ * The telldir() function returns the current location
+ * associated with the directory stream dirp.
+ *
+ * Inputs:
+ * dirp -- An instance of type DIR created by a previous
+ * call to opendir();
+ *
+ * Return:
+ * On success, the telldir() function returns the current
+ * location in the directory stream. On error, -1 is
+ * returned, and errno is set appropriately.
+ *
+ * EBADF - Invalid directory stream descriptor dir
+ *
+ ****************************************************************************/
+
+off_t telldir(FAR DIR *dirp)
+{
+ struct fs_dirent_s *idir = (struct fs_dirent_s *)dirp;
+
+ if (!idir || !idir->fd_root)
+ {
+ *get_errno_ptr() = EBADF;
+ return (off_t)-1;
+ }
+
+ /* Just return the current position */
+
+ return idir->fd_position;
+}
+
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/lib/signal/sig_addset.c b/nuttx/lib/signal/sig_addset.c
new file mode 100644
index 000000000..af9463aac
--- /dev/null
+++ b/nuttx/lib/signal/sig_addset.c
@@ -0,0 +1,100 @@
+/****************************************************************************
+ * lib/signal/sig_addset.c
+ *
+ * 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
+ * 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 <signal.h>
+
+/****************************************************************************
+ * Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Type Declarations
+ ****************************************************************************/
+
+/****************************************************************************
+ * Global Variables
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Variables
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Function: sigaddset
+ *
+ * Description:
+ * This function adds the signal specified by signo to the signal set
+ * specified by set.
+ *
+ * Parameters:
+ * set - Signal set to add signal to
+ * signo - Signal to add
+ *
+ * Return Value:
+ * 0 (OK), or -1 (ERROR) if the signal number is invalid.
+ *
+ * Assumptions:
+ *
+ ****************************************************************************/
+
+int sigaddset(FAR sigset_t *set, int signo)
+{
+ int ret = ERROR;
+
+ /* Verify the signal */
+
+ if (GOOD_SIGNO(signo))
+ {
+ /* Add the signal to the set */
+
+ *set |= SIGNO2SET(signo);
+ ret = OK;
+ }
+
+ return ret;
+}
+
diff --git a/nuttx/lib/signal/sig_delset.c b/nuttx/lib/signal/sig_delset.c
new file mode 100644
index 000000000..489c59afa
--- /dev/null
+++ b/nuttx/lib/signal/sig_delset.c
@@ -0,0 +1,100 @@
+/****************************************************************************
+ * lib/signal/sig_delset.c
+ *
+ * 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
+ * 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 <signal.h>
+
+/****************************************************************************
+ * Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Type Declarations
+ ****************************************************************************/
+
+/****************************************************************************
+ * Global Variables
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Variables
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Function: sigdelset
+ *
+ * Description:
+ * This function deletes the signal specified by signo from the signal
+ * set specified by the 'set' argument.
+ *
+ * Parameters:
+ * set - Signal set to delete the signal from
+ * signo - Signal to delete
+ *
+ * Return Value:
+ * 0 (OK), or -1 (ERROR) if the signal number is invalid.
+ *
+ * Assumptions:
+ *
+ ****************************************************************************/
+
+int sigdelset(FAR sigset_t *set, int signo)
+{
+ int ret = ERROR;
+
+ /* Verify the signal */
+
+ if (GOOD_SIGNO(signo))
+ {
+ /* Delete the signal to the set */
+
+ *set &= ~SIGNO2SET(signo);
+ ret = OK;
+ }
+
+ return ret;
+}
+
diff --git a/nuttx/lib/signal/sig_emptyset.c b/nuttx/lib/signal/sig_emptyset.c
new file mode 100644
index 000000000..bfee58832
--- /dev/null
+++ b/nuttx/lib/signal/sig_emptyset.c
@@ -0,0 +1,88 @@
+/****************************************************************************
+ * lib/signal/sig_emptyset.c
+ *
+ * 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
+ * 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 <signal.h>
+
+/****************************************************************************
+ * Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Type Declarations
+ ****************************************************************************/
+
+/****************************************************************************
+ * Global Variables
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Variables
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Function: sigemptyset
+ *
+ * Description:
+ * This function initializes the signal set specified by set such that all
+ * signals are excluded.
+ *
+ * Parameters:
+ * set - Signal set to initalize
+ *
+ * Return Value:
+ * 0 (OK), or -1 (ERROR) if the signal set cannot be initialized.
+ *
+ * Assumptions:
+ *
+ ****************************************************************************/
+
+int sigemptyset(FAR sigset_t *set)
+{
+ *set = NULL_SIGNAL_SET;
+ return OK;
+}
+
diff --git a/nuttx/lib/signal/sig_fillset.c b/nuttx/lib/signal/sig_fillset.c
new file mode 100644
index 000000000..c660da0ad
--- /dev/null
+++ b/nuttx/lib/signal/sig_fillset.c
@@ -0,0 +1,88 @@
+/****************************************************************************
+ * lib/signal/sig_fillset.c
+ *
+ * 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
+ * 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 <signal.h>
+
+/****************************************************************************
+ * Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Type Declarations
+ ****************************************************************************/
+
+/****************************************************************************
+ * Global Variables
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Variables
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Publics Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Function: sigfillset
+ *
+ * Description:
+ * This function initializes the signal set specified by set such that all
+ * signals are included.
+ *
+ * Parameters:
+ * set - Signal set to initalize
+ *
+ * Return Value:
+ * 0 (OK), or -1 (ERROR) if the signal set cannot be initialized.
+ *
+ * Assumptions:
+ *
+ ****************************************************************************/
+
+int sigfillset(FAR sigset_t *set)
+{
+ *set = ALL_SIGNAL_SET;
+ return OK;
+}
+
diff --git a/nuttx/lib/signal/sig_ismember.c b/nuttx/lib/signal/sig_ismember.c
new file mode 100644
index 000000000..88dc8d819
--- /dev/null
+++ b/nuttx/lib/signal/sig_ismember.c
@@ -0,0 +1,101 @@
+/****************************************************************************
+ * lib/signal/sig_ismember.c
+ *
+ * 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
+ * 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 <signal.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Type Declarations
+ ****************************************************************************/
+
+/****************************************************************************
+ * Global Variables
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Variables
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Function: sigismember
+ *
+ * Description:
+ * This function tests whether the signal specified by signo is a member
+ * of the set specified by set.
+ *
+ * Parameters:
+ * set - Signal set to test
+ * signo - Signal to test for
+ *
+ * Return Value:
+ * 1 (true), if the specified signal is a member of the set,
+ * 0 (OK or FALSE), if it is not, or
+ * -1 (ERROR) if the signal number is invalid.
+ *
+ * Assumptions:
+ *
+ ****************************************************************************/
+
+int sigismember(FAR const sigset_t *set, int signo)
+{
+ int ret = ERROR;
+
+ /* Verify the signal */
+
+ if (GOOD_SIGNO(signo))
+ {
+ /* Check if the signal is in the set */
+
+ ret = ((*set & SIGNO2SET(signo)) != 0);
+ }
+
+ 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;
}