source: trunk/libs/newlib/src/libgloss/aarch64/libcfunc.c @ 532

Last change on this file since 532 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 2.6 KB
Line 
1/* Copyright (c) 2009, 2010, 2011, 2012 ARM Ltd.  All rights reserved.
2
3 Redistribution and use in source and binary forms, with or without
4 modification, are permitted provided that the following conditions
5 are met:
6 1. Redistributions of source code must retain the above copyright
7    notice, this list of conditions and the following disclaimer.
8 2. Redistributions in binary form must reproduce the above copyright
9    notice, this list of conditions and the following disclaimer in the
10    documentation and/or other materials provided with the distribution.
11 3. The name of the company may not be used to endorse or promote
12    products derived from this software without specific prior written
13    permission.
14
15 THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
20 TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
22 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
25
26/* Support files for GNU libc.  Files in the C namespace go here.
27   Files in the system namespace (ie those that start with an underscore)
28   go in syscalls.c.
29
30   Note: These functions are in a seperate file so that OS providers can
31   overrride the system call stubs (defined in syscalls.c) without having
32   to provide libc funcitons as well.  */
33
34#include "svc.h"
35
36#include <errno.h>
37#include <sys/types.h>
38#include <time.h>
39#include <unistd.h>
40
41
42extern clock_t _clock (void);
43extern int _isatty (int);
44
45unsigned __attribute__((weak))
46alarm (unsigned seconds)
47{
48  (void) seconds;
49  return 0;
50}
51
52clock_t __attribute__((weak))
53clock (void)
54{
55  return _clock ();
56}
57
58int __attribute__((weak))
59isatty (int fildes)
60{
61  return _isatty (fildes);
62}
63
64int __attribute__((weak))
65pause (void)
66{
67  errno = ENOSYS;
68  return -1;
69}
70
71unsigned __attribute__((weak))
72sleep (unsigned seconds)
73{
74  clock_t t0 = _clock ();
75  clock_t dt = seconds * CLOCKS_PER_SEC;
76
77  while (_clock () - t0 < dt)
78    ;
79  return 0;
80}
81
82int __attribute__((weak))
83usleep (useconds_t useconds)
84{
85  clock_t t0 = _clock ();
86  clock_t dt = useconds / (1000000 / CLOCKS_PER_SEC);
87
88  while (_clock () - t0 < dt)
89    ;
90  return 0;
91}
Note: See TracBrowser for help on using the repository browser.