summaryrefslogtreecommitdiff
path: root/Build/source/utils/gzip/amiga
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-01-17 21:16:42 +0000
committerKarl Berry <karl@freefriends.org>2006-01-17 21:16:42 +0000
commita3d3111bfe26b8e5f5bc6049dfb2a4ca2edc7881 (patch)
treef4a8a34f904c1bb86adcc3ae0e14434badc6dbe4 /Build/source/utils/gzip/amiga
parent6c0eafbb1395d426a72a74538e0b2a95e8344ca6 (diff)
utils 1
git-svn-id: svn://tug.org/texlive/trunk@1484 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/gzip/amiga')
-rw-r--r--Build/source/utils/gzip/amiga/Makefile.gcc62
-rw-r--r--Build/source/utils/gzip/amiga/Makefile.sasc59
-rw-r--r--Build/source/utils/gzip/amiga/match.a175
-rw-r--r--Build/source/utils/gzip/amiga/tailor.c183
-rw-r--r--Build/source/utils/gzip/amiga/utime.h15
5 files changed, 494 insertions, 0 deletions
diff --git a/Build/source/utils/gzip/amiga/Makefile.gcc b/Build/source/utils/gzip/amiga/Makefile.gcc
new file mode 100644
index 00000000000..98635c1ae4e
--- /dev/null
+++ b/Build/source/utils/gzip/amiga/Makefile.gcc
@@ -0,0 +1,62 @@
+# Makefile for gzip (GNU zip) -*- Indented-Text -*-
+# Copyright (C) 1992-1993 Jean-loup Gailly and the Free Software Foundation
+
+# Amiga GCC version, written by Preston Hunt <gt5708a@prism.gatech.edu>
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+CC = gcc
+CPP = cpp
+
+CFLAGS = -m68020 -m68881 -O2
+#CFLAGS = -m68000 -O2
+#for the 68000, set below: OBJA=
+CPPFLAGS = -Dmc68020
+LDFLAGS =
+O = .o
+
+SRCS = gzip.c zip.c deflate.c trees.c bits.c unzip.c inflate.c util.c crypt.c\
+ lzw.c unlzw.c unpack.c unlzh.c makecrc.c getopt.c match.S
+
+OBJA = match$O
+
+OBJS = gzip$O zip$O deflate$O trees$O bits$O unzip$O inflate$O util$O \
+ crypt$O lzw$O unlzw$O unpack$O unlzh$O getopt$O match$O
+
+HDRS = gzip.h lzw.h tailor.h revision.h crypt.h getopt.h
+
+.c.o:
+ $(CC) -c $(DEFS) $(CFLAGS) $<
+
+.PHONY: default all
+all: gzip
+
+gzip: $(OBJS)
+ $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
+
+gzip$O zip$O deflate$O trees$O bits$O unzip$O inflate$O: gzip.h tailor.h
+util$O lzw$O unlzw$O unpack$O unlzh$O crypt$O: gzip.h tailor.h
+
+gzip$O unlzw$O: revision.h lzw.h
+
+bits$O unzip$O util$O zip$O: crypt.h
+
+gzip$O getopt$O: getopt.h
+
+match$O: match.S
+ $(CPP) $(CPPFLAGS) match.S > _match.s
+ $(CC) -c _match.s
+ mv _match$O match$O
+ rm -f _match.s
diff --git a/Build/source/utils/gzip/amiga/Makefile.sasc b/Build/source/utils/gzip/amiga/Makefile.sasc
new file mode 100644
index 00000000000..faf15fd3e87
--- /dev/null
+++ b/Build/source/utils/gzip/amiga/Makefile.sasc
@@ -0,0 +1,59 @@
+# Makefile for gzip (GNU zip) -*- Indented-Text -*-
+# This Makefile is for SAS/C 6.3 on the Amiga
+# Don't use it with SAS/C 6.2 or earlier versions. These versions will
+# produce incorrect code for trees.c because of a bug in the optimizer.
+# Made by Carsten Steger (carsten.steger@informatik.tu-muenchen.de)
+
+# Some notes on gzip for the Amiga:
+# Due to a strange implementation of the RAM-Disk on Commodore's part
+# you should not use gzip -r on a directory in the RAM-Disk. To zip all
+# files in a directory 'dir' in the RAM-Disk use something like
+# gzip ram:dir/#? ram:dir/#?/#? ...
+# where the number of '#?'s reflects the depth of the directory 'dir'.
+#
+# Alas, the program has it's full functionality only if you have
+# Kickstart 2.0 or higher installed. This affects the expansion of
+# wildcards and the preservation of file access times. You should use
+# a shell that does wildcard expansion under Kickstart 1.3.
+
+
+CC = sc
+
+# If you have a 68020 or more you can define UNALIGNED_OK below
+DEFS = DEF=AMIGA
+LIBS = LIB LIB:scnb.lib
+
+CFLAGS = DATA=FAR NOSTKCHK PARM=R IDIR=
+OPTFLAGS = OPT OPTGO OPTPEEP OPTCOMP=3 OPTDEP=3 OPTRDEP=3
+LDFLAGS = FROM LIB:c.o
+
+OBJS = gzip.o zip.o deflate.o trees.o bits.o unzip.o inflate.o util.o \
+ crypt.o lzw.o unlzw.o unpack.o unlzh.o getopt.o tailor.o match.o
+
+.c.o:
+ $(CC) $(DEFS) $(CFLAGS) $(OPTFLAGS) $<
+.a.o:
+ $(CC) $(DEFS) $(CFLAGS) $<
+
+all: gzip
+
+gzip: $(OBJS)
+ slink $(LDFLAGS) $(OBJS) TO $@ $(LIBS)
+
+gzip.o: gzip.c gzip.h tailor.h revision.h lzw.h getopt.h
+zip.o: zip.c gzip.h tailor.h crypt.h
+deflate.o: deflate.c gzip.h tailor.h lzw.h
+trees.o: trees.c gzip.h tailor.h
+bits.o: bits.c gzip.h tailor.h crypt.h
+unzip.o: unzip.c gzip.h tailor.h crypt.h
+inflate.o: inflate.c gzip.h tailor.h
+util.o: util.c gzip.h tailor.h crypt.h
+lzw.o: lzw.c lzw.h gzip.h tailor.h
+unlzw.o: unlzw.c gzip.h tailor.h lzw.h
+unpack.o: unpack.c gzip.h tailor.h crypt.h
+unlzh.o: unlzh.c gzip.h tailor.h lzw.h
+crypt.o: crypt.c
+getopt.o: getopt.c getopt.h
+tailor.o: tailor.c
+
+match.o: match.a
diff --git a/Build/source/utils/gzip/amiga/match.a b/Build/source/utils/gzip/amiga/match.a
new file mode 100644
index 00000000000..0b458d2bf61
--- /dev/null
+++ b/Build/source/utils/gzip/amiga/match.a
@@ -0,0 +1,175 @@
+; match.a -- optional optimized asm version of longest match in deflate.c
+; Copyright (C) 1992-1993 Jean-loup Gailly
+; This is free software; you can redistribute it and/or modify it under the
+; terms of the GNU General Public License, see the file COPYING.
+
+; $Id: match.a,v 1.1 1993/03/11 16:05:57 jloup Exp $
+;
+; Adapted for the Amiga by Carsten Steger <stegerc@informatik.tu-muenchen.de>
+; using the code in match.S.
+; The major change in this code consists of removing all unaligned
+; word accesses, because they cause 68000-based Amigas to crash.
+; For maximum speed, UNALIGNED_OK can be defined in Makefile.sasc.
+; The program will then only run on 68020-based Amigas, though.
+;
+; This code will run with registerized parameters too, unless SAS
+; changes parameter passing conventions between new releases of SAS/C.
+
+
+Cur_Match reg d0 ; Must be in d0!
+Best_Len reg d1
+Loop_Counter reg d2
+Scan_Start reg d3
+Scan_End reg d4
+Limit reg d5
+Chain_Length reg d6
+Scan_Test reg d7
+Scan reg a0
+Match reg a1
+Prev_Address reg a2
+Scan_Ini reg a3
+Match_Ini reg a4
+
+MAX_MATCH equ 258
+MIN_MATCH equ 3
+WSIZE equ 32768
+MAX_DIST equ WSIZE-MAX_MATCH-MIN_MATCH-1
+
+
+ xref _max_chain_length
+ xref _prev_length
+ xref _prev
+ xref _window
+ xref _strstart
+ xref _good_match
+ xref _match_start
+ xref _nice_match
+
+
+ section match,code
+
+ xdef _match_init
+ xdef @match_init
+ xdef _longest_match
+ xdef @longest_match
+
+
+_match_init:
+@match_init:
+ rts
+
+
+_longest_match:
+ move.l 4(sp),Cur_Match
+@longest_match:
+ ifd UNALIGNED_OK
+ movem.l d2-d6/a2-a4,-(sp)
+ else
+ movem.l d2-d7/a2-a4,-(sp)
+ endc
+ move.l _max_chain_length,Chain_Length
+ move.l _prev_length,Best_Len
+ lea _prev,Prev_Address
+ lea _window+MIN_MATCH,Match_Ini
+ move.l _strstart,Limit
+ move.l Match_Ini,Scan_Ini
+ add.l Limit,Scan_Ini
+ subi.w #MAX_DIST,Limit
+ bhi.b limit_ok
+ moveq #0,Limit
+limit_ok:
+ cmp.l _good_match,Best_Len
+ bcs.b length_ok
+ lsr.l #2,Chain_Length
+length_ok:
+ subq.l #1,Chain_Length
+
+ ifd UNALIGNED_OK
+
+ move.w -MIN_MATCH(Scan_Ini),Scan_Start
+ move.w -MIN_MATCH-1(Scan_Ini,Best_Len),Scan_End
+
+ else
+
+ move.b -MIN_MATCH(Scan_Ini),Scan_Start
+ lsl.w #8,Scan_Start
+ move.b -MIN_MATCH+1(Scan_Ini),Scan_Start
+ move.b -MIN_MATCH-1(Scan_Ini,Best_Len),Scan_End
+ lsl.w #8,Scan_End
+ move.b -MIN_MATCH(Scan_Ini,Best_Len),Scan_End
+
+ endc
+
+ bra.b do_scan
+
+long_loop:
+
+ ifd UNALIGNED_OK
+
+ move.w -MIN_MATCH-1(Scan_Ini,Best_Len),Scan_End
+
+ else
+
+ move.b -MIN_MATCH-1(Scan_Ini,Best_Len),Scan_End
+ lsl.w #8,Scan_End
+ move.b -MIN_MATCH(Scan_Ini,Best_Len),Scan_End
+
+ endc
+
+short_loop:
+ lsl.w #1,Cur_Match
+ move.w 0(Prev_Address,Cur_Match),Cur_Match
+ cmp.w Limit,Cur_Match
+ dbls Chain_Length,do_scan
+ bra.b return
+
+do_scan:
+ move.l Match_Ini,Match
+ add.l Cur_Match,Match
+
+ ifd UNALIGNED_OK
+
+ cmp.w -MIN_MATCH-1(Match,Best_Len),Scan_End
+ bne.b short_loop
+ cmp.w -MIN_MATCH(Match),Scan_Start
+ bne.b short_loop
+
+ else
+
+ move.b -MIN_MATCH-1(Match,Best_Len),Scan_Test
+ lsl.w #8,Scan_Test
+ move.b -MIN_MATCH(Match,Best_Len),Scan_Test
+ cmp.w Scan_Test,Scan_End
+ bne.b short_loop
+ move.b -MIN_MATCH(Match),Scan_Test
+ lsl.w #8,Scan_Test
+ move.b -MIN_MATCH+1(Match),Scan_Test
+ cmp.w Scan_Test,Scan_Start
+ bne.b short_loop
+
+ endc
+
+ move.w #(MAX_MATCH-MIN_MATCH),Loop_Counter
+ move.l Scan_Ini,Scan
+scan_loop:
+ cmpm.b (Match)+,(Scan)+
+ dbne Loop_Counter,scan_loop
+
+ sub.l Scan_Ini,Scan
+ addq.l #(MIN_MATCH-1),Scan
+ cmp.l Best_Len,Scan
+ bls.b short_loop
+ move.l Scan,Best_Len
+ move.l Cur_Match,_match_start
+ cmp.l _nice_match,Best_Len
+ bcs.b long_loop
+return:
+ move.l Best_Len,d0
+ ifd UNALIGNED_OK
+ movem.l (sp)+,d2-d6/a2-a4
+ else
+ movem.l (sp)+,d2-d7/a2-a4
+ endc
+ rts
+
+ end
diff --git a/Build/source/utils/gzip/amiga/tailor.c b/Build/source/utils/gzip/amiga/tailor.c
new file mode 100644
index 00000000000..9f14cc45b6c
--- /dev/null
+++ b/Build/source/utils/gzip/amiga/tailor.c
@@ -0,0 +1,183 @@
+/* tailor.c -- target dependent functions
+ * Copyright (C) 1993 Carsten Steger (carsten.steger@informatik.tu-muenchen.de)
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License, see the file COPYING.
+ */
+
+/*
+ * This file contains Amiga specific functions for gzip.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <error.h>
+#include <time.h>
+#include <utime.h>
+#include <exec/types.h>
+#include <dos/dos.h>
+#include <dos/dosextens.h>
+#include <dos/dosasl.h>
+#include <proto/dos.h>
+
+#define MAXPATH 1024
+#define MAXARGS 512
+
+extern struct DosLibrary *DOSBase;
+
+extern void *xmalloc(unsigned int size);
+
+static char *expand_next_file (char *pattern);
+static int in_prev_args (char *arg, char **argv, int argc);
+extern void _expand_args (int *oargc, char ***oargv);
+
+
+static char *expand_next_file (pattern)
+ char *pattern;
+{
+ long err;
+ char *pathname;
+ static struct AnchorPath *an = NULL;
+
+ pathname = NULL;
+ if (pattern == NULL)
+ err = -1;
+ else
+ do
+ {
+ if (an == NULL)
+ {
+ an = xmalloc (sizeof (struct AnchorPath) + MAXPATH);
+ memset (an, 0, sizeof (struct AnchorPath) + MAXPATH);
+ an->ap_BreakBits = SIGBREAKF_CTRL_C;
+ an->ap_Strlen = MAXPATH;
+ an->ap_Flags = APF_DOWILD;
+ err = MatchFirst (pattern, an);
+ }
+ else
+ err = MatchNext (an);
+
+ pathname = an->ap_Buf;
+ } while (err == 0 && pathname == NULL);
+
+ if (err)
+ {
+ MatchEnd (an);
+ free (an);
+ an = NULL;
+ return NULL;
+ }
+ else
+ return pathname;
+}
+
+
+static int in_prev_args (arg, argv, argc)
+ char *arg, **argv;
+ int argc;
+{
+ int i, is_in_args;
+
+ is_in_args = 0;
+ for (i = 1; i < argc - 1; i++)
+ if (stricmp (arg, argv[i]) == 0)
+ is_in_args = 1;
+ return is_in_args;
+}
+
+
+void _expand_args (oargc, oargv)
+ int *oargc;
+ char ***oargv;
+{
+ int i;
+ char *str, **argv;
+ static char buf[MAXPATH];
+ int argc, no_match_at_all, num_matches, contains_wildcards;
+
+ /* With Kickstart 1.3 wildcards can't be expanded. */
+ if (DOSBase->dl_lib.lib_Version < 37) return;
+
+ no_match_at_all = 1;
+ contains_wildcards = 0;
+ argc = 0;
+ argv = xmalloc (MAXARGS * sizeof (char *));
+
+ argv[argc++] = (*oargv)[0];
+ for (i = 1; i < *oargc; i++)
+ {
+ if (ParsePattern ((*oargv)[i], buf, MAXPATH))
+ {
+ contains_wildcards = 1;
+ num_matches = 0;
+ while (str = expand_next_file ((*oargv)[i]))
+ if (argc >= MAXARGS)
+ {
+ expand_next_file (NULL);
+ fprintf (stderr,"Too many files.\n");
+ exit (20);
+ }
+ else
+ {
+ /* Avoid duplicate entries */
+ if (!in_prev_args (str, argv, argc))
+ {
+ argv[argc++] = strdup (str);
+ num_matches++;
+ }
+ }
+ if (num_matches != 0)
+ no_match_at_all = 0;
+ }
+ else
+ if (argc >= MAXARGS)
+ {
+ fprintf (stderr,"Too many files.\n");
+ exit (20);
+ }
+ else
+ {
+ if (!in_prev_args ((*oargv)[i], argv, argc))
+ argv[argc++] = (*oargv)[i];
+ }
+ }
+ *oargc = argc;
+ *oargv = argv;
+ if (no_match_at_all && contains_wildcards) {
+ fprintf (stderr,"No match.\n");
+ exit (20);
+ }
+}
+
+
+int utime (path, times)
+ char *path;
+ struct utimbuf *times;
+{
+ struct DateStamp date;
+ LONG error;
+ time_t modtime;
+
+ /* With Kickstart 1.3 setting the filedate could be done, I guess.
+ * Maybe someone else will implement and test the code for this
+ * case (I don't have Kickstart 1.3). */
+ if (DOSBase->dl_lib.lib_Version < 37) return 0;
+
+ /* Amiga dates are counted from 1. Jan 1978 as opposed to 1. Jan 1970
+ * on Unix. Therefore we have to subtract 2922 days (8*365+2). We also
+ * have to subtract the value of __timezone since SAS/C uses "CST+06"
+ * as the default value. */
+ modtime = times->modtime - __timezone;
+ date.ds_Days = (modtime / 86400) - 2922;
+ modtime %= 86400;
+ date.ds_Minute = modtime / 60;
+ modtime %= 60;
+ date.ds_Tick = modtime * TICKS_PER_SECOND;
+ error = SetFileDate (path, &date);
+ if (error == DOSFALSE)
+ {
+ errno = EOSERR;
+ return -1;
+ }
+ return 0;
+}
diff --git a/Build/source/utils/gzip/amiga/utime.h b/Build/source/utils/gzip/amiga/utime.h
new file mode 100644
index 00000000000..8c35a1aac09
--- /dev/null
+++ b/Build/source/utils/gzip/amiga/utime.h
@@ -0,0 +1,15 @@
+#ifndef _UTIME_H
+#define _UTIME_H 1
+
+#ifndef _TIME_H
+#include <time.h>
+#endif
+
+struct utimbuf {
+ time_t actime;
+ time_t modtime;
+};
+
+extern int utime (char *path, struct utimbuf *times);
+
+#endif