1 // Copyright 2013 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef PARTITION_ALLOC_PARTITION_ALLOC_BASE_PROCESS_PROCESS_HANDLE_H_
6 #define PARTITION_ALLOC_PARTITION_ALLOC_BASE_PROCESS_PROCESS_HANDLE_H_
7 
8 #include <sys/types.h>
9 
10 #include <cstdint>
11 
12 #include "build/build_config.h"
13 #include "partition_alloc/partition_alloc_base/component_export.h"
14 
15 #if BUILDFLAG(IS_WIN)
16 #include "partition_alloc/partition_alloc_base/win/windows_types.h"
17 #endif
18 
19 #if BUILDFLAG(IS_FUCHSIA)
20 #include <zircon/types.h>
21 #endif
22 
23 namespace partition_alloc::internal::base {
24 
25 // ProcessHandle is a platform specific type which represents the underlying OS
26 // handle to a process.
27 // ProcessId is a number which identifies the process in the OS.
28 #if BUILDFLAG(IS_WIN)
29 typedef DWORD ProcessId;
30 const ProcessId kNullProcessId = 0;
31 #elif BUILDFLAG(IS_FUCHSIA)
32 typedef zx_koid_t ProcessId;
33 const ProcessId kNullProcessId = ZX_KOID_INVALID;
34 #elif BUILDFLAG(IS_POSIX)
35 // On POSIX, our ProcessHandle will just be the PID.
36 typedef pid_t ProcessId;
37 const ProcessId kNullProcessId = 0;
38 #endif  // BUILDFLAG(IS_WIN)
39 
40 // Returns the id of the current process.
41 // Note that on some platforms, this is not guaranteed to be unique across
42 // processes (use GetUniqueIdForProcess if uniqueness is required).
43 PA_COMPONENT_EXPORT(PARTITION_ALLOC_BASE) ProcessId GetCurrentProcId();
44 
45 }  // namespace partition_alloc::internal::base
46 
47 #endif  // PARTITION_ALLOC_PARTITION_ALLOC_BASE_PROCESS_PROCESS_HANDLE_H_
48