mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-13 07:36:23 +00:00
58360a629c
- use helper functions to reduce occurrences of BLOCK_SIZE and SECTOR_SIZE - wmi: provide for shutting it down (gets rid of its two threads); only initialize if actually needed (costs 200ms) - ogl_tex: don't complain if there's no gfx_card info (due to not having used wmi) This was SVN commit r5572.
36 lines
1.1 KiB
C++
36 lines
1.1 KiB
C++
#ifndef INCLUDED_IO_ALIGN
|
|
#define INCLUDED_IO_ALIGN
|
|
|
|
#include "lib/bits.h" // IsAligned, round_up
|
|
|
|
/**
|
|
* block := power-of-two sized chunk of a file.
|
|
* all transfers are expanded to naturally aligned, whole blocks.
|
|
* (this makes caching parts of files feasible; it is also much faster
|
|
* for some aio implementations, e.g. wposix.)
|
|
* (blocks are also thereby page-aligned, which allows write-protecting
|
|
* file buffers without worrying about their boundaries.)
|
|
**/
|
|
static const size_t BLOCK_SIZE = 256*KiB;
|
|
|
|
// note: *sizes* and *offsets* are aligned to blocks to allow zero-copy block cache.
|
|
// that the *buffer* need only be sector-aligned (we assume 4kb for simplicity)
|
|
// (this is a requirement of the underlying Windows OS)
|
|
static const size_t SECTOR_SIZE = 4*KiB;
|
|
|
|
|
|
template<class T>
|
|
bool IsAligned_Data(T* address)
|
|
{
|
|
return IsAligned((uintptr_t)address, SECTOR_SIZE);
|
|
}
|
|
|
|
extern bool IsAligned_Offset(off_t ofs);
|
|
|
|
|
|
extern off_t AlignedOffset(off_t ofs);
|
|
extern off_t AlignedSize(off_t size);
|
|
extern off_t PaddedSize(off_t size, off_t ofs);
|
|
|
|
#endif // #ifndef INCLUDED_IO_ALIGN
|