C library: Add swab()

This commit is contained in:
Gregory Nutt 2017-02-16 14:42:27 -06:00
parent 3b351615be
commit a49b349614
4 changed files with 17 additions and 9 deletions

View File

@ -251,10 +251,10 @@
# define I2C_FLT_SHIFT (0) /* Bits 0-3: I2C programmable filter factor */
# define I2C_FLT_MASK (15 << I2C_FLT_SHIFT)
# define I2C_FLT(n) ((uint8_t)(n) << I2C_FLT_SHIFT)
# define I2C_FLT_STARTF (1 << 4) /* I2C bus start detect flag */
# define I2C_FLT_SSIE (1 << 5) /* I2C bus stop or start interrupt enable */
# define I2C_FLT_STOPF (1 << 6) /* I2C bus stop detect flag */
# define I2C_FLT_SHEN (1 << 7) /* Stop hold enable */
# define I2C_FLT_STARTF (1 << 4) /* I2C bus start detect flag */
# define I2C_FLT_SSIE (1 << 5) /* I2C bus stop or start interrupt enable */
# define I2C_FLT_STOPF (1 << 6) /* I2C bus stop detect flag */
# define I2C_FLT_SHEN (1 << 7) /* Stop hold enable */
#endif
/* I2C Range Address register (8-bit) */

View File

@ -106,7 +106,11 @@ namespace std
using ::execv;
#endif
// Other
// Byte operations
using ::swab;
// getopt and friends
using ::getopt;

View File

@ -203,7 +203,11 @@ int execl(FAR const char *path, ...);
int execv(FAR const char *path, FAR char *const argv[]);
#endif
/* Other */
/* Byte operations */
void swab(FAR const void *src, FAR void *dest, ssize_t nbytes);
/* getopt and friends */
int getopt(int argc, FAR char *const argv[], FAR const char *optstring);

View File

@ -1,7 +1,7 @@
############################################################################
# libc/unistd/Make.defs
#
# Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
# Copyright (C) 2011-2012, 2017 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
@ -35,8 +35,8 @@
# Add the unistd C files to the build
CSRCS += lib_access.c lib_getopt.c lib_getoptargp.c lib_getoptindp.c
CSRCS += lib_getoptoptp.c
CSRCS += lib_access.c lib_swab.c
CSRCS += lib_getopt.c lib_getoptargp.c lib_getoptindp.c lib_getoptoptp.c
ifneq ($(CONFIG_NFILE_DESCRIPTORS),0)
ifneq ($(CONFIG_DISABLE_ENVIRON),y)