[Lldb-commits] [lldb] 5fb4147 - [lldb][NFC] Update and re-organize lldb-types.h
Alex Langford via lldb-commits
lldb-commits at lists.llvm.org
Fri Mar 24 17:41:11 PDT 2023
Author: Alex Langford
Date: 2023-03-24T17:40:58-07:00
New Revision: 5fb4147f74ad90095f08f243e5f19877d09d11b9
URL: https://github.com/llvm/llvm-project/commit/5fb4147f74ad90095f08f243e5f19877d09d11b9
DIFF: https://github.com/llvm/llvm-project/commit/5fb4147f74ad90095f08f243e5f19877d09d11b9.diff
LOG: [lldb][NFC] Update and re-organize lldb-types.h
- Address the TODO by identifying and documenting all types needed by a
host system in order for lldb to work correctly
- Reformatted the comments to be easier to read
- Put everything inside of one namespace declaration instead of having
multiple of the same
- Move the macros up to be right under the accompanying definitions
Added:
Modified:
lldb/include/lldb/lldb-types.h
Removed:
################################################################################
diff --git a/lldb/include/lldb/lldb-types.h b/lldb/include/lldb/lldb-types.h
index 462f4275042c..890b513cd6ee 100644
--- a/lldb/include/lldb/lldb-types.h
+++ b/lldb/include/lldb/lldb-types.h
@@ -15,71 +15,65 @@
#include <cstdint>
// All host systems must define:
+// lldb::rwlock_t The type representing a read/write lock on the host
+// lldb::process_t The type representing a process on the host
// lldb::thread_t The native thread type for spawned threads on the
-// system
-// lldb::thread_arg_t The type of the one any only thread creation
-// argument for the host system
-// lldb::thread_result_t The return type that gets returned when a thread
-// finishes.
+// host
+// lldb::file_t The type representing a file on the host
+// lldb::socket_t The type representing a socket on the host
+// lldb::thread_arg_t The type of the one and only thread creation
+// argument for the host system
+// lldb::thread_result_t The type that gets returned when a thread finishes
// lldb::thread_func_t The function prototype used to spawn a thread on the
-// host system.
-// #define LLDB_INVALID_PROCESS_ID ...
-// #define LLDB_INVALID_THREAD_ID ...
-// #define LLDB_INVALID_HOST_THREAD ...
+// host system.
+// lldb::pipe_t The type representing a pipe on the host
+//
+// Additionally, lldb defines a few macros based on these definitions:
+// LLDB_INVALID_PROCESS The value of an invalid lldb::process_t
+// LLDB_INVALID_HOST_THREAD The value of an invalid lldb::thread_t
+// LLDB_INVALID_PIPE The value of an invalid lldb::pipe_t
-// TODO: Add a bunch of ifdefs to determine the host system and what
-// things should be defined. Currently MacOSX is being assumed by default since
-// that is what lldb was first developed for.
+namespace lldb {
#ifdef _WIN32
#include <process.h>
-
-namespace lldb {
typedef void *rwlock_t;
-typedef void *process_t; // Process type is HANDLE
-typedef void *thread_t; // Host thread type
-typedef void *file_t; // Host file type
-typedef unsigned int __w64 socket_t; // Host socket type
+typedef void *process_t; // Process type is HANDLE
+typedef void *thread_t; // Host thread type
+typedef void *file_t; // Host file type
+typedef unsigned int __w64 socket_t; // Host socket type
typedef void *thread_arg_t; // Host thread argument type
typedef unsigned thread_result_t; // Host thread result type
typedef thread_result_t (*thread_func_t)(void *); // Host thread function type
typedef void *pipe_t; // Host pipe type is HANDLE
-} // namespace lldb
#else
#include <pthread.h>
-
-namespace lldb {
-// MacOSX Types
typedef pthread_rwlock_t rwlock_t;
-typedef uint64_t process_t; // Process type is just a pid.
-typedef pthread_t thread_t; // Host thread type
-typedef int file_t; // Host file type
-typedef int socket_t; // Host socket type
+typedef uint64_t process_t; // Process type is just a pid.
+typedef pthread_t thread_t; // Host thread type
+typedef int file_t; // Host file type
+typedef int socket_t; // Host socket type
typedef void *thread_arg_t; // Host thread argument type
typedef void *thread_result_t; // Host thread result type
typedef void *(*thread_func_t)(void *); // Host thread function type
typedef int pipe_t; // Host pipe type
-} // namespace lldb
-#endif
+#endif // _WIN32
+
+#define LLDB_INVALID_PROCESS ((lldb::process_t)-1)
+#define LLDB_INVALID_HOST_THREAD ((lldb::thread_t)NULL)
+#define LLDB_INVALID_PIPE ((lldb::pipe_t)-1)
-namespace lldb {
typedef void (*LogOutputCallback)(const char *, void *baton);
typedef bool (*CommandOverrideCallback)(void *baton, const char **argv);
typedef bool (*CommandOverrideCallbackWithResult)(
void *baton, const char **argv, lldb_private::CommandReturnObject &result);
typedef bool (*ExpressionCancelCallback)(ExpressionEvaluationPhase phase,
void *baton);
-} // namespace lldb
-
-#define LLDB_INVALID_PROCESS ((lldb::process_t)-1)
-#define LLDB_INVALID_HOST_THREAD ((lldb::thread_t)NULL)
-#define LLDB_INVALID_PIPE ((lldb::pipe_t)-1)
-namespace lldb {
typedef uint64_t addr_t;
typedef uint64_t user_id_t;
typedef uint64_t pid_t;
@@ -90,6 +84,7 @@ typedef int32_t watch_id_t;
typedef void *opaque_compiler_type_t;
typedef uint64_t queue_id_t;
typedef uint32_t cpu_id_t; // CPU core id
+
} // namespace lldb
#endif // LLDB_LLDB_TYPES_H
More information about the lldb-commits
mailing list