1 : /*
2 : * Copyright 2010 The Native Client Authors. All rights reserved.
3 : * Use of this source code is governed by a BSD-style license that can
4 : * be found in the LICENSE file.
5 : */
6 :
7 :
8 : // This module defines the interface for interacting with platform specific
9 : // threads. This API provides a mechanism to query for a thread, by using
10 : // the acquire method with the ID of a pre-existing thread.
11 :
12 : #ifndef NATIVE_CLIENT_PORT_THREAD_H_
13 : #define NATIVE_CLIENT_PORT_THREAD_H_ 1
14 :
15 : #include "native_client/src/include/portability.h"
16 :
17 : struct NaClAppThread;
18 : struct NaClSignalContext;
19 :
20 : namespace port {
21 :
22 20 : class IThread {
23 : public:
24 3 : virtual ~IThread() {}
25 :
26 : virtual uint32_t GetId() = 0;
27 :
28 : virtual bool SetStep(bool on) = 0;
29 :
30 : virtual bool GetRegister(uint32_t index, void *dst, uint32_t len) = 0;
31 : virtual bool SetRegister(uint32_t index, void *src, uint32_t len) = 0;
32 :
33 : virtual void CopyRegistersFromAppThread() = 0;
34 : virtual void CopyRegistersToAppThread() = 0;
35 :
36 : virtual void SuspendThread() = 0;
37 : virtual void ResumeThread() = 0;
38 : virtual bool HasThreadFaulted() = 0;
39 : virtual void UnqueueFaultedThread() = 0;
40 :
41 : virtual struct NaClSignalContext *GetContext() = 0;
42 : virtual struct NaClAppThread *GetAppThread() = 0;
43 :
44 : virtual int GetFaultSignal() = 0;
45 : virtual void SetFaultSignal(int signal) = 0;
46 :
47 : static IThread *Create(uint32_t id, struct NaClAppThread *natp);
48 : static int ExceptionToSignal(int exception_code);
49 : };
50 :
51 : } // namespace port
52 :
53 : #endif // PORT_THREAD_H_
|