1aed325430
- Update to 2.4 - Add workaround to use ccache when USE_GCC is used in a port PR: ports/71717 Submitted by: Michael Johnson <ahze@ahze.net>
145 lines
3.3 KiB
Plaintext
145 lines
3.3 KiB
Plaintext
--- ccache.h.orig Wed Sep 8 21:30:40 2004
|
|
+++ ccache.h Wed Sep 8 21:31:53 2004
|
|
@@ -65,14 +65,14 @@
|
|
|
|
typedef unsigned uint32;
|
|
|
|
-#include "mdfour.h"
|
|
+#include <md4.h>
|
|
|
|
void hash_start(void);
|
|
void hash_string(const char *s);
|
|
void hash_int(int x);
|
|
void hash_file(const char *fname);
|
|
char *hash_result(void);
|
|
-void hash_buffer(const char *s, int len);
|
|
+void hash_buffer(const unsigned char *s, unsigned int len);
|
|
|
|
void cc_log(const char *format, ...);
|
|
void fatal(const char *msg);
|
|
--- hash.c.orig Wed Sep 8 21:36:22 2004
|
|
+++ hash.c Wed Sep 8 21:36:25 2004
|
|
@@ -20,17 +20,22 @@
|
|
*/
|
|
|
|
#include "ccache.h"
|
|
+#include <sys/types.h>
|
|
+#include <sys/mman.h>
|
|
+#include <sys/stat.h>
|
|
|
|
-static struct mdfour md;
|
|
+static MD4_CTX md;
|
|
+static off_t totalN;
|
|
|
|
-void hash_buffer(const char *s, int len)
|
|
+void hash_buffer(const unsigned char *s, unsigned int len)
|
|
{
|
|
- mdfour_update(&md, (unsigned char *)s, len);
|
|
+ totalN += len;
|
|
+ MD4Update(&md, s, len);
|
|
}
|
|
|
|
void hash_start(void)
|
|
{
|
|
- mdfour_begin(&md);
|
|
+ MD4Init(&md);
|
|
}
|
|
|
|
void hash_string(const char *s)
|
|
@@ -46,35 +51,40 @@
|
|
/* add contents of a file to the hash */
|
|
void hash_file(const char *fname)
|
|
{
|
|
- char buf[1024];
|
|
- int fd, n;
|
|
+ char *buf;
|
|
+ int fd;
|
|
+ struct stat stats;
|
|
|
|
fd = open(fname, O_RDONLY|O_BINARY);
|
|
if (fd == -1) {
|
|
cc_log("Failed to open %s\n", fname);
|
|
- fatal("hash_file");
|
|
+ fatal(__FUNCTION__);
|
|
}
|
|
|
|
- while ((n = read(fd, buf, sizeof(buf))) > 0) {
|
|
- hash_buffer(buf, n);
|
|
- }
|
|
+ if (fstat(fd, &stats) != 0) {
|
|
+ cc_log("Failed to fstat the opened %s (descriptor %d)\n",
|
|
+ fname, fd);
|
|
+ close(fd);
|
|
+ fatal(__FUNCTION__);
|
|
+ }
|
|
+ buf = mmap(NULL, stats.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
|
+ if (buf == MAP_FAILED) {
|
|
+ cc_log("Failed to mmap %s\n", fname);
|
|
+ close(fd);
|
|
+ fatal(__FUNCTION__);
|
|
+ }
|
|
+
|
|
+ hash_buffer(buf, stats.st_size);
|
|
close(fd);
|
|
}
|
|
|
|
/* return the hash result as a static string */
|
|
char *hash_result(void)
|
|
{
|
|
- unsigned char sum[16];
|
|
static char ret[53];
|
|
- int i;
|
|
|
|
- hash_buffer(NULL, 0);
|
|
- mdfour_result(&md, sum);
|
|
+ MD4End(&md, ret);
|
|
|
|
- for (i=0;i<16;i++) {
|
|
- sprintf(&ret[i*2], "%02x", (unsigned)sum[i]);
|
|
- }
|
|
- sprintf(&ret[i*2], "-%u", (unsigned)md.totalN);
|
|
-
|
|
+ snprintf(ret + 32, sizeof ret - 32, "-%lu", (unsigned long)totalN);
|
|
return ret;
|
|
}
|
|
--- unify.c.orig Wed Sep 8 21:36:41 2004
|
|
+++ unify.c Wed Sep 8 21:37:20 2004
|
|
@@ -104,13 +104,12 @@
|
|
hash_buffer((char *)buf, len);
|
|
len = 0;
|
|
}
|
|
- hash_buffer(NULL, 0);
|
|
return;
|
|
}
|
|
|
|
buf[len++] = c;
|
|
- if (len == 64) {
|
|
- hash_buffer((char *)buf, len);
|
|
+ if (len == sizeof buf) {
|
|
+ hash_buffer((char *)buf, sizeof buf);
|
|
len = 0;
|
|
}
|
|
}
|
|
--- Makefile.in.orig Mon Sep 6 09:04:22 2004
|
|
+++ Makefile.in Wed Sep 8 21:41:00 2004
|
|
@@ -11,16 +11,16 @@
|
|
CFLAGS=@CFLAGS@ -I.
|
|
EXEEXT=@EXEEXT@
|
|
|
|
-OBJS= ccache.o mdfour.o hash.o execute.o util.o args.o stats.o \
|
|
+OBJS= ccache.o hash.o execute.o util.o args.o stats.o \
|
|
cleanup.o snprintf.o unify.o
|
|
-HEADERS = ccache.h mdfour.h
|
|
+HEADERS = ccache.h
|
|
|
|
all: ccache$(EXEEXT)
|
|
|
|
docs: ccache.1 web/ccache-man.html
|
|
|
|
ccache$(EXEEXT): $(OBJS) $(HEADERS)
|
|
- $(CC) $(CFLAGS) -o $@ $(OBJS)
|
|
+ $(CC) $(CFLAGS) -o $@ $(OBJS) -lmd
|
|
|
|
ccache.1: ccache.yo
|
|
-yodl2man -o ccache.1 ccache.yo
|