Commit Graph

17829 Commits

Author SHA1 Message Date
Sebastian Huber 4de8754bac Change time_t to 64-bit by default
In order to avoid the year 2038 problem, define time_t to a signed
integer with at least 64-bits.  The type for time_t can be forced to
long with the --enable-newlib-long-time_t configure option or with the
_USE_LONG_TIME_T system configuration define.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2017-09-07 15:39:34 +02:00
Sebastian Huber ad45b86533 Remove harmful casts in gmtime_r()
In case time_t is long, then the cast to long is a nop.  In case time_t
is __int_least64_t, then the cast to long may truncate the value before
the division.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2017-09-07 15:39:34 +02:00
Sebastian Huber f9205f1d47 Let RTEMS provide clock()
Newlib uses _times_r() in clock().  The problem is that the _times_r()
clock frequency is defined by sysconf(_SC_CLK_TCK).  The clock frequency
of clock() is the constant CLOCKS_PER_SEC.

FreeBSD uses getrusage() for clock().  Since RTEMS has only one process,
the implementation can be simplified.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2017-09-07 07:41:07 +02:00
Corinna Vinschen e18b7ffa48 stdio.h: Don't define unlocked macros using static inline on C++
In C++, the usage of static inline functions for getchar_unlocked and
putchar_unlocked may result in error messages like

  error: ‘_putchar_unlocked’ was not declared in this scope

Fix this by not using the _getchar_unlocked and _putchar_unlocked
macros in C++.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-09-04 10:52:33 +02:00
Yaakov Selkowitz ff53f489fa cygwin: Document crypt_r
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-09-02 22:48:55 -05:00
Achim Gratz 5325111d03 Remove some dangerous advice from the FAQ 2017-09-02 20:41:43 +02:00
Yaakov Selkowitz 51d1fb715d include: fix ffs, fls guards
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-08-30 12:29:47 -05:00
Corinna Vinschen 192986ab03 newlib: string/Makefile.am (CHEWOUT_FILES): Add strnstr.def
Regenerate strings/Makefile.in

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-08-30 16:48:55 +02:00
Corinna Vinschen 5fc315b597 newlib: strnstr: drop traditional synopisis
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-08-30 16:45:36 +02:00
Sichen Zhao 42885ea4b8 Add man page entry for strnstr.c. 2017-08-30 15:10:07 +02:00
Sichen Zhao f22054c94d Modify strnstr.c. 2017-08-30 15:08:58 +02:00
Corinna Vinschen cdbec10e79 cygwin: add strptime %F fix to release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-08-29 21:12:21 +02:00
Brian Inglis d8e2463c75 winsup/cygwin/libc/strptime.cc(__strptime) fix %F width 2017-08-29 21:10:06 +02:00
Corinna Vinschen 4dfaef8141 cygwin: document %s support in strptime
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-08-29 11:16:13 +02:00
Sebastian Huber f1863582ed Fix compile error due to new strnstr()
Remove local strnstr() implementation to fix compile error:

newlib/libc/iconv/lib/aliasesi.c:53:8: error: conflicting types for 'strnstr'
 _DEFUN(strnstr, (haystack, needle, length),
        ^
In file included from newlib/libc/iconv/lib/aliasesi.c:29:0:
newlib/libc/include/string.h:125:10:
note: previous declaration of 'strnstr' was here
 char    *strnstr(const char *, const char *, size_t) __pure;
          ^~~~~~~

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2017-08-28 17:31:52 +02:00
Corinna Vinschen cf8bf843f8 cygwin: export strnstr
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-08-25 18:00:46 +02:00
Corinna Vinschen c070326d31 newlib: rebuild string/Makefile.in
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-08-25 18:00:46 +02:00
Sichen Zhao c206d04422 Port strnstr.c to newlib. 2017-08-25 18:00:46 +02:00
Sichen Zhao 3437665ac8 Import strnstr.c from FreeBSD. 2017-08-25 18:00:46 +02:00
Eric Blake a4961ccd3f Revert "headers: avoid bareword attributes" for clang
This reverts most of commit 979d467ff6.

We cannot avoid some bareword attributes until clang is fixed to
properly support __-decorated attributes; see this bug:
https://bugs.llvm.org/show_bug.cgi?id=34319

The macros in question expand to the empty string under gcc, so
only compilation under clang is affected, and since clang has the
bug, the obvious solution is to roll back the changes, and document
the issue.

Signed-off-by: Eric Blake <eblake@redhat.com>
2017-08-25 09:23:10 -05:00
Sebastian Huber 524eb4dc29 RTEMS: Use __uint64_t for _CLOCK_T_
This addresses:

https://devel.rtems.org/ticket/2135

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2017-08-25 14:25:42 +02:00
Sebastian Huber 7b2c362190 Make _CLOCK_T_ system configurable
Let systems optionally provide the _CLOCK_T_ type via
<machine/_types.h>.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2017-08-25 14:25:42 +02:00
Brian Inglis 406bd10fb4 newlib/libc/time/strptime.c(strptime_l) add %F %s support for strptime 2017-08-25 14:04:22 +02:00
Brian Inglis 8324ab5e2a winsup/cygwin/libc/strptime.cc(__strptime) add %s support to strptime 2017-08-25 11:39:11 +02:00
Alexander Fedotov-B55613 3ec9892f5d move ILP32 sanity check on heap base code under ARM_RDI_MONITOR 2017-08-24 14:41:19 +02:00
Corinna Vinschen b706c6b479 cygwin: only expose /dev/con{in,out,sole} when started from a Windows console
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-08-23 17:43:41 +02:00
Kito Cheng bd86e9de75 Add myself to RISC-V Port Maintainer 2017-08-21 11:09:15 +02:00
Kito Cheng 6864c08b94 Change license to FreeBSD License for RISC-V
- For prevent confuse about what BSD license variant we used, 2- or
   3-clause license, we change the license to FreeBSD license to make
   it unambiguously refers to the 2-clause license.
2017-08-21 11:08:54 +02:00
Ken Brown 3012e251fa Document renameat2 2017-08-19 19:43:15 +02:00
Ken Brown f665b1cef3 cygwin: Implement renameat2
Define the RENAME_NOREPLACE flag in <cygwin/fs.h> as defined on Linux
in <linux/fs.h>.  The other RENAME_* flags defined on Linux are not
supported.
2017-08-19 18:06:49 +02:00
Kito Cheng c496cbb6bd Add RISC-V port for libgloss
Contributor list:
    - Andrew Waterman  <andrew@sifive.com>
    - Palmer Dabbelt  <palmer@dabbelt.com>
    - Kito Cheng  <kito.cheng@gmail.com>
    - Alex Suykov  <alex.suykov@gmail.com>
2017-08-17 14:51:05 -04:00
Kito Cheng 7040b2de08 Add RISC-V port for libm
Contributor list:
    - Michael Neilly  <mneilly@yahoo.com>
    - Kito Cheng  <kito.cheng@gmail.com>
2017-08-17 12:54:56 -04:00
Eric Blake 979d467ff6 headers: avoid bareword attributes
Always use the __-decorated form of an attribute name in public
headers, as the bareword form is in the user's namespace, and we
don't want compilation to break just because the user defines the
bareword to mean something else.

Signed-off-by: Eric Blake <eblake@redhat.com>
2017-08-17 07:10:03 -05:00
Eric Blake 7b3d8b9485 headers: avoid bareword attributes
Always use the __-decorated form of an attribute name in public
headers, as the bareword form is in the user's namespace, and we
don't want compilation to break just because the user defines the
bareword to mean something else.

Signed-off-by: Eric Blake <eblake@redhat.com>
2017-08-17 07:10:03 -05:00
Szabolcs Nagy cfa64a86d1 Fix crt0 init fini code
__USES_INITFINI__ ifdef was incorrectly copied from arm
(it's an arm backend thing in gcc, not meaningful on aarch64)
2017-08-17 13:45:26 +02:00
Kito Cheng 363dbb9e44 Add RISC-V port for newlib
Contributor list:
    - Andrew Waterman  <andrew@sifive.com>
    - Palmer Dabbelt  <palmer@dabbelt.com>
    - Kito Cheng  <kito.cheng@gmail.com>
    - Scott Beamer  <sbeamer@eecs.berkeley.edu>
2017-08-16 18:00:58 -04:00
Alexander Fedotov-B55613 7e69f983a4 fix typo in AArch64 crt0 2017-08-15 16:19:25 +02:00
Alexander Fedotov-B55613 1f6644876e use stack from linker script when nosys 2017-08-14 10:18:14 +02:00
Corinna Vinschen 9d602b98f8 newlib: regenerate libc/stdlib/Makefile.am
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-08-11 10:17:16 +02:00
Yao Qi 32ca315312 Don't fetch command line options without semi-hosting
Nowadays, the code fetching command line options via semi-hosting are
unconditionally pulled in, so that the semi-hosting code is still
there even I compile with option --specs=nosys.specs.

gdb ./aarch64-none-elf/libgloss/aarch64/crt0.o

(gdb) disassemble _start

   0x0000000000000050 <+80>:	ldr	x1, 0x128 <_cpu_init_hook+48>
   0x0000000000000054 <+84>:	mov	w0, #0x15
   0x0000000000000058 <+88>:	hlt	#0xf000

This patch fixes this problem by wrapping the code by ARM_RDI_MONITOR.
When semi-hosting is not used, set command line options to NULL.
2017-08-09 17:43:09 +02:00
Tamar Christina 61ddc7a436 Fix crt0 overwriting.
On AArch64 we currently always link in crt0 regardless of if another
one is being provided by something else, like rdimon.a. This was never
an issue before as nosys was not supported on AArch64.

This updates the specs to supply a different crt0 when a semihosting
call is required.

Signed-off-by: Tamar Christina <tamar.christina@arm.com>
2017-08-09 14:50:13 +02:00
Ken Brown d7821c045e Define sigsetjmp/siglongjmp only if __POSIX_VISIBLE 2017-08-07 16:07:46 +02:00
Sebastian Huber b0f271d1db Proper locking for getchar() and putchar()
Add internal inline functions _getchar_unlocked() and
_putchar_unlocked() if __CUSTOM_FILE_IO__ is not defined.  These
functions get _REENT only once.  Use them for getchar_unlocked() and
putchar_unlocked().  Define getchar() and putchar() to these unlocked
internal functions if __SINGLE_THREAD__ is defined, otherwise use the
external functions to use proper locking of the FILE object.

Assumes that __SINGLE_THREAD__ is not defined if __CYGWIN__ is defined.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2017-08-07 07:54:58 +02:00
Corinna Vinschen 65c13851b3 cygwin: pthread timed locks: actually timeout on timeout
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-08-03 23:14:21 +02:00
Corinna Vinschen f378384804 cygwin: pthread_rwlock_rdlock: don't set errno, just return error code
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-08-03 23:09:57 +02:00
Corinna Vinschen 8128f5482f cygwin: Implement pthread_rwlock_timedrdlock, pthread_rwlock_timedwrlock
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-08-03 21:31:38 +02:00
Corinna Vinschen eb206317a8 cygwin: Bump DLL version to 2.9.0
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-08-03 19:17:45 +02:00
Corinna Vinschen 37738448a0 cygwin: Implement pthread_mutex_timedlock
- pthread_mutex::lock now takes a PLARGE_INTEGER timeout pointer
  and uses that in the call to cygwait.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-08-03 19:13:21 +02:00
Corinna Vinschen 68217c3178 cygwin: simplify pthread timedwait handling
- Introduce inline helper pthread_convert_abstime.  It converts
  an absolute timespec to a Windows LARGE_INTEGER timestamp,
  depending on the used clock.

- Use this function from pthread_cond_timedwait and semaphore::timedwait

- Merge semaphore::_wait and semaphore::_timedwait into single _wait
  method, taking a LARGER_INTEGER timestamp.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-08-03 19:08:31 +02:00
Corinna Vinschen a346a26790 cygwin/signal.h: Remove SI_QUEUE unimplemented comment
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-08-03 14:56:24 +02:00