diff options
author | Hans-Peter Nilsson <hp@axis.com> | 2001-11-13 05:49:12 +0300 |
---|---|---|
committer | Hans-Peter Nilsson <hp@axis.com> | 2001-11-13 05:49:12 +0300 |
commit | 4cede8c4ce75127a528ab2dfb33fa5bf925a2d05 (patch) | |
tree | b97549d3e0575500385db31e6e32fd279786b956 /newlib/libc/sys/mmixware | |
parent | f513298e1801560b0b2af19be879356874d60aa7 (diff) |
* libc/sys/mmixware/*: Correct spacing in all source files.
* libc/sys/mmixware/syscall.h: Move misplaced file...
* libc/sys/mmixware/sys/syscall.h: ...here.
Diffstat (limited to 'newlib/libc/sys/mmixware')
30 files changed, 197 insertions, 226 deletions
diff --git a/newlib/libc/sys/mmixware/_exit.c b/newlib/libc/sys/mmixware/_exit.c index b528182ed..c20b7c95e 100644 --- a/newlib/libc/sys/mmixware/_exit.c +++ b/newlib/libc/sys/mmixware/_exit.c @@ -1,7 +1,6 @@ /* _exit for MMIXware. Copyright (C) 2001 Hans-Peter Nilsson. - Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved with no changes. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR @@ -20,7 +19,7 @@ void _exit (int n) simulator, so it seems in effect ineffective. We set it anyway; there may be a purpose. */ __asm__ ("SET $255,%0\n\tTRAP 0,0,0" - : /* No outputs. */ - : "r" (n) - : "memory"); + : /* No outputs. */ + : "r" (n) + : "memory"); } diff --git a/newlib/libc/sys/mmixware/access.c b/newlib/libc/sys/mmixware/access.c index a3cfeacfd..f4bcb20b2 100644 --- a/newlib/libc/sys/mmixware/access.c +++ b/newlib/libc/sys/mmixware/access.c @@ -1,7 +1,6 @@ /* access for MMIXware. Copyright (C) 2001 Hans-Peter Nilsson. - Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved with no changes. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR @@ -30,8 +29,8 @@ access (const char *fn, int flags) if (ret == 0) { /* Yes, this was readable. As in other simulator access functions, - we always return success in this case (though the others check - for directory access). */ + we always return success in this case (though the others check + for directory access). */ TRAP1f (SYS_Fclose, TMPFNO); return 0; } diff --git a/newlib/libc/sys/mmixware/chmod.c b/newlib/libc/sys/mmixware/chmod.c index 2ff614157..d7ddc369e 100644 --- a/newlib/libc/sys/mmixware/chmod.c +++ b/newlib/libc/sys/mmixware/chmod.c @@ -1,7 +1,6 @@ /* chmod stub for MMIXware. Copyright (C) 2001 Hans-Peter Nilsson. - Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved with no changes. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR diff --git a/newlib/libc/sys/mmixware/chown.c b/newlib/libc/sys/mmixware/chown.c index 6df7c4247..6857efa13 100644 --- a/newlib/libc/sys/mmixware/chown.c +++ b/newlib/libc/sys/mmixware/chown.c @@ -1,7 +1,6 @@ /* chown stub for MMIXware. Copyright (C) 2001 Hans-Peter Nilsson. - Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved with no changes. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR diff --git a/newlib/libc/sys/mmixware/close.c b/newlib/libc/sys/mmixware/close.c index d2065da11..0194b87df 100644 --- a/newlib/libc/sys/mmixware/close.c +++ b/newlib/libc/sys/mmixware/close.c @@ -1,7 +1,6 @@ /* close for MMIXware. Copyright (C) 2001 Hans-Peter Nilsson. - Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved with no changes. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR diff --git a/newlib/libc/sys/mmixware/creat.c b/newlib/libc/sys/mmixware/creat.c index 5555f1844..3e9d24972 100644 --- a/newlib/libc/sys/mmixware/creat.c +++ b/newlib/libc/sys/mmixware/creat.c @@ -1,7 +1,6 @@ /* creat for MMIXware. Copyright (C) 2001 Hans-Peter Nilsson. - Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved with no changes. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR diff --git a/newlib/libc/sys/mmixware/crt0.c b/newlib/libc/sys/mmixware/crt0.c index d39ff4332..5b8ba0df9 100644 --- a/newlib/libc/sys/mmixware/crt0.c +++ b/newlib/libc/sys/mmixware/crt0.c @@ -1,7 +1,6 @@ /* crt0 stub for MMIXware. Copyright (C) 2001 Hans-Peter Nilsson. - Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved with no changes. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR diff --git a/newlib/libc/sys/mmixware/execv.c b/newlib/libc/sys/mmixware/execv.c index 6bbe50a02..720b3d67b 100644 --- a/newlib/libc/sys/mmixware/execv.c +++ b/newlib/libc/sys/mmixware/execv.c @@ -1,7 +1,6 @@ /* execv stub for MMIXware. Copyright (C) 2001 Hans-Peter Nilsson. - Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved with no changes. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR diff --git a/newlib/libc/sys/mmixware/execve.c b/newlib/libc/sys/mmixware/execve.c index 2456a3d69..8f35440d4 100644 --- a/newlib/libc/sys/mmixware/execve.c +++ b/newlib/libc/sys/mmixware/execve.c @@ -1,7 +1,6 @@ /* execve stub for MMIXware. Copyright (C) 2001 Hans-Peter Nilsson. - Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved with no changes. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR diff --git a/newlib/libc/sys/mmixware/fork.c b/newlib/libc/sys/mmixware/fork.c index e09d664f2..6d3c4cdbd 100644 --- a/newlib/libc/sys/mmixware/fork.c +++ b/newlib/libc/sys/mmixware/fork.c @@ -1,7 +1,6 @@ /* fork stub for MMIXware. Copyright (C) 2001 Hans-Peter Nilsson. - Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved with no changes. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR diff --git a/newlib/libc/sys/mmixware/fstat.c b/newlib/libc/sys/mmixware/fstat.c index aeec86083..8608e7d01 100644 --- a/newlib/libc/sys/mmixware/fstat.c +++ b/newlib/libc/sys/mmixware/fstat.c @@ -1,7 +1,6 @@ /* fstat for MMIXware. Copyright (C) 2001 Hans-Peter Nilsson. - Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved with no changes. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR @@ -16,7 +15,7 @@ int _fstat (int file, - struct stat *st) + struct stat *st) { st->st_mode = S_IFCHR; st->st_blksize = 4096; diff --git a/newlib/libc/sys/mmixware/getpid.c b/newlib/libc/sys/mmixware/getpid.c index 9146361ad..9444ead12 100644 --- a/newlib/libc/sys/mmixware/getpid.c +++ b/newlib/libc/sys/mmixware/getpid.c @@ -1,7 +1,6 @@ /* getpid stub for MMIXware. Copyright (C) 2001 Hans-Peter Nilsson. - Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved with no changes. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR diff --git a/newlib/libc/sys/mmixware/gettime.c b/newlib/libc/sys/mmixware/gettime.c index d067150dc..cd0b79a4c 100644 --- a/newlib/libc/sys/mmixware/gettime.c +++ b/newlib/libc/sys/mmixware/gettime.c @@ -1,7 +1,6 @@ /* gettime stub for MMIXware. Copyright (C) 2001 Hans-Peter Nilsson. - Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved with no changes. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR diff --git a/newlib/libc/sys/mmixware/isatty.c b/newlib/libc/sys/mmixware/isatty.c index 54647f62e..a399531a5 100644 --- a/newlib/libc/sys/mmixware/isatty.c +++ b/newlib/libc/sys/mmixware/isatty.c @@ -1,7 +1,6 @@ /* isatty for MMIXware. Copyright (C) 2001 Hans-Peter Nilsson. - Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved with no changes. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR diff --git a/newlib/libc/sys/mmixware/kill.c b/newlib/libc/sys/mmixware/kill.c index 2c4373b95..6cc4b3658 100644 --- a/newlib/libc/sys/mmixware/kill.c +++ b/newlib/libc/sys/mmixware/kill.c @@ -1,7 +1,6 @@ /* kill for MMIXware. Copyright (C) 2001 Hans-Peter Nilsson. - Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved with no changes. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR diff --git a/newlib/libc/sys/mmixware/lseek.c b/newlib/libc/sys/mmixware/lseek.c index 9405dd2a4..69ec8f30b 100644 --- a/newlib/libc/sys/mmixware/lseek.c +++ b/newlib/libc/sys/mmixware/lseek.c @@ -1,7 +1,6 @@ /* lseek for MMIXware. Copyright (C) 2001 Hans-Peter Nilsson. - Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved with no changes. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR @@ -18,8 +17,8 @@ off_t _lseek (int file, - off_t ptr, - int dir) + off_t ptr, + int dir) { off_t simoff = dir == SEEK_END ? -(ptr + 1) : ptr; long ret; @@ -35,10 +34,10 @@ _lseek (int file, long curpos = TRAP2f (SYS_Ftell, file, 0); if (curpos == -1) - { - errno = EIO; - return -1; - } + { + errno = EIO; + return -1; + } ptr += (off_t) curpos; } diff --git a/newlib/libc/sys/mmixware/open.c b/newlib/libc/sys/mmixware/open.c index ec0d222d5..6a6475d4e 100644 --- a/newlib/libc/sys/mmixware/open.c +++ b/newlib/libc/sys/mmixware/open.c @@ -1,7 +1,6 @@ /* open for MMIXware. Copyright (C) 2001 Hans-Peter Nilsson. - Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved with no changes. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR @@ -40,13 +39,13 @@ _open (const char *path, for (fileno = 0; fileno < (sizeof (_MMIX_allocated_filehandle) / - sizeof (_MMIX_allocated_filehandle[0])); + sizeof (_MMIX_allocated_filehandle[0])); fileno++) if (_MMIX_allocated_filehandle[fileno] == 0) break; if (fileno == (sizeof (_MMIX_allocated_filehandle) / - sizeof (_MMIX_allocated_filehandle[0]))) + sizeof (_MMIX_allocated_filehandle[0]))) { errno = EMFILE; return -1; @@ -74,7 +73,7 @@ _open (const char *path, fffile = 1; } else if ((flags & (O_WRONLY | O_CREAT)) == (O_WRONLY | O_CREAT) - || (flags & (O_WRONLY | O_TRUNC)) == (O_WRONLY | O_TRUNC)) + || (flags & (O_WRONLY | O_TRUNC)) == (O_WRONLY | O_TRUNC)) mode = BinaryWrite; else if ((flags & (O_RDWR | O_CREAT)) == (O_RDWR | O_CREAT)) mode = BinaryReadWrite; @@ -90,7 +89,7 @@ _open (const char *path, if (ret < 0) { /* It's totally unknown what the error was. We'll just take our - chances and assume ENOENT. */ + chances and assume ENOENT. */ errno = ENOENT; return -1; } diff --git a/newlib/libc/sys/mmixware/pipe.c b/newlib/libc/sys/mmixware/pipe.c index 76be53401..6c4fa6bec 100644 --- a/newlib/libc/sys/mmixware/pipe.c +++ b/newlib/libc/sys/mmixware/pipe.c @@ -1,7 +1,6 @@ /* pipe stub for MMIXware. Copyright (C) 2001 Hans-Peter Nilsson. - Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved with no changes. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR diff --git a/newlib/libc/sys/mmixware/read.c b/newlib/libc/sys/mmixware/read.c index b474b807e..4dfb0f025 100644 --- a/newlib/libc/sys/mmixware/read.c +++ b/newlib/libc/sys/mmixware/read.c @@ -1,7 +1,6 @@ /* read for MMIXware. Copyright (C) 2001 Hans-Peter Nilsson. - Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved with no changes. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR @@ -40,7 +39,7 @@ _read (int file, if (ret == -1 - (long) len) { /* We don't know the nature of the failure, so this is an - approximation. */ + approximation. */ errno = EIO; return -1; } diff --git a/newlib/libc/sys/mmixware/sbrk.c b/newlib/libc/sys/mmixware/sbrk.c index 5d256127a..5eb9d77cf 100644 --- a/newlib/libc/sys/mmixware/sbrk.c +++ b/newlib/libc/sys/mmixware/sbrk.c @@ -1,7 +1,6 @@ /* sbrk for MMIXware. Copyright (C) 2001 Hans-Peter Nilsson. - Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved with no changes. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR @@ -26,13 +25,13 @@ extern char *_Sbrk_high; Pool_Segment and any other symbols that would be predefined in mmixal. */ __asm__ (" .global _Sbrk_high\n" - "_Sbrk_high IS Pool_Segment\n" - "Pool_Segment IS 0x40<<56"); + "_Sbrk_high IS Pool_Segment\n" + "Pool_Segment IS 0x40<<56"); caddr_t _sbrk (size_t incr) { - extern char end; /* Defined by the linker */ + extern char end; /* Defined by the linker */ char *prev_heap_end; prev_heap_end = _Sbrk_high; diff --git a/newlib/libc/sys/mmixware/setjmp.S b/newlib/libc/sys/mmixware/setjmp.S index e5f043155..17d9ea841 100644 --- a/newlib/libc/sys/mmixware/setjmp.S +++ b/newlib/libc/sys/mmixware/setjmp.S @@ -1,7 +1,6 @@ /* Setjmp and longjmp for mmix. Copyright (C) 2001 Hans-Peter Nilsson. - Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved with no changes. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR @@ -10,11 +9,11 @@ PURPOSE. jmp_buf[5]: - 0: fp - 1: rJ (return-address) - 2: sp - 3: rO *before* the setjmp call. - 4: temporary storage. Reserved between setjmp and longjmp. */ + 0: fp + 1: rJ (return-address) + 2: sp + 3: rO *before* the setjmp call. + 4: temporary storage. Reserved between setjmp and longjmp. */ #ifdef __MMIX_ABI_GNU__ #define arg1 $231 @@ -28,38 +27,38 @@ #define popval 1 #endif - .section .text.setjmp,"ax",@progbits - .global setjmp + .section .text.setjmp,"ax",@progbits + .global setjmp setjmp: % Store fp, sp and return address. Recycle the static-chain and % structure-return registers as temporary register, since we need to keep % the jmp_buf (parameter 1) and the return address across a "POP". - SET $251,arg1 - STOU $253,$251,0 - GET $252,rJ - STOU $252,$251,8 - STOU $254,$251,16 - SETL outret,0 + SET $251,arg1 + STOU $253,$251,0 + GET $252,rJ + STOU $252,$251,8 + STOU $254,$251,16 + SETL outret,0 % Jump through hoops to get the value of rO *before* the setjmp call. - GETA $255,0f - PUT rJ,$255 - POP popval,0 + GETA $255,0f + PUT rJ,$255 + POP popval,0 0: - GET $255,rO - STOU $255,$251,24 - GO $255,$252,0 - .size setjmp,.-setjmp + GET $255,rO + STOU $255,$251,24 + GO $255,$252,0 + .size setjmp,.-setjmp - .section .text.longjmp,"ax",@progbits - .global longjmp + .section .text.longjmp,"ax",@progbits + .global longjmp longjmp: % Reset arg2 to 1 if it is 0 (see longjmp(2)) and store it in jmp_buf. % Save arg1 in a global register, since it will be destroyed by the POPs % (in the mmixware ABI). - CSZ arg2,arg2,1 - STOU arg2,arg1,32 - SET $251,arg1 + CSZ arg2,arg2,1 + STOU arg2,arg1,32 + SET $251,arg1 % Loop and "POP 0,0" until rO is the expected value, like % the expansion of nonlocal_goto_receiver, except that we put the return @@ -68,18 +67,18 @@ longjmp: % GNU ABI, it is unnecessary to do this in the loop and perhaps the memory % access can be hoisted outside the loop, but this is safe and simple and % I see no need to optimize longjmps. - GETA $255,0f - PUT rJ,$255 - LDOU $255,$251,24 + GETA $255,0f + PUT rJ,$255 + LDOU $255,$251,24 0: - GET $252,rO - CMPU $252,$252,$255 - BNP $252,1f - LDOU outret,$251,32 - POP popval,0 + GET $252,rO + CMPU $252,$252,$255 + BNP $252,1f + LDOU outret,$251,32 + POP popval,0 1: - LDOU $253,$251,0 - LDOU $255,$251,8 - LDOU $254,$251,16 - GO $255,$255,0 - .size longjmp,.-longjmp + LDOU $253,$251,0 + LDOU $255,$251,8 + LDOU $254,$251,16 + GO $255,$255,0 + .size longjmp,.-longjmp diff --git a/newlib/libc/sys/mmixware/stat.c b/newlib/libc/sys/mmixware/stat.c index 5dd1b24f6..e72c15f9d 100644 --- a/newlib/libc/sys/mmixware/stat.c +++ b/newlib/libc/sys/mmixware/stat.c @@ -1,7 +1,6 @@ /* stat stub for MMIXware. Copyright (C) 2001 Hans-Peter Nilsson. - Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved with no changes. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR diff --git a/newlib/libc/sys/mmixware/sys/syscall.h b/newlib/libc/sys/mmixware/sys/syscall.h new file mode 100644 index 000000000..a2e3668f7 --- /dev/null +++ b/newlib/libc/sys/mmixware/sys/syscall.h @@ -0,0 +1,137 @@ +/* syscall defines for MMIXware. + + Copyright (C) 2001 Hans-Peter Nilsson. + Permission to use, copy, modify, and distribute this software is freely + granted, provided that this notice is preserved with no changes. + THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + PURPOSE. */ + +/* These are the mmixware simulator calls that are of use in newlib. */ + +#define SYS_halt 0 +#define SYS_Fopen 1 +#define SYS_Fclose 2 +#define SYS_Fread 3 +#define SYS_Fwrite 6 +#define SYS_Fseek 9 +#define SYS_Ftell 10 + + +enum MMIX_filemode + { + TextRead = 0, + TextWrite = 1, + BinaryRead = 2, + BinaryWrite = 3, + BinaryReadWrite = 4 + }; + +#define N_MMIX_FILEHANDLES 32 + +/* We store a bitmap of allocated filehandles + _MMIX_allocated_filehandle[fileno] in an array. There are 32 of them. + Indexes 0, 1 and 2 are allocated from start. The reason we keep track + of them is that *we* have to allocate a filehandle when opening a file. + Had we got a filehandle from the simulator, we wouldn't have to keep + track of it. A value of 0 denotes a free handle. */ +extern unsigned char _MMIX_allocated_filehandle[N_MMIX_FILEHANDLES]; + +/* We use this file-handle number as a temporary; not used by usual file + I/O. */ +#define TMPFNO 127 + +/* Simulator call with one argument. Also used for zero-argument calls; + pass a zero as ARG1. */ +#define TRAP1i(FUN, ARG1) \ + ({ long ret_; \ + __asm__ ("TRAP 0,%1,%2\n\tSET %0,$255" \ + : "=r" (ret_) : "i" (FUN), "i" (ARG1) \ + : "memory"); \ + ret_; \ + }) + +/* Helper macros to cope with the file-handle parameter to the simulator + being *constant*. We support up to 32 simultaneously open files. */ +#define I3f(FUN, ARG1, N, ARGS) \ + if (ARG1 == N) \ + __asm__ ("SET $255,%3\n\tTRAP 0,%1,%2\n\tSET %0,$255" \ + : "=r" (ret_) : "i" (FUN), "i" (N), "r" (ARGS) \ + : "memory") + +/* Using if:s rather than switches to help GCC optimize the rest away. */ +#define DO32(FUN, ARG1, ARGS) \ + I3f (FUN, ARG1, 0, ARGS); \ + else I3f (FUN, ARG1, 1, ARGS); \ + else I3f (FUN, ARG1, 2, ARGS); \ + else I3f (FUN, ARG1, 3, ARGS); \ + else I3f (FUN, ARG1, 4, ARGS); \ + else I3f (FUN, ARG1, 5, ARGS); \ + else I3f (FUN, ARG1, 6, ARGS); \ + else I3f (FUN, ARG1, 7, ARGS); \ + else I3f (FUN, ARG1, 8, ARGS); \ + else I3f (FUN, ARG1, 9, ARGS); \ + else I3f (FUN, ARG1, 10, ARGS); \ + else I3f (FUN, ARG1, 11, ARGS); \ + else I3f (FUN, ARG1, 12, ARGS); \ + else I3f (FUN, ARG1, 13, ARGS); \ + else I3f (FUN, ARG1, 14, ARGS); \ + else I3f (FUN, ARG1, 15, ARGS); \ + else I3f (FUN, ARG1, 16, ARGS); \ + else I3f (FUN, ARG1, 17, ARGS); \ + else I3f (FUN, ARG1, 18, ARGS); \ + else I3f (FUN, ARG1, 19, ARGS); \ + else I3f (FUN, ARG1, 20, ARGS); \ + else I3f (FUN, ARG1, 21, ARGS); \ + else I3f (FUN, ARG1, 22, ARGS); \ + else I3f (FUN, ARG1, 23, ARGS); \ + else I3f (FUN, ARG1, 24, ARGS); \ + else I3f (FUN, ARG1, 25, ARGS); \ + else I3f (FUN, ARG1, 26, ARGS); \ + else I3f (FUN, ARG1, 27, ARGS); \ + else I3f (FUN, ARG1, 28, ARGS); \ + else I3f (FUN, ARG1, 29, ARGS); \ + else I3f (FUN, ARG1, 30, ARGS); \ + else I3f (FUN, ARG1, 31, ARGS); \ + else \ + { \ + errno = EBADF; \ + return -1; \ + } + +#define TRAP1f(FUN, ARG1) \ + ({ long ret_; \ + DO32 (FUN, ARG1, 0); \ + ret_; \ + }) + +#define TRAP2f(FUN, ARG1, ARG2) \ + ({ long ret_; \ + DO32 (FUN, ARG1, ARG2); \ + ret_; \ + }) + +#define TRAP3f(FUN, ARG1, ARG2, ARG3) \ + ({ long ret_; \ + unsigned long args_[] \ + = { (unsigned long) (ARG2), (unsigned long) (ARG3) }; \ + DO32 (FUN, ARG1, args_); \ + ret_; \ + }) + +#ifndef __GNUC__ +/* Probably will not happen. Nevertheless... */ +# define UNIMPLEMENTED(MSG) +#else +# define UNIMPLEMENTED(MSG) UNIMPLEMENTEDi MSG +# define UNIMPLEMENTEDi(MSG, ARGS...) \ + do { \ + char buf[2000]; \ + sprintf (buf, "UNIMPLEMENTED %s in %s\n", __FUNCTION__, __FILE__); \ + write (2, buf, strlen (buf)); \ + sprintf (buf, MSG , ##ARGS); \ + write (2, buf, strlen (buf)); \ + write (2, "\n", 1); \ + } while (0) +#endif diff --git a/newlib/libc/sys/mmixware/syscall.h b/newlib/libc/sys/mmixware/syscall.h deleted file mode 100644 index e639ba2c0..000000000 --- a/newlib/libc/sys/mmixware/syscall.h +++ /dev/null @@ -1,138 +0,0 @@ -/* syscall defines for MMIXware. - - Copyright (C) 2001 Hans-Peter Nilsson. - - Permission to use, copy, modify, and distribute this software is freely - granted, provided that this notice is preserved with no changes. - THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - PURPOSE. */ - -/* These are the mmixware simulator calls that are of use in newlib. */ - -#define SYS_halt 0 -#define SYS_Fopen 1 -#define SYS_Fclose 2 -#define SYS_Fread 3 -#define SYS_Fwrite 6 -#define SYS_Fseek 9 -#define SYS_Ftell 10 - - -enum MMIX_filemode - { - TextRead = 0, - TextWrite = 1, - BinaryRead = 2, - BinaryWrite = 3, - BinaryReadWrite = 4 - }; - -#define N_MMIX_FILEHANDLES 32 - -/* We store a bitmap of allocated filehandles - _MMIX_allocated_filehandle[fileno] in an array. There are 32 of them. - Indexes 0, 1 and 2 are allocated from start. The reason we keep track - of them is that *we* have to allocate a filehandle when opening a file. - Had we got a filehandle from the simulator, we wouldn't have to keep - track of it. A value of 0 denotes a free handle. */ -extern unsigned char _MMIX_allocated_filehandle[N_MMIX_FILEHANDLES]; - -/* We use this file-handle number as a temporary; not used by usual file - I/O. */ -#define TMPFNO 127 - -/* Simulator call with one argument. Also used for zero-argument calls; - pass a zero as ARG1. */ -#define TRAP1i(FUN, ARG1) \ - ({ long ret_; \ - __asm__ ("TRAP 0,%1,%2\n\tSET %0,$255" \ - : "=r" (ret_) : "i" (FUN), "i" (ARG1) \ - : "memory"); \ - ret_; \ - }) - -/* Helper macros to cope with the file-handle parameter to the simulator - being *constant*. We support up to 32 simultaneously open files. */ -#define I3f(FUN, ARG1, N, ARGS) \ - if (ARG1 == N) \ - __asm__ ("SET $255,%3\n\tTRAP 0,%1,%2\n\tSET %0,$255" \ - : "=r" (ret_) : "i" (FUN), "i" (N), "r" (ARGS) \ - : "memory") - -/* Using if:s rather than switches to help GCC optimize the rest away. */ -#define DO32(FUN, ARG1, ARGS) \ - I3f (FUN, ARG1, 0, ARGS); \ - else I3f (FUN, ARG1, 1, ARGS); \ - else I3f (FUN, ARG1, 2, ARGS); \ - else I3f (FUN, ARG1, 3, ARGS); \ - else I3f (FUN, ARG1, 4, ARGS); \ - else I3f (FUN, ARG1, 5, ARGS); \ - else I3f (FUN, ARG1, 6, ARGS); \ - else I3f (FUN, ARG1, 7, ARGS); \ - else I3f (FUN, ARG1, 8, ARGS); \ - else I3f (FUN, ARG1, 9, ARGS); \ - else I3f (FUN, ARG1, 10, ARGS); \ - else I3f (FUN, ARG1, 11, ARGS); \ - else I3f (FUN, ARG1, 12, ARGS); \ - else I3f (FUN, ARG1, 13, ARGS); \ - else I3f (FUN, ARG1, 14, ARGS); \ - else I3f (FUN, ARG1, 15, ARGS); \ - else I3f (FUN, ARG1, 16, ARGS); \ - else I3f (FUN, ARG1, 17, ARGS); \ - else I3f (FUN, ARG1, 18, ARGS); \ - else I3f (FUN, ARG1, 19, ARGS); \ - else I3f (FUN, ARG1, 20, ARGS); \ - else I3f (FUN, ARG1, 21, ARGS); \ - else I3f (FUN, ARG1, 22, ARGS); \ - else I3f (FUN, ARG1, 23, ARGS); \ - else I3f (FUN, ARG1, 24, ARGS); \ - else I3f (FUN, ARG1, 25, ARGS); \ - else I3f (FUN, ARG1, 26, ARGS); \ - else I3f (FUN, ARG1, 27, ARGS); \ - else I3f (FUN, ARG1, 28, ARGS); \ - else I3f (FUN, ARG1, 29, ARGS); \ - else I3f (FUN, ARG1, 30, ARGS); \ - else I3f (FUN, ARG1, 31, ARGS); \ - else \ - { \ - errno = EBADF; \ - return -1; \ - } - -#define TRAP1f(FUN, ARG1) \ - ({ long ret_; \ - DO32 (FUN, ARG1, 0); \ - ret_; \ - }) - -#define TRAP2f(FUN, ARG1, ARG2) \ - ({ long ret_; \ - DO32 (FUN, ARG1, ARG2); \ - ret_; \ - }) - -#define TRAP3f(FUN, ARG1, ARG2, ARG3) \ - ({ long ret_; \ - unsigned long args_[] \ - = { (unsigned long) (ARG2), (unsigned long) (ARG3) }; \ - DO32 (FUN, ARG1, args_); \ - ret_; \ - }) - -#ifndef __GNUC__ -/* Probably will not happen. Nevertheless... */ -# define UNIMPLEMENTED(MSG) -#else -# define UNIMPLEMENTED(MSG) UNIMPLEMENTEDi MSG -# define UNIMPLEMENTEDi(MSG, ARGS...) \ - do { \ - char buf[2000]; \ - sprintf (buf, "UNIMPLEMENTED %s in %s\n", __FUNCTION__, __FILE__); \ - write (2, buf, strlen (buf)); \ - sprintf (buf, MSG , ##ARGS); \ - write (2, buf, strlen (buf)); \ - write (2, "\n", 1); \ - } while (0) -#endif diff --git a/newlib/libc/sys/mmixware/time.c b/newlib/libc/sys/mmixware/time.c index 56d2de57d..7de89c01f 100644 --- a/newlib/libc/sys/mmixware/time.c +++ b/newlib/libc/sys/mmixware/time.c @@ -1,7 +1,6 @@ /* time stub for MMIXware. Copyright (C) 2001 Hans-Peter Nilsson. - Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved with no changes. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR diff --git a/newlib/libc/sys/mmixware/times.c b/newlib/libc/sys/mmixware/times.c index c44dd48f0..df9edb10d 100644 --- a/newlib/libc/sys/mmixware/times.c +++ b/newlib/libc/sys/mmixware/times.c @@ -1,7 +1,6 @@ /* times stub for MMIXware. Copyright (C) 2001 Hans-Peter Nilsson. - Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved with no changes. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR diff --git a/newlib/libc/sys/mmixware/unlink.c b/newlib/libc/sys/mmixware/unlink.c index c4ac7386b..86490868b 100644 --- a/newlib/libc/sys/mmixware/unlink.c +++ b/newlib/libc/sys/mmixware/unlink.c @@ -1,7 +1,6 @@ /* unlink stub for MMIXware. Copyright (C) 2001 Hans-Peter Nilsson. - Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved with no changes. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR diff --git a/newlib/libc/sys/mmixware/utime.c b/newlib/libc/sys/mmixware/utime.c index 8c6d25dd7..043bdf06b 100644 --- a/newlib/libc/sys/mmixware/utime.c +++ b/newlib/libc/sys/mmixware/utime.c @@ -1,7 +1,6 @@ /* utime stub for MMIXware. Copyright (C) 2001 Hans-Peter Nilsson. - Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved with no changes. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR diff --git a/newlib/libc/sys/mmixware/wait.c b/newlib/libc/sys/mmixware/wait.c index 69c677f44..fd0b8b708 100644 --- a/newlib/libc/sys/mmixware/wait.c +++ b/newlib/libc/sys/mmixware/wait.c @@ -1,7 +1,6 @@ /* wait stub for MMIXware. Copyright (C) 2001 Hans-Peter Nilsson. - Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved with no changes. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR diff --git a/newlib/libc/sys/mmixware/write.c b/newlib/libc/sys/mmixware/write.c index 492eafa45..988f9fa23 100644 --- a/newlib/libc/sys/mmixware/write.c +++ b/newlib/libc/sys/mmixware/write.c @@ -1,7 +1,6 @@ /* write for MMIXware. Copyright (C) 2001 Hans-Peter Nilsson. - Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved with no changes. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR @@ -17,8 +16,8 @@ int _write ( int file, - char *ptr, - size_t len) + char *ptr, + size_t len) { long ret; |