Browse Source

create package borg.algorithms with borg.algorithms.crc32 module

Marian Beermann 8 years ago
parent
commit
fa381ffcbe

+ 1 - 1
.gitignore

@@ -9,7 +9,7 @@ chunker.c
 compress.c
 crypto.c
 item.c
-src/borg/crc32.c
+src/borg/algorithms/crc32.c
 src/borg/platform/darwin.c
 src/borg/platform/freebsd.c
 src/borg/platform/linux.c

+ 4 - 4
setup.py

@@ -54,7 +54,7 @@ crypto_source = 'src/borg/crypto.pyx'
 chunker_source = 'src/borg/chunker.pyx'
 hashindex_source = 'src/borg/hashindex.pyx'
 item_source = 'src/borg/item.pyx'
-crc32_source = 'src/borg/crc32.pyx'
+crc32_source = 'src/borg/algorithms/crc32.pyx'
 platform_posix_source = 'src/borg/platform/posix.pyx'
 platform_linux_source = 'src/borg/platform/linux.pyx'
 platform_darwin_source = 'src/borg/platform/darwin.pyx'
@@ -91,8 +91,8 @@ try:
                 'src/borg/chunker.c', 'src/borg/_chunker.c',
                 'src/borg/hashindex.c', 'src/borg/_hashindex.c',
                 'src/borg/item.c',
-                'src/borg/crc32.c',
-                'src/borg/_crc32/crc32.c', 'src/borg/_crc32/clmul.c', 'src/borg/_crc32/slice_by_8.c',
+                'src/borg/algorithms/crc32.c',
+                'src/borg/algorithms/crc32_dispatch.c', 'src/borg/algorithms/crc32_clmul.c', 'src/borg/algorithms/crc32_slice_by_8.c',
                 'src/borg/platform/posix.c',
                 'src/borg/platform/linux.c',
                 'src/borg/platform/freebsd.c',
@@ -582,7 +582,7 @@ if not on_rtd:
     Extension('borg.chunker', [chunker_source]),
     Extension('borg.hashindex', [hashindex_source]),
     Extension('borg.item', [item_source]),
-    Extension('borg.crc32', [crc32_source]),
+    Extension('borg.algorithms.crc32', [crc32_source]),
 ]
     if not sys.platform.startswith(('win32', )):
         ext_modules.append(Extension('borg.platform.posix', [platform_posix_source]))

+ 1 - 1
src/borg/crc32.pyx → src/borg/algorithms/crc32.pyx

@@ -3,7 +3,7 @@ from libc.stdint cimport uint32_t
 from cpython.buffer cimport PyBUF_SIMPLE, PyObject_GetBuffer, PyBuffer_Release
 
 
-cdef extern from "_crc32/crc32.c":
+cdef extern from "crc32_dispatch.c":
     uint32_t _crc32_slice_by_8 "crc32_slice_by_8"(const void* data, size_t length, uint32_t initial_crc)
     uint32_t _crc32_clmul "crc32_clmul"(const void* data, size_t length, uint32_t initial_crc)
 

+ 0 - 0
src/borg/_crc32/clmul.c → src/borg/algorithms/crc32_clmul.c


+ 2 - 2
src/borg/_crc32/crc32.c → src/borg/algorithms/crc32_dispatch.c

@@ -1,6 +1,6 @@
 
 /* always compile slice by 8 as a runtime fallback */
-#include "slice_by_8.c"
+#include "crc32_slice_by_8.c"
 
 #ifdef __GNUC__
 /*
@@ -69,7 +69,7 @@
 #endif /* ifdef __GNUC__ */
 
 #ifdef FOLDING_CRC
-#include "clmul.c"
+#include "crc32_clmul.c"
 #else
 
 static uint32_t

+ 0 - 0
src/borg/_crc32/slice_by_8.c → src/borg/algorithms/crc32_slice_by_8.c


+ 1 - 1
src/borg/archiver.py

@@ -31,12 +31,12 @@ import msgpack
 import borg
 from . import __version__
 from . import helpers
+from .algorithms.crc32 import crc32
 from .archive import Archive, ArchiveChecker, ArchiveRecreater, Statistics, is_special
 from .archive import BackupOSError, backup_io
 from .cache import Cache
 from .constants import *  # NOQA
 from .compress import CompressionSpec
-from .crc32 import crc32
 from .helpers import EXIT_SUCCESS, EXIT_WARNING, EXIT_ERROR
 from .helpers import Error, NoManifestError, set_ec
 from .helpers import location_validator, archivename_validator, ChunkerParams

+ 1 - 1
src/borg/repository.py

@@ -23,7 +23,7 @@ from .locking import Lock, LockError, LockErrorT
 from .logger import create_logger
 from .lrucache import LRUCache
 from .platform import SaveFile, SyncFile, sync_dir, safe_fadvise
-from .crc32 import crc32
+from .algorithms.crc32 import crc32
 
 logger = create_logger(__name__)
 

+ 1 - 1
src/borg/testsuite/crc32.py

@@ -3,7 +3,7 @@ import zlib
 
 import pytest
 
-from .. import crc32
+from ..algorithms import crc32
 
 crc32_implementations = [crc32.crc32_slice_by_8]
 if crc32.have_clmul: