|
|
1.1 root 1: /*
2: Copyright (c) 2008 TrueCrypt Foundation. All rights reserved.
3:
4: Governed by the TrueCrypt License 2.4 the full text of which is contained
5: in the file License.txt included in TrueCrypt binary and source code
6: distribution packages.
7: */
8:
9: #include <pthread.h>
10: #include <unistd.h>
11: #include "Platform/SystemException.h"
12: #include "Platform/Thread.h"
13: #include "Platform/SystemLog.h"
14:
15: namespace TrueCrypt
16: {
17: void Thread::Start (ThreadProcPtr threadProc, void *parameter)
18: {
19: pthread_t thread;
20: pthread_attr_t attr;
21: size_t stackSize = 0;
22: int status;
23:
24: status = pthread_attr_init (&attr);
25: if (status != 0)
26: throw SystemException (SRC_POS, status);
27:
28: status = pthread_attr_getstacksize (&attr, &stackSize);
29: if (status != 0)
30: throw SystemException (SRC_POS, status);
31:
32: if (stackSize < MinThreadStackSize)
33: {
34: status = pthread_attr_setstacksize (&attr, MinThreadStackSize);
35: if (status != 0)
36: throw SystemException (SRC_POS, status);
37: }
38:
39: status = pthread_create (&thread, nullptr, threadProc, parameter);
40: if (status != 0)
41: throw SystemException (SRC_POS, status);
42: }
43:
44: void Thread::Sleep (uint32 milliSeconds)
45: {
46: ::usleep (milliSeconds * 1000);
47: }
48: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.