Initializing a pointer to struct __locale_t to point to a string "C"
is not such a bright idea in the long run...
Signed-off by: Corinna Vinschen <corinna@vinschen.de>
Don't use global variables. This allows to call loadlocale from
the yet to be created newlocale().
Rename _thr_locale_t to __locale_t (these locales are not restricted
to threads so the name is misleading).
Along these lines, fix _set_ctype to take a __locale_t as parameter.
Signed-off by: Corinna Vinschen <corinna@vinschen.de>
The _reent members _current_category and _current_locale are not
used at all. _current_locale is set to "C" in various points of
the code but its value is just as unused as _current_category.
This patch redefines these members without changing the size of the
structure to allow for an implementation of per-thread locales per
POSIX-1.2008 (i.e. uselocale and usage of the per-thread locale in
subsequent function calls).
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
gettimeofday is currently guarded with __MISC_VISIBLE || __XSI_VISIBLE.
However, gettimeofday should be always visible, as in GLibc.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
The proper location for these functions has always been <stdio.h>, however
XPG4 and SUSv2 did mandate a duplicate declaration in <unistd.h>. cuserid
was dropped in SUSv3 (it was marked legacy since XPG4) and the ctermid
declaration in <unistd.h> was made optional and obsolete in SUSv4.
Fixes: https://cygwin.com/ml/cygwin/2016-05/msg00002.html
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
The following testcase:
$ cat > test.c <<EOF
#include <sys/select.h>
#include <sys/time.h>
EOF
$ gcc -c test.c
emits the following error:
/usr/include/sys/reent.h:276:3: error: expected specifier-qualifier-list befor
e ‘_fpos64_t’
_fpos64_t _EXFNPTR(_seek64, (struct _reent *, _PTR, _fpos64_t, int));
^
The reason is that the load order from sys/select.h includes sys/_types.h
before sys/config.h has been included from anywhere else. sys/_types.h
defines _fpos64_t only if __LARGE64_FILES is defined, but it never is in
this scenario. So sys/_types.h has to make sure to get the configuration
info by itself.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Always provide register_t via <sys/types.h> for glibc and BSD
compatibility. Define __BIT_TYPES_DEFINED__ to 1 like glibc for legacy
header files.
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* libc/include/sys/types.h: Fix a comment about Cygwin. Simplify
guarding pthread types against inclusion on Cygwin.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Resurrect <machine/_user_types.h> for use in <sys/types.h>. Newlib
targets may provide an own version of <machine/types.h> in their machine
directory to add custom user types for <sys/types.h>. Check the
_SYS_TYPES_H header guard to prevent a direct include of
<machine/types.h>, since the <machine/types.h> file is a Newlib
speciality.
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
Various FreeBSD source and header files need a typedef __size_t via
<sys/_types.h>. Unfortunately the GCC provided <stddef.h> uses
#if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \
|| defined(__DragonFly__) \
|| defined(__FreeBSD_kernel__)
/* __size_t is a typedef on FreeBSD 5, must not trash it. */
#elif defined (__VMS__)
/* __size_t is also a typedef on VMS. */
#else
#define __size_t
#endif
and therefore defines __size_t on Newlib targets which would trash a
__size_t typedef. Include <stddef.h> before <sys/_types.h> in
<sys/types.h> and undefine __size_t in <sys/_types.h> as a workaround.
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
Include <machine/endian.h> in <sys/types.h> if __BSD_VISIBLE for BSD
compatibility. This is in line with glibc <sys/types.h>.
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
Add __va_list to <sys/_types.h> for BSD compatibility. In FreeBSD this
typedef is provided by the various architecture-specific
<machine/_types.h> in a copy and paste manner.
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
Newlib defines defaults for internal types via <sys/_types.h> and uses
<machine/_types.h> to let targets define their own type if necessary.
Previously for example
#ifndef __dev_t_defined
typedef short __dev_t;
#endif
However, the __*_t_defined pattern conflicts with the glibc type guard
pattern for user types, e.g. dev_t in this example. Introduce a
__machine_*_t_defined pattern for internal types (defined by
<machine/_types.h>, used by <sys/_types.h>). For example
#ifndef __machine_dev_t_defined
typedef short __dev_t;
#endif
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
Remove off_t typedef from cygwin/types.h thus relying on sys/types.h.
Introduce winsup/cygwin/machine/_types.h and move some types shared
with newlib into it. Get rid of their definition in cygwin/types.h.
Add same handling for __key_t/key_t as for the other types.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Copy definitions of off_t, dev_t, uid_t, and gid_t verbatim from latest
FreeBSD <sys/types.h>.
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
This change solves a glibc/BSD compatibility problem.
glibc and BSD use double underscore types for internal types. The Linux
port of Newlib uses some glibc provided internal type definitions which
are not protected by guard defines, e.g. __off_t. To avoid a conflict
Newlib uses single underscore types for some internal types, e.g.
_off_t. However, for BSD compatibility we have to define the internal
types with double underscore names in <sys/_types.h>.
The header file <machine/types.h> is Newlib-specific. It was used
instead of <sys/_types.h> to provide the internal type definitions
_CLOCK_T, _TIME_T_, _CLOCKID_T_, _TIMER_T_, and __suseconds_t. Move
these definitions to <sys/_types.h> (there exist two instances of this
file, one for Linux and one for all other targets). This makes the
_HAVE_SYSTYPES configuration define obsolete (could possibly break the
__RDOS__ target). Use the standard <sys/_types.h> include throughout.
Move __loff_t defintion to default (non-Linux) <sys/_types.h>. Define
it via _off64_t to avoid a dependency on the compiler.
Provide the __off_t definition via default (non-Linux) <sys/_types.h>
based on _off_t for all systems except Cygwin. For Cygwin use _off64_t.
Define off_t via __off_t.
Provide the __pid_t definition via default (non-Linux) <sys/_types.h>.
This prevents a potential __pid_t and pid_t incompatibility. Add BSD
guard defines for pid_t.
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
Move the kernel dependent parts of <sys/time.h> to new system-specific
header file <machine/_time.h>. Provide an empty default implementation.
Add a specialized implementation for RTEMS.
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
Each version of SUS specifies a different value for _POSIX_VERSION,
_POSIX2_VERSION, and _XOPEN_VERSION. glibc also changes the value
of the other _POSIX2_ variables but not the _POSIX_* variables.
_POSIX_TIMERS should be set to a version number, not just 1.
The _POSIX_V7_* macros were missing, which was not noticed because
the V6 values were aliased in sysconf (<unistd.h>).
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
u_char, u_short, u_int, u_long are BSD-only types. Remove them from
Cygwin headers which are supposed to be used in a non-BSD scenario.
Drop special Cygwin handling of those types in sys/types.h.
newlib:
* libc/include/sys/types.h (u_char,u_short,u_int,u_long): Drop
Cygwin exception.
cygwin:
* fhandler_socket.cc (fhandler_socket::ioctl): Accommodate change
in include/asm/socket.h. Continue using u_long since that's the
MS type here.
* include/asm/socket.h: Since the type given in _IOR/_IOW macros
is only used for its sizeof, replace u_long with equivalent long.
* netdb.h (getnetbyaddr): Fix prototype.
* netinet/ip.h: Replace old BSD-only types with generically defined
old BSD types (u_char -> u_int8_t, etc).
* netinet/tcp.h: Ditto.
* netinet/udp.h: Ditto.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
The u_intN_t types are BSD types but sanctioned by POSIX. They are
always defined when using Glibc headers so we follow suit.
newlib:
* libc/include/sys/types.h: Drop outdated __INTTYPES_DEFINED__
macro. Always define u_intN_t types.
cygwin:
* include/cygwin/types.h: Remove definition of u_intN_t types.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
While C++11 was the first version of the standard to use C99 functionality,
TR1 (for C++03) also does, and G++ does not distinguish between C++98 and
C++03, or when TR1 is in use. Therefore, while not strictly correct for
"pure" C++98, enabling C99 for all C++ usage is the simplest solution (and
much better than always using -D_GNU_SOURCE as on Linux).
See thread starting: https://sourceware.org/ml/newlib/2016/msg00297.html
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
These types are available in SVID as well.
* libc/include/sys/types.h (u_char,u_short,u_int,u_long): Replace
__BSD_VISIBLE with __MISC_VISIBLE.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Move the sig*set macros following the functions inside their feature
test macro conditional.
This fixes the build on bare-metal targets following
commit 5c78499ae2.
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
Acked-by: Corinna Vinschen <vinschen@redhat.com>