Yet more issues with errno access via syscalls fixed

This commit is contained in:
Gregory Nutt 2014-08-30 08:43:10 -06:00
parent 253fa09752
commit 0c7e97658e
3 changed files with 104 additions and 18 deletions

90
include/nuttx/errno.h Normal file
View File

@ -0,0 +1,90 @@
/************************************************************************
* include/nuttx/errno.h
*
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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.
*
************************************************************************/
#ifndef __INCLUDE_NUTTX_ERRNO_H
#define __INCLUDE_NUTTX_ERRNO_H
/************************************************************************
* Included Files
************************************************************************/
#include <nuttx/config.h>
#ifdef CONFIG_LIB_SYSCALL
/************************************************************************
* Pre-processor Definitions
************************************************************************/
/************************************************************************
* Type Declarations
************************************************************************/
/************************************************************************
* Public Data
************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/************************************************************************
* Public Function Prototypes
************************************************************************/
/* These get_errno() set_errno() are always exported as functions from
* the kernel always when the system call interface is built. errno.h
* provides the context-specific usage interface for both the kernel- and
* user-spaces which may be different: These are macros within the
* kernel and system call proxy signatures from user space.
*
* This header file always exists to disambuiguate the context. The
* prototypes here duplicate thos of errno.h and must exactly match.
*/
void set_errno(int errcode);
int get_errno(void);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* CONFIG_LIB_SYSCALL */
#endif /* __INCLUDE_NUTTX_ERRNO_H */

View File

@ -18,7 +18,7 @@
"fcntl","fcntl.h","CONFIG_NFILE_DESCRIPTORS > 0","int","int","int","..."
"fs_fdopen","nuttx/fs/fs.h","CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0","FAR struct file_struct*","int","int","FAR struct tcb_s*"
"fsync","unistd.h","CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT)","int","int"
"get_errno","errno.h","","int"
"get_errno","nuttx/errno.h","","int"
"getenv","stdlib.h","!defined(CONFIG_DISABLE_ENVIRON)","FAR char*","FAR const char*"
"getpid","unistd.h","","pid_t"
"getsockopt","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","int","int","int","int","FAR void*","FAR socklen_t*"
@ -110,7 +110,7 @@
"send","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","ssize_t","int","FAR const void*","size_t","int"
"sendfile","sys/sendfile.h","CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_NET_SENDFILE)","ssize_t","int","int","FAR off_t*","size_t"
"sendto","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","ssize_t","int","FAR const void*","size_t","int","FAR const struct sockaddr*","socklen_t"
"set_errno","errno.h","","void","int"
"set_errno","nuttx/errno.h","","void","int"
"setenv","stdlib.h","!defined(CONFIG_DISABLE_ENVIRON)","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*"

Can't render this file because it has a wrong number of fields in line 2.

View File

@ -72,8 +72,19 @@
#include <mqueue.h>
#include <spawn.h>
#include <assert.h>
#include <errno.h>
/* Errno access is awkward. We need to generate get_errno() and set_errno()
* interfaces to support the system calls, even though we don't use them
* ourself.
*
* The "normal" pre-processor defintions for these functions is in errno.h
* but we need the internal function prototypes in nuttx/errno.h.
*/
#undef get_errno
#undef set_errno
#include <nuttx/errno.h>
#include <nuttx/clock.h>
/* clock_systimer is a special case: In the kernel build, proxying for
@ -93,21 +104,6 @@ uint32_t syscall_clock_systimer(void);
* Pre-processor Definitions
****************************************************************************/
/* Errno access is awkward. We need to generate get_errno() and set_errno()
* interfaces to support the system calls, even though we don't use them
* ourself.
*
* The "normal" protoypes for these functions is in errno.h. The following
* must agree exactly.
*/
#ifdef __DIRECT_ERRNO_ACCESS
# undef set_errno
# undef get_errno
void set_errno(int errcode);
int get_errno(void);
#endif
/****************************************************************************
* Public Data
****************************************************************************/