Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: platforms/stm/disco_fletch/src/syscalls.c

Issue 1659163007: Rename fletch -> dartino (Closed) Base URL: https://github.com/dartino/sdk.git@master
Patch Set: address comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE.md file.
4
5 // Support file for GNU libc. Most of this is noops or always
6 // returning an error. The read and write functions can be hooked into
7 // through weak functions. `gettimeofday` is implemented in terms of cmsis_os
8 // osKernelSysTick.
9
10 #include <sys/types.h>
11 #include <sys/stat.h>
12 #include <sys/fcntl.h>
13 #include <stdio.h>
14 #include <string.h>
15 #include <time.h>
16 #include <sys/time.h>
17 #include <sys/times.h>
18 #include <errno.h>
19 #include <sys/wait.h>
20
21 #include <cmsis_os.h>
22
23 #define MAX_STACK_SIZE 0x2000
24
25 extern int Write(int file, char *ptr, int len);
26
27 void* _sbrk(int incr) {
28 // We don't use the newlib C-heap implementation (which use _sbrk to
29 // get system memory). The cmpctmalloc C-heap implementation we use
30 // does not use _sbrk (uses the page allocator) to get system memory.
31 // So we don't expect any calls to _sbrk at the moment.
32 for (;;) {}
33 }
34
35 int _gettimeofday (struct timeval * tp, struct timezone * tzp) {
36 uint64_t microseconds =
37 ((uint64_t)osKernelSysTick()) * osKernelSysTickFrequency;
38 tp->tv_sec = microseconds / 1000000;
39 tp->tv_usec = microseconds % 1000000;
40 if (tzp) {
41 tzp->tz_minuteswest = 0;
42 tzp->tz_dsttime = 0;
43 }
44 return 0;
45 }
46
47 int _getpid(void) {
48 return 1;
49 }
50
51 int _kill(int pid, int sig) {
52 errno = EINVAL;
53 return -1;
54 }
55
56 void _exit (int status) {
57 _kill(status, -1);
58 while (1) {}
59 }
60
61 int _write(int file, char *ptr, int len) {
62 return Write(file, ptr, len);
63 }
64
65 int _close(int file) {
66 return -1;
67 }
68
69 int _fstat(int file, struct stat *st) {
70 st->st_mode = S_IFCHR;
71 return 0;
72 }
73
74 int _isatty(int file) {
75 return 1;
76 }
77
78 int _lseek(int file, int ptr, int dir) {
79 return 0;
80 }
81
82 int _read(int file, char *ptr, int len) {
83 // Nothing to read anywhere.
84 errno = EINVAL;
85 return -1;
86 }
87
88 int _open(char *path, int flags, ...) {
89 return -1;
90 }
91
92 int _wait(int *status) {
93 errno = ECHILD;
94 return -1;
95 }
96
97 int _unlink(char *name) {
98 errno = ENOENT;
99 return -1;
100 }
101
102 int _times(struct tms *buf) {
103 return -1;
104 }
105
106 int _stat(char *file, struct stat *st) {
107 st->st_mode = S_IFCHR;
108 return 0;
109 }
110
111 int _link(char *old, char *new) {
112 errno = EMLINK;
113 return -1;
114 }
115
116 int _fork(void) {
117 errno = EAGAIN;
118 return -1;
119 }
120
121 int _execve(char *name, char **argv, char **env) {
122 errno = ENOMEM;
123 return -1;
124 }
OLDNEW
« no previous file with comments | « platforms/stm/disco_fletch/src/page_allocator_test.cc ('k') | platforms/stm/disco_fletch/src/test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698