From fa381ffcbe02edb3b7c605973075a03d7dc16225 Mon Sep 17 00:00:00 2001 From: Marian Beermann Date: Tue, 2 May 2017 18:48:28 +0200 Subject: [PATCH] create package borg.algorithms with borg.algorithms.crc32 module --- .gitignore | 2 +- setup.py | 8 ++++---- src/borg/{ => algorithms}/crc32.pyx | 2 +- src/borg/{_crc32/clmul.c => algorithms/crc32_clmul.c} | 0 src/borg/{_crc32/crc32.c => algorithms/crc32_dispatch.c} | 4 ++-- .../slice_by_8.c => algorithms/crc32_slice_by_8.c} | 0 src/borg/archiver.py | 2 +- src/borg/repository.py | 2 +- src/borg/testsuite/crc32.py | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) rename src/borg/{ => algorithms}/crc32.pyx (96%) rename src/borg/{_crc32/clmul.c => algorithms/crc32_clmul.c} (100%) rename src/borg/{_crc32/crc32.c => algorithms/crc32_dispatch.c} (97%) rename src/borg/{_crc32/slice_by_8.c => algorithms/crc32_slice_by_8.c} (100%) diff --git a/.gitignore b/.gitignore index e5ec9ae78..69cf3f751 100644 --- a/.gitignore +++ b/.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 diff --git a/setup.py b/setup.py index 15ebb8ed2..4ebf10fc7 100644 --- a/setup.py +++ b/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])) diff --git a/src/borg/crc32.pyx b/src/borg/algorithms/crc32.pyx similarity index 96% rename from src/borg/crc32.pyx rename to src/borg/algorithms/crc32.pyx index 4854e38f4..07c8560f3 100644 --- a/src/borg/crc32.pyx +++ b/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) diff --git a/src/borg/_crc32/clmul.c b/src/borg/algorithms/crc32_clmul.c similarity index 100% rename from src/borg/_crc32/clmul.c rename to src/borg/algorithms/crc32_clmul.c diff --git a/src/borg/_crc32/crc32.c b/src/borg/algorithms/crc32_dispatch.c similarity index 97% rename from src/borg/_crc32/crc32.c rename to src/borg/algorithms/crc32_dispatch.c index 239592592..19c7ebe9d 100644 --- a/src/borg/_crc32/crc32.c +++ b/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 diff --git a/src/borg/_crc32/slice_by_8.c b/src/borg/algorithms/crc32_slice_by_8.c similarity index 100% rename from src/borg/_crc32/slice_by_8.c rename to src/borg/algorithms/crc32_slice_by_8.c diff --git a/src/borg/archiver.py b/src/borg/archiver.py index c2d972024..d7bf37420 100644 --- a/src/borg/archiver.py +++ b/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 diff --git a/src/borg/repository.py b/src/borg/repository.py index b5c2e193f..d7a7f449c 100644 --- a/src/borg/repository.py +++ b/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__) diff --git a/src/borg/testsuite/crc32.py b/src/borg/testsuite/crc32.py index 4faed809b..4eb59fa88 100644 --- a/src/borg/testsuite/crc32.py +++ b/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: