syscalls.c
Go to the documentation of this file.
1 
33 /*
34  * Support and FAQ: visit <a href="https://www.microchip.com/support/">Microchip Support</a>
35  */
36 
37 #include <stdio.h>
38 #include <stdarg.h>
39 #include <sys/types.h>
40 #include <sys/stat.h>
41 
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 
50 #undef errno
51 extern int errno;
52 extern int _end;
53 extern int __ram_end__;
54 
55 extern caddr_t _sbrk(int incr);
56 extern int link(char *old, char *new);
57 extern int _close(int file);
58 extern int _fstat(int file, struct stat *st);
59 extern int _isatty(int file);
60 extern int _lseek(int file, int ptr, int dir);
61 extern void _exit(int status);
62 extern void _kill(int pid, int sig);
63 extern int _getpid(void);
64 
65 extern caddr_t _sbrk(int incr)
66 {
67  static unsigned char *heap = NULL;
68  unsigned char *prev_heap;
69  int ramend = (int)&__ram_end__;
70 
71  if (heap == NULL) {
72  heap = (unsigned char *)&_end;
73  }
74  prev_heap = heap;
75 
76  if (((int)prev_heap + incr) > ramend) {
77  return (caddr_t) -1;
78  }
79 
80  heap += incr;
81 
82  return (caddr_t) prev_heap;
83 }
84 
85 extern int link(char *old, char *new)
86 {
87  return -1;
88 }
89 
90 extern int _close(int file)
91 {
92  return -1;
93 }
94 
95 extern int _fstat(int file, struct stat *st)
96 {
97  st->st_mode = S_IFCHR;
98 
99  return 0;
100 }
101 
102 extern int _isatty(int file)
103 {
104  return 1;
105 }
106 
107 extern int _lseek(int file, int ptr, int dir)
108 {
109  return 0;
110 }
111 
112 extern void _exit(int status)
113 {
114  asm("BKPT #0");
115  for (;;);
116 }
117 
118 extern void _kill(int pid, int sig)
119 {
120  return;
121 }
122 
123 extern int _getpid(void)
124 {
125  return -1;
126 }
127 
129 
130 #ifdef __cplusplus
131 }
132 #endif
133 
134 
caddr_t _sbrk(int incr)
Definition: syscalls.c:65
int __ram_end__
#define NULL
Definition: nm_bsp.h:52
void _exit(int status)
Definition: syscalls.c:112
int _end
int _getpid(void)
Definition: syscalls.c:123
int _isatty(int file)
Definition: syscalls.c:102
void _kill(int pid, int sig)
Definition: syscalls.c:118
int _fstat(int file, struct stat *st)
Definition: syscalls.c:95
int errno
int _close(int file)
Definition: syscalls.c:90
int _lseek(int file, int ptr, int dir)
Definition: syscalls.c:107
int link(char *old, char *new)
Definition: syscalls.c:85


inertial_sense_ros
Author(s):
autogenerated on Sat Sep 19 2020 03:19:05