// D import file generated from '../../../../libphobos/libdruntime/core/sys/windows/threadaux.d'
module core.sys.windows.threadaux;
version (Windows)
{
	import core.sys.windows.windows;
	import core.stdc.stdlib;
	public import core.thread;

	extern (Windows) nothrow HANDLE OpenThread(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwThreadId);

	extern (C) extern __gshared int _tls_index;


	extern (C) 
	{
		void rt_moduleTlsCtor();
		void rt_moduleTlsDtor();
	}
	private 
	{
		struct thread_aux
		{
			enum SystemProcessInformation = 5;
			enum STATUS_INFO_LENGTH_MISMATCH = 3221225476u;
			struct UNICODE_STRING
			{
				short Length;
				short MaximumLength;
				wchar* Buffer;
			}
			alias size_t PTID;
			struct _SYSTEM_PROCESS_INFORMATION
			{
				int NextEntryOffset;
				int NumberOfThreads;
				long WorkingSetPrivateSize;
				uint HardFaultCount;
				uint NumberOfThreadsHighWatermark;
				ulong CycleTime;
				long CreateTime;
				long UserTime;
				long KernelTime;
				UNICODE_STRING ImageName;
				int BasePriority;
				PTID ProcessId;
				PTID InheritedFromUniqueProcessId;
				uint HandleCount;
				uint SessionId;
				size_t UniqueProcessKey;
				size_t PeakVirtualSize;
				size_t VirtualSize;
				uint PageFaultCount;
				size_t PeakWorkingSetSize;
				size_t WorkingSetSize;
				size_t QuotaPeakPagedPoolUsage;
				size_t QuotaPagedPoolUsage;
				size_t QuotaPeakNonPagedPoolUsage;
				size_t QuotaNonPagedPoolUsage;
				size_t PagefileUsage;
				size_t PeakPagefileUsage;
				size_t PrivatePageCount;
				long ReadOperationCount;
				long WriteOperationCount;
				long OtherOperationCount;
				long ReadTransferCount;
				long WriteTransferCount;
				long OtherTransferCount;
			}
			struct _SYSTEM_THREAD_INFORMATION
			{
				long KernelTime;
				long UserTime;
				long CreateTime;
				uint WaitTime;
				void* StartAddress;
				PTID ProcessId;
				PTID ThreadId;
				int Priority;
				int BasePriority;
				uint ContextSwitches;
				uint ThreadState;
				int WaitReason;
				int reserved;
			}
			extern (Windows) alias nothrow HRESULT fnNtQuerySystemInformation(uint SystemInformationClass, void* info, uint infoLength, uint* ReturnLength);

			enum ThreadBasicInformation = 0;
			struct THREAD_BASIC_INFORMATION
			{
				int ExitStatus;
				void** TebBaseAddress;
				PTID ProcessId;
				PTID ThreadId;
				size_t AffinityMask;
				int Priority;
				int BasePriority;
			}
			extern (Windows) alias nothrow int fnNtQueryInformationThread(HANDLE ThreadHandle, uint ThreadInformationClass, void* buf, uint size, uint* ReturnLength);

			enum SYNCHRONIZE = 1048576;
			enum THREAD_GET_CONTEXT = 8;
			enum THREAD_QUERY_INFORMATION = 64;
			enum THREAD_SUSPEND_RESUME = 2;
			static nothrow void** getTEB(HANDLE hnd);

			static nothrow void** getTEB(uint id);

			static void** getTEB();

			static nothrow void* getThreadStackBottom(HANDLE hnd);

			static nothrow void* getThreadStackBottom(uint id);

			static nothrow HANDLE OpenThreadHandle(uint id);

			static bool enumProcessThreads(uint procid, bool function(uint id, void* context) dg, void* context);

			static bool enumProcessThreads(bool function(uint id, void* context) dg, void* context);

			extern (C) alias void function() externCVoidFunc;

			static void impersonate_thread(uint id, externCVoidFunc fn);

		}
		public 
		{
			alias thread_aux.getTEB getTEB;
			alias thread_aux.getThreadStackBottom getThreadStackBottom;
			alias thread_aux.OpenThreadHandle OpenThreadHandle;
			alias thread_aux.enumProcessThreads enumProcessThreads;
			nothrow void* GetTlsDataAddress(HANDLE hnd);
			nothrow void* GetTlsDataAddress(uint id);
			void thread_moduleTlsCtor(uint id);
			void thread_moduleTlsDtor(uint id);
		}
	}
}
