[PATCH] Importing inttypes.h library and related methods.
Aditya Upadhyay
aadit0402 at gmail.com
Mon Jun 12 18:52:08 UTC 2017
---
cpukit/Makefile.am | 20 +++---
cpukit/configure.ac | 4 +-
cpukit/inttypes/Makefile.am | 14 ++++
cpukit/inttypes/imaxabs.c | 44 +++++++++++++
cpukit/inttypes/imaxdiv.c | 53 ++++++++++++++++
cpukit/inttypes/strtoimax.c | 144 ++++++++++++++++++++++++++++++++++++++++++
cpukit/inttypes/strtoumax.c | 135 +++++++++++++++++++++++++++++++++++++++
cpukit/inttypes/wcstoimax.c | 151 ++++++++++++++++++++++++++++++++++++++++++++
cpukit/inttypes/wcstoumax.c | 144 ++++++++++++++++++++++++++++++++++++++++++
cpukit/preinstall.am | 59 +++++++++--------
10 files changed, 724 insertions(+), 44 deletions(-)
create mode 100644 cpukit/inttypes/Makefile.am
create mode 100644 cpukit/inttypes/imaxabs.c
create mode 100644 cpukit/inttypes/imaxdiv.c
create mode 100644 cpukit/inttypes/strtoimax.c
create mode 100644 cpukit/inttypes/strtoumax.c
create mode 100644 cpukit/inttypes/wcstoimax.c
create mode 100644 cpukit/inttypes/wcstoumax.c
diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am
index 2c2f2e5..045017e 100644
--- a/cpukit/Makefile.am
+++ b/cpukit/Makefile.am
@@ -7,6 +7,7 @@ include $(top_srcdir)/automake/multilib.am
_SUBDIRS = . score rtems sapi posix
_SUBDIRS += dev
_SUBDIRS += dtc/libfdt
+_SUBDIRS += inttypes
_SUBDIRS += libcrypt
_SUBDIRS += libcsupport libblock libfs
_SUBDIRS += libdrvmgr
@@ -59,25 +60,22 @@ include_HEADERS += include/memory.h
include_HEADERS += libmisc/xz/xz.h
include_sys_HEADERS += libcsupport/include/sys/event.h
-include_sys_HEADERS += libcsupport/include/sys/poll.h
-include_sys_HEADERS += libcsupport/include/sys/statvfs.h
-include_sys_HEADERS += libcsupport/include/sys/utsname.h
-
-include_sys_HEADERS += include/sys/endian.h
-include_sys_HEADERS += include/sys/priority.h
-
-if !HAS_NEWLIB_20170522_HEADER
-include_sys_HEADERS += include/sys/_iovec.h
-include_sys_HEADERS += include/sys/uio.h
include_sys_HEADERS += libcsupport/include/sys/filio.h
include_sys_HEADERS += libcsupport/include/sys/ioccom.h
include_sys_HEADERS += libcsupport/include/sys/ioctl.h
+include_sys_HEADERS += libcsupport/include/sys/poll.h
include_sys_HEADERS += libcsupport/include/sys/sockio.h
+include_sys_HEADERS += libcsupport/include/sys/statvfs.h
include_sys_HEADERS += libcsupport/include/sys/_termios.h
include_sys_HEADERS += libcsupport/include/sys/termios.h
include_sys_HEADERS += libcsupport/include/sys/ttycom.h
include_sys_HEADERS += libcsupport/include/sys/ttydefaults.h
-endif
+include_sys_HEADERS += libcsupport/include/sys/utsname.h
+
+include_sys_HEADERS += include/sys/endian.h
+include_sys_HEADERS += include/sys/uio.h
+include_sys_HEADERS += include/sys/_iovec.h
+include_sys_HEADERS += include/sys/priority.h
if LIBNETWORKING
include_rtems_bsdnetdir = $(includedir)/rtems/bsdnet
diff --git a/cpukit/configure.ac b/cpukit/configure.ac
index 8d5b322..ad0865b 100644
--- a/cpukit/configure.ac
+++ b/cpukit/configure.ac
@@ -166,9 +166,6 @@ if test x"$RTEMS_USE_NEWLIB" = xyes ; then
AC_CHECK_DECLS([__getreent],[],[RTEMS_TOOL_CHAIN_ERROR],[#include <sys/reent.h>])
fi
-AC_CHECK_HEADER([sys/socket.h],[],[])
-AM_CONDITIONAL(HAS_NEWLIB_20170522_HEADER,[test x"${ac_cv_header_sys_socket_h}" = xyes])
-
RTEMS_CHECK_MULTIPROCESSING
RTEMS_CHECK_POSIX_API
RTEMS_CHECK_NETWORKING
@@ -464,6 +461,7 @@ score/cpu/sparc64/Makefile
score/cpu/v850/Makefile
score/cpu/no_cpu/Makefile
posix/Makefile
+inttypes/Makefile
libblock/Makefile
libdrvmgr/Makefile
libfs/Makefile
diff --git a/cpukit/inttypes/Makefile.am b/cpukit/inttypes/Makefile.am
new file mode 100644
index 0000000..c90b872
--- /dev/null
+++ b/cpukit/inttypes/Makefile.am
@@ -0,0 +1,14 @@
+include $(top_srcdir)/automake/multilib.am
+include $(top_srcdir)/automake/compile.am
+
+
+noinst_LIBRARIES = libinttypes.a
+
+libinttypes_a_SOURCES = imaxdiv.c imaxabs.c strtoimax.c strtoumax.c wcstoimax.c wcstoumax.c
+
+libinttypes_a_CPPFLAGS = $(AM_CPPFLAGS)
+
+
+#include $(srcdir)/preinstall.am
+include $(top_srcdir)/automake/subdirs.am
+include $(top_srcdir)/automake/local.am
diff --git a/cpukit/inttypes/imaxabs.c b/cpukit/inttypes/imaxabs.c
new file mode 100644
index 0000000..fe9331f
--- /dev/null
+++ b/cpukit/inttypes/imaxabs.c
@@ -0,0 +1,44 @@
+/*-
+ * Copyright (c) 2001 Mike Barcroft <mike at FreeBSD.org>
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+/* intmax_t data type defined here */
+
+#include <stdint.h>
+#include <stdio.h>
+
+#include <rtems/inttypes.h>
+
+
+intmax_t
+imaxabs(
+ intmax_t j)
+{
+ return (j < 0 ? -j : j);
+}
diff --git a/cpukit/inttypes/imaxdiv.c b/cpukit/inttypes/imaxdiv.c
new file mode 100644
index 0000000..765481e
--- /dev/null
+++ b/cpukit/inttypes/imaxdiv.c
@@ -0,0 +1,53 @@
+/*-
+ * Copyright (c) 2001 Mike Barcroft <mike at FreeBSD.org>
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+/* intmax_t data type defined here */
+
+#include <stdint.h>
+
+#include <rtems/inttypes.h>
+
+imaxdiv_t
+imaxdiv(
+ intmax_t numer, intmax_t denom)
+{
+ imaxdiv_t retval;
+
+ retval.quot = numer / denom;
+ retval.rem = numer % denom;
+
+ #if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
+ if (numer >= 0 && retval.rem < 0) {
+ retval.quot++;
+ retval.rem -= denom;
+ }
+ #endif
+ return (retval);
+}
diff --git a/cpukit/inttypes/strtoimax.c b/cpukit/inttypes/strtoimax.c
new file mode 100644
index 0000000..092a2a9
--- /dev/null
+++ b/cpukit/inttypes/strtoimax.c
@@ -0,0 +1,144 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+/*
+ * This source code was extracted from the Q8 package created and
+ * placed in the PUBLIC DOMAIN by Doug Gwyn <gwyn at arl.mil>
+ * last edit: 1999/11/05 gwyn at arl.mil
+ *
+ * Implements subclause 7.8.2 of ISO/IEC 9899:1999 (E).
+ *
+ * This particular implementation requires the matching <inttypes.h>.
+ * It also assumes that character codes for A..Z and a..z are in
+ * contiguous ascending order; this is true for ASCII but not EBCDIC.
+ */
+
+#include <stdlib.h>
+#include <errno.h>
+#include <ctype.h>
+#include <inttypes.h>
+
+/* Helper macros */
+
+/* convert digit character to number, in any base */
+
+#define ToNumber(c) (isdigit(c) ? (c) - '0' : \
+ isupper(c) ? (c) - 'A' + 10 : \
+ islower(c) ? (c) - 'a' + 10 : \
+ -1 /* "invalid" flag */ \
+ )
+/* validate converted digit character for specific base */
+
+#define valid(n, b) ((n) >= 0 && (n) < (b))
+
+intmax_t
+strtoimax(
+ nptr, endptr, base)
+ register const char * __restrict__ nptr;
+ char ** __restrict__ endptr;
+ register int base;
+{
+ register uintmax_t accum;
+ register int n;
+ int minus;
+ int toobig;
+
+ /* in case no conversion's performed */
+
+ if (endptr != NULL)
+ *endptr = (char *)nptr;
+
+ /* unspecified behavior */
+
+ if (base < 0 || base == 1 || base > 36){
+ errno = EDOM;
+ return 0;
+ }
+
+ /* skip initial, possibly empty sequence of white-space characters */
+
+ while (isspace(*nptr))
+ ++nptr;
+
+ /* process subject sequence: */
+
+ /* optional sign */
+
+ if ((minus = *nptr == '-') || *nptr == '+')
+ ++nptr;
+
+ if (base == 0) {
+ if (*nptr == '0') {
+ if (nptr[1] == 'X' || nptr[1] == 'x'){
+ base = 16;
+ }else{
+ base = 8;
+ }
+ }else{
+ base = 10;
+ }
+
+ }
+
+ /* optional "0x" or "0X" for base 16 */
+
+ /* skip past this prefix */
+
+ if (base == 16 && *nptr == '0' && (nptr[1] == 'X' || nptr[1] == 'x'))
+ nptr += 2;
+
+ /* check whether there is at least one valid digit */
+
+ n = ToNumber(*nptr);
+ ++nptr;
+
+ /* subject seq. not of expected form */
+
+ if (!valid(n, base))
+ return 0;
+
+ accum = n;
+
+ for (toobig = 0; n = ToNumber(*nptr), valid(n, base); ++nptr)
+
+ /* major wrap-around */
+
+ if (accum > (uintmax_t)(INTMAX_MAX / base + 2))
+
+ /* but keep scanning */
+
+ toobig = 1;
+ else
+ accum = base * accum + n;
+
+ /* points to first not-valid-digit */
+
+ if (endptr != NULL)
+ *endptr = (char *)nptr;
+
+ if (minus){
+ if (accum > (uintmax_t)INTMAX_MAX + 1)
+ toobig = 1;
+ }
+ else
+ if (accum > (uintmax_t)INTMAX_MAX)
+ toobig = 1;
+
+ if (toobig){
+ errno = ERANGE;
+ return minus ? INTMAX_MIN : INTMAX_MAX;
+ }
+ else
+ return (intmax_t)(minus ? -accum : accum);
+}
+
+long long __attribute__ (
+(alias ("strtoimax")))
+
+strtoll (
+const char* __restrict__ nptr,
+char ** __restrict__ endptr, int base );
+
diff --git a/cpukit/inttypes/strtoumax.c b/cpukit/inttypes/strtoumax.c
new file mode 100644
index 0000000..48c818b
--- /dev/null
+++ b/cpukit/inttypes/strtoumax.c
@@ -0,0 +1,135 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+/*
+ * This source code was extracted from the Q8 package created and
+ * placed in the PUBLIC DOMAIN by Doug Gwyn <gwyn at arl.mil>
+ * last edit: 1999/11/05 gwyn at arl.mil
+ *
+ * Implements subclause 7.8.2 of ISO/IEC 9899:1999 (E).
+ *
+ * This particular implementation requires the matching <inttypes.h>.
+ * It also assumes that character codes for A..Z and a..z are in
+ * contiguous ascending order; this is true for ASCII but not EBCDIC.
+*/
+
+#include <stdlib.h>
+#include <errno.h>
+#include <ctype.h>
+#include <inttypes.h>
+
+/* Helper macros */
+
+/* convert digit character to number, in any base */
+
+#define ToNumber(c) (isdigit(c) ? (c) - '0' : \
+ isupper(c) ? (c) - 'A' + 10 : \
+ islower(c) ? (c) - 'a' + 10 : \
+ -1 /* "invalid" flag */ \
+ )
+/* validate converted digit character for specific base */
+
+#define valid(n, b) ((n) >= 0 && (n) < (b))
+
+uintmax_t
+strtoumax(
+ nptr, endptr, base)
+ register const char * __restrict__ nptr;
+ char ** __restrict__ endptr;
+ register int base;
+{
+ register uintmax_t accum;
+ register uintmax_t next;
+ register int n;
+ int minus;
+ int toobig;
+
+ /* in case no conversion's performed */
+
+ if ( endptr != NULL )
+ *endptr = (char *)nptr;
+
+ /* unspecified behavior */
+
+ if ( base < 0 || base == 1 || base > 36 ){
+ errno = EDOM;
+ return 0;
+ }
+
+ /* skip initial, possibly empty sequence of white-space characters */
+
+ while ( isspace(*nptr) )
+ ++nptr;
+
+ /* process subject sequence: */
+
+ /* optional sign (yes!) */
+
+ if ((minus = *nptr == '-') || *nptr == '+')
+ ++nptr;
+
+ if (base == 0){
+ if (*nptr == '0'){
+ if (nptr[1] == 'X' || nptr[1] == 'x')
+ base = 16;
+ else
+ base = 8;
+ }
+ else
+ base = 10;
+ }
+
+ /* optional "0x" or "0X" for base 16 */
+
+ if (base == 16 && *nptr == '0' && (nptr[1] == 'X' || nptr[1] == 'x'))
+
+ /* skip past this prefix */
+
+ nptr += 2;
+
+ /* check whether there is at least one valid digit */
+
+ n = ToNumber(*nptr);
+ ++nptr;
+
+ /* subject seq. not of expected form */
+
+ if ( !valid(n, base) )
+ return 0;
+
+ accum = n;
+
+ for ( toobig = 0; n = ToNumber(*nptr), valid(n, base); ++nptr )
+
+ /* major wrap-around and minor wrap-around */
+
+ if (accum > UINTMAX_MAX / base + 1 || (next = base * accum + n) < accum)
+
+ /* but keep scanning */
+
+ toobig = 1;
+ else
+ accum = next;
+
+ /* points to first not-valid-digit */
+
+ if (endptr != NULL)
+ *endptr = (char *)nptr;
+
+ if (toobig){
+ errno = ERANGE;
+ return UINTMAX_MAX;
+ }
+ else
+ return minus ? -accum : accum; /* (yes!) */
+}
+
+unsigned long long
+ __attribute__ (
+ (alias ("strtoumax")))
+strtoull (const char* __restrict__ nptr,
+ char ** __restrict__ endptr, int base);
+
diff --git a/cpukit/inttypes/wcstoimax.c b/cpukit/inttypes/wcstoimax.c
new file mode 100644
index 0000000..4ec0e91
--- /dev/null
+++ b/cpukit/inttypes/wcstoimax.c
@@ -0,0 +1,151 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+/*
+ * This source code was extracted from the Q8 package created and
+ * placed in the PUBLIC DOMAIN by Doug Gwyn <gwyn at arl.mil>
+ * last edit: 1999/11/05 gwyn at arl.mil
+ * Implements subclause 7.8.2 of ISO/IEC 9899:1999 (E).
+ * This particular implementation requires the matching <inttypes.h>.
+ * It also assumes that character codes for A..Z and a..z are in
+ * contiguous ascending order; this is true for ASCII but not EBCDIC.
+*/
+
+#include <wchar.h>
+#include <errno.h>
+#include <ctype.h>
+#include <inttypes.h>
+
+/* convert digit wide character to number, in any base */
+
+#define ToWNumber(c) (iswdigit(c) ? (c) - L'0' : \
+ iswupper(c) ? (c) - L'A' + 10 : \
+ iswlower(c) ? (c) - L'a' + 10 : \
+ -1 /* "invalid" flag */ \
+ )
+
+/* validate converted digit character for specific base */
+
+#define valid(n, b) ((n) >= 0 && (n) < (b))
+
+intmax_t
+wcstoimax(
+ nptr, endptr, base)
+ register const wchar_t * __restrict__ nptr;
+ wchar_t ** __restrict__ endptr;
+ register int base;
+{
+ /* accumulates converted value */
+
+ register uintmax_t accum;
+
+ /* numeral from digit character */
+
+ register int n;
+
+ /* set iff minus sign seen */
+
+ int minus;
+
+ /* set iff value overflows */
+
+ int toobig;
+
+ /* in case no conv performed */
+
+ if (endptr != NULL)
+ *endptr = (wchar_t *)nptr;
+
+ /* unspecified behavior */
+
+ if (base < 0 || base == 1 || base > 36){
+ errno = EDOM;
+ return 0;
+ }
+
+ /* skip initial, possibly empty sequence of white-space w.characters */
+
+ while (iswspace(*nptr))
+ ++nptr;
+
+ /* process subject sequence: */
+
+ /* optional sign */
+
+ if ((minus = *nptr == L'-') || *nptr == L'+')
+ ++nptr;
+
+ if (base == 0){
+ if (*nptr == L'0'){
+ if (nptr[1] == L'X' || nptr[1] == L'x')
+ base = 16;
+ else
+ base = 8;
+ }
+ else
+ base = 10;
+ }
+
+ /* optional "0x" or "0X" for base 16 */
+
+ if ( base == 16 && *nptr == L'0' && (nptr[1] == L'X' || nptr[1] == L'x'))
+
+ /* skip past this prefix */
+
+ nptr += 2;
+
+ /* check whether there is at least one valid digit */
+
+ n = ToWNumber(*nptr);
+ ++nptr;
+
+ /* subject seq. not of expected form */
+
+ if (!valid(n, base))
+ return 0;
+
+ accum = n;
+
+ for (toobig = 0; n = ToWNumber(*nptr), valid(n, base); ++nptr)
+
+ /* major wrap-around */
+
+ if (accum > (uintmax_t)(INTMAX_MAX / base + 2))
+
+ /* but keep scanning */
+
+ toobig = 1;
+ else
+ accum = base * accum + n;
+
+ /* -> first not-valid-digit */
+
+ if (endptr != NULL)
+ *endptr = (wchar_t *)nptr;
+
+ if (minus){
+ if (accum > (uintmax_t)INTMAX_MAX + 1)
+ toobig = 1;
+ }
+ else
+ if (accum > (uintmax_t)INTMAX_MAX)
+ toobig = 1;
+
+ if (toobig){
+ errno = ERANGE;
+ return minus ? INTMAX_MIN : INTMAX_MAX;
+ }
+ else
+ return (intmax_t)(minus ? -accum : accum);
+}
+
+long long
+__attribute__ (
+ (alias ("wcstoimax")))
+wcstoll (
+ const wchar_t* __restrict__ nptr,
+ wchar_t ** __restrict__ endptr, int base);
+
diff --git a/cpukit/inttypes/wcstoumax.c b/cpukit/inttypes/wcstoumax.c
new file mode 100644
index 0000000..890126e
--- /dev/null
+++ b/cpukit/inttypes/wcstoumax.c
@@ -0,0 +1,144 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+/*
+ * This source code was extracted from the Q8 package created and
+ * placed in the PUBLIC DOMAIN by Doug Gwyn <gwyn at arl.mil>
+ * last edit: 1999/11/05 gwyn at arl.mil
+ * Implements subclause 7.8.2 of ISO/IEC 9899:1999 (E).
+ * This particular implementation requires the matching <inttypes.h>.
+ * It also assumes that character codes for A..Z and a..z are in
+ * contiguous ascending order; this is true for ASCII but not EBCDIC.
+*/
+
+#include <wchar.h>
+#include <errno.h>
+#include <ctype.h>
+#include <inttypes.h>
+
+/* convert digit wide character to number, in any base */
+
+#define ToWNumber(c) (iswdigit(c) ? (c) - L'0' : \
+ iswupper(c) ? (c) - L'A' + 10 : \
+ iswlower(c) ? (c) - L'a' + 10 : \
+ -1 /* "invalid" flag */ \
+ )
+
+/* validate converted digit character for specific base */
+#define valid(n, b) ((n) >= 0 && (n) < (b))
+
+uintmax_t
+wcstoumax(
+ nptr, endptr, base)
+ register const wchar_t * __restrict__ nptr;
+ wchar_t ** __restrict__ endptr;
+ register int base;
+{
+ /* accumulates converted value */
+
+ register uintmax_t accum, next;
+
+ /* numeral from digit character */
+
+ register int n;
+
+ /* set iff minus sign seen */
+
+ int minus;
+
+ /* set iff value overflows */
+
+ int toobig;
+
+ /* in case no conv performed */
+
+ if (endptr != NULL)
+ *endptr = (wchar_t *)nptr;
+
+ /* unspecified behavior */
+
+ if (base < 0 || base == 1 || base > 36){
+ errno = EDOM;
+ return 0;
+ }
+
+
+ /* skip initial, possibly empty sequence of white-space w.characters */
+
+ while (iswspace(*nptr))
+ ++nptr;
+
+ /* process subject sequence: */
+
+ /* optional sign */
+
+ if ((minus = *nptr == L'-') || *nptr == L'+')
+ ++nptr;
+
+ if (base == 0){
+ if (*nptr == L'0'){
+ if (nptr[1] == L'X' || nptr[1] == L'x')
+ base = 16;
+ else
+ base = 8;
+ }
+ else
+ base = 10;
+ }
+
+ /* optional "0x" or "0X" for base 16 */
+
+ if ( base == 16 && *nptr == L'0' && (nptr[1] == L'X' || nptr[1] == L'x'))
+
+ /* skip past this prefix */
+
+ nptr += 2;
+
+ /* check whether there is at least one valid digit */
+
+ n = ToWNumber(*nptr);
+ ++nptr;
+
+ /* subject seq. not of expected form */
+
+ if (!valid(n, base))
+ return 0;
+
+ accum = n;
+
+ for (toobig = 0; n = ToWNumber(*nptr), valid(n, base); ++nptr)
+
+ /* minor wrap-around */
+
+ if (accum > UINTMAX_MAX / base + 1 || (next = base * accum + n) < accum)
+
+ /* but keep scanning */
+
+ toobig = 1;
+ else
+ accum = next;
+
+ /* -> first not-valid-digit */
+
+ if ( endptr != NULL )
+ *endptr = (wchar_t *)nptr;
+
+ if ( toobig )
+ {
+ errno = ERANGE;
+ return UINTMAX_MAX;
+ }
+ else
+ return minus ? -accum : accum; /* (yes!) */
+}
+
+unsigned long long
+__attribute__ (
+ (alias ("wcstoumax")))
+wcstoull (
+ const wchar_t* __restrict__ nptr,
+ wchar_t ** __restrict__ endptr, int base);
+
diff --git a/cpukit/preinstall.am b/cpukit/preinstall.am
index ef09294..6f94076 100644
--- a/cpukit/preinstall.am
+++ b/cpukit/preinstall.am
@@ -71,35 +71,6 @@ $(PROJECT_INCLUDE)/sys/event.h: libcsupport/include/sys/event.h $(PROJECT_INCLUD
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/event.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/event.h
-$(PROJECT_INCLUDE)/sys/poll.h: libcsupport/include/sys/poll.h $(PROJECT_INCLUDE)/sys/$(dirstamp)
- $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/poll.h
-PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/poll.h
-
-$(PROJECT_INCLUDE)/sys/statvfs.h: libcsupport/include/sys/statvfs.h $(PROJECT_INCLUDE)/sys/$(dirstamp)
- $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/statvfs.h
-PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/statvfs.h
-
-$(PROJECT_INCLUDE)/sys/utsname.h: libcsupport/include/sys/utsname.h $(PROJECT_INCLUDE)/sys/$(dirstamp)
- $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/utsname.h
-PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/utsname.h
-
-$(PROJECT_INCLUDE)/sys/endian.h: include/sys/endian.h $(PROJECT_INCLUDE)/sys/$(dirstamp)
- $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/endian.h
-PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/endian.h
-
-$(PROJECT_INCLUDE)/sys/priority.h: include/sys/priority.h $(PROJECT_INCLUDE)/sys/$(dirstamp)
- $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/priority.h
-PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/priority.h
-
-if !HAS_NEWLIB_20170522_HEADER
-$(PROJECT_INCLUDE)/sys/_iovec.h: include/sys/_iovec.h $(PROJECT_INCLUDE)/sys/$(dirstamp)
- $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/_iovec.h
-PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/_iovec.h
-
-$(PROJECT_INCLUDE)/sys/uio.h: include/sys/uio.h $(PROJECT_INCLUDE)/sys/$(dirstamp)
- $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/uio.h
-PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/uio.h
-
$(PROJECT_INCLUDE)/sys/filio.h: libcsupport/include/sys/filio.h $(PROJECT_INCLUDE)/sys/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/filio.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/filio.h
@@ -112,10 +83,18 @@ $(PROJECT_INCLUDE)/sys/ioctl.h: libcsupport/include/sys/ioctl.h $(PROJECT_INCLUD
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/ioctl.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/ioctl.h
+$(PROJECT_INCLUDE)/sys/poll.h: libcsupport/include/sys/poll.h $(PROJECT_INCLUDE)/sys/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/poll.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/poll.h
+
$(PROJECT_INCLUDE)/sys/sockio.h: libcsupport/include/sys/sockio.h $(PROJECT_INCLUDE)/sys/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/sockio.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/sockio.h
+$(PROJECT_INCLUDE)/sys/statvfs.h: libcsupport/include/sys/statvfs.h $(PROJECT_INCLUDE)/sys/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/statvfs.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/statvfs.h
+
$(PROJECT_INCLUDE)/sys/_termios.h: libcsupport/include/sys/_termios.h $(PROJECT_INCLUDE)/sys/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/_termios.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/_termios.h
@@ -131,7 +110,27 @@ PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/ttycom.h
$(PROJECT_INCLUDE)/sys/ttydefaults.h: libcsupport/include/sys/ttydefaults.h $(PROJECT_INCLUDE)/sys/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/ttydefaults.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/ttydefaults.h
-endif
+
+$(PROJECT_INCLUDE)/sys/utsname.h: libcsupport/include/sys/utsname.h $(PROJECT_INCLUDE)/sys/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/utsname.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/utsname.h
+
+$(PROJECT_INCLUDE)/sys/endian.h: include/sys/endian.h $(PROJECT_INCLUDE)/sys/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/endian.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/endian.h
+
+$(PROJECT_INCLUDE)/sys/uio.h: include/sys/uio.h $(PROJECT_INCLUDE)/sys/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/uio.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/uio.h
+
+$(PROJECT_INCLUDE)/sys/_iovec.h: include/sys/_iovec.h $(PROJECT_INCLUDE)/sys/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/_iovec.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/_iovec.h
+
+$(PROJECT_INCLUDE)/sys/priority.h: include/sys/priority.h $(PROJECT_INCLUDE)/sys/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/priority.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/priority.h
+
if LIBNETWORKING
$(PROJECT_INCLUDE)/rtems/bsdnet/$(dirstamp):
@$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/bsdnet
--
2.7.4
More information about the devel
mailing list