View mode: basic / threaded / horizontal-split · Log in · Help
March 12, 2012
how to know at compile time pagesize?
I would like use std.mmfile ang give to mmFile ctor a window.
For this i want to give value from getPagesize.
On my linux system in C i can do this.
#include <unistd.h>
#include <stdio.h>

int main(){
int pageSize = getpagesize();
printf("Page size on your system = %i bytes\n", pageSize);
return 0;

In D i have try this but do not build:


import std.string;
import std.stdio;
import std.mmfile;

   import std.parallelism;
   extern(Windows){ void GetSystemInfo(void*); }
   SYSTEM_INFO sysinfo;
   GetSystemInfo( &sysinfo );
   size_t win = sysinfo.dwAllocationGranularity;
else version(linux){
   import core.sys.posix.sys.shm;
   // extern(System) int getpagesize();    
   // size_t win = getpagesize();
   size_t win = SHMLBA;
else version( FreeBSD ){
   import core.sys.posix.sys.shm;
   size_t win = SHMLBA;
   static assert( false, "Not supported plateform");

void main(  ){
   witefln( "Page size: %d", win);

Top | Discussion index | About this forum | D home