[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Fwd: [PATCHES] Amd64 support and kernel >=2.6.7 support



---------- Forwarded message ----------
From: Stefan Schweizer <sschweizer@gmail.com>
Date: Wed, 24 Nov 2004 16:14:47 +0100
Subject: [PATCHES] Amd64 support and kernel >=2.6.7 support
To: cloop@knopper.net


Hi,
While making the Gentoo package for cloop, I got some interesting
patches from users in the bugreport:
http://bugs.gentoo.org/show_bug.cgi?id=57912

I want to send you them, requesting inclusion in the official cloop source.

Single patches attached.

kind regards,


Stefan Schweizer
Gentoo developer
http://dev.gentoo.org/genstef
diff -urN ../tmp-orig/cloop-2.01.4/advancecomp-1.9_create_compressed_fs/7z/AriBitCoder.h ./advancecomp-1.9_create_compressed_fs/7z/AriBitCoder.h
--- ../tmp-orig/cloop-2.01.4/advancecomp-1.9_create_compressed_fs/7z/AriBitCoder.h	2003-02-10 20:25:06.000000000 +0100
+++ ./advancecomp-1.9_create_compressed_fs/7z/AriBitCoder.h	2004-07-10 15:27:58.225214667 +0200
@@ -51,13 +51,13 @@
 public:
   void Encode(CRangeEncoder *aRangeEncoder, UINT32 aSymbol)
   {
-    aRangeEncoder->EncodeBit(m_Probability, kNumBitModelTotalBits, aSymbol);
-    UpdateModel(aSymbol);
+    aRangeEncoder->EncodeBit(this->m_Probability, kNumBitModelTotalBits, aSymbol);
+    this->UpdateModel(aSymbol);
   }
   UINT32 GetPrice(UINT32 aSymbol) const
   {
     return g_PriceTables.m_StatePrices[
-      (((m_Probability - aSymbol) ^ ((-(int)aSymbol))) & (kBitModelTotal - 1)) >> kNumMoveReducingBits];
+      (((this->m_Probability - aSymbol) ^ ((-(int)aSymbol))) & (kBitModelTotal - 1)) >> kNumMoveReducingBits];
   }
 };
 
@@ -68,11 +68,11 @@
 public:
   UINT32 Decode(CRangeDecoder *aRangeDecoder)
   {
-    UINT32 aNewBound = (aRangeDecoder->m_Range >> kNumBitModelTotalBits) * m_Probability;
+    UINT32 aNewBound = (aRangeDecoder->m_Range >> kNumBitModelTotalBits) * this->m_Probability;
     if (aRangeDecoder->m_Code < aNewBound)
     {
       aRangeDecoder->m_Range = aNewBound;
-      m_Probability += (kBitModelTotal - m_Probability) >> aNumMoveBits;
+      this->m_Probability += (kBitModelTotal - this->m_Probability) >> aNumMoveBits;
       if (aRangeDecoder->m_Range < kTopValue)
       {
         aRangeDecoder->m_Code = (aRangeDecoder->m_Code << 8) | aRangeDecoder->m_Stream.ReadByte();
@@ -84,7 +84,7 @@
     {
       aRangeDecoder->m_Range -= aNewBound;
       aRangeDecoder->m_Code -= aNewBound;
-      m_Probability -= (m_Probability) >> aNumMoveBits;
+      this->m_Probability -= (this->m_Probability) >> aNumMoveBits;
       if (aRangeDecoder->m_Range < kTopValue)
       {
         aRangeDecoder->m_Code = (aRangeDecoder->m_Code << 8) | aRangeDecoder->m_Stream.ReadByte();

diff -ru cloop-2.01/Makefile cloop-2.01.new/Makefile
--- cloop-2.01/Makefile	2004-05-14 14:17:51.000000000 -0500
+++ cloop-2.01.new/Makefile	2004-07-21 16:26:59.167257880 -0500
@@ -1,18 +1,51 @@
 #!/usr/bin/make
 
-KERNEL_DIR=/usr/src/linux
+KVERSION=$(shell uname -r)
+MACHINE=$(shell uname -m)
+KERNEL_DIR=/lib/modules/$(KVERSION)/build
+KERNEL_INCLUDE=$(KERNEL_DIR)/include
+INCLUDE_26:=-include $(KERNEL_INCLUDE)/config/modversions.h -include $(KERNEL_INCLUDE)/linux/version.h
+INCLUDE_24:=-include $(KERNEL_INCLUDE)/linux/modversions.h
+
+file_exist=$(shell test -f $(1) && echo yes || echo no)
+
+# test for 2.6 or 2.4 kernel
+ifeq ($(call file_exist,$(KERNEL_DIR)/Rules.make), yes)
+PATCHLEVEL:=4
+else
+PATCHLEVEL:=6
+endif
 
 ifdef APPSONLY
 CFLAGS:=-Wall -Wstrict-prototypes -Wno-trigraphs -O2 -s -I. -fno-strict-aliasing -fno-common -fomit-frame-pointer 
 else
-include $(KERNEL_DIR)/.config
+ifeq ($(PATCHLEVEL),4)
 include $(KERNEL_DIR)/conf.vars
+else
+include $(KERNEL_DIR)/.config
+endif
 endif
 
 CKERNOPS:=-D__KERNEL__ -DMODULE -fno-builtin -nostdlib -DKBUILD_MODNAME="cloop" -DKBUILD_BASENAME="cloop"
 
+# I needed this for my amd64 system running 2.6.7
+# it maybe required for 2.6, so I add it here
+ifeq ($(PATCHLEVEL),6)
+CKERNOPS+= -D__OPTIMIZE__
+endif
+
+# check for amd64
+ifeq ($(MACHINE),x86_64)
+CKERNOPS+=-mno-red-zone -mcmodel=kernel
+endif
+
 ifdef CONFIG_MODVERSIONS
-MODVERSIONS:= -DMODVERSIONS -include $(KERNEL_DIR)/include/linux/modversions.h
+MODVERSIONS:= -DMODVERSIONS
+ifeq ($(PATCHLEVEL),4)
+MODVERSIONS+=$(INCLUDE_24)
+else
+MODVERSIONS+=$(INCLUDE_26)
+endif
 CKERNOPS += $(MODVERSIONS)
 endif
 
diff -ru cloop-2.01/advancecomp-1.9_create_compressed_fs/advfs.cc cloop-2.01.new/advancecomp-1.9_create_compressed_fs/advfs.cc
--- cloop-2.01/advancecomp-1.9_create_compressed_fs/advfs.cc	2004-04-18 15:33:29.000000000 -0500
+++ cloop-2.01.new/advancecomp-1.9_create_compressed_fs/advfs.cc	2004-07-20 11:55:28.000000000 -0500
@@ -30,6 +30,7 @@
 #include "utility.h"
 #include "compress.h"
 #include "siglock.h"
+#define __OPTIMIZE__
 #include <netinet/in.h>
 
 #include "lib/mng.h"

--- cloop-2.01/advancecomp-1.9_create_compressed_fs/advfs.cc	2004-04-18 16:33:29.000000000 -0400
+++ cloop-2.01.new/advancecomp-1.9_create_compressed_fs/advfs.cc	2004-11-23 18:04:49.859941344 -0500
@@ -81,7 +81,7 @@
   {
    int z_error;
    unsigned long total=0;
-   unsigned len[maxalg];
+   uLong len[maxalg];
    unsigned int best;
    //memset(compressed,0,len); memset(uncompressed,0,blocksize);
    for(j=0; j<maxalg; j++) memset(compressed[j],0,maxlen), len[j]=maxlen;
@@ -111,7 +111,8 @@
       }
 
      /* Try 7ZIP compression now. */
-     if(!compress_zlib(shrink_extreme, (unsigned char *)compressed[maxalg-1], len[maxalg-1], (unsigned char *)uncompressed, blocksize))
+     unsigned zlib_length=(unsigned int)len[maxalg-1];
+     if(!compress_zlib(shrink_extreme, (unsigned char *)compressed[maxalg-1], zlib_length, (unsigned char *)uncompressed, blocksize))
       {
        fprintf(stderr, "*** Error %d compressing block %lu! (compressed=%p, len=%lu, uncompressed=%p, blocksize=%lu)\n", z_error, i, compressed,len,uncompressed,blocksize);
        goto error_free_cb_list;

This patch is taken from debian and fixes some incompatible kernel changes
in 2.6.7 and later linux-kernels.

--- cloop-2.01/compressed_loop.c.orig	2004-05-14 15:22:47.000000000 -0400
+++ cloop-2.01/compressed_loop.c	2004-11-22 11:32:45.772837000 -0500
@@ -202,7 +202,11 @@
                           unsigned long offset, unsigned long size)
 {
  char *kaddr;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,7)
+ struct clo_read_data *p = (struct clo_read_data*)desc->arg.buf;
+#else
  struct clo_read_data *p = (struct clo_read_data*)desc->buf;
+#endif
  unsigned long count = desc->count;
  if (size > count) size = count;
  kaddr = kmap(page);
@@ -228,7 +232,11 @@
    read_descriptor_t desc;
    desc.written = 0;
    desc.count   = size;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,7)
+   desc.arg.buf = (char*)&cd;
+#else
    desc.buf     = (char*)&cd;
+#endif
    desc.error   = 0;
 #ifdef REDHAT_KERNEL /* Greenshoe Linux */
    do_generic_file_read(f, &pos, &desc, clo_read_actor, 0);


Reply to: