Kernel-space ctypes.h support?

Sebastian Huber sebastian.huber at embedded-brains.de
Thu Sep 13 08:28:40 UTC 2018


Hello,

I test currently the tqm8xx BSP which worked fine until RTEMS 5. The 
problem is that this BSP uses strtoul() to get some system configuration 
parameters from the boot loader. The Newlib used by RTEMS 5 has now 
support for C locales in strtoul(). The C locale support needs an 
executing thread with a valid Newlib reentrancy structure. This is 
definitely not the case during bsp_start().

I think we need a kernel-space ctypes.h implementation without this C 
locale stuff and string support functions which use this. For example 
FreeBSD has this:

sys/sys/ctype.h
sys/libkern/strtoul.c

Maybe add a <rtems/string.h> header file with this content:

#define rtems_isspace(c)    ((c) == ' ' || ((c) >= '\t' && (c) <= '\r'))
#define rtems_isascii(c)    (((c) & ~0x7f) == 0)
#define rtems_isupper(c)    ((c) >= 'A' && (c) <= 'Z')
#define rtems_islower(c)    ((c) >= 'a' && (c) <= 'z')
#define rtems_isalpha(c)    (rtems_isupper(c) || rtems_islower(c))
#define rtems_isdigit(c)    ((c) >= '0' && (c) <= '9')
#define rtems_isxdigit(c)    (rtems_isdigit(c) \
                   || ((c) >= 'A' && (c) <= 'F') \
                   || ((c) >= 'a' && (c) <= 'f'))
#define rtems_isprint(c)    ((c) >= ' ' && (c) <= '~')
#define rtems_toupper(c)    ((c) - 0x20 * (((c) >= 'a') && ((c) <= 'z')))
#define rtems_tolower(c)    ((c) + 0x20 * (((c) >= 'A') && ((c) <= 'Z')))

unsigned rtems_strtol(const char *nptr, char **endptr, int base);
unsigned long rtems_strtoul(const char *nptr, char **endptr, int base);

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the devel mailing list