// D import file generated from '../../../../libphobos/libdruntime/core/sys/posix/sys/mman.d'
module core.sys.posix.sys.mman;
private import core.sys.posix.config;

public import core.stdc.stddef;

public import core.sys.posix.sys.types;

version (Posix)
{
	extern (C) 
	{
		version (linux)
		{
			enum POSIX_MADV_NORMAL = 0;
			enum POSIX_MADV_RANDOM = 1;
			enum POSIX_MADV_SEQUENTIAL = 2;
			enum POSIX_MADV_WILLNEED = 3;
			enum POSIX_MADV_DONTNEED = 4;
		}
		else
		{
			version (OSX)
			{
				enum POSIX_MADV_NORMAL = 0;
				enum POSIX_MADV_RANDOM = 1;
				enum POSIX_MADV_SEQUENTIAL = 2;
				enum POSIX_MADV_WILLNEED = 3;
				enum POSIX_MADV_DONTNEED = 4;
			}
			else
			{
				version (FreeBSD)
				{
					enum POSIX_MADV_NORMAL = 0;
					enum POSIX_MADV_RANDOM = 1;
					enum POSIX_MADV_SEQUENTIAL = 2;
					enum POSIX_MADV_WILLNEED = 3;
					enum POSIX_MADV_DONTNEED = 4;
				}
				else
				{
					version (Solaris)
					{
						enum POSIX_MADV_NORMAL = 0;
						enum POSIX_MADV_RANDOM = 1;
						enum POSIX_MADV_SEQUENTIAL = 2;
						enum POSIX_MADV_WILLNEED = 3;
						enum POSIX_MADV_DONTNEED = 4;
					}
					else
					{
						static assert(false,"Unsupported platform");
					}
				}
			}
		}
		version (linux)
		{
			enum PROT_NONE = 0;
			enum PROT_READ = 1;
			enum PROT_WRITE = 2;
			enum PROT_EXEC = 4;
		}
		else
		{
			version (OSX)
			{
				enum PROT_NONE = 0;
				enum PROT_READ = 1;
				enum PROT_WRITE = 2;
				enum PROT_EXEC = 4;
			}
			else
			{
				version (FreeBSD)
				{
					enum PROT_NONE = 0;
					enum PROT_READ = 1;
					enum PROT_WRITE = 2;
					enum PROT_EXEC = 4;
				}
				else
				{
					version (Solaris)
					{
						enum PROT_NONE = 0;
						enum PROT_READ = 1;
						enum PROT_WRITE = 2;
						enum PROT_EXEC = 4;
					}
					else
					{
						static assert(false,"Unsupported platform");
					}
				}
			}
		}
		version (linux)
		{
			int munmap(void*, size_t);
			static if(__USE_FILE_OFFSET64)
			{
				void* mmap64(void*, size_t, int, int, int, off_t);
				alias mmap64 mmap;
			}
			else
			{
				void* mmap(void*, size_t, int, int, int, off_t);
			}
		}
		else
		{
			version (OSX)
			{
				void* mmap(void*, size_t, int, int, int, off_t);
				int munmap(void*, size_t);
			}
			else
			{
				version (FreeBSD)
				{
					void* mmap(void*, size_t, int, int, int, off_t);
					int munmap(void*, size_t);
				}
				else
				{
					version (Solaris)
					{
						void* mmap(void*, size_t, int, int, int, off_t);
						int munmap(void*, size_t);
					}
					else
					{
						static assert(false,"Unsupported platform");
					}
				}
			}
		}
		version (linux)
		{
			enum MAP_SHARED = 1;
			enum MAP_PRIVATE = 2;
			enum MAP_FIXED = 16;
			version (MIPS)
			{
				enum MAP_ANON = 2048;
			}
			else
			{
				enum MAP_ANON = 32;
			}
			enum MAP_FAILED = cast(void*)-1;
			enum 
			{
				MS_ASYNC = 1,
				MS_SYNC = 4,
				MS_INVALIDATE = 2,
			}
			int msync(void*, size_t, int);
		}
		else
		{
			version (OSX)
			{
				enum MAP_SHARED = 1;
				enum MAP_PRIVATE = 2;
				enum MAP_FIXED = 16;
				enum MAP_ANON = 4096;
				enum MAP_FAILED = cast(void*)-1;
				enum MS_ASYNC = 1;
				enum MS_INVALIDATE = 2;
				enum MS_SYNC = 16;
				int msync(void*, size_t, int);
			}
			else
			{
				version (FreeBSD)
				{
					enum MAP_SHARED = 1;
					enum MAP_PRIVATE = 2;
					enum MAP_FIXED = 16;
					enum MAP_ANON = 4096;
					enum MAP_FAILED = cast(void*)-1;
					enum MS_SYNC = 0;
					enum MS_ASYNC = 1;
					enum MS_INVALIDATE = 2;
					int msync(void*, size_t, int);
				}
				else
				{
					version (Solaris)
					{
						enum MAP_SHARED = 1;
						enum MAP_PRIVATE = 2;
						enum MAP_FIXED = 16;
						enum MAP_ANON = 256;
						enum MAP_FAILED = cast(void*)-1;
						enum MS_SYNC = 4;
						enum MS_ASYNC = 1;
						enum MS_INVALIDATE = 2;
						int msync(void*, size_t, int);
					}
					else
					{
						static assert(false,"Unsupported platform");
					}
				}
			}
		}
		version (linux)
		{
			enum MCL_CURRENT = 1;
			enum MCL_FUTURE = 2;
			int mlockall(int);
			int munlockall();
		}
		else
		{
			version (OSX)
			{
				enum MCL_CURRENT = 1;
				enum MCL_FUTURE = 2;
				int mlockall(int);
				int munlockall();
			}
			else
			{
				version (FreeBSD)
				{
					enum MCL_CURRENT = 1;
					enum MCL_FUTURE = 2;
					int mlockall(int);
					int munlockall();
				}
				else
				{
					version (Solaris)
					{
						enum MCL_CURRENT = 1;
						enum MCL_FUTURE = 2;
						int mlockall(int);
						int munlockall();
					}
					else
					{
						static assert(false,"Unsupported platform");
					}
				}
			}
		}
		version (linux)
		{
			int mlock(in void*, size_t);
			int munlock(in void*, size_t);
		}
		else
		{
			version (OSX)
			{
				int mlock(in void*, size_t);
				int munlock(in void*, size_t);
			}
			else
			{
				version (FreeBSD)
				{
					int mlock(in void*, size_t);
					int munlock(in void*, size_t);
				}
				else
				{
					version (Solaris)
					{
						int mlock(in void*, size_t);
						int munlock(in void*, size_t);
					}
					else
					{
						static assert(false,"Unsupported platform");
					}
				}
			}
		}
		version (linux)
		{
			int mprotect(void*, size_t, int);
		}
		else
		{
			version (OSX)
			{
				int mprotect(void*, size_t, int);
			}
			else
			{
				version (FreeBSD)
				{
					int mprotect(void*, size_t, int);
				}
				else
				{
					version (Solaris)
					{
						int mprotect(void*, size_t, int);
					}
					else
					{
						static assert(false,"Unsupported platform");
					}
				}
			}
		}
		version (linux)
		{
			int shm_open(in char*, int, mode_t);
			int shm_unlink(in char*);
		}
		else
		{
			version (OSX)
			{
				int shm_open(in char*, int, mode_t);
				int shm_unlink(in char*);
			}
			else
			{
				version (FreeBSD)
				{
					int shm_open(in char*, int, mode_t);
					int shm_unlink(in char*);
				}
				else
				{
					version (Solaris)
					{
						int shm_open(in char*, int, mode_t);
						int shm_unlink(in char*);
					}
					else
					{
						static assert(false,"Unsupported platform");
					}
				}
			}
		}
	}
}
