Merge remote-tracking branch 'upstream/default' into carl-ansi-part1

# Conflicts:
#	util/arch/archiver.c
#	util/led/finish.c
#	util/led/output.c
This commit is contained in:
carl 2019-03-24 21:42:56 +08:00
commit 56e64a1fd0
30 changed files with 57 additions and 29 deletions

View file

@ -10,6 +10,8 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
struct exec { struct exec {
short a_magic; short a_magic;
@ -28,6 +30,7 @@ struct nlist
short n_value; short n_value;
}; };
#include <object.h>
#include <out.h> #include <out.h>
#ifndef NORCSID #ifndef NORCSID
@ -164,14 +167,14 @@ main(argc, argv)
} }
/* Action at last */ /* Action at last */
wr_int2(e->a_magic); cv_int2(e->a_magic);
wr_int2(e->a_text); cv_int2(e->a_text);
wr_int2(e->a_data); cv_int2(e->a_data);
wr_int2(e->a_bss); cv_int2(e->a_bss);
wr_int2(e->a_syms); cv_int2(e->a_syms);
wr_int2(e->a_entry); cv_int2(e->a_entry);
wr_int2(e->a_unused); cv_int2(e->a_unused);
wr_int2(e->a_flag); cv_int2(e->a_flag);
emits(&outsect[TEXTSG]) ; emits(&outsect[TEXTSG]) ;
emits(&outsect[ROMSG]) ; emits(&outsect[ROMSG]) ;
emits(&outsect[DATASG]) ; emits(&outsect[DATASG]) ;
@ -180,14 +183,14 @@ main(argc, argv)
return 0; return 0;
} }
wr_int2(n) cv_int2(n)
{ {
putc(n, output); putc(n, output);
putc((n>>8), output); putc((n>>8), output);
} }
/* /*
wr_long(l) cv_long(l)
long l; long l;
{ {
putc((int)(l >> 16), output); putc((int)(l >> 16), output);
@ -231,7 +234,6 @@ emit_symtab()
struct nlist PDP_name; /* symbol table entry in PDP V7 format */ struct nlist PDP_name; /* symbol table entry in PDP V7 format */
register unsigned short i; register unsigned short i;
extern char *malloc();
char *chars; char *chars;
long l; long l;
long off = OFF_CHAR(outhead); long off = OFF_CHAR(outhead);
@ -289,8 +291,8 @@ emit_symtab()
PDP_name.n_name[j] = 0; PDP_name.n_name[j] = 0;
} }
fwrite((char *) &PDP_name, sizeof(char), 8, output); fwrite((char *) &PDP_name, sizeof(char), 8, output);
wr_int2(PDP_name.n_type); cv_int2(PDP_name.n_type);
wr_int2(PDP_name.n_value); cv_int2(PDP_name.n_value);
} }
} }

View file

@ -11,6 +11,7 @@
struct ar_hdr; struct ar_hdr;
struct outhead; struct outhead;
struct outname;
struct outrelo; struct outrelo;
struct outsect; struct outsect;
struct ranlib; struct ranlib;

View file

@ -4,6 +4,7 @@
*/ */
/* $Id$ */ /* $Id$ */
#include <unistd.h>
#include "system.h" #include "system.h"
int int

View file

@ -4,6 +4,7 @@
*/ */
/* $Id$ */ /* $Id$ */
#include <unistd.h>
#include "system.h" #include "system.h"
void void

View file

@ -4,6 +4,7 @@
*/ */
/* $Id$ */ /* $Id$ */
#include <fcntl.h>
#include "system.h" #include "system.h"
extern File *_get_entry(); extern File *_get_entry();
@ -14,7 +15,7 @@ sys_create(filep, path, mode)
char *path; char *path;
int mode; int mode;
{ {
register fd; register int fd;
register File *fp; register File *fp;
if ((fp = _get_entry()) == (File *)0) if ((fp = _get_entry()) == (File *)0)

View file

@ -4,6 +4,8 @@
*/ */
/* $Id$ */ /* $Id$ */
#include <fcntl.h>
#include <unistd.h>
#include "system.h" #include "system.h"
extern File *_get_entry(); extern File *_get_entry();
@ -16,7 +18,6 @@ sys_open(path, flag, filep)
{ {
register int fd; register int fd;
register File *fp; register File *fp;
long lseek();
if ((fp = _get_entry()) == (File *)0) if ((fp = _get_entry()) == (File *)0)
return 0; return 0;

View file

@ -4,6 +4,7 @@
*/ */
/* $Id$ */ /* $Id$ */
#include <unistd.h>
#include "system.h" #include "system.h"
int int

View file

@ -4,10 +4,9 @@
*/ */
/* $Id$ */ /* $Id$ */
#include <unistd.h>
#include "system.h" #include "system.h"
long lseek();
int int
sys_seek(fp, off, whence, poff) sys_seek(fp, off, whence, poff)
File *fp; File *fp;

View file

@ -1,5 +1,4 @@
#define _XOPEN_SOURCE 500 #define _XOPEN_SOURCE 700
#define _POSIX_C_SOURCE 200809
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -440,4 +439,4 @@ int file_rename(cpm_filename_t* src, cpm_filename_t* dest)
int drivefd = get_drive_fd(src); int drivefd = get_drive_fd(src);
return renameat(drivefd, srcunixfilename, drivefd, destunixfilename); return renameat(drivefd, srcunixfilename, drivefd, destunixfilename);
} }

View file

@ -18,6 +18,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include <out.h> #include <out.h>
#include <object.h> #include <object.h>

View file

@ -6,6 +6,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include "ack.h" #include "ack.h"
#include "list.h" #include "list.h"
#include "trans.h" #include "trans.h"

View file

@ -4,9 +4,11 @@
* *
*/ */
#include <fcntl.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include "ack.h" #include "ack.h"
#include "list.h" #include "list.h"
#include "trans.h" #include "trans.h"
@ -386,7 +388,7 @@ static int process(char* arg)
if (linker) if (linker)
add_input(&orig, linker); add_input(&orig, linker);
return 1; return 1;
case F_OK: case F_TRANSFORM:
break; break;
} }
if (!phase) if (!phase)
@ -555,7 +557,7 @@ static void setneeds(const char* suffix, int tail)
p_suffix = suffix; p_suffix = suffix;
switch (getpath(&phase)) switch (getpath(&phase))
{ {
case F_OK: case F_TRANSFORM:
for (; phase; phase = phase->t_next) for (; phase; phase = phase->t_next)
{ {
if (phase->t_needed) if (phase->t_needed)

View file

@ -4,9 +4,11 @@
* *
*/ */
#include <fcntl.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include "ack.h" #include "ack.h"
#include "list.h" #include "list.h"
#include "trans.h" #include "trans.h"

View file

@ -237,7 +237,7 @@ static enum f_path scan_end(trf **first) { /* Finalization */
*first= curr ; *first= curr ;
} }
if ( curr->t_next ) { if ( curr->t_next ) {
return F_OK ; return F_TRANSFORM ;
} }
prev=curr ; prev=curr ;
} }
@ -249,7 +249,7 @@ static enum f_path scan_end(trf **first) { /* Finalization */
if ( prev ) { if ( prev ) {
prev->t_keep=YES ; prev->t_keep=YES ;
} }
return F_OK ; return F_TRANSFORM ;
} }
static void find_cpp(void) { static void find_cpp(void) {

View file

@ -57,7 +57,7 @@ void add_input(path *, trf *);
int runphase(trf *); int runphase(trf *);
/* scan.c */ /* scan.c */
enum f_path { F_OK, F_NOMATCH, F_NOPATH } ; enum f_path { F_TRANSFORM, F_NOMATCH, F_NOPATH } ;
enum f_path getpath(trf **); enum f_path getpath(trf **);
/* trans.c */ /* trans.c */

View file

@ -24,6 +24,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <string.h> #include <string.h>
#include <inttypes.h> #include <inttypes.h>
#include <unistd.h>
#include "out.h" #include "out.h"
#define ASSERT(x) switch (2) { case 0: case (x): ; } #define ASSERT(x) switch (2) { case 0: case (x): ; }

View file

@ -10,11 +10,14 @@
** anm [-gopruns] [name ...] ** anm [-gopruns] [name ...]
*/ */
#include <fcntl.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <unistd.h>
#include "object.h"
#include "out.h" #include "out.h"
#include "arch.h" #include "arch.h"
#include "ranlib.h" #include "ranlib.h"

View file

@ -7,6 +7,7 @@ static char rcsid[] = "$Id$";
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <object.h>
#include <out.h> #include <out.h>
#define OK 0 /* Return value of gethead if Orl Korekt. */ #define OK 0 /* Return value of gethead if Orl Korekt. */

View file

@ -6,6 +6,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "object.h"
#include "out.h" #include "out.h"
/* /*

View file

@ -4,9 +4,12 @@
*/ */
/* $Id$ */ /* $Id$ */
#include <fcntl.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <signal.h> #include <signal.h>
#include <unistd.h>
#include "object.h"
#include "out.h" #include "out.h"
/* /*

View file

@ -26,6 +26,7 @@
#endif #endif
*/ */
#include <fcntl.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include <stdio.h> #include <stdio.h>
@ -552,6 +553,7 @@ void get(int argc, char *argv[])
*/ */
void add(char *name, FILE* ar, FILE* dst, char *mess) void add(char *name, FILE* ar, FILE* dst, char *mess)
{ {
<<<<<<< HEAD
static MEMBER member; static MEMBER member;
size_t read_chars; size_t read_chars;
struct stat status; struct stat status;

View file

@ -26,7 +26,7 @@ int main(int argc, const char* argv[])
count++; count++;
} }
printf("\n};\n"); printf("\n};\n");
printf("const size_t %s_len = %d;\n", argv[1], count); printf("const size_t %s_len = %zu;\n", argv[1], count);
return 0; return 0;
} }

View file

@ -4,8 +4,10 @@
/* $Id$ */ /* $Id$ */
#include <fcntl.h>
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include <unistd.h>
#include "logging.h" #include "logging.h"
#include "global.h" #include "global.h"

View file

@ -11,6 +11,7 @@ static char rcsid[] = "$Id$";
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include "arch.h" #include "arch.h"
#include "object.h"
#include "out.h" #include "out.h"
#include "ranlib.h" #include "ranlib.h"
#include "object.h" #include "object.h"

View file

@ -11,6 +11,7 @@ static char rcsid[] = "$Id$";
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdarg.h> #include <stdarg.h>
#include <unistd.h>
#include <out.h> #include <out.h>
#include "const.h" #include "const.h"

View file

@ -126,8 +126,6 @@ static void handle_relos(struct outhead *head, struct outsect *sects, struct out
register int sectindex; register int sectindex;
register int nrelo; register int nrelo;
register char *emit; register char *emit;
extern char *getemit();
extern struct outrelo *nextrelo();
static long zeros[MAXSECT]; static long zeros[MAXSECT];
if (incore) { if (incore) {
@ -168,7 +166,6 @@ static void handle_relos(struct outhead *head, struct outsect *sects, struct out
long sz = sects[sectindex].os_flen; long sz = sects[sectindex].os_flen;
long sf = 0; long sf = 0;
long blksz; long blksz;
char *getblk();
emit = getblk(sz, &blksz, sectindex); emit = getblk(sz, &blksz, sectindex);
while (sz) { while (sz) {

View file

@ -12,6 +12,7 @@ static char rcsid[] = "$Id$";
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <string.h> #include <string.h>
#include <object.h>
#include "out.h" #include "out.h"
#include "object.h" #include "object.h"
#include "const.h" #include "const.h"

View file

@ -23,6 +23,7 @@ static char rcsid[]= "$Id$";
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
#include <unistd.h>
#include "varinfo.h" #include "varinfo.h"
#include "param.h" #include "param.h"
#include "reg.h" #include "reg.h"

View file

@ -4,6 +4,7 @@ static char rcsid[] = "$Id$";
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h>
#include "param.h" #include "param.h"
#include "types.h" #include "types.h"
#include <em_pseu.h> #include <em_pseu.h>

View file

@ -11,6 +11,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h>
#include "Lpars.h" #include "Lpars.h"
extern int lineno, newline; extern int lineno, newline;