1/**
2 * This module provides types and constants used in thread package.
3 *
4 * Copyright: Copyright Sean Kelly 2005 - 2012.
5 * License: Distributed under the
6 *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
7 *    (See accompanying file LICENSE)
8 * Authors:   Sean Kelly, Walter Bright, Alex R��nne Petersen, Martin Nowak
9 * Source:    $(DRUNTIMESRC core/thread/osthread.d)
10 */
11
12module core.thread.types;
13
14/**
15 * Represents the ID of a thread, as returned by $(D Thread.)$(LREF id).
16 * The exact type varies from platform to platform.
17 */
18version (Windows)
19    alias ThreadID = uint;
20else
21version (Posix)
22{
23    import core.sys.posix.pthread;
24
25    alias ThreadID = pthread_t;
26}
27
28struct ll_ThreadData
29{
30    ThreadID tid;
31    version (Windows)
32        void delegate() nothrow cbDllUnload;
33}
34
35version (GNU)
36{
37    version (GNU_StackGrowsDown)
38        enum isStackGrowingDown = true;
39    else
40        enum isStackGrowingDown = false;
41}
42else
43{
44    // this should be true for most architectures
45    enum isStackGrowingDown = true;
46}
47
48package
49{
50    static immutable size_t PAGESIZE;
51    version (Posix) static immutable size_t PTHREAD_STACK_MIN;
52}
53
54shared static this()
55{
56    version (Windows)
57    {
58        import core.sys.windows.winbase;
59
60        SYSTEM_INFO info;
61        GetSystemInfo(&info);
62
63        PAGESIZE = info.dwPageSize;
64        assert(PAGESIZE < int.max);
65    }
66    else version (Posix)
67    {
68        import core.sys.posix.unistd;
69
70        PAGESIZE = cast(size_t)sysconf(_SC_PAGESIZE);
71        PTHREAD_STACK_MIN = cast(size_t)sysconf(_SC_THREAD_STACK_MIN);
72    }
73    else
74    {
75        static assert(0, "unimplemented");
76    }
77}
78