PageCacheMacros

Define macros to access thread local object of type pagecache_t storead in threadcontext_t.

Summary
PageCacheMacrosDefine macros to access thread local object of type pagecache_t storead in threadcontext_t.
CopyrightThis program is free software.
Files
C-kern/api/memory/pagecache_macros.hHeader file PageCacheMacros.
C-kern/memory/pagecache_macros.cImplementation file PageCacheMacros impl.
Functions
alloc
ALLOC_PAGECACHEAllocates a single memory page of size pgsize (see pagesize_e) and returns it in page.
RELEASE_PAGECACHEReleases previously allocated memory page.
ALLOCSTATIC_PAGECACHEAllocates static block of memory and returns it in memblock.
FREESTATIC_PAGECACHEFrees static block of memory and clears memblock.
query
SIZEALLOCATED_PAGECACHEReturns sum of size of all allocated pages.
SIZESTATIC_PAGECACHEReturns size of static allocated memory.
cache
EMPTYCACHE_PAGECACHEReturns unused memory blocks back to OS.
test
unittest_memory_pagecache_macrosTest pagecache_t functionality.

Copyright

This program is free software.  You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

Author

© 2013 Jörg Seebohn

Files

C-kern/api/memory/pagecache_macros.h

Header file PageCacheMacros.

C-kern/memory/pagecache_macros.c

Implementation file PageCacheMacros impl.

Functions

Summary
alloc
ALLOC_PAGECACHEAllocates a single memory page of size pgsize (see pagesize_e) and returns it in page.
RELEASE_PAGECACHEReleases previously allocated memory page.
ALLOCSTATIC_PAGECACHEAllocates static block of memory and returns it in memblock.
FREESTATIC_PAGECACHEFrees static block of memory and clears memblock.
query
SIZEALLOCATED_PAGECACHEReturns sum of size of all allocated pages.
SIZESTATIC_PAGECACHEReturns size of static allocated memory.
cache
EMPTYCACHE_PAGECACHEReturns unused memory blocks back to OS.
test
unittest_memory_pagecache_macrosTest pagecache_t functionality.

alloc

ALLOC_PAGECACHE

#define ALLOC_PAGECACHE(
   pgsize,
   page
) (allocpage_pagecache(pagecache_maincontext(), (pgsize), (page)))

Allocates a single memory page of size pgsize (see pagesize_e) and returns it in page.  See pagecache_it.allocpage for a description.

RELEASE_PAGECACHE

#define RELEASE_PAGECACHE(
   page
) (releasepage_pagecache(pagecache_maincontext(), (page)))

Releases previously allocated memory page.  See pagecache_it.releasepage for a description.

ALLOCSTATIC_PAGECACHE

#define ALLOCSTATIC_PAGECACHE(
   bytesize,
   memblock
) (allocstatic_pagecache(pagecache_maincontext(), (bytesize), (memblock)))

Allocates static block of memory and returns it in memblock.  See pagecache_it.allocstatic for a description.

FREESTATIC_PAGECACHE

#define FREESTATIC_PAGECACHE(
   memblock
) (freestatic_pagecache(pagecache_maincontext(), (memblock)))

Frees static block of memory and clears memblock.  See pagecache_it.freestatic for a description.

query

SIZEALLOCATED_PAGECACHE

#define SIZEALLOCATED_PAGECACHE(
   
) (sizeallocated_pagecache(pagecache_maincontext()))

Returns sum of size of all allocated pages.  See pagecache_it.sizeallocated for a description.

SIZESTATIC_PAGECACHE

#define SIZESTATIC_PAGECACHE() (sizestatic_pagecache(pagecache_maincontext()))

Returns size of static allocated memory.  See pagecache_it.sizestatic for a description.

cache

EMPTYCACHE_PAGECACHE

#define EMPTYCACHE_PAGECACHE() (emptycache_pagecache(pagecache_maincontext()))

Returns unused memory blocks back to OS.  See pagecache_it.emptycache for a description.

test

unittest_memory_pagecache_macros

int unittest_memory_pagecache_macros(void)

Test pagecache_t functionality.

iobj_DECLARE(pagecache_t,
pagecache)
Uses iobj_DECLARE to declare interfaceable object.
Define macros to access thread local object of type pagecache_t storead in threadcontext_t.
Implements PageCacheMacros.
#define ALLOC_PAGECACHE(
   pgsize,
   page
) (allocpage_pagecache(pagecache_maincontext(), (pgsize), (page)))
Allocates a single memory page of size pgsize (see pagesize_e) and returns it in page.
List of supported page sizes.
#define RELEASE_PAGECACHE(
   page
) (releasepage_pagecache(pagecache_maincontext(), (page)))
Releases previously allocated memory page.
#define ALLOCSTATIC_PAGECACHE(
   bytesize,
   memblock
) (allocstatic_pagecache(pagecache_maincontext(), (bytesize), (memblock)))
Allocates static block of memory and returns it in memblock.
#define FREESTATIC_PAGECACHE(
   memblock
) (freestatic_pagecache(pagecache_maincontext(), (memblock)))
Frees static block of memory and clears memblock.
#define SIZEALLOCATED_PAGECACHE(
   
) (sizeallocated_pagecache(pagecache_maincontext()))
Returns sum of size of all allocated pages.
#define SIZESTATIC_PAGECACHE() (sizestatic_pagecache(pagecache_maincontext()))
Returns size of static allocated memory.
#define EMPTYCACHE_PAGECACHE() (emptycache_pagecache(pagecache_maincontext()))
Returns unused memory blocks back to OS.
int unittest_memory_pagecache_macros(void)
Test pagecache_t functionality.
int (
   *allocpage
) (pagecache_t * pgcache, uint8_t pgsize, /*out*/struct memblock_t * page)
Allocates a single memory page of size pgsize.
int (*releasepage) (pagecache_t * pgcache, struct memblock_t * page)
Releases a single memory page.
int (
   *allocstatic
) (pagecache_t * pgcache, size_t bytesize, /*out*/struct memblock_t * memblock)
Allocates static memory which should live as long as pgcache.
int (*freestatic) (pagecache_t * pgcache, struct memblock_t * memblock)
Frees static memory.
size_t (*sizeallocated) (const pagecache_t * pgcache)
Returns the sum of the size of all allocated pages.
size_t (*sizestatic) (const pagecache_t * pgcache)
Size of memory allocated with allocstatic.
int (*emptycache) (pagecache_t * pgcache)
Releases all unused memory blocks back to the operating system.
Close