lldb-types.h revision 9a3c2a58db644dc93915f938cb4c99558e41966c
1//===-- lldb-types.h --------------------------------------------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef LLDB_lldb_types_h_
11#define LLDB_lldb_types_h_
12
13#include "lldb/lldb-enumerations.h"
14#include "lldb/lldb-forward.h"
15#include "lldb/Utility/SharingPtr.h"
16
17#include <assert.h>
18#include <pthread.h>
19#include <signal.h>
20#include <stdint.h>
21#include <stdbool.h>
22#include <unistd.h>
23
24//----------------------------------------------------------------------
25// All host systems must define:
26//  liblldb::condition_t       The native condition type (or a substitute class) for conditions on the host system.
27//  liblldb::mutex_t           The native mutex type for mutex objects on the host system.
28//  liblldb::thread_t          The native thread type for spawned threads on the system
29//  liblldb::thread_arg_t      The type of the one any only thread creation argument for the host system
30//  liblldb::thread_result_t   The return type that gets returned when a thread finishes.
31//  liblldb::thread_func_t     The function prototype used to spawn a thread on the host system.
32//  liblldb::SharedPtr         The template that wraps up the host version of a reference counted pointer (like boost::shared_ptr)
33//  #define LLDB_INVALID_PROCESS_ID ...
34//  #define LLDB_INVALID_THREAD_ID ...
35//  #define LLDB_INVALID_HOST_THREAD ...
36//  #define IS_VALID_LLDB_HOST_THREAD ...
37//----------------------------------------------------------------------
38
39// TODO: Add a bunch of ifdefs to determine the host system and what
40// things should be defined. Currently MacOSX is being assumed by default
41// since that is what lldb was first developed for.
42
43namespace lldb {
44        //----------------------------------------------------------------------
45        // MacOSX Types
46        //----------------------------------------------------------------------
47        typedef ::pthread_mutex_t   mutex_t;
48        typedef pthread_cond_t      condition_t;
49        typedef pthread_t           thread_t;                   // Host thread type
50        typedef void *              thread_arg_t;               // Host thread argument type
51        typedef void *              thread_result_t;            // Host thread result type
52        typedef void *              (*thread_func_t)(void *);   // Host thread function type
53
54        // The template below can be used in a few useful ways:
55        //
56        //      // Make a single shared pointer a class Foo
57        //      lldb::SharePtr<Foo>::Type foo_sp;
58        //
59        //      // Make a typedef to a Foo shared pointer
60        //      typedef lldb::SharePtr<Foo>::Type FooSP;
61        //
62        template<typename _Tp>
63        struct SharedPtr
64        {
65            typedef lldb_private::SharingPtr<_Tp> Type;
66        };
67        template<typename _Tp>
68        struct LoggingSharedPtr
69        {
70            typedef lldb_private::LoggingSharingPtr<_Tp> Type;
71        };
72
73} // namespace lldb
74
75#if defined(__MINGW32__)
76
77const lldb::thread_t lldb_invalid_host_thread_const = { NULL, 0 } ;
78#define LLDB_INVALID_HOST_THREAD         (lldb_invalid_host_thread_const)
79#define IS_VALID_LLDB_HOST_THREAD(t)     (!(NULL == (t).p && 0 == (t).x))
80
81#else
82
83#define LLDB_INVALID_HOST_THREAD         ((lldb::thread_t)NULL)
84#define IS_VALID_LLDB_HOST_THREAD(t)     ((t) != LLDB_INVALID_HOST_THREAD)
85
86#endif
87
88#define LLDB_INVALID_HOST_TIME           { 0, 0 }
89
90namespace lldb
91{
92    typedef uint64_t    addr_t;
93    typedef uint32_t    user_id_t;
94    typedef int32_t     pid_t;
95    typedef uint32_t    tid_t;
96    typedef int32_t     break_id_t;
97    typedef int32_t     watch_id_t;
98    typedef void *      clang_type_t;
99}
100
101
102#endif  // LLDB_lldb_types_h_
103