diff options
author | Jamey Hicks <jamey.hicks@nokia.com> | 2012-09-27 13:53:46 -0400 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-10-12 19:50:42 +0200 |
commit | 97cf5a258307a48394ea5e0c1565640f953915d8 (patch) | |
tree | 62bd994e5809259dc4a97286f34801a3d5415bc4 | |
parent | 6396dad6cc27208817a6ee416c539f08477dcc6c (diff) |
adapt hbtree to windows
Change-Id: I1aef5540cebd859572fb6640e03442e5c2416ee4
Reviewed-by: Kevin Simons <kevin.b.simons@gmail.com>
-rw-r--r-- | src/hbtree/hbtree.cpp | 37 | ||||
-rw-r--r-- | src/hbtree/hbtree_p.h | 6 |
2 files changed, 43 insertions, 0 deletions
diff --git a/src/hbtree/hbtree.cpp b/src/hbtree/hbtree.cpp index 5e006d0..9a4225a 100644 --- a/src/hbtree/hbtree.cpp +++ b/src/hbtree/hbtree.cpp @@ -89,6 +89,38 @@ const quint32 HBtreePrivate::PageInfo::INVALID_PAGE = 0xFFFFFFFF; + + +#ifdef Q_OS_WIN32 +ssize_t pread(int fd, void *buf, size_t count, off_t offset) +{ + lseek(fd, offset, SEEK_SET); + return read(fd, buf, count); +} + +ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset) +{ + lseek(fd, offset, SEEK_SET); + return write(fd, buf, count); +} + +int fsync(int fd) +{ + return 0; +} + +#define LOCK_UN 0 +#define LOCK_EX 22 +#define LOCK_NB 23 + +int flock(int fd, int operation) +{ + return 0; +} + +#endif + + // ###################################################################### // ### Creation destruction // ###################################################################### @@ -324,7 +356,12 @@ bool HBtreePrivate::writeSpec() Spec spec; spec.version = HBTREE_VERSION; spec.keySize = 255; +#ifndef Q_OS_WIN32 spec.pageSize = spec_.pageSize ? spec_.pageSize : (sb.st_blksize > HBTREE_DEFAULT_PAGE_SIZE ? sb.st_blksize : HBTREE_DEFAULT_PAGE_SIZE); +#else + spec.pageSize = spec_.pageSize ? spec_.pageSize : HBTREE_DEFAULT_PAGE_SIZE; +#endif + pageBuffer_.fill((char)0, spec.pageSize); diff --git a/src/hbtree/hbtree_p.h b/src/hbtree/hbtree_p.h index 2e0f2f3..dd9b7ff 100644 --- a/src/hbtree/hbtree_p.h +++ b/src/hbtree/hbtree_p.h @@ -53,7 +53,11 @@ #include <QSharedPointer> #include <QStack> +#ifndef Q_OS_WIN32 #define HBTREE_ATTRIBUTE_PACKED __attribute__((packed)) +#else +#define HBTREE_ATTRIBUTE_PACKED +#endif class HBtreePrivate { @@ -217,7 +221,9 @@ public: quint32 size; // size of file at time of commit quint32 flags; // If marker has this, it was synced. } HBTREE_ATTRIBUTE_PACKED; +#ifndef Q_OS_WIN32 Q_STATIC_ASSERT(sizeof(Meta) == 28); +#endif Meta meta; QSet<quint32> residueHistory; // history nodes that don't have a home. usable after sync. quint32 overflowPage; |