uclibc: sync with upstream

This commit is contained in:
Maxim Anisimov
2019-03-19 10:17:54 +03:00
parent 6cc9b18381
commit 56960f9cc3
15 changed files with 136 additions and 74 deletions

View File

@ -9,6 +9,7 @@ Vineet Gupta <Vineet.Gupta1@synopsys.com>
CSKY:
Guo Ren <ren_guo@c-sky.com>
Mao Han <han_mao@c-sky.com>
MIPS:
Matthew Fortune <Matthew.Fortune@imgtec.com>

View File

@ -271,9 +271,10 @@ typedef struct
#define EM_AARCH64 183 /* ARM AARCH64 */
#define EM_MICROBLAZE 189 /* Xilinx Microblaze */
#define EM_ARCV2 195 /* ARCv2 Cores */
#define EM_CSKY 252 /* C-SKY Cores */
/* NEXT FREE NUMBER: Increment this after adding your official arch number */
#define EM_NUM 196
#define EM_NUM 253
/* If it is necessary to assign new unofficial EM_* values, please pick large
random numbers (0x8523, 0xa7f2, etc.) to minimize the chances of collision

View File

@ -18,7 +18,7 @@ do { \
/* Here we define the magic numbers that this dynamic loader should accept */
#define MAGIC1 EM_MCORE
#undef MAGIC2
#define MAGIC2 EM_CSKY
/* Used for error messages */
#define ELF_TARGET "csky"

View File

@ -32,11 +32,11 @@ static const char *__ether_line(const char *line, struct ether_addr *addr)
if (!res)
return NULL;
while (*line && (*line != ' ') && (*line != '\t'))
while (*line && (*line != '\n') && (*line != ' ') && (*line != '\t'))
line++;
while (*line && ((*line == ' ') || (*line == '\t')))
while (*line && (*line != '\n') && ((*line == ' ') || (*line == '\t')))
line++;
return (*line) ? line : NULL;
return (*line && (*line != '\n')) ? line : NULL;
}
/*
@ -45,9 +45,7 @@ static const char *__ether_line(const char *line, struct ether_addr *addr)
*/
static const char *__ether_line_w(char *line, struct ether_addr *addr)
{
char *end = strchr(line, '#');
if (!end)
end = strchr(line, '\n');
char *end = strpbrk(line, "#\n");
if (end)
*end = '\0';
return __ether_line(line, addr);

View File

@ -156,9 +156,10 @@ FILE *open_memstream(char **bufloc, size_t *sizeloc)
__STDIO_STREAM_VALIDATE(fp);
return fp;
}
free(cookie->buf);
}
free(cookie->buf);
EXIT_cookie:
free(cookie);

View File

@ -11,65 +11,61 @@
#include <endian.h>
#include <bits/align64bit.h>
#include <bits/types.h>
#include <bits/wordsize.h>
/* 64-bit libc uses the kernel's 'struct statfs', accessed via the
statfs() syscall; 32-bit libc uses the kernel's 'struct statfs64'
and accesses it via the statfs64() syscall. All the various
APIs offered by libc use the kernel shape for their struct statfs
structure; the only difference is that 32-bit programs not
using __USE_FILE_OFFSET64 only see the low 32 bits of some
of the fields (the __fsblkcnt_t and __fsfilcnt_t fields). */
#if defined __USE_FILE_OFFSET64
# define __field64(type, type64, name) type64 name
#elif __WORDSIZE == 64
# define __field64(type, type64, name) type name
#elif __BYTE_ORDER == __LITTLE_ENDIAN
# define __field64(type, type64, name) \
type name __attribute__((__aligned__ (__alignof__ (type64)))); int __##name##_pad
#else
# define __field64(type, type64, name) \
int __##name##_pad __attribute__((__aligned__ (__alignof__ (type64)))); type name
#endif
struct statfs
{
__U32_TYPE f_type;
__U32_TYPE f_bsize;
#ifndef __USE_FILE_OFFSET64
# if __BYTE_ORDER == __LITTLE_ENDIAN
__U32_TYPE f_blocks;
__U32_TYPE __pad1;
__U32_TYPE f_bfree;
__U32_TYPE __pad2;
__U32_TYPE f_bavail;
__U32_TYPE __pad3;
__U32_TYPE f_files;
__U32_TYPE __pad4;
__U32_TYPE f_ffree;
__U32_TYPE __pad5;
# else
__U32_TYPE __pad1;
__U32_TYPE f_blocks;
__U32_TYPE __pad2;
__U32_TYPE f_bfree;
__U32_TYPE __pad3;
__U32_TYPE f_bavail;
__U32_TYPE __pad4;
__U32_TYPE f_files;
__U32_TYPE __pad5;
__U32_TYPE f_ffree;
# endif /* __LITTLE_ENDIAN */
#else
__U64_TYPE f_blocks;
__U64_TYPE f_bfree;
__U64_TYPE f_bavail;
__U64_TYPE f_files;
__U64_TYPE f_ffree;
#endif /* __USE_FILE_OFFSET64 */
__SWORD_TYPE f_type;
__SWORD_TYPE f_bsize;
__field64(__fsblkcnt_t, __fsblkcnt64_t, f_blocks);
__field64(__fsblkcnt_t, __fsblkcnt64_t, f_bfree);
__field64(__fsblkcnt_t, __fsblkcnt64_t, f_bavail);
__field64(__fsfilcnt_t, __fsfilcnt64_t, f_files);
__field64(__fsfilcnt_t, __fsfilcnt64_t, f_ffree);
__fsid_t f_fsid;
__U32_TYPE f_namelen;
__U32_TYPE f_frsize;
__U32_TYPE f_flags;
__U32_TYPE f_spare[4];
} __ARCH_64BIT_ALIGNMENT__;
__SWORD_TYPE f_namelen;
__SWORD_TYPE f_frsize;
__SWORD_TYPE f_flags;
__SWORD_TYPE f_spare[4];
};
#undef __field64
#ifdef __USE_LARGEFILE64
struct statfs64
{
__U32_TYPE f_type;
__U32_TYPE f_bsize;
__SWORD_TYPE f_type;
__SWORD_TYPE f_bsize;
__U64_TYPE f_blocks;
__U64_TYPE f_bfree;
__U64_TYPE f_bavail;
__U64_TYPE f_files;
__U64_TYPE f_ffree;
__fsid_t f_fsid;
__U32_TYPE f_namelen;
__U32_TYPE f_frsize;
__U32_TYPE f_flags;
__U32_TYPE f_spare[4];
__SWORD_TYPE f_namelen;
__SWORD_TYPE f_frsize;
__SWORD_TYPE f_flags;
__SWORD_TYPE f_spare[4];
};
#endif

View File

@ -30,7 +30,7 @@ int fcntl64(int fd, int cmd, ...)
arg = va_arg(list, long);
va_end(list);
if (SINGLE_THREAD_P || (cmd != F_SETLKW64))
if (SINGLE_THREAD_P || (cmd != F_SETLKW && cmd != F_SETLKW64))
return __NC(fcntl64)(fd, cmd, arg);
# ifdef __NEW_THREADS
oldtype = LIBC_CANCEL_ASYNC();

View File

@ -30,15 +30,6 @@ _syscall2(int, __libc_fstatfs, int, fd, struct statfs *, buf)
int __libc_fstatfs (int __fildes, struct statfs *__buf)
{
int err = INLINE_SYSCALL(fstatfs64, 3, __fildes, sizeof(*__buf), __buf);
if (err == 0) {
/* Did we overflow? */
if (__buf->__pad1 || __buf->__pad2 || __buf->__pad3 ||
__buf->__pad4 || __buf->__pad5) {
__set_errno(EOVERFLOW);
return -1;
}
}
return err;
};
/* Redefined fstatfs because we need it for backwards compatibility */

View File

@ -15,7 +15,11 @@
int ftruncate(int fd, __off_t length)
{
# if __WORDSIZE == 32
# if defined(__UCLIBC_SYSCALL_ALIGN_64BIT__)
return INLINE_SYSCALL(ftruncate64, 4, fd, 0, OFF_HI_LO(length));
# else
return INLINE_SYSCALL(ftruncate64, 3, fd, OFF_HI_LO(length));
# endif
# else
return ftruncate64(fd, length);
# endif

View File

@ -9,6 +9,7 @@
#include <sys/syscall.h>
#include <fcntl.h>
#include <stdarg.h>
#include <cancel.h>
#ifdef __NR_openat
# define __NR___syscall_openat __NR_openat
@ -16,13 +17,25 @@ static __inline__ _syscall4(int, __syscall_openat, int, fd, const char *, file,
int __openat(int fd, const char *file, int o_flag, ...)
{
#ifdef __NEW_THREADS
int oldtype, result;
#endif
va_list ap;
mode_t mode;
va_start(ap, o_flag);
mode = va_arg(ap, int);
va_end(ap);
return __syscall_openat(fd, file, o_flag, mode);
if (SINGLE_THREAD_P)
return __syscall_openat(fd, file, o_flag, mode);
#ifdef __NEW_THREADS
oldtype = LIBC_CANCEL_ASYNC ();
result = __syscall_openat(fd, file, o_flag, mode);
LIBC_CANCEL_RESET (oldtype);
return result;
#endif
}
strong_alias_untyped(__openat,openat)

View File

@ -18,16 +18,6 @@ extern __typeof(statfs) __libc_statfs attribute_hidden;
int __libc_statfs(const char *path, struct statfs *buf)
{
int err = INLINE_SYSCALL(statfs64, 3, path, sizeof(*buf), buf);
if (err == 0) {
/* Did we overflow? */
if (buf->__pad1 || buf->__pad2 || buf->__pad3 ||
buf->__pad4 || buf->__pad5) {
__set_errno(EOVERFLOW);
return -1;
}
}
return err;
}
# if defined __UCLIBC_LINUX_SPECIFIC__ || defined __UCLIBC_HAS_THREADS_NATIVE__

View File

@ -29,6 +29,16 @@
} \
result_var; })
#define INLINE_SYSCALL_NOERR_NCS(name, nr, args...) \
({ \
INTERNAL_SYSCALL_DECL(err); \
long res = INTERNAL_SYSCALL_NCS(name, err, nr, args); \
if (unlikely(INTERNAL_SYSCALL_ERROR_P(res, err))) { \
res = -res; \
} \
res; \
})
#define INTERNAL_SYSCALL_DECL(err) long err attribute_unused
#define INTERNAL_SYSCALL_ERROR_P(val, err) ((long) (err))

View File

@ -0,0 +1,49 @@
/* Copyright (C) 1997, 2001, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef _SYS_POLL_H
# error "Never use <bits/poll.h> directly; include <sys/poll.h> instead."
#endif
/* Event types that can be polled for. These bits may be set in `events'
to indicate the interesting event types; they will appear in `revents'
to indicate the status of the file descriptor. */
#define POLLIN 0x001 /* There is data to read. */
#define POLLPRI 0x002 /* There is urgent data to read. */
#define POLLOUT 0x004 /* Writing now will not block. */
#ifdef __USE_XOPEN
/* These values are defined in XPG4.2. */
# define POLLRDNORM 0x040 /* Normal data may be read. */
# define POLLRDBAND 0x080 /* Priority data may be read. */
# define POLLWRNORM POLLOUT /* Writing now will not block. */
# define POLLWRBAND 0x100 /* Priority data may be written. */
#endif
#ifdef __USE_GNU
/* These are extensions for Linux. */
# define POLLMSG 0x400
# define POLLREMOVE 0x800
# define POLLRDHUP 0x2000
#endif
/* Event types always implicitly polled for. These bits need not be set in
`events', but they will appear in `revents' to indicate the status of
the file descriptor. */
#define POLLERR 0x008 /* Error condition. */
#define POLLHUP 0x010 /* Hung up. */
#define POLLNVAL 0x020 /* Invalid polling request. */

View File

@ -146,15 +146,18 @@ CFLAGS-clock_nanosleep.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-close.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-connect.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-creat.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-creat64.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-fdatasync.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-fsync.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-lockf.c = -fexceptions
CFLAGS-lockf64.c = -fexceptions
CFLAGS-msgrcv.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-msgsnd.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-msync.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-nanosleep.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-open64.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-open.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-openat.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-pause.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-poll.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-ppoll.c = -fexceptions -fasynchronous-unwind-tables

View File

@ -292,7 +292,12 @@ __pthread_initialize_minimal_internal (void)
/* Make sure it meets the minimum size that allocate_stack
(allocatestack.c) will demand, which depends on the page size. */
#ifdef SHARED
extern size_t GLRO(dl_pagesize);
const uintptr_t pagesz = GLRO(dl_pagesize);
#else
const uintptr_t pagesz = sysconf (_SC_PAGESIZE);
#endif
const size_t minstack = pagesz + __static_tls_size + MINIMAL_REST_STACK;
if (limit.rlim_cur < minstack)
limit.rlim_cur = minstack;