all: ar ar.1.0 ar.5.0
ar: ${OBJS} ${EXTRAOBJ}
- ${CC} ${SEPFLAG} -o ar ${OBJS} ${EXTRAOBJ}
+ ${CC} ${SEPFLAG} -o ar ${OBJS} ${EXTRAOBJ} ${LIBCROSS}
ar.1.0: ar.1
${MANROFF} ar.1 > ar.1.0
CHDR chdr;
u_int options;
char *archive, *envtmp, *posarg, *posname;
-static void badoptions PARAMS((char *arg));
-static void usage PARAMS((void));
+
+static void badoptions __P((char *arg));
+static void usage __P((void));
/*
* main --
#include <sys/param.h>
#include <sys/stat.h>
#include <errno.h>
-#include <sys/dir.h>
#include <sys/file.h>
#include <ar.h>
#include <stdio.h>
#include "archive.h"
#include "extern.h"
+#ifdef CROSS
+#include "cross/ar.h"
+#include "cross/sys/dir.h"
+#else
+#include <ar.h>
+#include <sys/dir.h>
+#define CROSS_MAXNAMLEN MAXNAMLEN
+#define cross_ar_hdr ar_hdr
+#endif
+
extern CHDR chdr; /* converted header */
extern char *archive; /* archive name */
extern int errno;
-typedef struct ar_hdr HDR;
+typedef struct cross_ar_hdr HDR;
static char hb[sizeof(HDR) + 1]; /* real header */
int open_archive(mode) int mode; {
* read the archive header for this member
*/
int get_arobj(fd) int fd; {
- struct ar_hdr *hdr;
+ struct cross_ar_hdr *hdr;
register int len, nr;
register char *p;
char buf[20];
badfmt();
}
- hdr = (struct ar_hdr *)hb;
+ hdr = (struct cross_ar_hdr *)hb;
if (strncmp(hdr->ar_fmag, ARFMAG, sizeof(ARFMAG) - 1))
badfmt();
*/
if (!bcmp(hdr->ar_name, AR_EFMT1, sizeof(AR_EFMT1) - 1)) {
chdr.lname = len = atoi(hdr->ar_name + sizeof(AR_EFMT1) - 1);
- if (len <= 0 || len > MAXNAMLEN)
+ if (len <= 0 || len > CROSS_MAXNAMLEN)
badfmt();
nr = read(fd, chdr.name, (size_t)len);
if (nr != len) {
void put_arobj(cfp, sb) CF *cfp; struct stat *sb; {
register int lname;
register char *name;
- struct ar_hdr *hdr;
+ struct cross_ar_hdr *hdr;
off_t size;
/*
#define _ARCHIVE_H 1
#include <sys/stat.h>
-#include "krcompat.h"
+#include <sys/types.h>
+
+#ifdef CROSS
+#include "cross/sys/dir.h"
+#else
+#include <sys/dir.h>
+#define CROSS_MAXNAMLEN MAXNAMLEN
+#endif
/* Ar(1) options. */
#define AR_A 0x0001
int gid; /* group */
int uid; /* owner */
u_short mode; /* permissions */
- char name[MAXNAMLEN + 1]; /* name */
+ char name[CROSS_MAXNAMLEN + 1]; /* name */
} CHDR;
/* Header format strings. */
#define OLDARMAXNAME 15
#define HDR3 "%-16.15s%-12ld%-6u%-6u%-8o%-10ld%2s"
-int open_archive PARAMS((int mode));
-void close_archive PARAMS((int fd));
-int get_arobj PARAMS((int fd));
-void put_arobj PARAMS((CF *cfp, struct stat *sb));
-void copy_ar PARAMS((CF *cfp, off_t size));
-void skip_arobj PARAMS((int fd));
+#ifndef __P
+#ifdef __STDC__
+#define __P(params) params
+#else
+#define __P(params) ()
+#endif
+#endif
+
+int open_archive __P((int mode));
+void close_archive __P((int fd));
+int get_arobj __P((int fd));
+void put_arobj __P((CF *cfp, struct stat *sb));
+void copy_ar __P((CF *cfp, off_t size));
+void skip_arobj __P((int fd));
#endif
#include <stdlib.h>
#include <unistd.h>
-#include "krcompat.h"
+
+#ifndef __P
+#ifdef __STDC__
+#define __P(params) params
+#else
+#define __P(params) ()
+#endif
+#endif
/* append.c */
-int append PARAMS((char **argv));
+int append __P((char **argv));
/* ar.c */
-int main PARAMS((int argc, char **argv));
+int main __P((int argc, char **argv));
/* contents.c */
-int contents PARAMS((register char **argv));
+int contents __P((register char **argv));
/* delete.c */
-int delete PARAMS((register char **argv));
+int delete __P((register char **argv));
/* extract.c */
-int extract PARAMS((char **argv));
+int extract __P((char **argv));
/* misc.c */
-int tmp PARAMS((void));
-char *files PARAMS((char **argv));
-void orphans PARAMS((char **argv));
-char *rname PARAMS((char *path));
-int compare PARAMS((char *dest));
-void badfmt PARAMS((void));
-void error PARAMS((char *name));
+int tmp __P((void));
+char *files __P((char **argv));
+void orphans __P((char **argv));
+char *rname __P((char *path));
+int compare __P((char *dest));
+void badfmt __P((void));
+void error __P((char *name));
/* move.c */
-int move PARAMS((char **argv));
+int move __P((char **argv));
/* print.c */
-int print PARAMS((char **argv));
+int print __P((char **argv));
/* replace.c */
-int replace PARAMS((char **argv));
+int replace __P((char **argv));
/* strmode.c */
-void strmode PARAMS((register mode_t mode, register char *p));
+void strmode __P((register mode_t mode, register char *p));
#endif
+++ /dev/null
-../../../include/ar.h
\ No newline at end of file
+++ /dev/null
-#ifndef _KRCOMPAT_H
-#define _KRCOMPAT_H 1
-
-#undef PARAMS
-#ifdef __STDC__
-#include <stdarg.h>
-#define VA_START(ap, arg) va_start(ap, arg)
-#define PARAMS(args) args
-#else
-#include <varargs.h>
-#define VA_START(ap, arg) va_start(ap)
-#define PARAMS(args) ()
-#endif
-
-#ifdef __GNUC__
-#define NORETURN __attribute__ ((noreturn))
-#else
-#define NORETURN
-#endif
-
-#endif
#!/bin/sh
ROOT="`pwd |sed -e 's/\/bin\/ar$//'`"
-HOSTCC="cc -g -Iinclude -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result"
+HOSTCC="cc -I$ROOT/cross/usr/include -L$ROOT/cross/usr/lib -DCROSS -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result"
+HOSTLIBCROSS="-lcross"
INSTALL="$ROOT/scripts/install.sh --strip-program=/bin/true"
MANROFF="nroff -man"
mkdir --parents "$ROOT/cross/bin"
mkdir --parents "$ROOT/cross/usr/man/cat1"
mkdir --parents "$ROOT/cross/usr/man/cat5"
-make CC="$HOSTCC" MANROFF="$MANROFF" SEPFLAG= && \
+make CC="$HOSTCC" LIBCROSS="$HOSTLIBCROSS" MANROFF="$MANROFF" SEPFLAG= && \
make INSTALL="$INSTALL" DESTDIR="$ROOT/cross" install
#else
#include <a.out.h>
#include <ar.h>
+#include <sys/types.h> /* work around bug in original 2.11BSD ranlib.h */
#include <ranlib.h>
-#include <sys/types.h>
#define cross_ar_hdr ar_hdr
#define cross_exec exec
#define cross_int_t int
INSTALL=install
-# using VPATH to compile ./nsym.o from ../../lib/libc/pdp/gen/nsym.c does not
-# work if there is a ../../lib/libc.pdp/gen/nsym.o leftover from building libc
-#VPATH=../../lib/libc/pdp/gen
-SRCS=nm.c ../../lib/libc/pdp/gen/nsym.c
-OBJS=nm.o ../../lib/libc/pdp/gen/nsym.o
+SRCS=nm.c
+OBJS=nm.o
CFLAGS=-O -I../ar
SEPFLAG=-i
all: nm
nm: ${OBJS}
- ${CC} ${SEPFLAG} -o nm ${OBJS}
+ ${CC} ${SEPFLAG} -o nm ${OBJS} ${LIBCROSS}
install: all
${INSTALL} -c -s -o bin -g bin -m 755 nm ${DESTDIR}/bin/nm
+++ /dev/null
-../../../include/a.out.h
\ No newline at end of file
+++ /dev/null
-../../../include/ar.h
\ No newline at end of file
+++ /dev/null
-../../../include/nlist.h
\ No newline at end of file
+++ /dev/null
-../../../../sys/h/exec.h
\ No newline at end of file
+++ /dev/null
-#ifndef _KRCOMPAT_H
-#define _KRCOMPAT_H 1
-
-#undef PARAMS
-#ifdef __STDC__
-#include <stdarg.h>
-#define VA_START(ap, arg) va_start(ap, arg)
-#define PARAMS(args) args
-#else
-#include <varargs.h>
-#define VA_START(ap, arg) va_start(ap)
-#define PARAMS(args) ()
-#endif
-
-#ifdef __GNUC__
-#define NORETURN __attribute__ ((noreturn))
-#else
-#define NORETURN
-#endif
-
-#endif
#!/bin/sh
ROOT="`pwd |sed -e 's/\/bin\/nm$//'`"
-HOSTCC="cc -g -Iinclude -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result"
+HOSTCC="cc -I$ROOT/cross/usr/include -L$ROOT/cross/usr/lib -DCROSS -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result"
+HOSTLIBCROSS="-lcross"
INSTALL="$ROOT/scripts/install.sh --strip-program=/bin/true"
MANROFF="nroff -man"
mkdir --parents "$ROOT/cross/bin"
-make CC="$HOSTCC" MANROFF="$MANROFF" SEPFLAG= && \
+mkdir --parents "$ROOT/cross/usr/man/cat1"
+make CC="$HOSTCC" LIBCROSS="$HOSTLIBCROSS" MANROFF="$MANROFF" STAGEPREFIX="\\\"$ROOT/stage\\\"" SEPFLAG= LDFLAGS="-L$ROOT/cross/usr/lib" && \
make INSTALL="$INSTALL" DESTDIR="$ROOT/cross" install
*/
#include <sys/types.h>
#include <sys/dir.h>
-#include <ar.h>
#include <stdio.h>
#include <ctype.h>
-#include <a.out.h>
#include <sys/file.h>
#include "archive.h"
#include <stdlib.h>
#include <string.h>
-#include "krcompat.h"
-#ifdef pdp11
-#include <sys/types.h>
-#define OFF_T off_t
+#ifdef CROSS
+#include "cross/a.out.h"
+#include "cross/ar.h"
+#include "cross/sys/types.h"
#else
-#include <stdint.h>
-#define OFF_T int32_t
+#include <a.out.h>
+#include <ar.h>
+#include <sys/types.h>
+#define cross_ar_hdr ar_hdr
+#define cross_exec exec
+#define cross_nlist nlist
+#define cross_off_t off_t
+#define cross_xexec xexec
#endif
CHDR chdr;
char *strp;
union {
char mag_armag[SARMAG+1];
- struct xexec mag_exp;
+ struct cross_xexec mag_exp;
} mag_un;
- OFF_T off;
+ cross_off_t off;
int narg, errs;
-/* we do not support n_name when cross compiling, it breaks on 64-bit hosts */
-#ifdef pdp11
+#ifdef CROSS
+#define N_NAME(sym) (strp + (int)(sym).n_un.n_strx)
+#else
#define N_NAME(sym) ((sym).n_un.n_name)
+#endif
+
+#ifndef __P
+#ifdef __STDC__
+#define __P(params) params
#else
-#define N_NAME(sym) (strp + (int)(sym).n_un.n_strx)
+#define __P(params) ()
+#endif
#endif
-int main PARAMS((int argc, char **argv));
-void namelist PARAMS((void));
-void psyms PARAMS((register struct nlist *symp, int nsyms));
-int compare PARAMS((register struct nlist *p1, register struct nlist *p2));
-int nextel PARAMS((FILE *af));
-void error PARAMS((int n, char *s));
-int _get_arobj PARAMS((FILE *fp));
+int main __P((int argc, char **argv));
+void namelist __P((void));
+void psyms __P((register struct cross_nlist *symp, int nsyms));
+int compare __P((register struct cross_nlist *p1, register struct cross_nlist *p2));
+int nextel __P((FILE *af));
+void error __P((int n, char *s));
+int _get_arobj __P((FILE *fp));
int main(argc, argv) int argc; char **argv; {
if (--argc>0 && argv[1][0]=='-' && argv[1][1]!=0) {
void namelist() {
char ibuf[BUFSIZ];
register FILE *fi;
-#ifndef pdp11
- /* note: must be at least as large as SARMAG+1, struct nlist, OFF_T */
- char temp[sizeof(struct xexec)];
-#endif
archive = 0;
fi = fopen(*xargv, "r");
setbuf(fi, ibuf);
off = 0;
-#ifdef pdp11
fread((char *)&mag_un, 1, sizeof(mag_un), fi);
if (strncmp(mag_un.mag_armag, ARMAG, SARMAG)==0)
-#else
- fread(temp, 1, sizeof(mag_un), fi);
- if (strncmp(temp, ARMAG, SARMAG)==0)
-#endif
{
archive++;
off = SARMAG;
}
else {
-#ifndef pdp11
- mag_un.mag_exp.e.a_magic = (temp[0] & 0xff) | ((temp[1] & 0xff) << 8);
+#ifdef CROSS
+ mag_un.mag_exp.e.a_magic = cross_read_int((char *)&mag_un.mag_exp.e.a_magic);
#endif
if (N_BADMAG(mag_un.mag_exp.e)) {
error(0, "bad format");
printf("\n%s:\n", *xargv);
}
do {
- OFF_T o, curpos, stroff;
- long strsiz;
+ cross_off_t o, curpos, stroff;
+ cross_off_t strsiz;
register int i, n;
- struct nlist *symp = NULL;
- struct nlist sym;
+ struct cross_nlist *symp = NULL;
+ struct cross_nlist sym;
curpos = ftell(fi);
-#ifdef pdp11
- fread((char *)&mag_un.mag_exp, 1, sizeof(struct xexec), fi);
-#else
- fread(temp, 1, sizeof(struct xexec), fi);
- mag_un.mag_exp.e.a_magic = (temp[0] & 0xff) | ((temp[1] & 0xff) << 8);
- mag_un.mag_exp.e.a_text = (temp[2] & 0xff) | ((temp[3] & 0xff) << 8);
- mag_un.mag_exp.e.a_data = (temp[4] & 0xff) | ((temp[5] & 0xff) << 8);
- mag_un.mag_exp.e.a_bss = (temp[6] & 0xff) | ((temp[7] & 0xff) << 8);
- mag_un.mag_exp.e.a_syms = (temp[8] & 0xff) | ((temp[9] & 0xff) << 8);
- mag_un.mag_exp.e.a_entry = (temp[10] & 0xff) | ((temp[11] & 0xff) << 8);
- mag_un.mag_exp.e.a_unused = (temp[12] & 0xff) | ((temp[13] & 0xff) << 8);
- mag_un.mag_exp.e.a_flag = (temp[14] & 0xff) | ((temp[15] & 0xff) << 8);
- mag_un.mag_exp.o.max_ovl = (temp[16] & 0xff) | ((temp[17] & 0xff) << 8);
+ fread((char *)&mag_un.mag_exp, 1, sizeof(struct cross_xexec), fi);
+#ifdef CROSS
+ mag_un.mag_exp.e.a_magic = cross_read_int((char *)&mag_un.mag_exp.e.a_magic);
+ mag_un.mag_exp.e.a_text = cross_read_uint((char *)&mag_un.mag_exp.e.a_text);
+ mag_un.mag_exp.e.a_data = cross_read_uint((char *)&mag_un.mag_exp.e.a_data);
+ mag_un.mag_exp.e.a_bss = cross_read_uint((char *)&mag_un.mag_exp.e.a_bss);
+ mag_un.mag_exp.e.a_syms = cross_read_uint((char *)&mag_un.mag_exp.e.a_syms);
+ mag_un.mag_exp.e.a_entry = cross_read_uint((char *)&mag_un.mag_exp.e.a_entry);
+ mag_un.mag_exp.e.a_unused = cross_read_uint((char *)&mag_un.mag_exp.e.a_unused);
+ mag_un.mag_exp.e.a_flag = cross_read_uint((char *)&mag_un.mag_exp.e.a_flag);
+ mag_un.mag_exp.o.max_ovl = cross_read_int((char *)&mag_un.mag_exp.o.max_ovl);
for (i = 0; i < NOVL; ++i)
- mag_un.mag_exp.o.ov_siz[i] = (temp[i * 2 + 18] & 0xff) | ((temp[i * 2 + 19] & 0xff) << 8);
+ mag_un.mag_exp.o.ov_siz[i] = cross_read_uint((char *)(mag_un.mag_exp.o.ov_siz + i));
#endif
if (N_BADMAG(mag_un.mag_exp.e))
continue;
o = N_SYMOFF(mag_un.mag_exp);
fseek(fi, (off_t)(curpos + o), L_SET);
- n = mag_un.mag_exp.e.a_syms / sizeof(struct nlist);
+ n = mag_un.mag_exp.e.a_syms / sizeof(struct cross_nlist);
if (n == 0) {
error(0, "no name list");
continue;
if (strp)
free(strp), strp = 0;
while (--n >= 0) {
-#ifdef pdp11
fread((char *)&sym, 1, sizeof(sym), fi);
-#else
- fread(temp, 1, sizeof(sym), fi);
- sym.n_un.n_strx = ((temp[0] & 0xffL) << 16) | ((temp[1] & 0xffL) << 24) |
- (temp[2] & 0xffL) | ((temp[3] & 0xffL) << 8);
- sym.n_type = temp[4] & 0xff;
- sym.n_ovly = temp[5] & 0xff;
- sym.n_value = (temp[6] & 0xff) | ((temp[7] & 0xff) << 8);
+#ifdef CROSS
+ sym.n_un.n_strx = cross_read_off_t((char *)&sym.n_un.n_strx);
+ sym.n_value = cross_read_uint((char *)&sym.n_value);
#endif
+ /*fprintf(stderr, "n_strx=%ld n_type=%d n_ovly=%d n_value=%d\n", sym.n_un.n_strx, sym.n_type, sym.n_ovly, sym.n_value);*/
if (sym.n_un.n_strx == 0)
continue;
if (gflg && (sym.n_type & N_EXT) == 0)
}
fseek(fi, (off_t)(curpos + o), L_SET);
- symp = (struct nlist *)malloc(i * sizeof (struct nlist));
+ symp = (struct cross_nlist *)malloc(i * sizeof (struct cross_nlist));
if (symp == 0)
error(1, "out of memory");
i = 0;
- n = mag_un.mag_exp.e.a_syms / sizeof(struct nlist);
+ n = mag_un.mag_exp.e.a_syms / sizeof(struct cross_nlist);
while (--n >= 0) {
-#ifdef pdp11
fread((char *)&sym, 1, sizeof(sym), fi);
-#else
- fread(temp, 1, sizeof(sym), fi);
- sym.n_un.n_strx = ((temp[0] & 0xffL) << 16) | ((temp[1] & 0xffL) << 24) |
- (temp[2] & 0xffL) | ((temp[3] & 0xffL) << 8);
- sym.n_type = temp[4] & 0xff;
- sym.n_ovly = temp[5] & 0xff;
- sym.n_value = (temp[6] & 0xff) | ((temp[7] & 0xff) << 8);
+#ifdef CROSS
+ sym.n_un.n_strx = cross_read_off_t((char *)&sym.n_un.n_strx);
+ sym.n_value = cross_read_uint((char *)&sym.n_value);
#endif
+ /*fprintf(stderr, "n_strx=%ld n_type=%d n_ovly=%d n_value=%d\n", sym.n_un.n_strx, sym.n_type, sym.n_ovly, sym.n_value);*/
if (sym.n_un.n_strx == 0)
continue;
if (gflg && (sym.n_type & N_EXT) == 0)
}
stroff = curpos + N_STROFF(mag_un.mag_exp);
fseek(fi, (off_t)stroff, L_SET);
-#ifdef pdp11
- if (fread(&strsiz, sizeof (OFF_T), 1, fi) != 1)
-#else
- if (fread(temp, sizeof (OFF_T), 1, fi) != 1)
-#endif
-
+ if (fread(&strsiz, sizeof (cross_off_t), 1, fi) != 1)
error(1, "no string table");
-#ifndef pdp11
- strsiz = ((temp[0] & 0xffL) << 16) | ((temp[1] & 0xffL) << 24) |
- (temp[2] & 0xffL) | ((temp[3] & 0xffL) << 8);
+#ifdef CROSS
+ strsiz = cross_read_off_t((char *)&strsiz);
#endif
strp = (char *)malloc((int)strsiz);
if (strp == NULL || strsiz > 48 * 1024L)
error(1, "ran out of memory");
if (fread(strp+sizeof(strsiz),(int)strsiz-sizeof(strsiz),1,fi) != 1)
error(1, "error reading strings");
-/* we do not support n_name when cross compiling, it breaks on 64-bit hosts */
-#ifdef pdp11
+#ifndef CROSS
for (n = 0; n < i; n++)
symp[n].n_un.n_name = strp + (int)symp[n].n_un.n_strx;
#endif
if (pflg==0)
- qsort(symp, i, sizeof(struct nlist), (int (*) PARAMS((const void *, const void *)))compare);
+ qsort(symp, i, sizeof(struct cross_nlist), (int (*) __P((const void *, const void *)))compare);
if ((archive || narg>1) && oflg==0)
printf("\n%s:\n", SELECT);
psyms(symp, i);
fclose(fi);
}
-void psyms(symp, nsyms) register struct nlist *symp; int nsyms; {
+void psyms(symp, nsyms) register struct cross_nlist *symp; int nsyms; {
register int n, c;
for (n=0; n<nsyms; n++) {
}
}
-int compare(p1, p2) register struct nlist *p1; register struct nlist *p2; {
+int compare(p1, p2) register struct cross_nlist *p1; register struct cross_nlist *p2; {
if (nflg) {
if (p1->n_value > p2->n_value)
return(rflg);
fseek(af, (off_t)off, L_SET);
if (_get_arobj(af) < 0)
return(0);
- off += (sizeof (struct ar_hdr) + chdr.size +
+ off += (sizeof (struct cross_ar_hdr) + chdr.size +
(chdr.size + chdr.lname & 1));
return(1);
}
* and the rest of 'ld' figures out what to do.
*/
-typedef struct ar_hdr HDR;
+typedef struct cross_ar_hdr HDR;
static char hb[sizeof(HDR) + 1]; /* real header */
/* Convert ar header field to an integer. */
INSTALL=install
# using VPATH to compile ./archive.o from ../../bin/ar/archive.c does not
# work if there is ../../bin/ar/archive.o leftover from building ar
-# using VPATH to compile ./nsym.o from ../../lib/libc/pdp/gen/nsym.c does not
-# work if there is a ../../lib/libc.pdp/gen/nsym.o leftover from building libc
-#VPATH=../../bin/ar:../../lib/libc/pdp/gen
-SRCS=../../bin/ar/archive.c build.c misc.c ranlib.c touch.c ../../lib/libc/pdp/gen/nsym.c
-OBJS=../../bin/ar/archive.o build.o misc.o ranlib.o touch.o ../../lib/libc/pdp/gen/nsym.o
+#VPATH=../../bin/ar
+SRCS=../../bin/ar/archive.c build.c misc.c ranlib.c touch.c
+OBJS=../../bin/ar/archive.o build.o misc.o ranlib.o touch.o
CFLAGS=-O -I../../bin/ar
SEPFLAG=-i
all: ranlib.0 ranlib.5.0 ranlib
ranlib.0: ranlib.1
-# ${MANROFF} ranlib.1 > ranlib.0
${MANROFF} ranlib.1 > ranlib.0
ranlib.5.0: ranlib.5.5
-# ${MANROFF} ranlib.5.5 > ranlib.5.0
${MANROFF} ranlib.5.5 > ranlib.5.0
ranlib: ${OBJS}
- ${CC} ${SEPFLAG} -o ranlib ${OBJS}
+ ${CC} ${SEPFLAG} -o ranlib ${OBJS} ${LIBCROSS}
install: all
${INSTALL} -c -o bin -g bin -m 444 ranlib.5.0 \
#define __RANLIB_H 1
#include <stdio.h>
-#include "krcompat.h"
+
+#ifndef __P
+#ifdef __STDC__
+#define __P(params) params
+#else
+#define __P(params) ()
+#endif
+#endif
/* build.c */
-int build PARAMS((void));
-int sgets PARAMS((char *buf, int n, register FILE *fp));
+int build __P((void));
+int sgets __P((char *buf, int n, register FILE *fp));
/* misc.c */
-int tmp PARAMS((void));
-void *emalloc PARAMS((int len));
-char *rname PARAMS((char *path));
-void badfmt PARAMS((void));
-void error PARAMS((char *name));
+int tmp __P((void));
+void *emalloc __P((int len));
+char *rname __P((char *path));
+void badfmt __P((void));
+void error __P((char *name));
/* touch.c */
-int touch PARAMS((void));
-void settime PARAMS((int afd));
+int touch __P((void));
+void settime __P((int afd));
/* ranlib.c */
-int main PARAMS((int argc, char **argv));
-void usage PARAMS((void));
+int main __P((int argc, char **argv));
+void usage __P((void));
#endif
#include <sys/errno.h>
#include <sys/stat.h>
#include <fcntl.h>
-#include <a.out.h>
#include <sys/dir.h>
#include <sys/file.h>
-#include <ar.h>
-#include <ranlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <archive.h>
#include "_ranlib.h"
-#ifdef pdp11
-#include <sys/types.h>
-#define OFF_T off_t
+#ifdef CROSS
+#include "cross/a.out.h"
+#include "cross/ar.h"
+#include "cross/ranlib.h"
+#include "cross/sys/types.h"
#else
-#include <stdint.h>
-#define OFF_T int32_t
+#include <a.out.h>
+#include <ar.h>
+#include <ranlib.h>
+/*#include <sys/types.h>*/
+#define cross_ar_hdr ar_hdr
+#define cross_exec exec
+#define cross_nlist nlist
+#define cross_off_t off_t
+#define cross_ranlib ranlib
+#define cross_xexec xexec
#endif
extern CHDR chdr; /* converted header */
typedef struct _rlib {
struct _rlib *next; /* next structure */
- OFF_T pos; /* offset of defining archive file */
+ cross_off_t pos; /* offset of defining archive file */
char *sym; /* symbol */
int symlen; /* strlen(sym) */
} RLIB;
RLIB *rhead, **pnext;
FILE *fp;
-OFF_T symcnt; /* symbol count */
-OFF_T tsymlen; /* total string length */
+cross_off_t symcnt; /* symbol count */
+cross_off_t tsymlen; /* total string length */
-static void rexec PARAMS((int rfd, int wfd));
-static void symobj PARAMS((void));
+static void rexec __P((int rfd, int wfd));
+static void symobj __P((void));
int build() {
CF cf;
int afd, tfd;
- OFF_T size;
+ cross_off_t size;
afd = open_archive(O_RDWR);
fp = fdopen(afd, "r+");
symobj();
/* Copy the saved objects into the archive. */
- size = (OFF_T)lseek(tfd, (off_t)0, L_INCR);
+ size = (cross_off_t)lseek(tfd, (off_t)0, L_INCR);
(void)lseek(tfd, (off_t)0, L_SET);
SETCF(tfd, tname, afd, archive, RPAD|WPAD);
copy_ar(&cf, size);
/*
* rexec
- * Read the exec structure; ignore any files that don't look
+ * Read the cross_exec structure; ignore any files that don't look
* exactly right.
*/
static void rexec(rfd, wfd) int rfd; int wfd; {
long nsyms;
register int nr, symlen;
char sym[512]; /* XXX - more than enough (we hope) */
-#ifndef pdp11
- /* note: must be at least as large as struct nlist */
- char temp[sizeof(struct exec)];
-#endif
- struct exec ebuf;
- struct nlist nl;
- OFF_T r_off, w_off, sympos;
+ struct cross_exec ebuf;
+ struct cross_nlist nl;
+ cross_off_t r_off, w_off, sympos;
void *emalloc();
/* Get current offsets for original and tmp files. */
r_off = lseek(rfd, (off_t)0, L_INCR);
w_off = lseek(wfd, (off_t)0, L_INCR);
- /* Read in exec structure. */
-#ifdef pdp11
- nr = read(rfd, (char *)&ebuf, sizeof(struct exec));
-#else
- nr = read(rfd, temp, sizeof(struct exec));
-#endif
- if (nr != sizeof(struct exec))
+ /* Read in cross_exec structure. */
+ nr = read(rfd, (char *)&ebuf, sizeof(struct cross_exec));
+ if (nr != sizeof(struct cross_exec))
goto bad1;
-#ifndef pdp11
- ebuf.a_magic = (temp[0] & 0xff) | ((temp[1] & 0xff) << 8);
- ebuf.a_text = (temp[2] & 0xff) | ((temp[3] & 0xff) << 8);
- ebuf.a_data = (temp[4] & 0xff) | ((temp[5] & 0xff) << 8);
- ebuf.a_bss = (temp[6] & 0xff) | ((temp[7] & 0xff) << 8);
- ebuf.a_syms = (temp[8] & 0xff) | ((temp[9] & 0xff) << 8);
- ebuf.a_entry = (temp[10] & 0xff) | ((temp[11] & 0xff) << 8);
- ebuf.a_unused = (temp[12] & 0xff) | ((temp[13] & 0xff) << 8);
- ebuf.a_flag = (temp[14] & 0xff) | ((temp[15] & 0xff) << 8);
+#ifdef CROSS
+ ebuf.a_magic = cross_read_int((char *)&ebuf.a_magic);
+ ebuf.a_text = cross_read_uint((char *)&ebuf.a_text);
+ ebuf.a_data = cross_read_uint((char *)&ebuf.a_data);
+ ebuf.a_bss = cross_read_uint((char *)&ebuf.a_bss);
+ ebuf.a_syms = cross_read_uint((char *)&ebuf.a_syms);
+ ebuf.a_entry = cross_read_uint((char *)&ebuf.a_entry);
+ ebuf.a_unused = cross_read_uint((char *)&ebuf.a_unused);
+ ebuf.a_flag = cross_read_uint((char *)&ebuf.a_flag);
#endif
/* Check magic number and symbol count. */
sympos = N_STROFF(ebuf) + r_off;
/* Seek to symbol table. */
- if (fseek(fp, (off_t)N_SYMOFF(ebuf) + r_off, L_SET) == (off_t)-1)
+ if (fseek(fp, (off_t)(N_SYMOFF(ebuf) + r_off), L_SET) == (off_t)-1)
goto bad1;
/* Save starting point in symbol chain */
savnext = pnext;
- /* For each symbol read the nlist entry and save it as necessary. */
- nsyms = ebuf.a_syms / sizeof(struct nlist);
+ /* For each symbol read the cross_nlist entry and save it as necessary. */
+ nsyms = ebuf.a_syms / sizeof(struct cross_nlist);
while (nsyms--) {
-#ifdef pdp11
- if (!fread((char *)&nl, sizeof(struct nlist), 1, fp))
-#else
- if (!fread(temp, sizeof(struct nlist), 1, fp))
-#endif
+ if (!fread((char *)&nl, sizeof(struct cross_nlist), 1, fp))
{
if (feof(fp))
badfmt();
error(archive);
}
-#ifndef pdp11
- nl.n_un.n_strx = ((temp[0] & 0xffL) << 16) | ((temp[1] & 0xffL) << 24) |
- (temp[2] & 0xffL) | ((temp[3] & 0xffL) << 8);
- nl.n_type = temp[4] & 0xff;
- nl.n_ovly = temp[5] & 0xff;
- nl.n_value = (temp[6] & 0xff) | ((temp[7] & 0xff) << 8);
+#ifdef CROSS
+ nl.n_un.n_strx = cross_read_off_t((char *)&nl.n_un.n_strx);
+ nl.n_value = cross_read_uint((char *)&nl.n_value);
#endif
/* Ignore if no name or local. */
*/
static void symobj() {
register RLIB *rp, *next;
- struct ranlib rn;
- char hb[sizeof(struct ar_hdr) + 1], pad;
- OFF_T ransize, size, stroff;
-#ifndef pdp11
- /* note: must be at least as large as OFF_T */
- char temp[sizeof(struct ranlib)];
-#endif
+ struct cross_ranlib rn;
+ char hb[sizeof(struct cross_ar_hdr) + 1], pad;
+ cross_off_t ransize, size, stroff;
gid_t getgid();
uid_t getuid();
+#ifdef CROSS
+ cross_off_t temp_size, temp_tsymlen;
+#endif
/* Rewind the archive, leaving the magic number. */
if (fseek(fp, (off_t)SARMAG, L_SET) == (off_t)-1)
error(archive);
- /* Size of the ranlib archive file, pad if necessary. */
- ransize = sizeof(OFF_T) +
- symcnt * sizeof(struct ranlib) + sizeof(OFF_T) + tsymlen;
+ /* Size of the cross_ranlib archive file, pad if necessary. */
+ ransize = sizeof(cross_off_t) +
+ symcnt * sizeof(struct cross_ranlib) + sizeof(cross_off_t) + tsymlen;
/*(fprintf(stderr, "symcnt=%ld tsymlen=%ld ransize=%ld\n", symcnt, tsymlen, ransize);*/
if (ransize & 01) {
++ransize;
} else
pad = '\0';
- /* Put out the ranlib archive file header. */
+ /* Put out the cross_ranlib archive file header. */
(void)sprintf(hb, HDR2, RANLIBMAG, 0L, getuid(), getgid(),
0666 & ~umask(0), ransize, ARFMAG);
- if (!fwrite(hb, sizeof(struct ar_hdr), 1, fp))
+ if (!fwrite(hb, sizeof(struct cross_ar_hdr), 1, fp))
error(tname);
- /* First long is the size of the ranlib structure section. */
- size = symcnt * sizeof(struct ranlib);
+ /* First long is the size of the cross_ranlib structure section. */
+ size = symcnt * sizeof(struct cross_ranlib);
/*fprintf(stderr, "size=%ld\n", size);*/
-#ifdef pdp11
- if (!fwrite((char *)&size, sizeof(size), 1, fp))
+#ifdef CROSS
+ cross_write_off_t((char *)&temp_size, size);
+ if (!fwrite((char *)&temp_size, sizeof(size), 1, fp))
#else
- temp[0] = (size >> 16) & 0xff;
- temp[1] = (size >> 24) & 0xff;
- temp[2] = size & 0xff;
- temp[3] = (size >> 8) & 0xff;
- if (!fwrite(temp, sizeof(size), 1, fp))
+ if (!fwrite((char *)&size, sizeof(size), 1, fp))
#endif
error(tname);
/* Offset of the first archive file. */
- size = SARMAG + sizeof(struct ar_hdr) + ransize;
+ size = SARMAG + sizeof(struct cross_ar_hdr) + ransize;
/*
- * Write out the ranlib structures. The offset into the string
+ * Write out the cross_ranlib structures. The offset into the string
* table is cumulative, the offset into the archive is the value
* set in rexec() plus the offset to the first archive file.
*/
rn.ran_un.ran_strx = stroff;
stroff += rp->symlen;
rn.ran_off = size + rp->pos;
-#ifdef pdp11
- if (!fwrite((char *)&rn, sizeof(struct ranlib), 1, fp))
-#else
- temp[0] = (rn.ran_un.ran_strx >> 16) & 0xff;
- temp[1] = (rn.ran_un.ran_strx >> 24) & 0xff;
- temp[2] = rn.ran_un.ran_strx & 0xff;
- temp[3] = (rn.ran_un.ran_strx >> 8) & 0xff;
- temp[4] = (rn.ran_off >> 16) & 0xff;
- temp[5] = (rn.ran_off >> 24) & 0xff;
- temp[6] = rn.ran_off & 0xff;
- temp[7] = (rn.ran_off >> 8) & 0xff;
- if (!fwrite(temp, sizeof(struct ranlib), 1, fp))
+#ifdef CROSS
+ cross_write_off_t((char *)&rn.ran_un.ran_strx, rn.ran_un.ran_strx);
+ cross_write_off_t((char *)&rn.ran_off, rn.ran_off);
#endif
+ if (!fwrite((char *)&rn, sizeof(struct cross_ranlib), 1, fp))
error(archive);
}
/* Second long is the size of the string table. */
-#ifdef pdp11
- if (!fwrite((char *)&tsymlen, sizeof(tsymlen), 1, fp))
+#ifdef CROSS
+ cross_write_off_t((char *)&temp_tsymlen, tsymlen);
+ if (!fwrite((char *)&temp_tsymlen, sizeof(tsymlen), 1, fp))
#else
- temp[0] = (tsymlen >> 16) & 0xff;
- temp[1] = (tsymlen >> 24) & 0xff;
- temp[2] = tsymlen & 0xff;
- temp[3] = (tsymlen >> 8) & 0xff;
- if (!fwrite(temp, sizeof(tsymlen), 1, fp))
+ if (!fwrite((char *)&tsymlen, sizeof(tsymlen), 1, fp))
#endif
error(tname);
+++ /dev/null
-../../../include/a.out.h
\ No newline at end of file
+++ /dev/null
-../../../include/ar.h
\ No newline at end of file
+++ /dev/null
-../../../include/nlist.h
\ No newline at end of file
+++ /dev/null
-../../../include/ranlib.h
\ No newline at end of file
+++ /dev/null
-../../../../sys/h/exec.h
\ No newline at end of file
+++ /dev/null
-#ifndef _KRCOMPAT_H
-#define _KRCOMPAT_H 1
-
-#undef PARAMS
-#ifdef __STDC__
-#include <stdarg.h>
-#define VA_START(ap, arg) va_start(ap, arg)
-#define PARAMS(args) args
-#else
-#include <varargs.h>
-#define VA_START(ap, arg) va_start(ap)
-#define PARAMS(args) ()
-#endif
-
-#ifdef __GNUC__
-#define NORETURN __attribute__ ((noreturn))
-#else
-#define NORETURN
-#endif
-
-#endif
#!/bin/sh
ROOT="`pwd |sed -e 's/\/usr\.bin\/ranlib$//'`"
-HOSTCC="cc -g -Iinclude -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result"
+HOSTCC="cc -I$ROOT/cross/usr/include -L$ROOT/cross/usr/lib -DCROSS -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result"
+HOSTLIBCROSS="-lcross"
INSTALL="$ROOT/scripts/install.sh --strip-program=/bin/true"
MANROFF="nroff -man"
-mkdir --parents "$ROOT/cross/usr/bin"
-make CC="$HOSTCC" MANROFF="$MANROFF" SEPFLAG= && \
+mkdir --parents "$ROOT/cross/bin"
+mkdir --parents "$ROOT/cross/usr/man/cat1"
+make CC="$HOSTCC" LIBCROSS="$HOSTLIBCROSS" MANROFF="$MANROFF" STAGEPREFIX="\\\"$ROOT/stage\\\"" SEPFLAG= LDFLAGS="-L$ROOT/cross/usr/lib" && \
make INSTALL="$INSTALL" DESTDIR="$ROOT/cross" install
#include <sys/dir.h>
#include <sys/file.h>
#include <fcntl.h>
-#include <ranlib.h>
-#include <ar.h>
#include <time.h>
#include <stdio.h>
#include <string.h>
#include <archive.h>
#include "_ranlib.h"
+#ifdef CROSS
+#include "cross/ar.h"
+#include "cross/ranlib.h"
+#else
+#include <ar.h>
+#include <ranlib.h>
+#define cross_ar_hdr ar_hdr
+#endif
+
extern CHDR chdr; /* converted header */
extern char *archive; /* archive name */
}
void settime(afd) int afd; {
- struct ar_hdr *hdr;
+ struct cross_ar_hdr *hdr;
off_t size;
char buf[50];
char *libF77_id[] = {
- "@(#)libF77.a Jan 11 21:13:12 2017",
+ "@(#)libF77.a Jan 11 22:27:23 2017",
"@(#)abort_.c 5.1 6/7/85",
"@(#)besj0_.c 5.1 6/7/85",
"@(#)besj1_.c 5.1 6/7/85",
all: include libcross.a
-include: cross/cross.h cross/a.out.h cross/ar.h cross/nlist.h cross/ranlib.h cross/time.h cross/tzfile.h cross/sys/exec.h cross/sys/param.h cross/sys/types.h
+include: cross/cross.h cross/a.out.h cross/ar.h cross/nlist.h cross/ranlib.h cross/time.h cross/tzfile.h cross/sys/dir.h cross/sys/exec.h cross/sys/param.h cross/sys/types.h
libcross.a: cross.o ctime.o nlist.o nsym.o timezone.o
rm -f $@
mkdir -p cross
sed -f copy.sed $< >$@
+cross/sys/dir.h: subset_sys_h/dir.h copy.sed
+ mkdir -p cross/sys
+ sed -f copy.sed $< >$@
cross/sys/exec.h: subset_sys_h/exec.h copy.sed
mkdir -p cross/sys
sed -f copy.sed $< >$@
s/^#\([\t ]*\)ifdef\([\t ]\+\)CROSS$/#\1if 1/
s/^#\([\t ]*\)ifndef\([\t ]\+\)CROSS$/#\1if 0/
-s/#\([\t ]*\)include\([\t ]\)"\(a\.out\|ar\|nlist\|sys\/exec\|sys\/param\|sys\/time\|sys\/types\|ranlib\|time\|tzfile\)\.h"/#\1include\2"cross\/\3.h"/
-s/#\([\t ]*\)include\([\t ]\)<\(a\.out\|ar\|nlist\|sys\/exec\|sys\/param\|sys\/time\|sys\/types\|ranlib\|time\|tzfile\)\.h>/#\1include\2"cross\/\3.h"/
+s/#\([\t ]*\)include\([\t ]\)"\(a\.out\|ar\|nlist\|sys\/dir\|sys\/exec\|sys\/param\|sys\/time\|sys\/types\|ranlib\|time\|tzfile\)\.h"/#\1include\2"cross\/\3.h"/
+s/#\([\t ]*\)include\([\t ]\)<\(a\.out\|ar\|nlist\|sys\/dir\|sys\/exec\|sys\/param\|sys\/time\|sys\/types\|ranlib\|time\|tzfile\)\.h>/#\1include\2"cross\/\3.h"/
s/^unsigned[\t ]\+\(int\|long\|short\)$/cross_u\1_t/g
s/^unsigned[\t ]\+\(int\|long\|short\)\([^0-9A-Za-z_]\)/cross_u\1_t\2/g
s/\([^0-9A-Za-z_]\)cross_unsigned_t$/\1cross_uint_t/g
s/\([^0-9A-Za-z_]\)cross_unsigned_t\([^0-9A-Za-z_]\)/\1cross_uint_t\2/g
-s/^\(MAXPATHLEN\)$/CROSS_\1/g
-s/^\(MAXPATHLEN\)\([^0-9A-Za-z_]\)/CROSS_\1\2/g
-s/\([^0-9A-Za-z_]\)\(MAXPATHLEN\)$/\1CROSS_\2/g
-s/\([^0-9A-Za-z_]\)\(MAXPATHLEN\)\([^0-9A-Za-z_]\)/\1CROSS_\2\3/g
+s/^\(MAXNAMLEN\|MAXPATHLEN\)$/CROSS_\1/g
+s/^\(MAXNAMLEN\|MAXPATHLEN\)\([^0-9A-Za-z_]\)/CROSS_\1\2/g
+s/\([^0-9A-Za-z_]\)\(MAXNAMLEN\|MAXPATHLEN\)$/\1CROSS_\2/g
+s/\([^0-9A-Za-z_]\)\(MAXNAMLEN\|MAXPATHLEN\)\([^0-9A-Za-z_]\)/\1CROSS_\2\3/g
s/^\(off_t\|time_t\|u_char\|u_int\|u_long\|u_short\)$/cross_\1/g
s/^\(off_t\|time_t\|u_char\|u_int\|u_long\|u_short\)\([^0-9A-Za-z_]\)/cross_\1\2/g
#ifndef _RANLIB_H_
#define _RANLIB_H_
+#include <sys/types.h>
+
#define RANLIBMAG "__.SYMDEF" /* archive file name */
#define RANLIBSKEW 3 /* creation time offset */
--- /dev/null
+/*
+ * Copyright (c) 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)dir.h 1.2 (2.11BSD GTE) 11/4/94
+ */
+
+#ifndef _DIR_
+#define _DIR_
+
+#ifndef MAXNAMLEN
+#define MAXNAMLEN 63
+#endif
+
+#ifndef CROSS
+#define DIRBLKSIZ 512
+
+/*
+ * inode numbers are ino_t rather than u_long now. before, when v7direct
+ * was used for the kernel, inode numbers were u_short/ino_t anyways, and since
+ * everything had to be recompiled when the fs structure was changed it seemed
+ * like a good idea to change the "real direct structure". SMS
+*/
+
+struct direct {
+ ino_t d_ino; /* inode number of entry */
+ u_short d_reclen; /* length of this record */
+ u_short d_namlen; /* length of string in d_name */
+ char d_name[MAXNAMLEN+1]; /* name must be no longer than this */
+};
+
+/*
+ * A directory consists of some number of blocks of DIRBLKSIZ
+ * bytes, where DIRBLKSIZ is chosen such that it can be transferred
+ * to disk in a single atomic operation (e.g. 512 bytes on most machines).
+ *
+ * Each DIRBLKSIZ byte block contains some number of directory entry
+ * structures, which are of variable length. Each directory entry has
+ * a struct direct at the front of it, containing its inode number,
+ * the length of the entry, and the length of the name contained in
+ * the entry. These are followed by the name padded to a 4 byte boundary
+ * with null bytes. All names are guaranteed null terminated.
+ * The maximum length of a name in a directory is MAXNAMLEN.
+ *
+ * The macro DIRSIZ(dp) gives the amount of space required to represent
+ * a directory entry. Free space in a directory is represented by
+ * entries which have dp->d_reclen > DIRSIZ(dp). All DIRBLKSIZ bytes
+ * in a directory block are claimed by the directory entries. This
+ * usually results in the last entry in a directory having a large
+ * dp->d_reclen. When entries are deleted from a directory, the
+ * space is returned to the previous entry in the same directory
+ * block by increasing its dp->d_reclen. If the first entry of
+ * a directory block is free, then its dp->d_ino is set to 0.
+ * Entries other than the first in a directory do not normally have
+ * dp->d_ino set to 0.
+ */
+
+#undef DIRSIZ
+#define DIRSIZ(dp) \
+ ((((sizeof (struct direct) - (MAXNAMLEN+1)) + (dp)->d_namlen+1) + 3) &~ 3)
+
+/*
+ * Definitions for library routines operating on directories.
+ */
+typedef struct _dirdesc {
+ int dd_fd;
+ long dd_loc;
+ long dd_size;
+ char dd_buf[DIRBLKSIZ];
+ struct direct dd_cur;
+} DIR;
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#ifndef KERNEL
+
+extern DIR *opendir();
+extern struct direct *readdir();
+extern long telldir();
+extern void seekdir();
+#define rewinddir(dirp) seekdir((dirp), (long)0)
+#define dirfd(dirp) ((dirp)->dd_fd)
+extern void closedir();
+
+#endif KERNEL
+
+/*
+ * Template for manipulating directories.
+ * Should use struct direct's, but the name field
+ * is MAXNAMLEN - 1, and this just won't do.
+ */
+#define dotdot_ino dtdt_ino
+#define dotdot_reclen dtdt_rec
+#define dotdot_name dtdt_name
+struct dirtemplate {
+ ino_t dot_ino;
+ u_short dot_reclen;
+ u_short dot_namlen;
+ char dot_name[2]; /* must be multiple of 4 */
+ ino_t dotdot_ino;
+ u_short dotdot_reclen;
+ u_short dotdot_namlen;
+ char dotdot_name[6]; /* ditto */
+};
+#endif
+
+#endif