This is the mail archive of the mailing list for the newlib project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

POSIX 2008 C Extensions and restrict Keyword


I was reviewing a standards checker report on RTEMS and noticed
that there are a couple of areas in newlib that need some attention.
I am sure there are more than this one case that fall into these
two categories of issues. But I wanted to get some general guidance
on how to proceed based on this one case -- strtok() and strtok_r().

#include <string.h>

char *strtok(char *restrict s1, const char *restrict s2);

[CX]  char *strtok_r(char *restrict s, const char *restrict sep,
       char **restrict lasts);

(1) From the notes, the restrict keyword was added for alignment
with ISO/IEC 9899:1999 which is C99.  The current sys/cdefs.h
defines __restrict which is conditionalized based on the compiler
and language version. Would it be OK to start sweeping __restrict
in per POSIX/C99?

(2) strtok_r() is part of the POSIX extensions to the C Library. But
it is wrapped only in __STRICT_ANSI__ while other methods
in string.h are wrapped in this:

!defined(__STRICT_ANSI__) || (_XOPEN_SOURCE - 0) >= 500.

Should all the methods marked CX (C Library Extensions) in the
POSIX standard be in a similar conditional? If so what should the
test be?

That should be enough to start a large chunk of work based on. :)

Joel Sherrill, Ph.D.             Director of Research & Development        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]