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
16#include <assert.h>
17#include <signal.h>
18#include <stdint.h>
19
20//----------------------------------------------------------------------
21// All host systems must define:
22//  lldb::condition_t       The native condition type (or a substitute class) for conditions on the host system.
23//  lldb::mutex_t           The native mutex type for mutex objects on the host system.
24//  lldb::thread_t          The native thread type for spawned threads on the system
25//  lldb::thread_arg_t      The type of the one any only thread creation argument for the host system
26//  lldb::thread_result_t   The return type that gets returned when a thread finishes.
27//  lldb::thread_func_t     The function prototype used to spawn a thread on the host system.
28//  #define LLDB_INVALID_PROCESS_ID ...
29//  #define LLDB_INVALID_THREAD_ID ...
30//  #define LLDB_INVALID_HOST_THREAD ...
31//  #define IS_VALID_LLDB_HOST_THREAD ...
32//----------------------------------------------------------------------
33
34// TODO: Add a bunch of ifdefs to determine the host system and what
35// things should be defined. Currently MacOSX is being assumed by default
36// since that is what lldb was first developed for.
37
38#ifndef _MSC_VER
39#include <stdbool.h>
40#include <unistd.h>
41#endif
42
43#ifdef _WIN32
44
45#include <process.h>
46
47namespace lldb
48{
49    typedef void*               mutex_t;
50    typedef void*               condition_t;
51    typedef void*               rwlock_t;
52    typedef uintptr_t           thread_t;                   // Host thread type
53    typedef uint32_t            thread_key_t;
54    typedef void *              thread_arg_t;               // Host thread argument type
55    typedef unsigned            thread_result_t;            // Host thread result type
56    typedef thread_result_t     (*thread_func_t)(void *);   // Host thread function type
57    typedef void                (*LogOutputCallback) (const char *, void *baton);
58    typedef bool                (*CommandOverrideCallback)(void *baton, const char **argv);
59}
60
61#else
62
63#include <pthread.h>
64
65namespace lldb {
66        //----------------------------------------------------------------------
67        // MacOSX Types
68        //----------------------------------------------------------------------
69        typedef ::pthread_mutex_t   mutex_t;
70        typedef pthread_cond_t      condition_t;
71        typedef pthread_rwlock_t    rwlock_t;
72        typedef pthread_t           thread_t;                   // Host thread type
73        typedef pthread_key_t       thread_key_t;
74        typedef void *              thread_arg_t;               // Host thread argument type
75        typedef void *              thread_result_t;            // Host thread result type
76        typedef void *              (*thread_func_t)(void *);   // Host thread function type
77        typedef void                (*LogOutputCallback) (const char *, void *baton);
78        typedef bool                (*CommandOverrideCallback)(void *baton, const char **argv);
79} // namespace lldb
80
81#endif
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#define LLDB_INVALID_HOST_TIME           { 0, 0 }
87
88namespace lldb
89{
90    typedef uint64_t    addr_t;
91    typedef uint64_t    user_id_t;
92    typedef uint64_t    pid_t;
93    typedef uint64_t    tid_t;
94    typedef uint64_t    offset_t;
95    typedef int32_t     break_id_t;
96    typedef int32_t     watch_id_t;
97    typedef void *      clang_type_t;
98    typedef uint64_t    queue_id_t;
99}
100
101
102#endif  // LLDB_lldb_types_h_
103