From: ljsebald <ljs...@us...> - 2023-06-13 20:25:55
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A serial program loader for the Dreamcast.". The branch, master has been updated via 91830faef38d8f3f52bfbbd23f867e446763f6b3 (commit) from 62f5b4d83a1f6fede8eb59b333ed25a6299200c1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 91830faef38d8f3f52bfbbd23f867e446763f6b3 Author: Andress Barajas <and...@gm...> Date: Tue Jun 13 13:24:52 2023 -0700 Fix style/spacing and some warnings (#15) ----------------------------------------------------------------------- Summary of changes: example-src/Makefile | 6 +- example-src/console-test.c | 17 +- example-src/dcload-syscalls.c | 139 +++++------ example-src/dcload-syscalls.h | 28 +-- example-src/exception-test.c | 3 +- host-src/misc/Makefile | 12 +- host-src/misc/lzo.c | 126 +++++----- host-src/tool/Makefile | 5 +- host-src/tool/dc-tool.c | 331 +++++++++++++-------------- host-src/tool/syscalls.c | 151 ++++++------ host-src/tool/unlink.c | 15 +- host-src/tool/utils.c | 13 +- make-cd/Makefile | 12 +- target-inc/_ansi.h | 54 ++--- target-inc/ar.h | 28 +-- target-inc/assert.h | 4 +- target-inc/ctype.h | 50 ++-- target-inc/grp.h | 36 +-- target-inc/ieeefp.h | 205 ++++++++--------- target-inc/locale.h | 47 ++-- target-inc/machine/fastmath.h | 33 ++- target-inc/machine/setjmp-dj.h | 18 +- target-inc/malloc.h | 22 +- target-inc/math.h | 89 ++++---- target-inc/paths.h | 6 +- target-inc/process.h | 10 +- target-inc/pwd.h | 40 ++-- target-inc/setjmp.h | 8 +- target-inc/signal.h | 18 +- target-inc/stdio.h | 294 ++++++++++++------------ target-inc/stdlib.h | 146 ++++++------ target-inc/string.h | 75 +++--- target-inc/sys/_types.h | 4 +- target-inc/sys/dirent.h | 10 +- target-inc/sys/errno.h | 180 +++++++-------- target-inc/sys/fcntl.h | 220 +++++++++--------- target-inc/sys/param.h | 10 +- target-inc/sys/reent.h | 210 +++++++++-------- target-inc/sys/resource.h | 8 +- target-inc/sys/signal.h | 193 ++++++++-------- target-inc/sys/stat-dj.h | 56 ++--- target-inc/sys/stat.h | 191 ++++++++-------- target-inc/sys/syscall.h | 52 ++--- target-inc/sys/time.h | 16 +- target-inc/sys/timeb.h | 11 +- target-inc/sys/times.h | 14 +- target-inc/sys/types.h | 82 ++++--- target-inc/sys/unistd.h | 210 ++++++++--------- target-inc/sys/utime.h | 7 +- target-inc/sys/wait.h | 12 +- target-inc/time.h | 43 ++-- target-inc/unctrl.h | 8 +- target-inc/unistd.h | 2 +- target-inc/utmp.h | 1 - target-src/dcload/Makefile | 4 +- target-src/dcload/asm.h | 8 +- target-src/dcload/cdfs_syscalls.c | 82 +++---- target-src/dcload/dcload.c | 468 ++++++++++++++++++-------------------- target-src/dcload/memcmp.c | 92 ++++---- target-src/dcload/memmove.c | 129 ++++++----- target-src/dcload/scif.c | 43 ++-- target-src/dcload/syscalls.c | 168 +++++++------- 62 files changed, 2206 insertions(+), 2369 deletions(-) diff --git a/example-src/Makefile b/example-src/Makefile index 6b06c0b..d82a7aa 100644 --- a/example-src/Makefile +++ b/example-src/Makefile @@ -1,6 +1,6 @@ include ../Makefile.cfg -CC = $(TARGETCC) +CC = $(TARGETCC) INCLUDE = -I../target-inc CFLAGS = $(TARGETCFLAGS) OBJCOPY = $(TARGETOBJCOPY) @@ -32,8 +32,8 @@ exception-test: $(OBJECTS) exception-test.o .PHONY : clean clean: - rm -f *.o console-test exception-test + -rm -f *.o console-test exception-test .PHONY : distclean distclean: clean - rm -f *.bin + -rm -f *.bin diff --git a/example-src/console-test.c b/example-src/console-test.c index 3a71e72..2db2b49 100644 --- a/example-src/console-test.c +++ b/example-src/console-test.c @@ -1,34 +1,31 @@ #include "dcload-syscalls.h" -int main(void) -{ +int main(void) { int fd; unsigned char buffer[2048]; int count; unsigned char wrkmem[65536]; assign_wrkmem(wrkmem); - write(1, "dcload console test program\n\n", 30); fd = open("console-test.c", O_RDONLY); - if (fd == -1) { - write(1, "open failed!\n", 14); - exit(1); + if(fd == -1) { + write(1, "open failed!\n", 14); + exit(1); } write(1, "Contents of console-test.c:\n\n", 30); count = read(fd, buffer, 2048); - if (count == -1) { - write(1, "read failed!\n", 14); - exit(1); + if(count == -1) { + write(1, "read failed!\n", 14); + exit(1); } write(1, buffer, count); - close(fd); exit(0); diff --git a/example-src/dcload-syscalls.c b/example-src/dcload-syscalls.c index c59a8bf..cb71ce0 100644 --- a/example-src/dcload-syscalls.c +++ b/example-src/dcload-syscalls.c @@ -1,126 +1,111 @@ #include "dcload-syscall.h" -int link (const char *oldpath, const char *newpath) -{ - if (*DCLOADMAGICADDR == DCLOADMAGICVALUE) - return dcloadsyscall(pclinknr, oldpath, newpath); +int link(const char *oldpath, const char *newpath) { + if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) + return dcloadsyscall(pclinknr, oldpath, newpath); else - return -1; + return -1; } -int read (int file, char *ptr, int len) -{ - if (*DCLOADMAGICADDR == DCLOADMAGICVALUE) - return dcloadsyscall(pcreadnr, file, ptr, len); +int read(int file, char *ptr, int len) { + if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) + return dcloadsyscall(pcreadnr, file, ptr, len); else - return -1; + return -1; } -int lseek (int file, int ptr, int dir) -{ - if (*DCLOADMAGICADDR == DCLOADMAGICVALUE) - return dcloadsyscall(pclseeknr, file, ptr, dir); +int lseek(int file, int ptr, int dir) { + if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) + return dcloadsyscall(pclseeknr, file, ptr, dir); else - return -1; + return -1; } -int write ( int file, char *ptr, int len) -{ - if (*DCLOADMAGICADDR == DCLOADMAGICVALUE) - return dcloadsyscall(pcwritenr, file, ptr, len); +int write(int file, char *ptr, int len) { + if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) + return dcloadsyscall(pcwritenr, file, ptr, len); else - return -1; + return -1; } -int close (int file) -{ - if (*DCLOADMAGICADDR == DCLOADMAGICVALUE) - return dcloadsyscall(pcclosenr, file); +int close(int file) { + if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) + return dcloadsyscall(pcclosenr, file); else - return -1; + return -1; } -int fstat (int file, struct stat *st) -{ - if (*DCLOADMAGICADDR == DCLOADMAGICVALUE) - return dcloadsyscall(pcfstatnr, file, st); +int fstat(int file, struct stat *st) { + if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) + return dcloadsyscall(pcfstatnr, file, st); else - return -1; + return -1; } -int open (const char *path, int flags) -{ - if (*DCLOADMAGICADDR == DCLOADMAGICVALUE) - return dcloadsyscall(pcopennr, path, flags); +int open(const char *path, int flags) { + if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) + return dcloadsyscall(pcopennr, path, flags); else - return -1; + return -1; } -int creat (const char *path, int mode) -{ +int creat(const char *path, int mode) { if (*DCLOADMAGICADDR == DCLOADMAGICVALUE) - return dcloadsyscall(pccreatnr, path, mode); + return dcloadsyscall(pccreatnr, path, mode); else - return -1; + return -1; } -int unlink (const char *path) -{ - if (*DCLOADMAGICADDR == DCLOADMAGICVALUE) - return dcloadsyscall(pcunlinknr, path); +int unlink(const char *path) { + if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) + return dcloadsyscall(pcunlinknr, path); else - return -1; + return -1; } -void exit (int status) -{ - if (*DCLOADMAGICADDR == DCLOADMAGICVALUE) - dcloadsyscall(pcexitnr); +void exit(int status) { + if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) + dcloadsyscall(pcexitnr); + __exit(status); } -int stat (const char *path, struct stat *st) -{ - if (*DCLOADMAGICADDR == DCLOADMAGICVALUE) - return dcloadsyscall(pcstatnr, path, st); +int stat(const char *path, struct stat *st) { + if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) + return dcloadsyscall(pcstatnr, path, st); else - return -1; + return -1; } -int chmod (const char *path, short mode) -{ - if (*DCLOADMAGICADDR == DCLOADMAGICVALUE) - return dcloadsyscall(pcchmodnr, path, mode); +int chmod(const char *path, short mode) { + if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) + return dcloadsyscall(pcchmodnr, path, mode); else - return -1; + return -1; } -int utime (const char *path, char *times) -{ - if (*DCLOADMAGICADDR == DCLOADMAGICVALUE) - return dcloadsyscall(pcutimenr, path, times); +int utime(const char *path, char *times) { + if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) + return dcloadsyscall(pcutimenr, path, times); else - return -1; + return -1; } -int chdir (const char *path) -{ - if (*DCLOADMAGICADDR == DCLOADMAGICVALUE) - return dcloadsyscall(pcchdirnr, path); +int chdir(const char *path) { + if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) + return dcloadsyscall(pcchdirnr, path); else - return -1; + return -1; } -long time(long *t) -{ - if (*DCLOADMAGICADDR == DCLOADMAGICVALUE) - return dcloadsyscall(pctimenr, t); +long time(long *t) { + if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) + return dcloadsyscall(pctimenr, t); else - return -1; + return -1; } -void assign_wrkmem(unsigned char *wrkmem) -{ - if (*DCLOADMAGICADDR == DCLOADMAGICVALUE) - dcloadsyscall(pcassignwrkmem, wrkmem); +void assign_wrkmem(unsigned char *wrkmem) { + if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) + dcloadsyscall(pcassignwrkmem, wrkmem); } diff --git a/example-src/dcload-syscalls.h b/example-src/dcload-syscalls.h index 585cafb..58c27d3 100644 --- a/example-src/dcload-syscalls.h +++ b/example-src/dcload-syscalls.h @@ -5,20 +5,20 @@ #define O_WRONLY 1 #define O_RDWR 2 -int link (const char *oldpath, const char *newpath); -int read (int file, char *ptr, int len); -int lseek (int file, int ptr, int dir); -int write ( int file, char *ptr, int len); -int close (int file); -int fstat (int file, struct stat *st); -int open (const char *path, int flags); -int creat (const char *path, int mode); -int unlink (const char *path); -void exit (int status); -int stat (const char *path, struct stat *st); -int chmod (const char *path, short mode); -int utime (const char *path, char *times); -int chdir (const char *path); +int link(const char *oldpath, const char *newpath); +int read(int file, char *ptr, int len); +int lseek(int file, int ptr, int dir); +int write( int file, char *ptr, int len); +int close(int file); +int fstat(int file, struct stat *st); +int open(const char *path, int flags); +int creat(const char *path, int mode); +int unlink(const char *path); +void exit(int status); +int stat(const char *path, struct stat *st); +int chmod(const char *path, short mode); +int utime(const char *path, char *times); +int chdir(const char *path); long time(long *t); void assign_wrkmem(unsigned char *wrkmem); diff --git a/example-src/exception-test.c b/example-src/exception-test.c index c0c2036..60507c4 100644 --- a/example-src/exception-test.c +++ b/example-src/exception-test.c @@ -1,5 +1,4 @@ -int main(void) -{ +int main(void) { int i; i = *((volatile unsigned int *)2); diff --git a/host-src/misc/Makefile b/host-src/misc/Makefile index 4f3db8f..a0e34a3 100644 --- a/host-src/misc/Makefile +++ b/host-src/misc/Makefile @@ -1,10 +1,10 @@ include ../../Makefile.cfg -LZOPATH = ../../minilzo.106 +LZOPATH = ../../minilzo.106 -CC = $(HOSTCC) -CFLAGS = $(HOSTCFLAGS) -INCLUDE = -I$(LZOPATH) +CC = $(HOSTCC) +CFLAGS = $(HOSTCFLAGS) +INCLUDE = -I$(LZOPATH) LZOFILES = $(LZOPATH)/minilzo.c $(LZOPATH)/minilzo.h $(LZOPATH)/lzoconf.h .c.o: @@ -20,8 +20,8 @@ minilzo.o: $(LZOFILES) .PHONY : clean clean: - rm -f *.o + -rm -f *.o .PHONY : distclean distclean: clean - rm -f lzo \ No newline at end of file + -rm -f lzo \ No newline at end of file diff --git a/host-src/misc/lzo.c b/host-src/misc/lzo.c index 371ca86..5a61ae4 100644 --- a/host-src/misc/lzo.c +++ b/host-src/misc/lzo.c @@ -32,72 +32,68 @@ static HEAP_ALLOC(wrkmem,LZO1X_1_MEM_COMPRESS); -void usage(void) -{ - printf("usage: lzo <in> <out>\n"); - exit(1); +void usage(void) { + printf("usage: lzo <in> <out>\n"); + exit(1); } -int main(int argc, char *argv[]) -{ - int in, out; - unsigned char * data; - unsigned char * cdata; - int r; - unsigned int length,clength; - - if (argc != 3) - usage(); - - in = open(argv[1], O_RDONLY); - - if (in < 0) { - perror(argv[1]); - exit(1); - } - - out = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC, 0644); - - if (out < 0) { - perror(argv[2]); - exit(1); - } - - length = lseek(in, 0, SEEK_END); - lseek(in, 0, SEEK_SET); - - data = malloc(length); - cdata = malloc(length+length/64 + 16 + 3); - - read(in, data, length); - - if (lzo_init() != LZO_E_OK) - { - printf("lzo_init() failed !!!\n"); - exit(1); - } - - r = lzo1x_1_compress(data,length,cdata,&clength,wrkmem); - if (r == LZO_E_OK) - printf("compressed %lu bytes into %lu bytes\n", - (long) length, (long) clength); - else - { - /* this should NEVER happen */ - printf("internal error - compression failed: %d\n", r); - return 2; - } - /* check for an incompressible block */ - if (clength >= length) - { - printf("This block contains incompressible data.\n"); - return 0; - } - - write(out, cdata, clength); - - close(in); - close(out); - exit(0); +int main(int argc, char *argv[]) { + int in, out; + unsigned char *data; + unsigned char *cdata; + int r; + unsigned int length, clength; + + if(argc != 3) + usage(); + + in = open(argv[1], O_RDONLY); + + if(in < 0) { + perror(argv[1]); + exit(1); + } + + out = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC, 0644); + + if(out < 0) { + perror(argv[2]); + exit(1); + } + + length = lseek(in, 0, SEEK_END); + lseek(in, 0, SEEK_SET); ...<truncated>... hooks/post-receive -- A serial program loader for the Dreamcast. |