modify nuttx bug of lack of files
This commit is contained in:
@@ -0,0 +1,447 @@
|
||||
/****************************************************************************
|
||||
* include/sys/boardctl.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_SYS_BOARDCTL_H
|
||||
#define __INCLUDE_SYS_BOARDCTL_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
# include <nuttx/power/pm.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_VNCSERVER
|
||||
# include <nuttx/nx/nx.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NXTERM
|
||||
# include <nuttx/nx/nxterm.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LIB_BOARDCTL
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Common commands
|
||||
*
|
||||
* CMD: BOARDIOC_INIT
|
||||
* DESCRIPTION: Perform one-time application initialization.
|
||||
* ARG: The boardctl() argument is passed to the
|
||||
* board_app_initialize() implementation without modification.
|
||||
* The argument has no meaning to NuttX; the meaning of the
|
||||
* argument is a contract between the board-specific
|
||||
* initialization logic and the matching application logic.
|
||||
* The value could be such things as a mode enumeration value,
|
||||
* a set of DIP switch switch settings, a pointer to
|
||||
* configuration data read from a file or serial FLASH, or
|
||||
* whatever you would like to do with it. Every
|
||||
* implementation should accept zero/NULL as a default
|
||||
* configuration.
|
||||
* CONFIGURATION: CONFIG_LIB_BOARDCTL
|
||||
* DEPENDENCIES: Board logic must provide board_app_initialize()
|
||||
*
|
||||
* CMD: BOARDIOC_POWEROFF
|
||||
* DESCRIPTION: Power off the board
|
||||
* ARG: Integer value providing power off status information
|
||||
* CONFIGURATION: CONFIG_BOARDCTL_POWEROFF
|
||||
* DEPENDENCIES: Board logic must provide the board_power_off() interface.
|
||||
*
|
||||
* CMD: BOARDIOC_RESET
|
||||
* DESCRIPTION: Reset the board
|
||||
* ARG: Integer value providing power off status information
|
||||
* CONFIGURATION: CONFIG_BOARDCTL_RESET
|
||||
* DEPENDENCIES: Board logic must provide the board_reset() interface.
|
||||
*
|
||||
* CMD: BOARDIOC_PM_CONTROL
|
||||
* DESCRIPTION: Manage power state transition and query
|
||||
* ARG: A pointer to an instance of struct boardioc_pm_ctrl_s
|
||||
* CONFIGURATION: CONFIG_PM
|
||||
* DEPENDENCIES: None
|
||||
*
|
||||
* CMD: BOARDIOC_UNIQUEID
|
||||
* DESCRIPTION: Return a unique ID associated with the board (such as a
|
||||
* serial number or a MAC address).
|
||||
* ARG: A writable array of size CONFIG_BOARDCTL_UNIQUEID_SIZE in
|
||||
* which to receive the board unique ID.
|
||||
* DEPENDENCIES: Board logic must provide the board_uniqueid() interface.
|
||||
*
|
||||
* CMD: BOARDIOC_MKRD
|
||||
* DESCRIPTION: Create a RAM disk
|
||||
* ARG: Pointer to read-only instance of struct boardioc_mkrd_s.
|
||||
* CONFIGURATION: CONFIG_BOARDCTL_MKRD
|
||||
* DEPENDENCIES: None
|
||||
*
|
||||
* CMD: BOARDIOC_ROMDISK
|
||||
* DESCRIPTION: Register a ROM disk
|
||||
* ARG: Pointer to read-only instance of struct boardioc_romdisk_s.
|
||||
* CONFIGURATION: CONFIG_BOARDCTL_ROMDISK
|
||||
* DEPENDENCIES: None
|
||||
*
|
||||
* CMD: BOARDIOC_APP_SYMTAB
|
||||
* DESCRIPTION: Select the application symbol table. This symbol table
|
||||
* provides the symbol definitions exported to application
|
||||
* code from application space.
|
||||
* ARG: A pointer to an instance of struct boardioc_symtab_s
|
||||
* CONFIGURATION: CONFIG_BOARDCTL_APP_SYMTAB
|
||||
* DEPENDENCIES: None
|
||||
*
|
||||
* CMD: BOARDIOC_OS_SYMTAB
|
||||
* DESCRIPTION: Select the OS symbol table. This symbol table provides
|
||||
* the symbol definitions exported by the OS to kernel
|
||||
* modules.
|
||||
* ARG: A pointer to an instance of struct boardioc_symtab_s
|
||||
* CONFIGURATION: CONFIG_BOARDCTL_OS_SYMTAB
|
||||
* DEPENDENCIES: None
|
||||
*
|
||||
* CMD: BOARDIOC_BUILTINS
|
||||
* DESCRIPTION: Provide the user-space list of built-in applications for
|
||||
* use by BINFS in protected mode. Normally this is small
|
||||
* set of globals provided by user-space logic. It provides
|
||||
* name-value pairs for associating built-in application
|
||||
* names with user-space entry point addresses. These
|
||||
* globals are only needed for use by BINFS which executes
|
||||
* built-in applications from kernel-space in PROTECTED mode.
|
||||
* In the FLAT build, the user space globals are readily
|
||||
* available. (BINFS is not supportable in KERNEL mode since
|
||||
* user-space address have no general meaning that
|
||||
* configuration).
|
||||
* ARG: A pointer to an instance of struct boardioc_builtin_s
|
||||
* CONFIGURATION: This BOARDIOC command is always available when
|
||||
* CONFIG_BUILTIN is enabled, but does nothing unless
|
||||
* CONFIG_BUILD_PROTECTED and CONFIG_FS_BINFS are also
|
||||
* selected.
|
||||
* DEPENDENCIES: None
|
||||
*
|
||||
* CMD: BOARDIOC_USBDEV_CONTROL
|
||||
* DESCRIPTION: Manage USB device classes
|
||||
* ARG: A pointer to an instance of struct boardioc_usbdev_ctrl_s
|
||||
* CONFIGURATION: CONFIG_LIB_BOARDCTL && CONFIG_BOARDCTL_USBDEVCTRL
|
||||
* DEPENDENCIES: Board logic must provide board_<usbdev>_initialize()
|
||||
*
|
||||
* CMD: BOARDIOC_NX_START
|
||||
* DESCRIPTION: Start the NX server
|
||||
* ARG: Integer display number to be served by this NXMU instance.
|
||||
* CONFIGURATION: CONFIG_NX
|
||||
* DEPENDENCIES: Base graphics logic provides nxmu_start()
|
||||
*
|
||||
* CMD: BOARDIOC_VNC_START
|
||||
* DESCRIPTION: Start the NX server and framebuffer driver.
|
||||
* ARG: A reference readable instance of struct
|
||||
* boardioc_vncstart_s
|
||||
* CONFIGURATION: CONFIG_VNCSERVER
|
||||
* DEPENDENCIES: VNC server provides vnc_default_fbinitialize()
|
||||
*
|
||||
* CMD: BOARDIOC_NXTERM
|
||||
* DESCRIPTION: Create an NX terminal device
|
||||
* ARG: A reference readable/writable instance of struct
|
||||
* boardioc_nxterm_create_s
|
||||
* CONFIGURATION: CONFIG_NXTERM
|
||||
* DEPENDENCIES: Base NX terminal logic provides nx_register() and
|
||||
* nxtk_register()
|
||||
*
|
||||
* CMD: BOARDIOC_NXTERM_IOCTL
|
||||
* DESCRIPTION: Create an NX terminal IOCTL command. Normal IOCTLs
|
||||
* cannot be be performed in most graphics contexts since
|
||||
* the depend on the task holding an open file descriptor
|
||||
* ARG: A reference readable/writable instance of struct
|
||||
* boardioc_nxterm_ioctl_s
|
||||
* CONFIGURATION: CONFIG_NXTERM
|
||||
* DEPENDENCIES: Base NX terminal logic provides nxterm_ioctl_tap()
|
||||
*
|
||||
* CMD: BOARDIOC_TESTSET
|
||||
* DESCRIPTION: Access architecture-specific up_testset() operation
|
||||
* ARG: A pointer to a write-able spinlock object. On success
|
||||
* the preceding spinlock state is returned: 0=unlocked,
|
||||
* 1=locked.
|
||||
* CONFIGURATION: CONFIG_BOARDCTL_TESTSET
|
||||
* DEPENDENCIES: Architecture-specific logic provides up_testset()
|
||||
*/
|
||||
|
||||
#define BOARDIOC_INIT _BOARDIOC(0x0001)
|
||||
#define BOARDIOC_FINALINIT _BOARDIOC(0x0002)
|
||||
#define BOARDIOC_POWEROFF _BOARDIOC(0x0003)
|
||||
#define BOARDIOC_RESET _BOARDIOC(0x0004)
|
||||
#define BOARDIOC_PM_CONTROL _BOARDIOC(0x0005)
|
||||
#define BOARDIOC_UNIQUEID _BOARDIOC(0x0006)
|
||||
#define BOARDIOC_MKRD _BOARDIOC(0x0007)
|
||||
#define BOARDIOC_ROMDISK _BOARDIOC(0x0008)
|
||||
#define BOARDIOC_APP_SYMTAB _BOARDIOC(0x0009)
|
||||
#define BOARDIOC_OS_SYMTAB _BOARDIOC(0x000a)
|
||||
#define BOARDIOC_BUILTINS _BOARDIOC(0x000b)
|
||||
#define BOARDIOC_USBDEV_CONTROL _BOARDIOC(0x000c)
|
||||
#define BOARDIOC_NX_START _BOARDIOC(0x000d)
|
||||
#define BOARDIOC_VNC_START _BOARDIOC(0x000e)
|
||||
#define BOARDIOC_NXTERM _BOARDIOC(0x000f)
|
||||
#define BOARDIOC_NXTERM_IOCTL _BOARDIOC(0x0010)
|
||||
#define BOARDIOC_TESTSET _BOARDIOC(0x0011)
|
||||
|
||||
/* If CONFIG_BOARDCTL_IOCTL=y, then board-specific commands will be support.
|
||||
* In this case, all commands not recognized by boardctl() will be forwarded
|
||||
* to the board-provided board_ioctl() function.
|
||||
*
|
||||
* User defined board commands may begin with this value:
|
||||
*/
|
||||
|
||||
#define BOARDIOC_USER _BOARDIOC(0x0012)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Structures used with IOCTL commands */
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
/* Arguments passed with the BOARDIOC_PM_CONTROL command */
|
||||
|
||||
enum boardioc_action_e
|
||||
{
|
||||
BOARDIOC_PM_ACTIVITY = 0,
|
||||
BOARDIOC_PM_STAY,
|
||||
BOARDIOC_PM_RELAX,
|
||||
BOARDIOC_PM_STAYCOUNT,
|
||||
BOARDIOC_PM_QUERYSTATE,
|
||||
BOARDIOC_PM_CHANGESTATE,
|
||||
BOARDIOC_PM_CHECKSTATE
|
||||
};
|
||||
|
||||
struct boardioc_pm_ctrl_s
|
||||
{
|
||||
uint32_t action;
|
||||
uint32_t domain;
|
||||
uint32_t state;
|
||||
uint32_t count;
|
||||
uint32_t priority;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BOARDCTL_MKRD
|
||||
/* Describes the RAM disk to be created */
|
||||
|
||||
struct boardioc_mkrd_s
|
||||
{
|
||||
uint8_t minor; /* Minor device number of the RAM disk. */
|
||||
uint32_t nsectors; /* The number of sectors in the RAM disk */
|
||||
uint16_t sectsize; /* The size of one sector in bytes */
|
||||
uint8_t rdflags; /* See RD_FLAGS_* definitions in include/nuttx/ramdisk.h */
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BOARDCTL_ROMDISK
|
||||
/* Describes the ROM disk image to be registered.
|
||||
*
|
||||
* The image points to a image of the file system in some read-only memory.
|
||||
* This image must conform to certain requirements: (1) it must be
|
||||
* accessible to the kernel code with no special address mapping, and (2)
|
||||
* it must be virtually contiguous.
|
||||
*/
|
||||
|
||||
struct boardioc_romdisk_s
|
||||
{
|
||||
uint8_t minor; /* Minor device number of the RAM disk. */
|
||||
uint32_t nsectors; /* The number of sectors in the RAM disk */
|
||||
uint16_t sectsize; /* The size of one sector in bytes */
|
||||
FAR const uint8_t *image;
|
||||
};
|
||||
#endif
|
||||
|
||||
/* In order to full describe a symbol table, a vector containing the address
|
||||
* of the symbol table and the number of elements in the symbol table is
|
||||
* required.
|
||||
*/
|
||||
|
||||
struct symtab_s; /* Forward reference */
|
||||
struct boardioc_symtab_s
|
||||
{
|
||||
FAR struct symtab_s *symtab;
|
||||
int nsymbols;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_BUILTIN
|
||||
/* Arguments passed with the BOARDIOC_BUILTIN command */
|
||||
|
||||
struct builtin_s; /* Forward reference */
|
||||
struct boardioc_builtin_s
|
||||
{
|
||||
FAR const struct builtin_s *builtins;
|
||||
int count;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BOARDCTL_USBDEVCTRL
|
||||
/* This structure provides the argument BOARDIOC_USBDEV_CONTROL and
|
||||
* describes which device should be controlled and what should be
|
||||
* done.
|
||||
*
|
||||
* enum boardioc_usbdev_identifier_e: Identifies the USB device class.
|
||||
* In the case of multiple instances of the USB device class, the
|
||||
* specific instance is identified by the 'inst' field of the structure.
|
||||
*
|
||||
* enum boardioc_usbdev_action_e: Identifies the action to perform on
|
||||
* the USB device class instance.
|
||||
*
|
||||
* struct boardioc_usbdev_ctrl_s:
|
||||
* - usbdev: A value from enum boardioc_usbdev_identifier_e that
|
||||
* identifies the USB device class.
|
||||
* - action: The action to be performed on the USB device class.
|
||||
* - instance: If there are multiple instances of the USB device
|
||||
* class, this identifies the particular instance. This is normally
|
||||
* zero but could be non-zero if there are multiple USB device ports
|
||||
* supported by the board. For CDC/ACM, this is the /dev/ttyACM minor
|
||||
* number; For other devices this would be a port number.
|
||||
* - handle: This value is returned by the BOARDIOC_USBDEV_CONNECT
|
||||
* action and must be provided to the BOARDIOC_USBDEV_DISCONNECT
|
||||
* action. It is not used with the BOARDIOC_USBDEV_INITIALIZE action.
|
||||
*/
|
||||
|
||||
enum boardioc_usbdev_identifier_e
|
||||
{
|
||||
BOARDIOC_USBDEV_NONE = 0 /* Not valid */
|
||||
#ifdef CONFIG_CDCACM
|
||||
, BOARDIOC_USBDEV_CDCACM /* CDC/ACM */
|
||||
#endif
|
||||
#ifdef CONFIG_PL2303
|
||||
, BOARDIOC_USBDEV_PL2303 /* PL2303 serial */
|
||||
#endif
|
||||
#ifdef CONFIG_USBMSC
|
||||
, BOARDIOC_USBDEV_MSC /* Mass storage class */
|
||||
#endif
|
||||
#ifdef CONFIG_USBDEV_COMPOSITE
|
||||
, BOARDIOC_USBDEV_COMPOSITE /* Composite device */
|
||||
#endif
|
||||
};
|
||||
|
||||
enum boardioc_usbdev_action_e
|
||||
{
|
||||
BOARDIOC_USBDEV_INITIALIZE = 0, /* Initialize USB device */
|
||||
BOARDIOC_USBDEV_CONNECT, /* Connect the USB device */
|
||||
BOARDIOC_USBDEV_DISCONNECT, /* Disconnect the USB device */
|
||||
};
|
||||
|
||||
struct boardioc_usbdev_ctrl_s
|
||||
{
|
||||
uint8_t usbdev; /* See enum boardioc_usbdev_identifier_e */
|
||||
uint8_t action; /* See enum boardioc_usbdev_action_e */
|
||||
uint8_t instance; /* Identifies the USB device class instance */
|
||||
uint8_t config; /* Configuration used with BOARDIOC_USBDEV_CONNECT */
|
||||
FAR void **handle; /* Connection handle */
|
||||
};
|
||||
#endif /* CONFIG_BOARDCTL_USBDEVCTRL */
|
||||
|
||||
#ifdef CONFIG_VNCSERVER
|
||||
/* Argument passed with the BOARDIOC_VNC_START command */
|
||||
|
||||
struct boardioc_vncstart_s
|
||||
{
|
||||
int display; /* Display number */
|
||||
NXHANDLE handle; /* Handle returned by nx_connect */
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NXTERM
|
||||
/* Arguments passed with the BOARDIOC_NXTERM command */
|
||||
|
||||
enum boardioc_termtype_e
|
||||
{
|
||||
BOARDIOC_XTERM_RAW = 0, /* Raw NX terminal window */
|
||||
BOARDIOC_XTERM_FRAMED, /* Framed NxTK terminal window */
|
||||
BOARDIOC_XTERM_TOOLBAR /* Toolbar of framed NxTK terminal window */
|
||||
};
|
||||
|
||||
struct boardioc_nxterm_create_s
|
||||
{
|
||||
NXTERM nxterm; /* Returned NXTERM handle */
|
||||
FAR void *hwnd; /* Window handle (NXWINDOW or NXTKWINDOW). */
|
||||
struct nxterm_window_s wndo; /* Describes the initial window: color, size, font */
|
||||
enum boardioc_termtype_e type; /* Terminal window type */
|
||||
uint8_t minor; /* Terminal device minor number, N, in
|
||||
* /dev/nxtermN. 0 <= N <= 255 */
|
||||
};
|
||||
|
||||
struct boardioc_nxterm_ioctl_s
|
||||
{
|
||||
int cmd; /* IOCTL command */
|
||||
uintptr_t arg; /* IOCTL argument */
|
||||
};
|
||||
#endif /* CONFIG_NXTERM */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: boardctl
|
||||
*
|
||||
* Description:
|
||||
* In a small embedded system, there will typically be a much greater
|
||||
* interaction between application and low-level board features. The
|
||||
* canonically correct to implement such interactions is by implementing a
|
||||
* character driver and performing the interactions via low level ioctl
|
||||
* calls. This, however, may not be practical in many cases and will lead
|
||||
* to "correct" but awkward implementations.
|
||||
*
|
||||
* boardctl() is non-standard OS interface to alleviate the problem.
|
||||
* It basically circumvents the normal device driver ioctl interlace and
|
||||
* allows the application to perform direct IOCTL-like calls to the
|
||||
* board-specific logic.
|
||||
* It is especially useful for setting up board operational and test
|
||||
* configurations.
|
||||
*
|
||||
* Input Parameters:
|
||||
* cmd - Identifies the board command to be executed
|
||||
* arg - The argument that accompanies the command. The nature of the
|
||||
* argument is determined by the specific command.
|
||||
*
|
||||
* Returned Value:
|
||||
* On success zero (OK) is returned; -1 (ERROR) is returned on failure
|
||||
* with the errno variable set to indicate the nature of the failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int boardctl(unsigned int cmd, uintptr_t arg);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_LIB_BOARDCTL */
|
||||
#endif /* __INCLUDE_SYS_BOARDCTL_H */
|
||||
@@ -0,0 +1,44 @@
|
||||
/****************************************************************************
|
||||
* include/sys/custom_file.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_SYS_CUSTOM_FILE_H
|
||||
#define __INCLUDE_SYS_CUSTOM_FILE_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/fs/fs.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
typedef struct file_struct __FILE;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#endif /* __INCLUDE_SYS_CUSTOM_FILE_H */
|
||||
@@ -0,0 +1,139 @@
|
||||
/****************************************************************************
|
||||
* include/sys/epoll.h
|
||||
*
|
||||
* Copyright (C) 2015 Anton D. Kachalov. All rights reserved.
|
||||
* Author: Anton D. Kachalov <mouse@mayc.ru>
|
||||
*
|
||||
* 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_SYS_EPOLL_H
|
||||
#define __INCLUDE_SYS_EPOLL_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <poll.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define EPOLL_CTL_ADD 1 /* Add a file descriptor to the interface. */
|
||||
#define EPOLL_CTL_DEL 2 /* Remove a file descriptor from the interface. */
|
||||
#define EPOLL_CTL_MOD 3 /* Change file descriptor epoll_event structure. */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
enum EPOLL_EVENTS
|
||||
{
|
||||
EPOLLIN = POLLIN,
|
||||
#define EPOLLIN EPOLLIN
|
||||
EPOLLPRI = POLLPRI,
|
||||
#define EPOLLPRI EPOLLPRI
|
||||
EPOLLOUT = POLLOUT,
|
||||
#define EPOLLOUT EPOLLOUT
|
||||
EPOLLRDNORM = POLLRDNORM,
|
||||
#define EPOLLRDNORM EPOLLRDNORM
|
||||
EPOLLRDBAND = POLLRDBAND,
|
||||
#define EPOLLRDBAND EPOLLRDBAND
|
||||
EPOLLWRNORM = POLLWRNORM,
|
||||
#define EPOLLWRNORM EPOLLWRNORM
|
||||
EPOLLWRBAND = POLLWRBAND,
|
||||
#define EPOLLWRBAND EPOLLWRBAND
|
||||
EPOLLERR = POLLERR,
|
||||
#define EPOLLERR EPOLLERR
|
||||
EPOLLHUP = POLLHUP,
|
||||
#define EPOLLHUP EPOLLHUP
|
||||
EPOLLRDHUP = 0x2000,
|
||||
#define EPOLLRDHUP EPOLLRDHUP
|
||||
EPOLLWAKEUP = 1u << 29,
|
||||
#define EPOLLWAKEUP EPOLLWAKEUP
|
||||
EPOLLONESHOT = 1u << 30,
|
||||
#define EPOLLONESHOT EPOLLONESHOT
|
||||
};
|
||||
|
||||
/* Flags to be passed to epoll_create1. */
|
||||
|
||||
enum
|
||||
{
|
||||
EPOLL_CLOEXEC = O_CLOEXEC
|
||||
#define EPOLL_CLOEXEC EPOLL_CLOEXEC
|
||||
};
|
||||
|
||||
typedef union poll_data
|
||||
{
|
||||
FAR void *ptr;
|
||||
int fd;
|
||||
uint32_t u32;
|
||||
} epoll_data_t;
|
||||
|
||||
struct epoll_event
|
||||
{
|
||||
uint32_t events;
|
||||
epoll_data_t data;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
int epoll_create(int size);
|
||||
int epoll_create1(int flags);
|
||||
int epoll_ctl(int epfd, int op, int fd, FAR struct epoll_event *ev);
|
||||
int epoll_wait(int epfd, FAR struct epoll_event *evs,
|
||||
int maxevents, int timeout);
|
||||
int epoll_pwait(int epfd, FAR struct epoll_event *evs,
|
||||
int maxevents, int timeout, FAR const sigset_t *sigmask);
|
||||
|
||||
void epoll_close(int epfd);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_SYS_EPOLL_H */
|
||||
@@ -0,0 +1,75 @@
|
||||
/****************************************************************************
|
||||
* include/sys/eventfd.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_SYS_EVENTFD_H
|
||||
#define __INCLUDE_SYS_EVENTFD_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define EFD_NONBLOCK O_NONBLOCK
|
||||
#define EFD_SEMAPHORE O_BINARY
|
||||
#define EFD_CLOEXEC O_CLOEXEC
|
||||
|
||||
/* Get device minor number */
|
||||
|
||||
#define EFD_FIOC_MINOR FIOC_MINOR
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
/* Type for event counter */
|
||||
|
||||
typedef uint32_t eventfd_t;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
int eventfd(unsigned int count, int flags);
|
||||
|
||||
int eventfd_read(int fd, FAR eventfd_t *value);
|
||||
int eventfd_write(int fd, eventfd_t value);
|
||||
|
||||
int eventfd_get_minor(int fd);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_SYS_EVENTFD_H */
|
||||
@@ -0,0 +1,31 @@
|
||||
/********************************************************************************
|
||||
* include/sys/file.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_SYS_FILE_H
|
||||
#define __INCLUDE_SYS_FILE_H
|
||||
|
||||
/********************************************************************************
|
||||
* Included Files
|
||||
********************************************************************************/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#endif /* __INCLUDE_SYS_FILE_H */
|
||||
@@ -0,0 +1,121 @@
|
||||
/****************************************************************************
|
||||
* include/sys/ioctl.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_SYS_IOCTL_H
|
||||
#define __INCLUDE_SYS_IOCTL_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
/* Get NuttX configuration and NuttX-specific IOCTL definitions */
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
|
||||
#ifdef CONFIG_NET
|
||||
/* Include network IOCTL definitions */
|
||||
|
||||
# include <nuttx/net/ioctl.h>
|
||||
|
||||
#ifdef CONFIG_NETDEV_WIRELESS_IOCTL
|
||||
/* Include wireless network IOCTL definitions */
|
||||
|
||||
# include <nuttx/wireless/wireless.h>
|
||||
#endif
|
||||
#endif /* CONFIG_NET */
|
||||
|
||||
#ifdef CONFIG_INPUT
|
||||
/* Include input driver IOCTL definitions */
|
||||
|
||||
# include <nuttx/input/ioctl.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DRIVERS_WIRELESS
|
||||
/* Include wireless character driver IOCTL definitions */
|
||||
|
||||
# include <nuttx/wireless/ioctl.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_WIRELESS_IEEE802154
|
||||
|
||||
/* Include ieee802.15.4 MAC IOCTL definitions */
|
||||
|
||||
# include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#endif /* CONFIG_WIRELESS_IEEE802154 */
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ioctl
|
||||
*
|
||||
* Description:
|
||||
* Perform device specific operations.
|
||||
*
|
||||
* ioctl() is a non-standard UNIX-like API
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd File/socket descriptor of device
|
||||
* req The ioctl command
|
||||
* arg The argument of the ioctl cmd, OR
|
||||
* ... A third argument of type unsigned long is still expected.
|
||||
*
|
||||
* Returned Value:
|
||||
* >=0 on success (positive non-zero values are cmd-specific)
|
||||
* -1 on failure with errno set properly:
|
||||
*
|
||||
* EBADF
|
||||
* 'fd' is not a valid descriptor.
|
||||
* EFAULT
|
||||
* 'arg' references an inaccessible memory area.
|
||||
* EINVAL
|
||||
* 'cmd' or 'arg' is not valid.
|
||||
* ENOTTY
|
||||
* 'fd' is not associated with a character special device.
|
||||
* ENOTTY
|
||||
* The specified request does not apply to the kind of object that the
|
||||
* descriptor 'fd' references.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ioctl(int fd, int req, ...);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_SYS_IOCTL_H */
|
||||
@@ -0,0 +1,98 @@
|
||||
/****************************************************************************
|
||||
* include/sys/ipc.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_SYS_IPC_H
|
||||
#define __INCLUDE_SYS_IPC_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Mode bits: The lower order 9-bit bits are the standard mode bits */
|
||||
|
||||
#define IPC_MODE 0x01ff /* Mode bit mask */
|
||||
#define IPC_CREAT (1 << 10) /* Create entry if key does not exist */
|
||||
#define IPC_EXCL (1 << 11) /* Fail if key exists */
|
||||
#define IPC_NOWAIT (1 << 12) /* Error if request must wait */
|
||||
|
||||
/* Keys: */
|
||||
|
||||
#define IPC_PRIVATE 0 /* Private key */
|
||||
|
||||
/* Control commands: */
|
||||
|
||||
#define IPC_RMID 0 /* Remove identifier */
|
||||
#define IPC_SET 1 /* Set options */
|
||||
#define IPC_STAT 2 /* Get options */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/* The ipc_perm structure is used by three mechanisms for XSI interprocess
|
||||
* communication (IPC): messages, semaphores, and shared memory. All use a
|
||||
* common structure type, ipc_perm, to pass information used in determining
|
||||
* permission to perform an IPC operation.
|
||||
*/
|
||||
|
||||
struct ipc_perm
|
||||
{
|
||||
#if 0 /* User and group IDs not yet supported by NuttX */
|
||||
uid_t uid; /* Owner's user ID */
|
||||
gid_t gid; /* Owner's group ID */
|
||||
uid_t cuid; /* Creator's user ID */
|
||||
gid_t cgid; /* Creator's group ID */
|
||||
#endif
|
||||
mode_t mode; /* Read/write permission */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
key_t ftok(FAR const char *path, int id);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_SYS_IPC_H */
|
||||
@@ -0,0 +1,177 @@
|
||||
/****************************************************************************
|
||||
* include/sys/mman.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_SYS_MMAN_H
|
||||
#define __INCLUDE_SYS_MMAN_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Protections are chosen from these bits, OR'd together. NuttX does not
|
||||
* yet support any of these, but are provided for source level compatibility
|
||||
*/
|
||||
|
||||
#define PROT_NONE 0x0 /* Page may not be accessed */
|
||||
#define PROT_READ (1 << 0) /* Bit 0: Page may be read */
|
||||
#define PROT_WRITE (1 << 1) /* Bit 1: Page may be written */
|
||||
#define PROT_EXEC (1 << 2) /* Bit 2: Page may be executed */
|
||||
|
||||
/* mmpa() flags bits. Only MAP_SHARED, MAP_PRIVATE, and MAP_FIXED are
|
||||
* specified by OpenGroup.org. The rest are unique to NuttX or are
|
||||
* definitions used by other systems.
|
||||
*/
|
||||
|
||||
/* Sharing types (most are not implemented). */
|
||||
|
||||
#define MAP_SHARED (1 << 0) /* Bit 0: Share this mapping */
|
||||
#define MAP_PRIVATE (1 << 1) /* Bit 1: Create a private copy-on-write mapping */
|
||||
#define MAP_TYPE (3 << 0) /* Mask for type of mapping */
|
||||
#define MAP_FIXED (1 << 2) /* Bit 2: Map to specified address exactly */
|
||||
#define MAP_FILE (1 << 3) /* Bit 3: The mapping is backed by a file */
|
||||
#define MAP_ANONYMOUS (1 << 4) /* Bit 4: The mapping is not backed by any file */
|
||||
#define MAP_ANON MAP_ANONYMOUS /* Alias */
|
||||
|
||||
/* These are Linux-specific (none are implemented). */
|
||||
|
||||
#define MAP_GROWSDOWN (1 << 5) /* Bit 5: Used to stack allocations */
|
||||
#define MAP_DENYWRITE (1 << 6) /* Bit 6: Do not permit writes to file */
|
||||
#define MAP_EXECUTABLE (1 << 7) /* Bit 7: Mark it as an executable */
|
||||
#define MAP_LOCKED (1 << 8) /* Bit 8: Lock pages mapped into memory */
|
||||
#define MAP_NORESERVE (1 << 9) /* Bit 9: Do not reserve swap space for this mapping */
|
||||
#define MAP_POPULATE (1 << 10) /* Bit 10: populate (prefault) page tables */
|
||||
#define MAP_NONBLOCK (1 << 11) /* Bit 11: Do not block on IO */
|
||||
|
||||
/* Failure return */
|
||||
|
||||
#define MAP_FAILED ((void*)-1)
|
||||
|
||||
/* The following flags are used with msync() */
|
||||
|
||||
#define MS_ASYNC 0x01 /* Perform asynchronous writes */
|
||||
#define MS_SYNC 0x02 /* Perform synchronous writes */
|
||||
#define MS_INVALIDATE 0x04 /* Invalidate mapping */
|
||||
|
||||
/* The following flags are used with mlockall() */
|
||||
|
||||
#define MCL_CURRENT 0x01 /* Lock currently mapped pages */
|
||||
#define MCL_FUTURE 0x02 /* Lock pages that become mapped */
|
||||
|
||||
/* If the Advisory Information and either the Memory Mapped Files or Shared
|
||||
* Memory Objects options are supported, values for advice used by
|
||||
* posix_madvise() are defined as follows:
|
||||
*
|
||||
* POSIX_MADV_NORMAL
|
||||
* The application has no advice to give on its behavior with respect to
|
||||
* the specified range. It is the default characteristic if no advice is
|
||||
* given for a range of memory.
|
||||
* POSIX_MADV_SEQUENTIAL
|
||||
* The application expects to access the specified range sequentially from
|
||||
* lower addresses to higher addresses.
|
||||
* POSIX_MADV_RANDOM
|
||||
* The application expects to access the specified range in a random order.
|
||||
* POSIX_MADV_WILLNEED
|
||||
* The application expects to access the specified range in the near
|
||||
* future.
|
||||
* POSIX_MADV_DONTNEED
|
||||
* The application expects that it will not access the specified range in
|
||||
* the near future.
|
||||
*/
|
||||
|
||||
#define POSIX_MADV_NORMAL (0)
|
||||
#define POSIX_MADV_SEQUENTIAL (1)
|
||||
#define POSIX_MADV_RANDOM (2)
|
||||
#define POSIX_MADV_WILLNEED (3)
|
||||
#define POSIX_MADV_DONTNEED (4)
|
||||
|
||||
/* The following flags are defined for posix_typed_mem_open():
|
||||
*
|
||||
* POSIX_TYPED_MEM_ALLOCATE
|
||||
* Allocate on mmap().
|
||||
* POSIX_TYPED_MEM_ALLOCATE_CONTIG
|
||||
* Allocate contiguously on mmap().
|
||||
* POSIX_TYPED_MEM_MAP_ALLOCATABLE
|
||||
* Map on mmap(), without affecting allocatability.
|
||||
*/
|
||||
|
||||
#define POSIX_TYPED_MEM_ALLOCATE (0)
|
||||
#define POSIX_TYPED_MEM_ALLOCATE_CONTIG (1)
|
||||
#define POSIX_TYPED_MEM_MAP_ALLOCATABLE (2)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
struct posix_typed_mem_info
|
||||
{
|
||||
size_t posix_tmi_length; /* Maximum length which may be allocated from a
|
||||
* typed memory object */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
int mlock(FAR const void *addr, size_t len);
|
||||
int mlockall(int flags);
|
||||
FAR void *mmap(FAR void *start, size_t length, int prot, int flags, int fd,
|
||||
off_t offset);
|
||||
int mprotect(FAR void *addr, size_t len, int prot);
|
||||
int msync(FAR void *addr, size_t len, int flags);
|
||||
int munlock(FAR const void *addr, size_t len);
|
||||
int munlockall(void);
|
||||
|
||||
int munmap(FAR void *start, size_t length);
|
||||
|
||||
int posix_madvise(FAR void *addr, size_t len, int advice);
|
||||
int posix_mem_offset(FAR const void *addr, size_t len, FAR off_t *off,
|
||||
FAR size_t *contig_len, FAR int *fildes);
|
||||
int posix_typed_mem_get_info(int fildes,
|
||||
FAR struct posix_typed_mem_info *info);
|
||||
int posix_typed_mem_open(FAR const char *name, int oflag, int tflag);
|
||||
int shm_open(FAR const char *name, int oflag, mode_t mode);
|
||||
int shm_unlink(FAR const char *name);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_SYS_MMAN_H */
|
||||
@@ -0,0 +1,100 @@
|
||||
/****************************************************************************
|
||||
* include/sys/mount.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_SYS_MOUNT_H
|
||||
#define __INCLUDE_SYS_MOUNT_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/compiler.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Mount flags */
|
||||
|
||||
#define MS_RDONLY 1 /* Mount file system read-only */
|
||||
|
||||
/* Un-mount flags
|
||||
*
|
||||
* These flags control the behavior of umount2() when there are open file
|
||||
* references through the mountpoint. umount2() with no flag bits set is
|
||||
* equivalent to umount(), i.e., the umount() will fail with EBUSY if there
|
||||
* are open references on the file.
|
||||
*
|
||||
* MNT_FORCE - Force unmount even if busy. This can cause data loss.
|
||||
* MNT_DETACH - Perform a lazy unmount: make the mount point unavailable
|
||||
* for new accesses, and actually perform the unmount when the mount
|
||||
* point ceases to be busy.
|
||||
* MNT_EXPIRE - Mark the mount point as expired. If a mount point is not
|
||||
* currently in use, then an initial call to umount2() with this flag
|
||||
* fails with the error EAGAIN, but marks the mount point as expired. The
|
||||
* mount point remains expired as long as it isn't accessed by any
|
||||
* process. A second umount2() call specifying MNT_EXPIRE unmounts an
|
||||
* expired mount point. This flag cannot be specified with either
|
||||
* MNT_FORCE or MNT_DETACH.
|
||||
* UMOUNT_NOFOLLOW (- Don't dereference target if it is a symbolic link.
|
||||
* For Linux, this flag allows security problems to be avoided in
|
||||
* set-user-ID-root programs that allow unprivileged users to unmount
|
||||
* file systems. For NuttX, it is provided only for compatibility
|
||||
*
|
||||
* Not all options are supported on all file systems.
|
||||
*/
|
||||
|
||||
#define MNT_FORCE (1 << 0)
|
||||
#define MNT_DETACH (1 << 1)
|
||||
#define MNT_EXPIRE (1 << 2)
|
||||
#define UMOUNT_NOFOLLOW (0)
|
||||
|
||||
/* umount() is equivalent to umount2() with flags = 0 */
|
||||
|
||||
#define umount(t) umount2(t,0)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
int mount(FAR const char *source, FAR const char *target,
|
||||
FAR const char *filesystemtype, unsigned long mountflags,
|
||||
FAR const void *data);
|
||||
int umount2(FAR const char *target, unsigned int flags);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_SYS_MOUNT_H */
|
||||
@@ -0,0 +1,40 @@
|
||||
/****************************************************************************
|
||||
* include/sys/param.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_SYS_PARAM_H
|
||||
#define __INCLUDE_SYS_PARAM_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#endif /* __INCLUDE_SYS_PARAM_H */
|
||||
@@ -0,0 +1,151 @@
|
||||
/****************************************************************************
|
||||
* include/sys/poll.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_SYS_POLL_H
|
||||
#define __INCLUDE_SYS_POLL_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/compiler.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <signal.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Poll event definitions:
|
||||
*
|
||||
* POLLIN
|
||||
* Data other than high-priority data may be read without blocking.
|
||||
* POLLRDNORM
|
||||
* Normal data may be read without blocking.
|
||||
* POLLRDBAND
|
||||
* Priority data may be read without blocking.
|
||||
* POLLPRI
|
||||
* High priority data may be read without blocking.
|
||||
*
|
||||
* POLLOUT
|
||||
* Normal data may be written without blocking.
|
||||
* POLLWRNORM
|
||||
* Equivalent to POLLOUT.
|
||||
* POLLWRBAND
|
||||
* Priority data may be written.
|
||||
*
|
||||
* POLLERR
|
||||
* An error has occurred (revents only).
|
||||
* POLLHUP
|
||||
* Device has been disconnected (revents only).
|
||||
* POLLNVAL
|
||||
* Invalid fd member (revents only).
|
||||
*/
|
||||
|
||||
#define POLLIN (0x01) /* NuttX does not make priority distinctions */
|
||||
#define POLLRDNORM (0x01)
|
||||
#define POLLRDBAND (0x01)
|
||||
|
||||
#define POLLPRI (0x02)
|
||||
|
||||
#define POLLOUT (0x04) /* NuttX does not make priority distinctions */
|
||||
#define POLLWRNORM (0x04)
|
||||
#define POLLWRBAND (0x04)
|
||||
|
||||
#define POLLERR (0x08)
|
||||
#define POLLHUP (0x10)
|
||||
#define POLLNVAL (0x20)
|
||||
|
||||
#define POLLFD (0x00)
|
||||
#define POLLFILE (0x40)
|
||||
#define POLLSOCK (0x80)
|
||||
#define POLLMASK (0xC0)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* The number of poll descriptors (required by poll() specification */
|
||||
|
||||
typedef unsigned int nfds_t;
|
||||
|
||||
/* In the standard poll() definition, the size of the event set is 'short'.
|
||||
* Here we pick the smallest storage element that will contain all of the
|
||||
* poll events.
|
||||
*/
|
||||
|
||||
typedef uint8_t pollevent_t;
|
||||
|
||||
/* This is the NuttX variant of the standard pollfd structure. The poll()
|
||||
* interfaces receive a variable length array of such structures.
|
||||
*
|
||||
* REVISIT: In a multi-threaded environment, one use case might be to share
|
||||
* a single, array of struct pollfd in poll calls on different threads.
|
||||
* That use case is not supportable with this variant due way in which the
|
||||
* non-standard internal fields are used in the implementation of poll().
|
||||
*/
|
||||
|
||||
struct pollfd
|
||||
{
|
||||
/* Standard fields */
|
||||
|
||||
int fd; /* The descriptor being polled */
|
||||
pollevent_t events; /* The input event flags */
|
||||
pollevent_t revents; /* The output event flags */
|
||||
|
||||
/* Non-standard fields used internally by NuttX. */
|
||||
|
||||
FAR void *ptr; /* The psock or file being polled */
|
||||
FAR sem_t *sem; /* Pointer to semaphore used to post output event */
|
||||
FAR void *priv; /* For use by drivers */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
int poll(FAR struct pollfd *fds, nfds_t nfds, int timeout);
|
||||
|
||||
int ppoll(FAR struct pollfd *fds, nfds_t nfds,
|
||||
FAR const struct timespec *timeout_ts,
|
||||
FAR const sigset_t *sigmask);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_SYS_POLL_H */
|
||||
@@ -0,0 +1,121 @@
|
||||
/****************************************************************************
|
||||
* include/sys/prctl.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_SYS_PRCTL_H
|
||||
#define __INCLUDE_SYS_PRCTL_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Supported prctl() commands.
|
||||
*
|
||||
* PR_SET_NAME
|
||||
* Set the name of the calling thread, using the value in the location
|
||||
* pointed to by (char *) arg2. The name can be up to
|
||||
* CONFIG_TASK_NAME_SIZE long, including the terminating null byte.
|
||||
* (If the length of the string, including the terminating null byte,
|
||||
* exceeds CONFIG_TASK_NAME_SIZE bytes, the string is silently truncated.)
|
||||
* As an example:
|
||||
*
|
||||
* prctl(PR_SET_NAME, "MyName");
|
||||
*
|
||||
* PR_GET_NAME
|
||||
* Return the name of the calling thread, in the buffer pointed to by
|
||||
* (char *) arg2. The buffer should allow space for up to
|
||||
* CONFIG_TASK_NAME_SIZE bytes; the returned string will be
|
||||
* null-terminated. As an example:
|
||||
*
|
||||
* char myname[CONFIG_TASK_NAME_SIZE];
|
||||
* prctl(PR_GET_NAME, myname);
|
||||
*
|
||||
* PR_SET_NAME_EXT
|
||||
* Set the task (or thread) name for the thread whose ID is in required
|
||||
* arg2 (int), using the value in the location pointed to by required arg1
|
||||
* (char*). The name can be up to CONFIG_TASK_NAME_SIZE long (including
|
||||
* any null termination). The thread ID of 0 will set the name of the
|
||||
* calling thread. As an example:
|
||||
*
|
||||
* prctl(PR_SET_NAME_EXT, "MyName", pid);
|
||||
*
|
||||
* PR_GET_NAME_EXT
|
||||
* Return the task (or thread) name for the for the thread whose ID is
|
||||
* optional arg2 (int), in the buffer pointed to by optional arg1
|
||||
* (char *). The buffer must be CONFIG_TASK_NAME_SIZE long (including
|
||||
* any null termination). As an example:
|
||||
*
|
||||
* char myname[CONFIG_TASK_NAME_SIZE];
|
||||
* prctl(PR_GET_NAME_EXT, myname, pid);
|
||||
*/
|
||||
|
||||
#define PR_SET_NAME 1
|
||||
#define PR_GET_NAME 2
|
||||
#define PR_SET_NAME_EXT 3
|
||||
#define PR_GET_NAME_EXT 4
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: prctl
|
||||
*
|
||||
* Description:
|
||||
* prctl() is called with a first argument describing what to do (with
|
||||
* values PR_* defined above) and with additional arguments depending on
|
||||
* the specific command.
|
||||
*
|
||||
* Returned Value:
|
||||
* The returned value may depend on the specific command. For PR_SET_NAME
|
||||
* and PR_GET_NAME, the returned value of 0 indicates successful operation.
|
||||
* On any failure, -1 is retruend and the errno value is set appropriately.
|
||||
*
|
||||
* EINVAL The value of 'option' is not recognized.
|
||||
* EFAULT optional arg1 is not a valid address.
|
||||
* ESRCH No task/thread can be found corresponding to that specified
|
||||
* by optional arg1.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int prctl(int option, ...);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_SYS_PRCTL_H */
|
||||
@@ -0,0 +1,123 @@
|
||||
/****************************************************************************
|
||||
* include/sys/resource.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_SYS_RESOURCE_H
|
||||
#define __INCLUDE_SYS_RESOURCE_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Possible values of the 'which' argument of getpriority() and
|
||||
* setpriority()
|
||||
*/
|
||||
|
||||
#define PRIO_PROCESS 1 /* 'who' argument is a process ID */
|
||||
#define PRIO_PGRP 2 /* 'who' argument is a process group ID */
|
||||
#define PRIO_USER 3 /* 'who' argument is a user ID */
|
||||
|
||||
/* Possible values of the 'who' parameter of getrusage(): */
|
||||
|
||||
#define RUSAGE_SELF 0 /* Returns information about the current
|
||||
* process */
|
||||
#define RUSAGE_CHILDREN 1 /* Returns information about children of
|
||||
* the current process */
|
||||
|
||||
/* Possible values for the resource argument of getrlimit() and setrlimit() */
|
||||
|
||||
#define RLIMIT_CORE 1 /* Limit on size of core dump file */
|
||||
#define RLIMIT_CPU 2 /* Limit on CPU time per process. */
|
||||
#define RLIMIT_DATA 3 /* Limit on data segment size */
|
||||
#define RLIMIT_FSIZE 4 /* Limit on file size */
|
||||
#define RLIMIT_NOFILE 5 /* Limit on number of open files */
|
||||
#define RLIMIT_STACK 6 /* Limit on stack size */
|
||||
#define RLIMIT_AS 7 /* Limit on address space size */
|
||||
|
||||
/* The following symbolic constants are defined. Each is a value of type
|
||||
* rlim_t.
|
||||
*
|
||||
* On implementations where all resource limits are representable in an
|
||||
* object of type rlim_t, RLIM_SAVED_MAX and RLIM_SAVED_CUR need not be
|
||||
* distinct from RLIM_INFINITY.
|
||||
*/
|
||||
|
||||
#define RLIM_INFINITY UINT32_MAX /* No limit */
|
||||
#define RLIM_SAVED_MAX UINT32_MAX /* Unrepresentable saved hard limit */
|
||||
#define RLIM_SAVED_CUR UINT32_MAX /* Unrepresentable saved soft limit */
|
||||
|
||||
/****************************************************************************
|
||||
* Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* All resource limits are represented with this type.
|
||||
* It must be an unsigned integral type.
|
||||
*/
|
||||
|
||||
typedef uint32_t rlim_t;
|
||||
|
||||
/* Minimal, compliant rlimit structure */
|
||||
|
||||
struct rlimit
|
||||
{
|
||||
rlim_t rlim_cur; /* The current (soft) limit */
|
||||
rlim_t rlim_max; /* The hard limit */
|
||||
};
|
||||
|
||||
/* Minimal, compliant rusage structure */
|
||||
|
||||
struct rusage
|
||||
{
|
||||
struct timeval ru_utime; /* User time used */
|
||||
struct timeval ru_stime; /* System time used */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
int getpriority(int which, id_t who);
|
||||
int getrlimit(int resource, FAR struct rlimit *rlp);
|
||||
int getrusage(int who, FAR struct rusage *r_usage);
|
||||
int setpriority(int which, id_t who, int value);
|
||||
int setrlimit(int resource, FAR const struct rlimit *rlp);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_SYS_RESOURCE_H */
|
||||
@@ -0,0 +1,119 @@
|
||||
/****************************************************************************
|
||||
* include/sys/select.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_SYS_SELECT_H
|
||||
#define __INCLUDE_SYS_SELECT_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Get the total number of descriptors that we will have to support */
|
||||
|
||||
#define FD_SETSIZE 256
|
||||
|
||||
/* We will use a 32-bit bitsets to represent the set of descriptors. How
|
||||
* many uint32_t's do we need to span all descriptors?
|
||||
*/
|
||||
|
||||
#if FD_SETSIZE <= 32
|
||||
# define __SELECT_NUINT32 1
|
||||
#elif FD_SETSIZE <= 64
|
||||
# define __SELECT_NUINT32 2
|
||||
#elif FD_SETSIZE <= 96
|
||||
# define __SELECT_NUINT32 3
|
||||
#elif FD_SETSIZE <= 128
|
||||
# define __SELECT_NUINT32 4
|
||||
#elif FD_SETSIZE <= 160
|
||||
# define __SELECT_NUINT32 5
|
||||
#elif FD_SETSIZE <= 192
|
||||
# define __SELECT_NUINT32 6
|
||||
#elif FD_SETSIZE <= 224
|
||||
# define __SELECT_NUINT32 7
|
||||
#elif FD_SETSIZE <= 256
|
||||
# define __SELECT_NUINT32 8
|
||||
#else
|
||||
# warning "Larger fd_set needed"
|
||||
#endif
|
||||
|
||||
/* These macros map a file descriptor to an index and bit number */
|
||||
|
||||
#define _FD_NDX(fd) ((fd) >> 5)
|
||||
#define _FD_BIT(fd) ((fd) & 0x1f)
|
||||
|
||||
/* Standard helper macros */
|
||||
|
||||
#define FD_CLR(fd,set) \
|
||||
((((fd_set*)(set))->arr)[_FD_NDX(fd)] &= ~(1 << _FD_BIT(fd)))
|
||||
#define FD_SET(fd,set) \
|
||||
((((fd_set*)(set))->arr)[_FD_NDX(fd)] |= (1 << _FD_BIT(fd)))
|
||||
#define FD_ISSET(fd,set) \
|
||||
(((((fd_set*)(set))->arr)[_FD_NDX(fd)] & (1 << _FD_BIT(fd))) != 0)
|
||||
#define FD_ZERO(set) \
|
||||
memset((set), 0, sizeof(fd_set))
|
||||
|
||||
/****************************************************************************
|
||||
* Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
struct fd_set_s
|
||||
{
|
||||
uint32_t arr[__SELECT_NUINT32];
|
||||
};
|
||||
|
||||
typedef struct fd_set_s fd_set;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
struct timeval;
|
||||
int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds,
|
||||
FAR fd_set *exceptfds, FAR struct timeval *timeout);
|
||||
|
||||
int pselect(int nfds, FAR fd_set *readfds, FAR fd_set *writefds,
|
||||
FAR fd_set *exceptfds, FAR const struct timespec *timeout,
|
||||
FAR const sigset_t *sigmask);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_SYS_SELECT_H */
|
||||
@@ -0,0 +1,110 @@
|
||||
/****************************************************************************
|
||||
* include/sys/sendfile.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_SYS_SENDFILE_H
|
||||
#define __INCLUDE_SYS_SENDFILE_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
#ifndef CONFIG_LIB_SENDFILE_BUFSIZE
|
||||
# define CONFIG_LIB_SENDFILE_BUFSIZE 512
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sendfile
|
||||
*
|
||||
* Description:
|
||||
* sendfile() copies data between one file descriptor and another.
|
||||
* sendfile() basically just wraps a sequence of reads() and writes()
|
||||
* to perform a copy. It serves a purpose in systems where there is
|
||||
* a penalty for copies to between user and kernel space, but really
|
||||
* nothing in NuttX but provide some Linux compatible (and adding
|
||||
* another 'almost standard' interface).
|
||||
*
|
||||
* NOTE: This interface is *not* specified in POSIX.1-2001, or other
|
||||
* standards. The implementation here is very similar to the Linux
|
||||
* sendfile interface. Other UNIX systems implement sendfile() with
|
||||
* different semantics and prototypes. sendfile() should not be used
|
||||
* in portable programs.
|
||||
*
|
||||
* Input Parameters:
|
||||
* infd - A file (or socket) descriptor opened for reading
|
||||
* outfd - A descriptor opened for writing.
|
||||
* offset - If 'offset' is not NULL, then it points to a variable
|
||||
* holding the file offset from which sendfile() will start
|
||||
* reading data from 'infd'. When sendfile() returns, this
|
||||
* variable will be set to the offset of the byte following
|
||||
* the last byte that was read. If 'offset' is not NULL,
|
||||
* then sendfile() does not modify the current file offset of
|
||||
* 'infd'; otherwise the current file offset is adjusted to
|
||||
* reflect the number of bytes read from 'infd.'
|
||||
*
|
||||
* If 'offset' is NULL, then data will be read from 'infd'
|
||||
* starting at the current file offset, and the file offset
|
||||
* will be updated by the call.
|
||||
* count - The number of bytes to copy between the file descriptors.
|
||||
*
|
||||
* Returned Value:
|
||||
* If the transfer was successful, the number of bytes written to outfd is
|
||||
* returned. On error, -1 is returned, and errno is set appropriately.
|
||||
* There error values are those returned by read() or write() plus:
|
||||
*
|
||||
* EINVAL - Bad input parameters.
|
||||
* ENOMEM - Could not allocated an I/O buffer
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
ssize_t sendfile(int outfd, int infd, FAR off_t *offset, size_t count);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_SYS_SENDFILE_H */
|
||||
@@ -0,0 +1,100 @@
|
||||
/****************************************************************************
|
||||
* include/sys/shm.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_SYS_SHM_H
|
||||
#define __INCLUDE_SYS_SHM_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <time.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Definitions required by POSIX */
|
||||
|
||||
#define SHM_RDONLY 0x01 /* Attach read-only (else read-write) */
|
||||
#define SHM_RND 0x02 /* Round attach address to SHMLBA */
|
||||
|
||||
/* Segment low boundary address multiple */
|
||||
|
||||
#ifdef CONFIG_SHM_SHMLBA
|
||||
# define SHMLBA CONFIG_SHM_SHMLBA
|
||||
#else
|
||||
# define SHMLBA 0x0
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Unsigned integer used for the number of current attaches that must be
|
||||
* able to store values at least as large as a type unsigned short.
|
||||
*/
|
||||
|
||||
typedef unsigned short shmatt_t;
|
||||
|
||||
struct shmid_ds
|
||||
{
|
||||
struct ipc_perm shm_perm; /* Operation permission structure */
|
||||
size_t shm_segsz; /* Size of segment in bytes */
|
||||
pid_t shm_lpid; /* Process ID of last shared memory operation */
|
||||
pid_t shm_cpid; /* Process ID of creator */
|
||||
shmatt_t shm_nattch; /* Number of current attaches */
|
||||
time_t shm_atime; /* Time of last shmat() */
|
||||
time_t shm_dtime; /* Time of last shmdt() */
|
||||
time_t shm_ctime; /* Time of last change by shmctl() */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
FAR void *shmat(int shmid, FAR const void *shmaddr, int shmflg);
|
||||
int shmctl(int shmid, int cmd, FAR struct shmid_ds *buf);
|
||||
int shmdt(FAR const void *shmaddr);
|
||||
int shmget(key_t key, size_t size, int shmflg);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_SYS_SHM_H */
|
||||
@@ -0,0 +1,409 @@
|
||||
/****************************************************************************
|
||||
* include/sys/socket.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_SYS_SOCKET_H
|
||||
#define __INCLUDE_SYS_SOCKET_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* The socket()domain parameter specifies a communication domain; this
|
||||
* selects the protocol family which will be used for communication.
|
||||
*/
|
||||
|
||||
/* Supported Protocol Families */
|
||||
|
||||
#define PF_UNSPEC 0 /* Protocol family unspecified */
|
||||
#define PF_UNIX 1 /* Local communication */
|
||||
#define PF_LOCAL 1 /* Local communication */
|
||||
#define PF_INET 2 /* IPv4 Internet protocols */
|
||||
#define PF_INET6 10 /* IPv6 Internet protocols */
|
||||
#define PF_NETLINK 16 /* Netlink IPC socket */
|
||||
#define PF_ROUTE PF_NETLINK /* 4.4BSD Compatibility*/
|
||||
#define PF_PACKET 17 /* Low level packet interface */
|
||||
#define PF_CAN 29 /* Controller Area Network (SocketCAN) */
|
||||
#define PF_BLUETOOTH 31 /* Bluetooth sockets */
|
||||
#define PF_IEEE802154 36 /* Low level IEEE 802.15.4 radio frame interface */
|
||||
#define PF_PKTRADIO 64 /* Low level packet radio interface */
|
||||
#define PF_RPMSG 65 /* Remote core communication */
|
||||
|
||||
/* Supported Address Families. Opengroup.org requires only AF_UNSPEC,
|
||||
* AF_UNIX, AF_INET and AF_INET6.
|
||||
*/
|
||||
|
||||
#define AF_UNSPEC PF_UNSPEC
|
||||
#define AF_UNIX PF_UNIX
|
||||
#define AF_LOCAL PF_LOCAL
|
||||
#define AF_INET PF_INET
|
||||
#define AF_INET6 PF_INET6
|
||||
#define AF_NETLINK PF_NETLINK
|
||||
#define AF_ROUTE PF_ROUTE
|
||||
#define AF_PACKET PF_PACKET
|
||||
#define AF_CAN PF_CAN
|
||||
#define AF_BLUETOOTH PF_BLUETOOTH
|
||||
#define AF_IEEE802154 PF_IEEE802154
|
||||
#define AF_PKTRADIO PF_PKTRADIO
|
||||
#define AF_RPMSG PF_RPMSG
|
||||
|
||||
/* The socket created by socket() has the indicated type, which specifies
|
||||
* the communication semantics.
|
||||
*/
|
||||
|
||||
#define SOCK_UNSPEC 0 /* Unspecified socket type */
|
||||
#define SOCK_STREAM 1 /* Provides sequenced, reliable, two-way,
|
||||
* connection-based byte streams. An out-of-band data
|
||||
* transmission mechanism may be supported.
|
||||
*/
|
||||
#define SOCK_DGRAM 2 /* Supports datagrams (connectionless, unreliable
|
||||
* messages of a fixed maximum length).
|
||||
*/
|
||||
#define SOCK_RAW 3 /* Provides raw network protocol access. */
|
||||
#define SOCK_RDM 4 /* Provides a reliable datagram layer that does not
|
||||
* guarantee ordering.
|
||||
*/
|
||||
#define SOCK_SEQPACKET 5 /* Provides a sequenced, reliable, two-way
|
||||
* connection-based data transmission path for
|
||||
* datagrams of fixed maximum length; a consumer is
|
||||
* required to read an entire packet with each read
|
||||
* system call.
|
||||
*/
|
||||
#define SOCK_PACKET 10 /* Obsolete and should not be used in new programs */
|
||||
|
||||
#define SOCK_CLOEXEC 02000000 /* Atomically set close-on-exec flag for the new
|
||||
* descriptor(s).
|
||||
*/
|
||||
#define SOCK_NONBLOCK 00004000 /* Atomically mark descriptor(s) as non-blocking. */
|
||||
|
||||
#define SOCK_MAX (SOCK_PACKET + 1)
|
||||
#define SOCK_TYPE_MASK 0xf /* Mask which covers at least up to SOCK_MASK-1.
|
||||
* The remaining bits are used as flags.
|
||||
*/
|
||||
|
||||
/* Bits in the FLAGS argument to `send', `recv', et al. These are the bits
|
||||
* recognized by Linux, not all are supported by NuttX.
|
||||
*/
|
||||
|
||||
#define MSG_OOB 0x0001 /* Process out-of-band data. */
|
||||
#define MSG_PEEK 0x0002 /* Peek at incoming messages. */
|
||||
#define MSG_DONTROUTE 0x0004 /* Don't use local routing. */
|
||||
#define MSG_CTRUNC 0x0008 /* Control data lost before delivery. */
|
||||
#define MSG_PROXY 0x0010 /* Supply or ask second address. */
|
||||
#define MSG_TRUNC 0x0020
|
||||
#define MSG_DONTWAIT 0x0040 /* Enable nonblocking IO. */
|
||||
#define MSG_EOR 0x0080 /* End of record. */
|
||||
#define MSG_WAITALL 0x0100 /* Wait for a full request. */
|
||||
#define MSG_FIN 0x0200
|
||||
#define MSG_SYN 0x0400
|
||||
#define MSG_CONFIRM 0x0800 /* Confirm path validity. */
|
||||
#define MSG_RST 0x1000
|
||||
#define MSG_ERRQUEUE 0x2000 /* Fetch message from error queue. */
|
||||
#define MSG_NOSIGNAL 0x4000 /* Do not generate SIGPIPE. */
|
||||
#define MSG_MORE 0x8000 /* Sender will send more. */
|
||||
|
||||
/* Protocol levels supported by get/setsockopt(): */
|
||||
|
||||
#define SOL_SOCKET 1 /* Only socket-level options supported */
|
||||
|
||||
/* Socket-level options */
|
||||
|
||||
#define SO_ACCEPTCONN 0 /* Reports whether socket listening is enabled
|
||||
* (get only).
|
||||
* arg: pointer to integer containing a boolean
|
||||
* value
|
||||
*/
|
||||
#define SO_BROADCAST 1 /* Permits sending of broadcast messages (get/set).
|
||||
* arg: pointer to integer containing a boolean
|
||||
* value
|
||||
*/
|
||||
#define SO_DEBUG 2 /* Enables recording of debugging information
|
||||
* (get/set).
|
||||
* arg: pointer to integer containing a boolean
|
||||
* value
|
||||
*/
|
||||
#define SO_DONTROUTE 3 /* Requests that outgoing messages bypass standard
|
||||
* routing (get/set)
|
||||
* arg: pointer to integer containing a boolean
|
||||
* value
|
||||
*/
|
||||
#define SO_ERROR 4 /* Reports and clears error status (get only).
|
||||
* arg: returns an integer value
|
||||
*/
|
||||
#define SO_KEEPALIVE 5 /* Keeps connections active by enabling the periodic
|
||||
* transmission of messages (get/set).
|
||||
* arg: pointer to integer containing a boolean int
|
||||
* value
|
||||
*/
|
||||
#define SO_LINGER 6 /* Lingers on a close() if data is present (get/set)
|
||||
* arg: struct linger
|
||||
*/
|
||||
#define SO_OOBINLINE 7 /* Leaves received out-of-band data (data marked
|
||||
* urgent) inline
|
||||
* (get/set) arg: pointer to integer containing a
|
||||
* boolean value
|
||||
*/
|
||||
#define SO_RCVBUF 8 /* Sets receive buffer size.
|
||||
* arg: integer value (get/set).
|
||||
*/
|
||||
#define SO_RCVLOWAT 9 /* Sets the minimum number of bytes to process for
|
||||
* socket input (get/set).
|
||||
* arg: integer value
|
||||
*/
|
||||
#define SO_RCVTIMEO 10 /* Sets the timeout value that specifies the maximum
|
||||
* amount of time an input function waits until it
|
||||
* completes (get/set).
|
||||
* arg: struct timeval
|
||||
*/
|
||||
#define SO_REUSEADDR 11 /* Allow reuse of local addresses (get/set)
|
||||
* arg: pointer to integer containing a boolean
|
||||
* value
|
||||
*/
|
||||
#define SO_SNDBUF 12 /* Sets send buffer size (get/set).
|
||||
* arg: integer value
|
||||
*/
|
||||
#define SO_SNDLOWAT 13 /* Sets the minimum number of bytes to process for
|
||||
* socket output (get/set).
|
||||
* arg: integer value
|
||||
*/
|
||||
#define SO_SNDTIMEO 14 /* Sets the timeout value specifying the amount of
|
||||
* time that an output function blocks because flow
|
||||
* control prevents data from being sent(get/set).
|
||||
* arg: struct timeval
|
||||
*/
|
||||
#define SO_TYPE 15 /* Reports the socket type (get only).
|
||||
* return: int
|
||||
*/
|
||||
#define SO_TIMESTAMP 16 /* Generates a timestamp for each incoming packet
|
||||
* arg: integer value
|
||||
*/
|
||||
|
||||
/* The options are unsupported but included for compatibility
|
||||
* and portability
|
||||
*/
|
||||
#define SO_SNDBUFFORCE 32
|
||||
#define SO_RCVBUFFORCE 33
|
||||
#define SO_RXQ_OVFL 40
|
||||
|
||||
/* Protocol-level socket operations. */
|
||||
|
||||
#define SOL_IP IPPROTO_IP /* See options in include/netinet/ip.h */
|
||||
#define SOL_IPV6 IPPROTO_IPV6 /* See options in include/netinet/ip6.h */
|
||||
#define SOL_TCP IPPROTO_TCP /* See options in include/netinet/tcp.h */
|
||||
#define SOL_UDP IPPROTO_UDP /* See options in include/netinit/udp.h */
|
||||
|
||||
/* Bluetooth-level operations. */
|
||||
|
||||
#define SOL_HCI 0 /* See options in include/netpacket/bluetooth.h */
|
||||
#define SOL_L2CAP 6 /* See options in include/netpacket/bluetooth.h */
|
||||
#define SOL_SCO 17 /* See options in include/netpacket/bluetooth.h */
|
||||
#define SOL_RFCOMM 18 /* See options in include/netpacket/bluetooth.h */
|
||||
|
||||
/* Protocol-level socket options may begin with this value */
|
||||
|
||||
#define __SO_PROTOCOL 16
|
||||
|
||||
/* Values for the 'how' argument of shutdown() */
|
||||
|
||||
#define SHUT_RD 1 /* Bit 0: Disables further receive operations */
|
||||
#define SHUT_WR 2 /* Bit 1: Disables further send operations */
|
||||
#define SHUT_RDWR 3 /* Bits 0+1: Disables further send and receive
|
||||
* operations
|
||||
*/
|
||||
|
||||
/* The maximum backlog queue length */
|
||||
|
||||
#ifdef CONFIG_NET_TCPBACKLOG_CONNS
|
||||
# define SOMAXCONN CONFIG_NET_TCPBACKLOG_CONNS
|
||||
#else
|
||||
# define SOMAXCONN 0
|
||||
#endif
|
||||
|
||||
/* Definitions associated with sendmsg/recvmsg */
|
||||
|
||||
#define CMSG_NXTHDR(mhdr, cmsg) cmsg_nxthdr((mhdr), (cmsg))
|
||||
|
||||
#define CMSG_ALIGN(len) \
|
||||
(((len)+sizeof(long)-1) & ~(sizeof(long)-1))
|
||||
#define CMSG_DATA(cmsg) \
|
||||
((FAR void *)((FAR char *)(cmsg) + CMSG_ALIGN(sizeof(struct cmsghdr))))
|
||||
#define CMSG_SPACE(len) \
|
||||
(CMSG_ALIGN(sizeof(struct cmsghdr)) + CMSG_ALIGN(len))
|
||||
#define CMSG_LEN(len) \
|
||||
(CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
|
||||
|
||||
#define __CMSG_FIRSTHDR(ctl, len) \
|
||||
((len) >= sizeof(struct cmsghdr) ? (FAR struct cmsghdr *)(ctl) : \
|
||||
(FAR struct cmsghdr *)NULL)
|
||||
#define CMSG_FIRSTHDR(msg) \
|
||||
__CMSG_FIRSTHDR((msg)->msg_control, (msg)->msg_controllen)
|
||||
|
||||
/* "Socket"-level control message types: */
|
||||
|
||||
#define SCM_RIGHTS 0x01 /* rw: access rights (array of int) */
|
||||
#define SCM_CREDENTIALS 0x02 /* rw: struct ucred */
|
||||
#define SCM_SECURITY 0x03 /* rw: security label */
|
||||
|
||||
/****************************************************************************
|
||||
* Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* sockaddr_storage structure. This structure must be (1) large enough to
|
||||
* accommodate all supported protocol-specific address structures, and (2)
|
||||
* aligned at an appropriate boundary so that pointers to it can be cast
|
||||
* as pointers to protocol-specific address structures and used to access
|
||||
* the fields of those structures without alignment problems.
|
||||
*
|
||||
* REVISIT: sizeof(struct sockaddr_storge) should be 128 bytes.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
struct sockaddr_storage
|
||||
{
|
||||
sa_family_t ss_family; /* Address family */
|
||||
char ss_data[26]; /* 26-bytes of address data */
|
||||
};
|
||||
#else
|
||||
struct sockaddr_storage
|
||||
{
|
||||
sa_family_t ss_family; /* Address family */
|
||||
char ss_data[14]; /* 14-bytes of address data */
|
||||
};
|
||||
#endif
|
||||
|
||||
/* The sockaddr structure is used to define a socket address which is used
|
||||
* in the bind(), connect(), getpeername(), getsockname(), recvfrom(), and
|
||||
* sendto() functions.
|
||||
*/
|
||||
|
||||
struct sockaddr
|
||||
{
|
||||
sa_family_t sa_family; /* Address family: See AF_* definitions */
|
||||
char sa_data[14]; /* 14-bytes data (actually variable length) */
|
||||
};
|
||||
|
||||
/* Used with the SO_LINGER socket option */
|
||||
|
||||
struct linger
|
||||
{
|
||||
int l_onoff; /* Indicates whether linger option is enabled. */
|
||||
int l_linger; /* Linger time, in seconds. */
|
||||
};
|
||||
|
||||
struct msghdr
|
||||
{
|
||||
FAR void *msg_name; /* Socket name */
|
||||
socklen_t msg_namelen; /* Length of name */
|
||||
FAR struct iovec *msg_iov; /* Data blocks */
|
||||
unsigned long msg_iovlen; /* Number of blocks */
|
||||
FAR void *msg_control; /* Per protocol magic (eg BSD file descriptor passing) */
|
||||
unsigned long msg_controllen; /* Length of cmsg list */
|
||||
unsigned int msg_flags;
|
||||
};
|
||||
|
||||
struct cmsghdr
|
||||
{
|
||||
unsigned long cmsg_len; /* Data byte count, including hdr */
|
||||
int cmsg_level; /* Originating protocol */
|
||||
int cmsg_type; /* Protocol-specific type */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
static inline FAR struct cmsghdr *__cmsg_nxthdr(FAR void *__ctl,
|
||||
unsigned int __size,
|
||||
FAR struct cmsghdr *__cmsg)
|
||||
{
|
||||
FAR struct cmsghdr *__ptr;
|
||||
|
||||
__ptr = (FAR struct cmsghdr *)
|
||||
(((FAR char *)__cmsg) + CMSG_ALIGN(__cmsg->cmsg_len));
|
||||
if ((unsigned long)((FAR char *)(__ptr + 1) - (FAR char *)__ctl) > __size)
|
||||
{
|
||||
return (FAR struct cmsghdr *)NULL;
|
||||
}
|
||||
|
||||
return __ptr;
|
||||
}
|
||||
|
||||
static inline FAR struct cmsghdr *cmsg_nxthdr(FAR struct msghdr *__msg,
|
||||
FAR struct cmsghdr *__cmsg)
|
||||
{
|
||||
return __cmsg_nxthdr(__msg->msg_control, __msg->msg_controllen, __cmsg);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
int socket(int domain, int type, int protocol);
|
||||
int socketpair(int domain, int type, int protocol, int sv[2]);
|
||||
int bind(int sockfd, FAR const struct sockaddr *addr, socklen_t addrlen);
|
||||
int connect(int sockfd, FAR const struct sockaddr *addr, socklen_t addrlen);
|
||||
|
||||
int listen(int sockfd, int backlog);
|
||||
int accept(int sockfd, FAR struct sockaddr *addr, FAR socklen_t *addrlen);
|
||||
|
||||
ssize_t send(int sockfd, FAR const void *buf, size_t len, int flags);
|
||||
ssize_t sendto(int sockfd, FAR const void *buf, size_t len, int flags,
|
||||
FAR const struct sockaddr *to, socklen_t tolen);
|
||||
|
||||
ssize_t recv(int sockfd, FAR void *buf, size_t len, int flags);
|
||||
ssize_t recvfrom(int sockfd, FAR void *buf, size_t len, int flags,
|
||||
FAR struct sockaddr *from, FAR socklen_t *fromlen);
|
||||
|
||||
int shutdown(int sockfd, int how);
|
||||
|
||||
int setsockopt(int sockfd, int level, int option,
|
||||
FAR const void *value, socklen_t value_len);
|
||||
int getsockopt(int sockfd, int level, int option,
|
||||
FAR void *value, FAR socklen_t *value_len);
|
||||
|
||||
int getsockname(int sockfd, FAR struct sockaddr *addr,
|
||||
FAR socklen_t *addrlen);
|
||||
int getpeername(int sockfd, FAR struct sockaddr *addr,
|
||||
FAR socklen_t *addrlen);
|
||||
|
||||
ssize_t recvmsg(int sockfd, FAR struct msghdr *msg, int flags);
|
||||
ssize_t sendmsg(int sockfd, FAR struct msghdr *msg, int flags);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_SYS_SOCKET_H */
|
||||
@@ -0,0 +1,84 @@
|
||||
/****************************************************************************
|
||||
* include/sys/sockio.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_SYS_SOCKIO_H
|
||||
#define __INCLUDE_SYS_SOCKIO_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
/* Get NuttX configuration and NuttX-specific network IOCTL definitions */
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
#include <nuttx/net/ioctl.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define IMSFNAMSIZ 8
|
||||
|
||||
/****************************************************************************
|
||||
* Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* RFC3678: IPv4 Options
|
||||
*
|
||||
* o ioctl() SIOCGIPMSFILTER: to retrieve the list of source addresses
|
||||
* that comprise the source filter along with the current filter mode.
|
||||
*
|
||||
* o ioctl() SIOCSIPMSFILTER: to set or modify the source filter content
|
||||
* (e.g., unicast source address list) or mode (exclude or include).
|
||||
*
|
||||
* Ioctl option Argument type
|
||||
* ----------------------------- ----------------------
|
||||
* SIOCGIPMSFILTER struct ip_msfilter
|
||||
* SIOCSIPMSFILTER struct ip_msfilter
|
||||
*
|
||||
* The structure ip_msfilter, defined in <netinet/in.h> is used with
|
||||
* these IOCTL commands to pass filter information. The field
|
||||
* imsf_fmode is a 32-bit integer that identifies the filter mode.
|
||||
* The value of this field must be either MCAST_INCLUDE or
|
||||
* MCAST_EXCLUDE, which are likewise defined in <netinet/in.h>.
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_SYS_SOCKIO_H */
|
||||
@@ -0,0 +1,182 @@
|
||||
/****************************************************************************
|
||||
* include/sys/stat.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_SYS_STAT_H
|
||||
#define __INCLUDE_SYS_STAT_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* mode_t bit settings (most of these do not apply to NuttX). This assumes
|
||||
* that the full size of a mode_t is 16-bits. (However, mode_t must be size
|
||||
* 'int' because it is promoted to size int when passed in varargs).
|
||||
*
|
||||
* TTTT ...U UUGG GOOO
|
||||
*
|
||||
* Bits 0-2: Permissions for others
|
||||
* Bits 3-5: Group permissions
|
||||
* Bits 6-8: Owner permissions
|
||||
* Bits 9-11: Not used
|
||||
* Bits 12-15: File type bits
|
||||
*/
|
||||
|
||||
#define S_IXOTH (1 << 0) /* Bits 0-2: Permissions for others: RWX */
|
||||
#define S_IWOTH (1 << 1)
|
||||
#define S_IROTH (1 << 2)
|
||||
#define S_IRWXO (7 << 0)
|
||||
|
||||
#define S_IXGRP (1 << 3) /* Bits 3-5: Group permissions: RWX */
|
||||
#define S_IWGRP (1 << 4)
|
||||
#define S_IRGRP (1 << 5)
|
||||
#define S_IRWXG (7 << 3)
|
||||
|
||||
#define S_IXUSR (1 << 6) /* Bits 6-8: Owner permissions: RWX */
|
||||
#define S_IWUSR (1 << 7)
|
||||
#define S_IRUSR (1 << 8)
|
||||
#define S_IRWXU (7 << 6)
|
||||
|
||||
#define S_IREAD S_IRUSR /* Obsolete synonym provided for BSD compatibility. */
|
||||
#define S_IWRITE S_IWUSR /* Obsolete synonym provided for BSD compatibility. */
|
||||
#define S_IEXEC S_IXUSR /* Obsolete synonym provided for BSD compatibility. */
|
||||
|
||||
#define S_ISVTX (1 << 9) /* "Sticky" bit (not used) */
|
||||
#define S_ISGID (1 << 10) /* Set group ID bit (not used)*/
|
||||
#define S_ISUID (1 << 11) /* Set UID bit (not used) */
|
||||
|
||||
#define S_IFIFO (1 << 12) /* Bits 12-15: File type bits (not all used) */
|
||||
#define S_IFCHR (2 << 12)
|
||||
#define S_IFSEM (3 << 12)
|
||||
#define S_IFDIR (4 << 12)
|
||||
#define S_IFMQ (5 << 12)
|
||||
#define S_IFBLK (6 << 12)
|
||||
#define S_IFSHM (7 << 12)
|
||||
#define S_IFREG (8 << 12)
|
||||
#define S_IFMTD (9 << 12)
|
||||
#define S_IFLNK (10 << 12)
|
||||
#define S_IFSOCK (12 << 12)
|
||||
#define S_IFMT (15 << 12)
|
||||
|
||||
/* File type macros that operate on an instance of mode_t */
|
||||
|
||||
#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
|
||||
#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
|
||||
#define S_ISSEM(m) (((m) & S_IFMT) == S_IFSEM)
|
||||
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
#define S_ISMQ(m) (((m) & S_IFMT) == S_IFMQ)
|
||||
#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
|
||||
#define S_ISSHM(m) (((m) & S_IFMT) == S_IFSHM)
|
||||
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||
#define S_ISMTD(m) (((m) & S_IFMT) == S_IFMTD)
|
||||
#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
|
||||
#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
|
||||
|
||||
/* These are from POSIX.1b. If the objects are not implemented using separate
|
||||
* distinct file types, the macros always will evaluate to zero. Unlike the
|
||||
* other S_* macros the following three take a pointer to a `struct stat'
|
||||
* object as the argument.
|
||||
*/
|
||||
|
||||
#define S_TYPEISSEM(buf) S_ISSEM((buf)->st_mode)
|
||||
#define S_TYPEISMQ(buf) S_ISMQ((buf)->st_mode)
|
||||
#define S_TYPEISSHM(buf) S_ISSHM((buf)->st_mode)
|
||||
|
||||
/* The following macros are required by POSIX to achieve backward
|
||||
* compatibility with earlier versions of struct stat.
|
||||
*/
|
||||
|
||||
#define st_atime st_atim.tv_sec
|
||||
#define st_ctime st_ctim.tv_sec
|
||||
#define st_mtime st_mtim.tv_sec
|
||||
|
||||
/****************************************************************************
|
||||
* Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* This is the simplified struct stat as returned by stat() and fstat().
|
||||
* This structure provides information about a specific file or directory in
|
||||
* the file system.
|
||||
*/
|
||||
|
||||
struct stat
|
||||
{
|
||||
/* Required, standard fields */
|
||||
|
||||
dev_t st_dev; /* Device ID of device containing file */
|
||||
ino_t st_ino; /* File serial number */
|
||||
mode_t st_mode; /* File type, attributes, and access mode bits */
|
||||
nlink_t st_nlink; /* Number of hard links to the file */
|
||||
uid_t st_uid; /* User ID of file */
|
||||
gid_t st_gid; /* Group ID of file */
|
||||
dev_t st_rdev; /* Device ID (if file is character or block special) */
|
||||
off_t st_size; /* Size of file/directory, in bytes */
|
||||
struct timespec st_atim; /* Time of last access */
|
||||
struct timespec st_mtim; /* Time of last modification */
|
||||
struct timespec st_ctim; /* Time of last status change */
|
||||
blksize_t st_blksize; /* Block size used for filesystem I/O */
|
||||
blkcnt_t st_blocks; /* Number of blocks allocated */
|
||||
|
||||
/* Internal fields. These are part this specific implementation and
|
||||
* should not referenced by application code for portability reasons.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_PSEUDOFS_SOFTLINKS
|
||||
uint8_t st_count; /* Used internally to limit traversal of links */
|
||||
#endif
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
int mkdir(FAR const char *pathname, mode_t mode);
|
||||
int mkfifo(FAR const char *pathname, mode_t mode);
|
||||
int stat(FAR const char *path, FAR struct stat *buf);
|
||||
int lstat(FAR const char *path, FAR struct stat *buf);
|
||||
int fstat(int fd, FAR struct stat *buf);
|
||||
int chmod(FAR const char *path, mode_t mode);
|
||||
int fchmod(int fd, mode_t mode);
|
||||
|
||||
mode_t umask(mode_t mask);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_SYS_STAT_H */
|
||||
@@ -0,0 +1,139 @@
|
||||
/****************************************************************************
|
||||
* include/sys/statfs.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_SYS_STATFS_H
|
||||
#define __INCLUDE_SYS_STATFS_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* struct statfs file system types. */
|
||||
|
||||
#define ADFS_SUPER_MAGIC 0xadf5
|
||||
#define AFFS_SUPER_MAGIC 0xadff
|
||||
#define BEFS_SUPER_MAGIC 0x42465331
|
||||
#define BFS_MAGIC 0x1badface
|
||||
#define CIFS_MAGIC_NUMBER 0xff534d42
|
||||
#define CODA_SUPER_MAGIC 0x73757245
|
||||
#define COH_SUPER_MAGIC 0x012ff7b7
|
||||
#define CRAMFS_MAGIC 0x28cd3d45
|
||||
#define DEVFS_SUPER_MAGIC 0x1373
|
||||
#define EFS_SUPER_MAGIC 0x00414a53
|
||||
#define EXT_SUPER_MAGIC 0x137d
|
||||
#define EXT2_OLD_SUPER_MAGIC 0xef51
|
||||
#define EXT2_SUPER_MAGIC 0xef53
|
||||
#define EXT3_SUPER_MAGIC 0xef53
|
||||
#define HFS_SUPER_MAGIC 0x4244
|
||||
#define HPFS_SUPER_MAGIC 0xf995e849
|
||||
#define HUGETLBFS_MAGIC 0x958458f6
|
||||
#define ISOFS_SUPER_MAGIC 0x9660
|
||||
#define JFFS2_SUPER_MAGIC 0x72b6
|
||||
#define JFS_SUPER_MAGIC 0x3153464a
|
||||
#define MINIX_SUPER_MAGIC 0x137f /* orig. minix */
|
||||
#define MINIX_SUPER_MAGIC2 0x138f /* 30 char minix */
|
||||
#define MINIX2_SUPER_MAGIC 0x2468 /* minix V2 */
|
||||
#define MINIX2_SUPER_MAGIC2 0x2478 /* minix V2, 30 char names */
|
||||
#define MSDOS_SUPER_MAGIC 0x4d44
|
||||
#define NCP_SUPER_MAGIC 0x564c
|
||||
#define NFS_SUPER_MAGIC 0x6969
|
||||
#define NTFS_SB_MAGIC 0x5346544e
|
||||
#define OPENPROM_SUPER_MAGIC 0x9fa1
|
||||
#define PROC_SUPER_MAGIC 0x9fa0
|
||||
#define QNX4_SUPER_MAGIC 0x002f
|
||||
#define REISERFS_SUPER_MAGIC 0x52654973
|
||||
#define ROMFS_MAGIC 0x7275
|
||||
#define SMB_SUPER_MAGIC 0x517B
|
||||
#define SYSV2_SUPER_MAGIC 0x012ff7b6
|
||||
#define SYSV4_SUPER_MAGIC 0x012FF7B5
|
||||
#define TMPFS_MAGIC 0x01021994
|
||||
#define UDF_SUPER_MAGIC 0x15013346
|
||||
#define UFS_MAGIC 0x00011954
|
||||
#define USBDEVICE_SUPER_MAGIC 0x9fa2
|
||||
#define VXFS_SUPER_MAGIC 0xa501fcf5
|
||||
#define XENIX_SUPER_MAGIC 0x012ff7b4
|
||||
#define XFS_SUPER_MAGIC 0x58465342
|
||||
#define _XIAFS_SUPER_MAGIC 0x012fd16d
|
||||
#define SPIFFS_SUPER_MAGIC 0x20090315
|
||||
#define LITTLEFS_SUPER_MAGIC 0x0a732923
|
||||
|
||||
/* NuttX specific file-systems */
|
||||
|
||||
#define BINFS_MAGIC 0x4242
|
||||
#define PROCFS_MAGIC 0x434f5250
|
||||
#define NXFFS_MAGIC 0x4747
|
||||
#define SMARTFS_MAGIC 0x54524D53
|
||||
#define UNIONFS_MAGIC 0x53464e55
|
||||
#define HOSTFS_MAGIC 0x54534f48
|
||||
#define USERFS_MAGIC 0x52455355
|
||||
#define CROMFS_MAGIC 0x4d4f5243
|
||||
|
||||
/****************************************************************************
|
||||
* Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
struct statfs
|
||||
{
|
||||
uint32_t f_type; /* Type of filesystem (see definitions above) */
|
||||
size_t f_namelen; /* Maximum length of filenames */
|
||||
size_t f_bsize; /* Optimal block size for transfers */
|
||||
off_t f_blocks; /* Total data blocks in the file system of this size */
|
||||
off_t f_bfree; /* Free blocks in the file system */
|
||||
off_t f_bavail; /* Free blocks avail to non-superuser */
|
||||
off_t f_files; /* Total file nodes in the file system */
|
||||
off_t f_ffree; /* Free file nodes in the file system */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/* Inspired by Linux statfs() which was, in turn, inspired by
|
||||
* the BSD statfs(). None of these implementations agree in the
|
||||
* form of the struct statfs.
|
||||
*/
|
||||
|
||||
int statfs(FAR const char *path, FAR struct statfs *buf);
|
||||
int fstatfs(int fd, FAR struct statfs *buf);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_SYS_STATFS_H */
|
||||
@@ -0,0 +1,84 @@
|
||||
/****************************************************************************
|
||||
* include/sys/statvfs.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_SYS_STATVFS_H
|
||||
#define __INCLUDE_SYS_STATVFS_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Definitions for the flag in `f_flag'. These definitions should be
|
||||
* kept in sync with the definitions in <sys/mount.h>.
|
||||
*/
|
||||
|
||||
#define ST_RDONLY 0x0001 /* Mount read-only. */
|
||||
#define ST_NOSUID 0x0002 /* Ignore suid and sgid bits. */
|
||||
|
||||
/****************************************************************************
|
||||
* Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
struct statvfs
|
||||
{
|
||||
unsigned long f_bsize; /* File system block size */
|
||||
unsigned long f_frsize; /* Fundamental file system block size */
|
||||
fsblkcnt_t f_blocks; /* Total number of blocks on file system in
|
||||
* units of f_frsize */
|
||||
fsblkcnt_t f_bfree; /* Total number of free blocks */
|
||||
fsblkcnt_t f_bavail; /* Number of free blocks available to
|
||||
* non-privileged process */
|
||||
fsfilcnt_t f_files; /* Total number of file serial numbers */
|
||||
fsfilcnt_t f_ffree; /* Total number of free file serial numbers */
|
||||
fsfilcnt_t f_favail; /* Number of file serial numbers available to
|
||||
* non-privileged process */
|
||||
unsigned long f_fsid; /* File system ID */
|
||||
unsigned long f_flag; /* Bit mask of f_flag values */
|
||||
unsigned long f_namemax; /* Maximum filename length */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
int statvfs(FAR const char *path, FAR struct statvfs *buf);
|
||||
int fstatvfs(int fd, FAR struct statvfs *buf);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_SYS_STATVFS_H */
|
||||
@@ -0,0 +1,119 @@
|
||||
/****************************************************************************
|
||||
* include/sys/syscall.h
|
||||
* This file contains the system call numbers.
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_SYS_SYSCALL_H
|
||||
#define __INCLUDE_SYS_SYSCALL_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LIB_SYSCALL
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Reserve the first system calls for platform-specific usage if so
|
||||
* configured.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_SYS_RESERVED
|
||||
# define CONFIG_SYS_RESERVED (0)
|
||||
#endif
|
||||
|
||||
/* Note that the reported number of system calls does *NOT* include the
|
||||
* architecture-specific system calls. If the "real" total is required,
|
||||
* use SYS_maxsyscall.
|
||||
*/
|
||||
|
||||
#define SYS_nsyscalls (SYS_maxsyscall - CONFIG_SYS_RESERVED)
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
enum
|
||||
{
|
||||
# define SYSCALL_LOOKUP_(f) SYS_##f
|
||||
# define SYSCALL_LOOKUP1(f,n) SYSCALL_LOOKUP_(f) = CONFIG_SYS_RESERVED
|
||||
# define SYSCALL_LOOKUP(f,n) , SYSCALL_LOOKUP_(f)
|
||||
# include "syscall_lookup.h"
|
||||
, SYS_maxsyscall
|
||||
# undef SYSCALL_LOOKUP_
|
||||
# undef SYSCALL_LOOKUP1
|
||||
# undef SYSCALL_LOOKUP
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LIB_SYSCALL
|
||||
|
||||
/* Given the system call number, the corresponding entry in this table
|
||||
* provides the address of the stub function.
|
||||
*
|
||||
* This table is only available during the kernel phase of a kernel build.
|
||||
*/
|
||||
|
||||
EXTERN const uintptr_t g_stublookup[SYS_nsyscalls];
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL
|
||||
|
||||
/* Given the system call number, the corresponding entry in this table
|
||||
* provides the name of the function.
|
||||
*/
|
||||
|
||||
EXTERN const char *g_funcnames[SYS_nsyscalls];
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* CONFIG_LIB_SYSCALL */
|
||||
#endif /* __INCLUDE_SYS_SYSCALL_H */
|
||||
@@ -0,0 +1,393 @@
|
||||
/****************************************************************************
|
||||
* include/sys/syscall_lookup.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* SYSCALL_LOOKUP must be defined before including this file.
|
||||
*
|
||||
* These first system calls are supported regardless of the NuttX
|
||||
* configuration
|
||||
*/
|
||||
|
||||
SYSCALL_LOOKUP1(_exit, 1)
|
||||
SYSCALL_LOOKUP(exit, 1)
|
||||
SYSCALL_LOOKUP(getpid, 0)
|
||||
SYSCALL_LOOKUP(gettid, 0)
|
||||
|
||||
#ifdef CONFIG_SCHED_HAVE_PARENT
|
||||
SYSCALL_LOOKUP(getppid, 0)
|
||||
#endif
|
||||
|
||||
SYSCALL_LOOKUP(sched_getparam, 2)
|
||||
SYSCALL_LOOKUP(sched_getscheduler, 1)
|
||||
SYSCALL_LOOKUP(sched_lock, 0)
|
||||
SYSCALL_LOOKUP(sched_lockcount, 0)
|
||||
SYSCALL_LOOKUP(sched_rr_get_interval, 2)
|
||||
SYSCALL_LOOKUP(sched_setparam, 2)
|
||||
SYSCALL_LOOKUP(sched_setscheduler, 3)
|
||||
SYSCALL_LOOKUP(sched_unlock, 0)
|
||||
SYSCALL_LOOKUP(sched_yield, 0)
|
||||
SYSCALL_LOOKUP(nxsched_get_stackinfo, 2)
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
SYSCALL_LOOKUP(sched_getaffinity, 3)
|
||||
SYSCALL_LOOKUP(sched_getcpu, 0)
|
||||
SYSCALL_LOOKUP(sched_setaffinity, 3)
|
||||
#endif
|
||||
|
||||
SYSCALL_LOOKUP(gethostname, 2)
|
||||
SYSCALL_LOOKUP(sethostname, 2)
|
||||
|
||||
/* User identity */
|
||||
|
||||
#ifdef CONFIG_SCHED_USER_IDENTITY
|
||||
SYSCALL_LOOKUP(setuid, 1)
|
||||
SYSCALL_LOOKUP(getuid, 0)
|
||||
SYSCALL_LOOKUP(setgid, 1)
|
||||
SYSCALL_LOOKUP(getgid, 0)
|
||||
#endif
|
||||
|
||||
/* Semaphores */
|
||||
|
||||
SYSCALL_LOOKUP(sem_destroy, 1)
|
||||
SYSCALL_LOOKUP(sem_post, 1)
|
||||
SYSCALL_LOOKUP(sem_clockwait, 3)
|
||||
SYSCALL_LOOKUP(sem_timedwait, 2)
|
||||
SYSCALL_LOOKUP(sem_trywait, 1)
|
||||
SYSCALL_LOOKUP(sem_wait, 1)
|
||||
|
||||
#ifdef CONFIG_PRIORITY_INHERITANCE
|
||||
SYSCALL_LOOKUP(sem_setprotocol, 2)
|
||||
#endif
|
||||
|
||||
/* Named semaphores */
|
||||
|
||||
#ifdef CONFIG_FS_NAMED_SEMAPHORES
|
||||
SYSCALL_LOOKUP(sem_open, 4)
|
||||
SYSCALL_LOOKUP(sem_close, 1)
|
||||
SYSCALL_LOOKUP(sem_unlink, 1)
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_BUILD_KERNEL
|
||||
SYSCALL_LOOKUP(task_create, 5)
|
||||
#ifdef CONFIG_LIB_SYSCALL
|
||||
SYSCALL_LOOKUP(nx_task_spawn, 1)
|
||||
#endif
|
||||
#else
|
||||
SYSCALL_LOOKUP(pgalloc, 2)
|
||||
#endif
|
||||
SYSCALL_LOOKUP(task_delete, 1)
|
||||
SYSCALL_LOOKUP(task_restart, 1)
|
||||
SYSCALL_LOOKUP(task_setcancelstate, 2)
|
||||
SYSCALL_LOOKUP(up_assert, 2)
|
||||
|
||||
#ifdef CONFIG_CANCELLATION_POINTS
|
||||
SYSCALL_LOOKUP(task_setcanceltype, 2)
|
||||
SYSCALL_LOOKUP(task_testcancel, 0)
|
||||
#endif
|
||||
|
||||
/* The following can be individually enabled */
|
||||
|
||||
#if defined(CONFIG_SCHED_WAITPID) && defined(CONFIG_ARCH_HAVE_VFORK)
|
||||
SYSCALL_LOOKUP(vfork, 0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SCHED_ATEXIT
|
||||
SYSCALL_LOOKUP(atexit, 1)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SCHED_ONEXIT
|
||||
SYSCALL_LOOKUP(on_exit, 2)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SCHED_WAITPID
|
||||
SYSCALL_LOOKUP(waitpid, 3)
|
||||
#ifdef CONFIG_SCHED_HAVE_PARENT
|
||||
SYSCALL_LOOKUP(wait, 1)
|
||||
SYSCALL_LOOKUP(waitid, 4)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* The following can only be defined if we are configured to load
|
||||
* OS modules from a file system.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_MODULE
|
||||
SYSCALL_LOOKUP(insmod, 2)
|
||||
SYSCALL_LOOKUP(rmmod, 1)
|
||||
SYSCALL_LOOKUP(modhandle, 1)
|
||||
#endif
|
||||
|
||||
/* The following can only be defined if we are configured to execute
|
||||
* programs from a file system.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_BINFMT_DISABLE
|
||||
#ifndef CONFIG_BUILD_KERNEL
|
||||
SYSCALL_LOOKUP(exec, 4)
|
||||
#endif
|
||||
#ifdef CONFIG_LIBC_EXECFUNCS
|
||||
#ifdef CONFIG_LIB_ENVPATH
|
||||
SYSCALL_LOOKUP(posix_spawnp, 6)
|
||||
#else
|
||||
SYSCALL_LOOKUP(posix_spawn, 6)
|
||||
#endif
|
||||
SYSCALL_LOOKUP(execv, 2)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* The following are only defined is signals are supported in the NuttX
|
||||
* configuration.
|
||||
*/
|
||||
|
||||
SYSCALL_LOOKUP(kill, 2)
|
||||
SYSCALL_LOOKUP(sigaction, 3)
|
||||
SYSCALL_LOOKUP(sigpending, 1)
|
||||
SYSCALL_LOOKUP(sigprocmask, 3)
|
||||
SYSCALL_LOOKUP(sigqueue, 3)
|
||||
SYSCALL_LOOKUP(sigsuspend, 1)
|
||||
SYSCALL_LOOKUP(sigtimedwait, 3)
|
||||
SYSCALL_LOOKUP(sigwaitinfo, 2)
|
||||
SYSCALL_LOOKUP(clock_nanosleep, 4)
|
||||
|
||||
/* The following are only defined if the system clock is enabled in the
|
||||
* NuttX configuration.
|
||||
*/
|
||||
|
||||
SYSCALL_LOOKUP(clock, 0)
|
||||
SYSCALL_LOOKUP(clock_getres, 2)
|
||||
SYSCALL_LOOKUP(clock_gettime, 2)
|
||||
SYSCALL_LOOKUP(clock_settime, 2)
|
||||
#ifdef CONFIG_CLOCK_TIMEKEEPING
|
||||
SYSCALL_LOOKUP(adjtime, 2)
|
||||
#endif
|
||||
|
||||
/* The following are defined only if POSIX timers are supported */
|
||||
|
||||
#ifndef CONFIG_DISABLE_POSIX_TIMERS
|
||||
SYSCALL_LOOKUP(timer_create, 3)
|
||||
SYSCALL_LOOKUP(timer_delete, 1)
|
||||
SYSCALL_LOOKUP(timer_getoverrun, 1)
|
||||
SYSCALL_LOOKUP(timer_gettime, 2)
|
||||
SYSCALL_LOOKUP(timer_settime, 4)
|
||||
SYSCALL_LOOKUP(getitimer, 2)
|
||||
SYSCALL_LOOKUP(setitimer, 3)
|
||||
#endif
|
||||
|
||||
/* System logging */
|
||||
|
||||
SYSCALL_LOOKUP(nx_vsyslog, 3)
|
||||
|
||||
/* The following are defined if either file or socket descriptor are
|
||||
* enabled.
|
||||
*/
|
||||
|
||||
SYSCALL_LOOKUP(close, 1)
|
||||
SYSCALL_LOOKUP(ioctl, 3)
|
||||
SYSCALL_LOOKUP(read, 3)
|
||||
SYSCALL_LOOKUP(write, 3)
|
||||
SYSCALL_LOOKUP(pread, 4)
|
||||
SYSCALL_LOOKUP(pwrite, 4)
|
||||
#ifdef CONFIG_FS_AIO
|
||||
SYSCALL_LOOKUP(aio_read, 1)
|
||||
SYSCALL_LOOKUP(aio_write, 1)
|
||||
SYSCALL_LOOKUP(aio_fsync, 2)
|
||||
SYSCALL_LOOKUP(aio_cancel, 2)
|
||||
#endif
|
||||
SYSCALL_LOOKUP(poll, 3)
|
||||
SYSCALL_LOOKUP(select, 5)
|
||||
SYSCALL_LOOKUP(ppoll, 4)
|
||||
SYSCALL_LOOKUP(pselect, 6)
|
||||
#ifdef CONFIG_EVENT_FD
|
||||
SYSCALL_LOOKUP(eventfd, 2)
|
||||
#endif
|
||||
#ifdef CONFIG_NETDEV_IFINDEX
|
||||
SYSCALL_LOOKUP(if_indextoname, 2)
|
||||
SYSCALL_LOOKUP(if_nametoindex, 1)
|
||||
#endif
|
||||
#ifdef CONFIG_SERIAL_TERMIOS
|
||||
SYSCALL_LOOKUP(tcdrain, 1)
|
||||
#endif
|
||||
|
||||
/* Board support */
|
||||
|
||||
#ifdef CONFIG_LIB_BOARDCTL
|
||||
SYSCALL_LOOKUP(boardctl, 2)
|
||||
#endif
|
||||
|
||||
/* The following are defined if file descriptors are enabled */
|
||||
|
||||
SYSCALL_LOOKUP(closedir, 1)
|
||||
SYSCALL_LOOKUP(dup, 1)
|
||||
SYSCALL_LOOKUP(dup2, 2)
|
||||
SYSCALL_LOOKUP(fcntl, 3)
|
||||
SYSCALL_LOOKUP(lseek, 3)
|
||||
SYSCALL_LOOKUP(mmap, 6)
|
||||
SYSCALL_LOOKUP(open, 3)
|
||||
SYSCALL_LOOKUP(opendir, 1)
|
||||
SYSCALL_LOOKUP(readdir, 1)
|
||||
SYSCALL_LOOKUP(rewinddir, 1)
|
||||
SYSCALL_LOOKUP(seekdir, 2)
|
||||
SYSCALL_LOOKUP(stat, 2)
|
||||
SYSCALL_LOOKUP(lstat, 2)
|
||||
SYSCALL_LOOKUP(fstat, 2)
|
||||
SYSCALL_LOOKUP(statfs, 2)
|
||||
SYSCALL_LOOKUP(fstatfs, 2)
|
||||
SYSCALL_LOOKUP(telldir, 1)
|
||||
|
||||
#if defined(CONFIG_FS_RAMMAP)
|
||||
SYSCALL_LOOKUP(munmap, 2)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_PSEUDOFS_SOFTLINKS)
|
||||
SYSCALL_LOOKUP(symlink, 2)
|
||||
SYSCALL_LOOKUP(readlink, 3)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 0
|
||||
SYSCALL_LOOKUP(nx_pipe, 3)
|
||||
SYSCALL_LOOKUP(nx_mkfifo, 3)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FILE_STREAM
|
||||
SYSCALL_LOOKUP(fs_fdopen, 4)
|
||||
SYSCALL_LOOKUP(nxsched_get_streams, 0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_SENDFILE
|
||||
SYSCALL_LOOKUP(sendfile, 4)
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
||||
SYSCALL_LOOKUP(mount, 5)
|
||||
SYSCALL_LOOKUP(fsync, 1)
|
||||
SYSCALL_LOOKUP(ftruncate, 2)
|
||||
SYSCALL_LOOKUP(mkdir, 2)
|
||||
SYSCALL_LOOKUP(rename, 2)
|
||||
SYSCALL_LOOKUP(rmdir, 1)
|
||||
SYSCALL_LOOKUP(umount2, 2)
|
||||
SYSCALL_LOOKUP(unlink, 1)
|
||||
#endif
|
||||
|
||||
/* Shared memory interfaces */
|
||||
|
||||
#ifdef CONFIG_MM_SHM
|
||||
SYSCALL_LOOKUP(shmget, 3)
|
||||
SYSCALL_LOOKUP(shmat, 3)
|
||||
SYSCALL_LOOKUP(shmctl, 3)
|
||||
SYSCALL_LOOKUP(shmdt, 1)
|
||||
#endif
|
||||
|
||||
#if CONFIG_TLS_NELEM > 0
|
||||
SYSCALL_LOOKUP(tls_alloc, 0)
|
||||
SYSCALL_LOOKUP(tls_free, 1)
|
||||
#endif
|
||||
|
||||
/* The following are defined if pthreads are enabled */
|
||||
|
||||
#ifndef CONFIG_DISABLE_PTHREAD
|
||||
SYSCALL_LOOKUP(pthread_cancel, 1)
|
||||
SYSCALL_LOOKUP(pthread_cond_broadcast, 1)
|
||||
SYSCALL_LOOKUP(pthread_cond_signal, 1)
|
||||
SYSCALL_LOOKUP(pthread_cond_wait, 2)
|
||||
SYSCALL_LOOKUP(pthread_create, 4)
|
||||
SYSCALL_LOOKUP(pthread_detach, 1)
|
||||
SYSCALL_LOOKUP(pthread_exit, 1)
|
||||
SYSCALL_LOOKUP(pthread_getschedparam, 3)
|
||||
SYSCALL_LOOKUP(pthread_join, 2)
|
||||
SYSCALL_LOOKUP(pthread_mutex_destroy, 1)
|
||||
SYSCALL_LOOKUP(pthread_mutex_init, 2)
|
||||
SYSCALL_LOOKUP(pthread_mutex_timedlock, 2)
|
||||
SYSCALL_LOOKUP(pthread_mutex_trylock, 1)
|
||||
SYSCALL_LOOKUP(pthread_mutex_unlock, 1)
|
||||
#ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
|
||||
SYSCALL_LOOKUP(pthread_mutex_consistent, 1)
|
||||
#endif
|
||||
SYSCALL_LOOKUP(pthread_setschedparam, 3)
|
||||
SYSCALL_LOOKUP(pthread_setschedprio, 2)
|
||||
#ifdef CONFIG_SMP
|
||||
SYSCALL_LOOKUP(pthread_setaffinity_np, 3)
|
||||
SYSCALL_LOOKUP(pthread_getaffinity_np, 3)
|
||||
#endif
|
||||
SYSCALL_LOOKUP(pthread_cond_clockwait, 4)
|
||||
SYSCALL_LOOKUP(pthread_kill, 2)
|
||||
SYSCALL_LOOKUP(pthread_sigmask, 3)
|
||||
#ifdef CONFIG_PTHREAD_CLEANUP
|
||||
SYSCALL_LOOKUP(pthread_cleanup_push, 2)
|
||||
SYSCALL_LOOKUP(pthread_cleanup_pop, 1)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* The following are defined only if message queues are enabled */
|
||||
|
||||
#ifndef CONFIG_DISABLE_MQUEUE
|
||||
SYSCALL_LOOKUP(mq_close, 1)
|
||||
SYSCALL_LOOKUP(mq_getattr, 2)
|
||||
SYSCALL_LOOKUP(mq_notify, 2)
|
||||
SYSCALL_LOOKUP(mq_open, 4)
|
||||
SYSCALL_LOOKUP(mq_receive, 4)
|
||||
SYSCALL_LOOKUP(mq_send, 4)
|
||||
SYSCALL_LOOKUP(mq_setattr, 3)
|
||||
SYSCALL_LOOKUP(mq_timedreceive, 5)
|
||||
SYSCALL_LOOKUP(mq_timedsend, 5)
|
||||
SYSCALL_LOOKUP(mq_unlink, 1)
|
||||
#endif
|
||||
|
||||
/* The following are defined only if environment variables are supported */
|
||||
|
||||
#ifndef CONFIG_DISABLE_ENVIRON
|
||||
SYSCALL_LOOKUP(clearenv, 0)
|
||||
SYSCALL_LOOKUP(getenv, 1)
|
||||
SYSCALL_LOOKUP(putenv, 1)
|
||||
SYSCALL_LOOKUP(setenv, 3)
|
||||
SYSCALL_LOOKUP(unsetenv, 1)
|
||||
#endif
|
||||
|
||||
/* The following are defined only if networking AND sockets are supported */
|
||||
|
||||
#ifdef CONFIG_NET
|
||||
SYSCALL_LOOKUP(accept, 3)
|
||||
SYSCALL_LOOKUP(bind, 3)
|
||||
SYSCALL_LOOKUP(connect, 3)
|
||||
SYSCALL_LOOKUP(getpeername, 3)
|
||||
SYSCALL_LOOKUP(getsockname, 3)
|
||||
SYSCALL_LOOKUP(getsockopt, 5)
|
||||
SYSCALL_LOOKUP(listen, 2)
|
||||
SYSCALL_LOOKUP(recv, 4)
|
||||
SYSCALL_LOOKUP(recvfrom, 6)
|
||||
SYSCALL_LOOKUP(recvmsg, 3)
|
||||
SYSCALL_LOOKUP(send, 4)
|
||||
SYSCALL_LOOKUP(sendto, 6)
|
||||
SYSCALL_LOOKUP(sendmsg, 3)
|
||||
SYSCALL_LOOKUP(setsockopt, 5)
|
||||
SYSCALL_LOOKUP(socket, 3)
|
||||
#endif
|
||||
|
||||
/* The following is defined only if CONFIG_TASK_NAME_SIZE > 0 */
|
||||
|
||||
#if CONFIG_TASK_NAME_SIZE > 0
|
||||
SYSCALL_LOOKUP(prctl, 2)
|
||||
#endif
|
||||
|
||||
/* The following is defined only if entropy pool random number generator
|
||||
* is enabled.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_CRYPTO_RANDOM_POOL
|
||||
SYSCALL_LOOKUP(arc4random_buf, 2)
|
||||
#endif
|
||||
@@ -0,0 +1,435 @@
|
||||
/****************************************************************************
|
||||
* include/sys/time.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_SYS_TIME_H
|
||||
#define __INCLUDE_SYS_TIME_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <time.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ITIMER_REAL 0 /* Timers run in real time. */
|
||||
#define ITIMER_VIRTUAL 1 /* Timers run only when the process is executing. */
|
||||
#define ITIMER_PROF 2 /* Timers run when the process is executing and when
|
||||
* the system is executing on behalf of the process.
|
||||
*/
|
||||
|
||||
/* The following are non-standard interfaces in the sense that they are not
|
||||
* in POSIX.1-2001 nor are they specified at OpenGroup.org. These interfaces
|
||||
* are present on most BSD derivatives, however, including Linux.
|
||||
*/
|
||||
|
||||
/* void timeradd(FAR struct timeval *a, FAR struct timeval *b,
|
||||
* FAR struct timeval *res);
|
||||
*/
|
||||
|
||||
#define timeradd(tvp, uvp, vvp) \
|
||||
do \
|
||||
{ \
|
||||
(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
|
||||
(vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
|
||||
if ((vvp)->tv_usec >= 1000000) \
|
||||
{ \
|
||||
(vvp)->tv_sec++; \
|
||||
(vvp)->tv_usec -= 1000000; \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/* void timersub(FAR struct timeval *a, FAR struct timeval *b,
|
||||
* FAR struct timeval *res);
|
||||
*/
|
||||
|
||||
#define timersub(tvp, uvp, vvp) \
|
||||
do \
|
||||
{ \
|
||||
(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
|
||||
(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
|
||||
if ((vvp)->tv_usec < 0) \
|
||||
{ \
|
||||
(vvp)->tv_sec--; \
|
||||
(vvp)->tv_usec += 1000000; \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/* void timerclear(FAR struct timeval *tvp); */
|
||||
|
||||
#define timerclear(tvp) \
|
||||
do \
|
||||
{ \
|
||||
(tvp)->tv_sec = 0; \
|
||||
(tvp)->tv_usec = 0; \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/* int timerisset(FAR struct timeval *tvp); */
|
||||
|
||||
#define timerisset(tvp) \
|
||||
((tvp)->tv_sec != 0 || (tvp)->tv_usec != 0)
|
||||
|
||||
/* int timercmp(FAR struct timeval *a, FAR struct timeval *b, CMP); */
|
||||
|
||||
#define timercmp(tvp, uvp, cmp) \
|
||||
(((tvp)->tv_sec == (uvp)->tv_sec) ? \
|
||||
((tvp)->tv_usec cmp (uvp)->tv_usec) : \
|
||||
((tvp)->tv_sec cmp (uvp)->tv_sec))
|
||||
|
||||
/* Macros for converting between `struct timeval' and `struct timespec'. */
|
||||
|
||||
#define TIMEVAL_TO_TIMESPEC(tv, ts) \
|
||||
do \
|
||||
{ \
|
||||
(ts)->tv_sec = (tv)->tv_sec; \
|
||||
(ts)->tv_nsec = (tv)->tv_usec * 1000; \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#define TIMESPEC_TO_TIMEVAL(tv, ts) \
|
||||
do \
|
||||
{ \
|
||||
(tv)->tv_sec = (ts)->tv_sec; \
|
||||
(tv)->tv_usec = (ts)->tv_nsec / 1000; \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
typedef clock_t hrtime_t;
|
||||
|
||||
/* struct timeval represents time as seconds plus microseconds */
|
||||
|
||||
struct timeval
|
||||
{
|
||||
time_t tv_sec; /* Seconds */
|
||||
long tv_usec; /* Microseconds */
|
||||
};
|
||||
|
||||
/* Type of the second argument to `getitimer' and
|
||||
* the second and third arguments `setitimer'.
|
||||
*/
|
||||
|
||||
struct itimerval
|
||||
{
|
||||
struct timeval it_interval; /* Interval for periodic timer */
|
||||
struct timeval it_value; /* Time until next expiration */
|
||||
};
|
||||
|
||||
/* The use of the struct timezone is obsolete; the tz argument should
|
||||
* normally be specified as NULL (and is ignored in any event).
|
||||
*/
|
||||
|
||||
struct timezone
|
||||
{
|
||||
int tz_minuteswest; /* Minutes west of Greenwich */
|
||||
int tz_dsttime; /* Type of DST correction */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: gettimeofday
|
||||
*
|
||||
* Description:
|
||||
* Get the current time
|
||||
*
|
||||
* Conforming to SVr4, 4.3BSD. POSIX.1-2001 describes gettimeofday().
|
||||
* POSIX.1-2008 marks gettimeofday() as obsolete, recommending the use of
|
||||
* clock_gettime(2) instead.
|
||||
*
|
||||
* NuttX implements gettimeofday() as a thin layer around clock_gettime();
|
||||
*
|
||||
* Input Parameters:
|
||||
* tv - The location to return the current time
|
||||
* tz - Ignored
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; -1 is returned on failure with the errno variable
|
||||
* set appropriately.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int gettimeofday(FAR struct timeval *tv, FAR struct timezone *tz);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: settimeofday
|
||||
*
|
||||
* Description:
|
||||
* Set the current time
|
||||
*
|
||||
* Conforming to SVr4, 4.3BSD. POSIX.1-2001 describes gettimeofday() but
|
||||
* not settimeofday().
|
||||
*
|
||||
* NuttX implements settimeofday() as a thin layer around clock_settime();
|
||||
*
|
||||
* Input Parameters:
|
||||
* tv - The net to time to be set
|
||||
* tz - Ignored
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; -1 is returned on failure with the errno variable
|
||||
* set appropriately.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int settimeofday(FAR const struct timeval *tv, FAR struct timezone *tz);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: adjtime
|
||||
*
|
||||
* Description:
|
||||
* The adjtime() function gradually adjusts the system clock (as returned
|
||||
* by gettimeofday(2)). The amount of time by which the clock is to be
|
||||
* adjusted is specified in the structure pointed to by delta.
|
||||
*
|
||||
* This structure has the following form:
|
||||
*
|
||||
* struct timeval
|
||||
* {
|
||||
* time_t tv_sec; (seconds)
|
||||
* suseconds_t tv_usec; (microseconds)
|
||||
* };
|
||||
*
|
||||
* If the adjustment in delta is positive, then the system clock is
|
||||
* speeded up by some small percentage (i.e., by adding a small amount of
|
||||
* time to the clock value in each second) until the adjustment has been
|
||||
* completed. If the adjustment in delta is negative, then the clock is
|
||||
* slowed down in a similar fashion.
|
||||
*
|
||||
* If a clock adjustment from an earlier adjtime() call is already in
|
||||
* progress at the time of a later adjtime() call, and delta is not NULL
|
||||
* for the later call, then the earlier adjustment is stopped, but any
|
||||
* already completed part of that adjustment is not undone.
|
||||
*
|
||||
* If olddelta is not NULL, then the buffer that it points to is used to
|
||||
* return the amount of time remaining from any previous adjustment that
|
||||
* has not yet been completed.
|
||||
*
|
||||
* NOTE: This is not a POSIX interface but derives from 4.3BSD, System V.
|
||||
* It is also supported for Linux compatibility.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_CLOCK_TIMEKEEPING
|
||||
int adjtime(FAR const struct timeval *delta, FAR struct timeval *olddelta);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: getitimer
|
||||
*
|
||||
* Description:
|
||||
* The getitimer() function will store the amount of time until the
|
||||
* specified timer, which, expires and the reload value of the timer
|
||||
* into the space pointed to by the value argument. The it_value member
|
||||
* of this structure will contain the amount of time before the timer
|
||||
* expires, or zero if the timer is disarmed. This value is returned as
|
||||
* the interval until timer expiration. The it_interval member of value
|
||||
* will contain the reload value last set by setitime().
|
||||
*
|
||||
* Input Parameters:
|
||||
* which - The predefined timer id
|
||||
* value - The current timer value
|
||||
*
|
||||
* Returned Value:
|
||||
* If the getitimer() succeeds, a value of 0 (OK) will be returned.
|
||||
* If an error occurs, the value -1 (ERROR) will be returned, and errno
|
||||
* set to indicate the error.
|
||||
*
|
||||
* EINVAL - The which argument does not correspond to an predefined ID.
|
||||
*
|
||||
* Assumptions/Limitations:
|
||||
* Due to the asynchronous operation of this function, the time reported
|
||||
* by this function could be significantly more than that actual time
|
||||
* remaining on the timer at any time.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int getitimer(int which, FAR struct itimerval *value);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: setitimer
|
||||
*
|
||||
* Description:
|
||||
* The setitimer() function sets the time until the next expiration of
|
||||
* the timer specified by which from the it_value member of the value
|
||||
* argument and arm the timer if the it_value member of value is non-zero.
|
||||
* If the specified timer was already armed when setitimer() is
|
||||
* called, this call will reset the time until next expiration to the
|
||||
* value specified. If the it_value member of value is zero, the timer
|
||||
* will be disarmed. The effect of disarming or resetting a timer with
|
||||
* pending expiration notifications is unspecified.
|
||||
*
|
||||
* The reload value of the timer will be set to the value specified by the
|
||||
* it_interval member of value. When a timer is armed with a non-zero
|
||||
* it_interval, a periodic (or repetitive) timer is specified.
|
||||
*
|
||||
* Time values that are between two consecutive non-negative integer
|
||||
* multiples of the resolution of the specified timer will be rounded up
|
||||
* to the larger multiple of the resolution. Quantization error will not
|
||||
* cause the timer to expire earlier than the rounded time value.
|
||||
*
|
||||
* If the argument ovalue is not NULL, the setitimer() function will
|
||||
* store, in the location referenced by ovalue, a value representing the
|
||||
* previous amount of time before the timer would have expired, or zero if
|
||||
* the timer was disarmed, together with the previous timer reload value.
|
||||
* Timers will not expire before their scheduled time.
|
||||
*
|
||||
* Input Parameters:
|
||||
* which - The predefined timer id
|
||||
* value - Specifies the timer value to set
|
||||
* ovalue - A location in which to return the time remaining from the
|
||||
* previous timer setting.
|
||||
*
|
||||
* Returned Value:
|
||||
* If the setitimer() succeeds, a value of 0 (OK) will be returned.
|
||||
* If an error occurs, the value -1 (ERROR) will be returned, and errno set
|
||||
* to indicate the error.
|
||||
*
|
||||
* EINVAL - The which argument does not correspond to an predefined ID.
|
||||
* EINVAL - A value structure specified a microsecond value less than zero
|
||||
* or greater than or equal to 1000 million, and the it_value member of
|
||||
* that structure did not specify zero seconds and nanoseconds.
|
||||
*
|
||||
* Assumptions:
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int setitimer(int which, FAR const struct itimerval *value,
|
||||
FAR struct itimerval *ovalue);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: utimes
|
||||
*
|
||||
* Description:
|
||||
* The utimes() function shall set the access and modification times of the
|
||||
* file pointed to by the path argument to the value of the times argument.
|
||||
* utimes() function allows time specifications accurate to the microsecond.
|
||||
|
||||
* For utimes(), the times argument is an array of timeval structures. The
|
||||
* first array member represents the date and time of last access, and the
|
||||
* second member represents the date and time of last modification. The times
|
||||
* in the timeval structure are measured in seconds and microseconds since
|
||||
* the Epoch, although rounding toward the nearest second may occur.
|
||||
|
||||
* If the times argument is a null pointer, the access and modification times
|
||||
* of the file shall be set to the current time. The effective user ID of the
|
||||
* process shall match the owner of the file, has write access to the file or
|
||||
* appropriate privileges to use this call in this manner. Upon completion,
|
||||
* utimes() shall mark the time of the last file status change, st_ctime, for
|
||||
* update.
|
||||
*
|
||||
* Input Parameters:
|
||||
* path - Specifies the file to be modified
|
||||
* times - Specifies the time value to set
|
||||
*
|
||||
* Returned Value:
|
||||
* Upon successful completion, 0 shall be returned. Otherwise, -1 shall be
|
||||
* returned and errno shall be set to indicate the error, and the file
|
||||
* times shall not be affected.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int utimes(FAR const char *path, const struct timeval times[2]);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: futimes
|
||||
*
|
||||
* Description:
|
||||
* futimens() update the timestamps of a file with nanosecond precision.
|
||||
* This contrasts with the historical utime(2) and utimes(2), which permit
|
||||
* only second and microsecond precision, respectively, when setting file
|
||||
* timestamps. With futimens() the file whose timestamps are to be updated
|
||||
* is specified via an open file descriptor, fd.
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd - Specifies the fd to be modified
|
||||
* times - Specifies the time value to set
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, futimens() return 0.
|
||||
* On error, -1 is returned and errno is set to indicate the error.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int futimes(int fd, const struct timeval tv[2]);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: futimes
|
||||
*
|
||||
* Description:
|
||||
* futimens() update the timestamps of a file with nanosecond precision.
|
||||
* This contrasts with the historical utime(2) and utimes(2), which permit
|
||||
* only second and microsecond precision, respectively, when setting file
|
||||
* timestamps.
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd - Specifies the fd to be modified
|
||||
* times - Specifies the time value to set
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, futimens() return 0.
|
||||
* On error, -1 is returned and errno is set to indicate the error.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int futimens(int fd, const struct timespec times[2]);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: gethrtime
|
||||
*
|
||||
* Description:
|
||||
* Get the current time
|
||||
*
|
||||
* Returned Value:
|
||||
* The current value of the system time in ns
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
hrtime_t gethrtime(void);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_SYS_TIME_H */
|
||||
@@ -0,0 +1,296 @@
|
||||
/****************************************************************************
|
||||
* include/sys/types.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_SYS_TYPES_H
|
||||
#define __INCLUDE_SYS_TYPES_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/compiler.h>
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Alternative values for type bool (for historic reasons) */
|
||||
|
||||
#ifndef TRUE
|
||||
# define TRUE 1
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
# define FALSE 0
|
||||
#endif
|
||||
|
||||
/* NULL is usually defined in stddef.h (which includes this file) */
|
||||
|
||||
#ifndef NULL
|
||||
/* SDCC is sensitive to NULL pointer type conversions, and C++ defines
|
||||
* NULL as zero
|
||||
*/
|
||||
|
||||
# if defined(SDCC) || defined(__SDCC) || defined(__cplusplus)
|
||||
# define NULL (0)
|
||||
# else
|
||||
# define NULL ((void*)0)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Scheduling Priorities.
|
||||
*
|
||||
* NOTES:
|
||||
* - Only the idle task can take the true minimum priority.
|
||||
* - These definitions are non-standard internal definitions and, for
|
||||
* portability reasons, should not be used by application software.
|
||||
*/
|
||||
|
||||
#define SCHED_PRIORITY_MAX 255
|
||||
#define SCHED_PRIORITY_DEFAULT 100
|
||||
#define SCHED_PRIORITY_MIN 1
|
||||
#define SCHED_PRIORITY_IDLE 0
|
||||
|
||||
/****************************************************************************
|
||||
* Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/* Misc. scalar types */
|
||||
|
||||
/* mode_t is an integer type used for file attributes. mode_t needs
|
||||
* to be at least 16-bits but, in fact, must be sizeof(int) because it is
|
||||
* passed via varargs.
|
||||
*/
|
||||
|
||||
typedef unsigned int mode_t;
|
||||
|
||||
/* size_t is used for sizes of memory objects.
|
||||
* ssize_t is used for a count of bytes or an error indication.
|
||||
*
|
||||
* See also definitions of SIZE_MAX et al in limits.h.
|
||||
*
|
||||
* REVISIT: size_t belongs in stddef.h
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_SMALL_MEMORY
|
||||
|
||||
typedef uint16_t size_t;
|
||||
typedef int16_t ssize_t;
|
||||
typedef uint16_t rsize_t;
|
||||
|
||||
#else /* CONFIG_SMALL_MEMORY */
|
||||
|
||||
typedef _size_t size_t;
|
||||
typedef _ssize_t ssize_t;
|
||||
typedef _size_t rsize_t;
|
||||
|
||||
#endif /* CONFIG_SMALL_MEMORY */
|
||||
|
||||
/* uid_t is used for user IDs
|
||||
* gid_t is used for group IDs.
|
||||
*/
|
||||
|
||||
typedef int16_t uid_t;
|
||||
typedef int16_t gid_t;
|
||||
|
||||
/* dev_t is used for device IDs */
|
||||
|
||||
typedef uint16_t dev_t;
|
||||
|
||||
/* ino_t is used for file serial numbers */
|
||||
|
||||
typedef uint16_t ino_t;
|
||||
|
||||
/* nlink_t is used for link counts */
|
||||
|
||||
typedef uint16_t nlink_t;
|
||||
|
||||
/* pid_t is used for process IDs and process group IDs. It must be signed
|
||||
* because negative PID values are used to represent invalid PIDs.
|
||||
*/
|
||||
|
||||
typedef int16_t pid_t;
|
||||
|
||||
/* id_t is a general identifier that can be used to contain at least a pid_t,
|
||||
* uid_t, or gid_t.
|
||||
*/
|
||||
|
||||
typedef int16_t id_t;
|
||||
|
||||
/* Unix requires a key of type key_t defined in file sys/types.h for
|
||||
* requesting resources such as shared memory segments, message queues and
|
||||
* semaphores. A key is simply an integer of type key_t
|
||||
*/
|
||||
|
||||
typedef int16_t key_t;
|
||||
|
||||
/* Signed integral type of the result of subtracting two pointers */
|
||||
|
||||
typedef intptr_t ptrdiff_t;
|
||||
|
||||
#if !defined(__cplusplus)
|
||||
/* Wide, 16-bit character types. wchar_t is a built-in type in C++ and
|
||||
* its declaration here may cause compilation errors on some compilers.
|
||||
*
|
||||
* REVISIT: wchar_t belongs in stddef.h
|
||||
*/
|
||||
|
||||
typedef uint16_t wchar_t;
|
||||
#endif
|
||||
|
||||
/* wint_t
|
||||
* An integral type capable of storing any valid value of wchar_t, or WEOF.
|
||||
*/
|
||||
|
||||
typedef int wint_t;
|
||||
|
||||
/* wctype_t
|
||||
* A scalar type of a data object that can hold values which represent
|
||||
* locale-specific character classification.
|
||||
*/
|
||||
|
||||
typedef int wctype_t;
|
||||
|
||||
/* fsblkcnt_t and fsfilcnt_t shall be defined as unsigned integer types. */
|
||||
|
||||
typedef uint32_t fsblkcnt_t;
|
||||
typedef uint32_t fsfilcnt_t;
|
||||
|
||||
/* blkcnt_t and off_t are signed integer types.
|
||||
*
|
||||
* blkcnt_t is used for file block counts.
|
||||
* off_t is used for file offsets and sizes.
|
||||
* fpos_t is used for file positions.
|
||||
*
|
||||
* Hence, all should be independent of processor architecture.
|
||||
*/
|
||||
|
||||
typedef uint32_t blkcnt_t;
|
||||
typedef int32_t off_t;
|
||||
typedef off_t fpos_t;
|
||||
|
||||
#ifdef CONFIG_HAVE_LONG_LONG
|
||||
/* Large file versions */
|
||||
|
||||
typedef int64_t off64_t;
|
||||
typedef int64_t fpos64_t;
|
||||
#endif
|
||||
|
||||
/* blksize_t is a signed integer value used for file block sizes */
|
||||
|
||||
typedef int16_t blksize_t;
|
||||
|
||||
/* Network related */
|
||||
|
||||
typedef unsigned int socklen_t;
|
||||
typedef uint16_t sa_family_t;
|
||||
|
||||
/* Used for system times in clock ticks. This type is the natural width of
|
||||
* the system timer.
|
||||
*
|
||||
* NOTE: The signed-ness of clock_t is not specified at OpenGroup.org. An
|
||||
* unsigned type is used to support the full range of the internal clock.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TIME64
|
||||
typedef uint64_t clock_t;
|
||||
#else
|
||||
typedef uint32_t clock_t;
|
||||
#endif
|
||||
|
||||
/* The type useconds_t shall be an unsigned integer type capable of storing
|
||||
* values at least in the range [0, 1000000]. The type suseconds_t shall be
|
||||
* a signed integer type capable of storing values at least in the range
|
||||
* [-1, 1000000].
|
||||
*/
|
||||
|
||||
typedef uint32_t useconds_t;
|
||||
typedef int32_t suseconds_t;
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
/* This is the smallest integer type that will hold a bitset of all CPUs */
|
||||
|
||||
#if (CONFIG_SMP_NCPUS <= 8)
|
||||
typedef volatile uint8_t cpu_set_t;
|
||||
#elif (CONFIG_SMP_NCPUS <= 16)
|
||||
typedef volatile uint16_t cpu_set_t;
|
||||
#elif (CONFIG_SMP_NCPUS <= 32)
|
||||
typedef volatile uint32_t cpu_set_t;
|
||||
#else
|
||||
# error SMP: Extensions needed to support this number of CPUs
|
||||
#endif
|
||||
#else
|
||||
typedef volatile uint8_t cpu_set_t;
|
||||
#endif /* CONFIG_SMP */
|
||||
|
||||
/* BSD types provided only to support porting to NuttX. */
|
||||
|
||||
typedef unsigned char u_char;
|
||||
typedef unsigned short u_short;
|
||||
typedef unsigned int u_int;
|
||||
typedef unsigned long u_long;
|
||||
|
||||
/* SYSV types provided only to support porting to NuttX. */
|
||||
|
||||
typedef unsigned char unchar;
|
||||
typedef unsigned short ushort;
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned long ulong;
|
||||
typedef signed char s_char;
|
||||
typedef FAR char *caddr_t;
|
||||
|
||||
/* These were defined by ISO C without the first `_'. */
|
||||
|
||||
typedef uint8_t u_int8_t;
|
||||
typedef uint16_t u_int16_t;
|
||||
typedef uint32_t u_int32_t;
|
||||
#ifdef __INT24_DEFINED
|
||||
typedef uint24_t u_int24_t;
|
||||
#endif
|
||||
#ifdef __INT64_DEFINED
|
||||
typedef uint64_t u_int64_t;
|
||||
#endif
|
||||
|
||||
/* Task entry point */
|
||||
|
||||
typedef CODE int (*main_t)(int argc, FAR char *argv[]);
|
||||
|
||||
/* POSIX-like OS return values: */
|
||||
|
||||
enum
|
||||
{
|
||||
ERROR = -1,
|
||||
OK = 0,
|
||||
};
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#endif /* __INCLUDE_SYS_TYPES_H */
|
||||
@@ -0,0 +1,155 @@
|
||||
/****************************************************************************
|
||||
* include/sys/uio.h
|
||||
*
|
||||
* Copyright (C) 2017 Grefory Nutt. All rights reserved.
|
||||
* Copyright (C) 2015 Stavros Polymenis. All rights reserved.
|
||||
* Author: Stavros Polymenis <sp@orbitalfox.com>
|
||||
* 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_SYS_UIO_H
|
||||
#define __INCLUDE_SYS_UIO_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
struct iovec
|
||||
{
|
||||
FAR void *iov_base; /* Base address of I/O memory region */
|
||||
size_t iov_len; /* Size of the memory pointed to by iov_base */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: readv()
|
||||
*
|
||||
* Description:
|
||||
* The readv() function is equivalent to read(), except as described below.
|
||||
* The readv() function places the input data into the 'iovcnt' buffers
|
||||
* specified by the members of the 'iov' array: iov[0], iov[1], ...,
|
||||
* iov['iovcnt'-1]. The 'iovcnt' argument is valid if greater than 0 and
|
||||
* less than or equal to IOV_MAX as defined in limits.h.
|
||||
*
|
||||
* Each iovec entry specifies the base address and length of an area in
|
||||
* memory where data should be placed. The readv() function will always
|
||||
* fill an area completely before proceeding to the next.
|
||||
*
|
||||
* TODO: pon successful completion, readv() will mark for update the
|
||||
* st_atime field of the file.
|
||||
*
|
||||
* Input Parameters:
|
||||
* filedes - The open file descriptor for the file to be read
|
||||
* iov - Array of read buffer descriptors
|
||||
* iovcnt - Number of elements in iov[]
|
||||
*
|
||||
* Returned Value:
|
||||
* Upon successful completion, readv() will return a non-negative integer
|
||||
* indicating the number of bytes actually read. Otherwise, the functions
|
||||
* will return -1 and set errno to indicate the error. See read() for the
|
||||
* list of returned errno values. In addition, the readv() function will
|
||||
* fail if:
|
||||
*
|
||||
* EINVAL.
|
||||
* The sum of the iov_len values in the iov array overflowed an ssize_t
|
||||
* or The 'iovcnt' argument was less than or equal to 0, or greater than
|
||||
* IOV_MAX (Not implemented).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
ssize_t readv(int fildes, FAR const struct iovec *iov, int iovcnt);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: writev()
|
||||
*
|
||||
* Description:
|
||||
* The writev() function is equivalent to write(), except as described
|
||||
* below. The writev() function will gather output data from the 'iovcnt'
|
||||
* buffers specified by the members of the 'iov' array: iov[0], iov[1],
|
||||
* ..., iov[iovcnt-1]. The 'iovcnt' argument is valid if greater than 0
|
||||
* and less than or equal to IOV_MAX, as defined in limits.h.
|
||||
*
|
||||
* Each iovec entry specifies the base address and length of an area in
|
||||
* memory from which data should be written. The writev() function always
|
||||
* writes a complete area before proceeding to the next.
|
||||
*
|
||||
* If 'filedes' refers to a regular file and all of the iov_len members in
|
||||
* the array pointed to by iov are 0, writev() will return 0 and have no
|
||||
* other effect. For other file types, the behavior is unspecified.
|
||||
*
|
||||
* TODO: If the sum of the iov_len values is greater than SSIZE_MAX, the
|
||||
* operation will fail and no data will be transferred.
|
||||
*
|
||||
* Input Parameters:
|
||||
* filedes - The open file descriptor for the file to be read
|
||||
* iov - Array of read buffer descriptors
|
||||
* iovcnt - Number of elements in iov[]
|
||||
*
|
||||
* Returned Value:
|
||||
* Upon successful completion, writev() shall return the number of bytes
|
||||
* actually written. Otherwise, it shall return a value of -1, the file-
|
||||
* pointer shall remain unchanged, and errno shall be set to indicate an
|
||||
* error. See write for the list of returned errno values. In addition,
|
||||
* the readv() function will fail if:
|
||||
*
|
||||
* EINVAL.
|
||||
* The sum of the iov_len values in the iov array overflowed an ssize_t
|
||||
* or The 'iovcnt' argument was less than or equal to 0, or greater than
|
||||
* IOV_MAX (Not implemented).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
ssize_t writev(int fildes, FAR const struct iovec *iov, int iovcnt);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_SYS_UIO_H */
|
||||
@@ -0,0 +1,73 @@
|
||||
/****************************************************************************
|
||||
* include/sys/un.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_SYS_UN_H
|
||||
#define __INCLUDE_SYS_UN_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* The size of sun_path is not specified. Different implementations us
|
||||
* different sizes. BSD4.3 uses a size of 108; BSD4.4 uses a size of 104.
|
||||
* Most implementation use a size that ranges from 92 to 108. Applications
|
||||
* should not assume a particular length for sun_path.
|
||||
*
|
||||
* _POSIX_PATH_MAX would be a good choice too.
|
||||
*/
|
||||
|
||||
#define UNIX_PATH_MAX 108
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* A UNIX domain socket address is represented in the following structure.
|
||||
* This structure must be cast compatible with struct sockaddr.
|
||||
*/
|
||||
|
||||
struct sockaddr_un
|
||||
{
|
||||
sa_family_t sun_family; /* AF_UNIX */
|
||||
char sun_path[UNIX_PATH_MAX]; /* pathname */
|
||||
};
|
||||
|
||||
/* There are three types of addresses:
|
||||
*
|
||||
* 1. pathname: sun_path holds a null terminated string. The allocated
|
||||
* size may be variable: sizeof(sa_family_t) + strlen(pathname) + 1
|
||||
* 2. unnamed: A unix socket that is not bound to any name. This case
|
||||
* there is no path. The allocated size may be sizeof(sa_family_t)
|
||||
* 3. abstract. The abstract path is distinguished because the pathname
|
||||
* consists of only the NUL terminator. The allocated size is then
|
||||
* sizeof(s_family_t) + 1.
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#endif /* __INCLUDE_SYS_UN_H */
|
||||
@@ -0,0 +1,81 @@
|
||||
/****************************************************************************
|
||||
* include/sys/utsname.h
|
||||
*
|
||||
* Copyright (C) 2015 Stavros Polymenis. All rights reserved.
|
||||
* Author: Stavros Polymenis <sp@orbitalfox.com>
|
||||
*
|
||||
* 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_SYS_UTSNAME_H
|
||||
#define __INCLUDE_SYS_UTSNAME_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define SYS_NAMELEN 21
|
||||
#define VERSION_NAMELEN 41
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* These are the values returned by uname:
|
||||
*
|
||||
* FIELD Default
|
||||
* sysname NuttX
|
||||
* nodename CONFIG_LIB_HOSTNAME
|
||||
* release From version.h
|
||||
* version From version.h
|
||||
* machine CONFIG_ARCH
|
||||
*/
|
||||
|
||||
struct utsname
|
||||
{
|
||||
char sysname[SYS_NAMELEN]; /* Name of OS */
|
||||
char nodename[HOST_NAME_MAX]; /* Name of this network node */
|
||||
char release[SYS_NAMELEN]; /* Release level */
|
||||
char version[VERSION_NAMELEN]; /* Version level */
|
||||
char machine[SYS_NAMELEN]; /* Machine hardware */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
int uname(FAR struct utsname *name);
|
||||
|
||||
#endif /* __INCLUDE_SYS_UTSNAME_H */
|
||||
@@ -0,0 +1,46 @@
|
||||
/****************************************************************************
|
||||
* include/sys/vfs.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_SYS_VFS_H
|
||||
#define __INCLUDE_SYS_VFS_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
/* sys/vfs.h is just an alternative location for the information in
|
||||
* sys/statfs.h.
|
||||
*/
|
||||
|
||||
#include <sys/statfs.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#endif /* __INCLUDE_SYS_VFS_H */
|
||||
@@ -0,0 +1,103 @@
|
||||
/****************************************************************************
|
||||
* include/sys/wait.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_SYS_WAIT_H
|
||||
#define __INCLUDE_SYS_WAIT_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
|
||||
#ifdef CONFIG_SCHED_WAITPID
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* The following are provided for analysis of returned status values.
|
||||
* Encoded is as follows as 2 bytes of _info(MS) then two bytes of code (LS).
|
||||
* Code:
|
||||
* 0 - Child has exited, info is the exit code.
|
||||
* Other values - Not implemented
|
||||
*/
|
||||
|
||||
#define WEXITSTATUS(s) (((s) >> 8) & 0xff) /* Return exit status */
|
||||
#define WIFEXITED(s) (((s) & 0xff) == 0) /* True: Child exited normally */
|
||||
|
||||
#define WIFCONTINUED(s) (false) /* True: Child has been continued */
|
||||
#define WIFSIGNALED(s) (false) /* True: Child exited due to uncaught signal */
|
||||
#define WIFSTOPPED(s) (false) /* True: Child is currently stopped */
|
||||
#define WSTOPSIG(s) (false) /* Return signal number that caused process to stop */
|
||||
#define WTERMSIG(s) (false) /* Return signal number that caused process to terminate */
|
||||
|
||||
/* The following symbolic constants are possible values for the options
|
||||
* argument to waitpid() (1) and/or waitid() (2),
|
||||
*/
|
||||
|
||||
#define WCONTINUED (1 << 0) /* Status for child that has been continued (1)(2) */
|
||||
#define WNOHANG (1 << 1) /* Do not wait if status not available (1) (2) */
|
||||
#define WUNTRACED (1 << 2) /* Report status of stopped child process (1) */
|
||||
#define WEXITED (1 << 3) /* Wait for processes that have exited (2) */
|
||||
#define WSTOPPED (1 << 4) /* Status for child stopped on signal (2) */
|
||||
#define WNOWAIT (1 << 5) /* Keep the process in a waitable state (2) */
|
||||
#define WCLAIMED (1 << 7) /* Non-standard (For internal OS use only) */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
enum idtype_e
|
||||
{
|
||||
P_PID = 1,
|
||||
P_PGID = 2,
|
||||
P_ALL = 3
|
||||
};
|
||||
typedef enum idtype_e idtype_t;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
pid_t wait(FAR int *stat_loc);
|
||||
int waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options);
|
||||
pid_t waitpid(pid_t pid, FAR int *stat_loc, int options);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* CONFIG_SCHED_WAITPID */
|
||||
#endif /* __INCLUDE_SYS_WAIT_H */
|
||||
Reference in New Issue
Block a user