aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple/syscalls.c
diff options
context:
space:
mode:
authorMichael Hope <michael.hope@linaro.org>2010-09-29 20:45:57 +1300
committerMichael Hope <michael.hope@linaro.org>2010-09-29 20:45:57 +1300
commit6fcd4cd306dbecf56f5b0b506a3c23762d1219fa (patch)
tree467125eca5a2e6706001cad8e09bc475e58a12d9 /libmaple/syscalls.c
parent368e4fc1662c2594b2a0908900713a2555a3ed8e (diff)
parentadde11b099ff5dad176e410279d21feac39d2c7e (diff)
downloadlibrambutan-6fcd4cd306dbecf56f5b0b506a3c23762d1219fa.tar.gz
librambutan-6fcd4cd306dbecf56f5b0b506a3c23762d1219fa.zip
Merge remote branch 'upstream/master'
Diffstat (limited to 'libmaple/syscalls.c')
-rw-r--r--libmaple/syscalls.c54
1 files changed, 18 insertions, 36 deletions
diff --git a/libmaple/syscalls.c b/libmaple/syscalls.c
index ec271a2..5611ce5 100644
--- a/libmaple/syscalls.c
+++ b/libmaple/syscalls.c
@@ -1,4 +1,4 @@
-/* *****************************************************************************
+/******************************************************************************
* The MIT License
*
* Copyright (c) 2010 Perry Hung.
@@ -20,7 +20,7 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
- * ****************************************************************************/
+ *****************************************************************************/
#include "libmaple.h"
#include <sys/stat.h>
@@ -35,10 +35,7 @@ void uart_send(const char*str);
* RAM. We just increment a pointer in what's
* left of memory on the board.
*/
-caddr_t
-_sbrk(nbytes)
-int nbytes;
-{
+caddr_t _sbrk(int nbytes) {
static caddr_t heap_ptr = NULL;
caddr_t base;
@@ -56,62 +53,52 @@ int nbytes;
}
}
-int _open(const char *path, int flags, ...)
-{
+int _open(const char *path, int flags, ...) {
return 1;
}
-int _close(int fd)
-{
+int _close(int fd) {
return 0;
}
-int _fstat(int fd, struct stat *st)
-{
+int _fstat(int fd, struct stat *st) {
st->st_mode = S_IFCHR;
return 0;
}
-int _isatty(int fd)
-{
+int _isatty(int fd) {
return 1;
}
-int isatty(int fd)
-{
+int isatty(int fd) {
return 1;
}
-int _lseek(int fd, off_t pos, int whence)
-{
+int _lseek(int fd, off_t pos, int whence) {
return -1;
}
-unsigned char getch(void)
-{
+unsigned char getch(void) {
// while (!(USART2->SR & USART_FLAG_RXNE));
// return USART2->DR;
return 0;
}
-int _read(int fd, char *buf, size_t cnt)
-{
+int _read(int fd, char *buf, size_t cnt) {
*buf = getch();
return 1;
}
-void putch(unsigned char c)
-{
+void putch(unsigned char c) {
// if (c == '\n') putch('\r');
// while (!(USART2->SR & USART_FLAG_TXE));
// USART2->DR = c;
}
-void cgets(char *s, int bufsize)
-{
+void cgets(char *s, int bufsize) {
char *p;
int c;
int i;
@@ -123,11 +110,9 @@ void cgets(char *s, int bufsize)
p = s;
- for (p = s; p < s + bufsize-1;)
- {
+ for (p = s; p < s + bufsize-1;) {
c = getch();
- switch (c)
- {
+ switch (c) {
case '\r' :
case '\n' :
putch('\r');
@@ -136,8 +121,7 @@ void cgets(char *s, int bufsize)
return;
case '\b' :
- if (p > s)
- {
+ if (p > s) {
*p-- = 0;
putch('\b');
putch(' ');
@@ -154,8 +138,7 @@ void cgets(char *s, int bufsize)
return;
}
-int _write(int fd, const char *buf, size_t cnt)
-{
+int _write(int fd, const char *buf, size_t cnt) {
int i;
// uart_send("_write\r\n");
@@ -166,8 +149,7 @@ int _write(int fd, const char *buf, size_t cnt)
}
/* Override fgets() in newlib with a version that does line editing */
-char *fgets(char *s, int bufsize, void *f)
-{
+char *fgets(char *s, int bufsize, void *f) {
// uart_send("fgets\r\n");
cgets(s, bufsize);
return s;