• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 BASE_ALLOCATOR_PARTITION_ALLOCATOR_SRC_PARTITION_ALLOC_PARTITION_ALLOC_BASE_PROCESS_PROCESS_HANDLE_H_
6 #define BASE_ALLOCATOR_PARTITION_ALLOCATOR_SRC_PARTITION_ALLOC_PARTITION_ALLOC_BASE_PROCESS_PROCESS_HANDLE_H_
7 
8 #include <stdint.h>
9 #include <sys/types.h>
10 
11 #include "build/build_config.h"
12 #include "partition_alloc/partition_alloc_base/component_export.h"
13 
14 #if BUILDFLAG(IS_WIN)
15 #include "partition_alloc/partition_alloc_base/win/windows_types.h"
16 #endif
17 
18 #if BUILDFLAG(IS_FUCHSIA)
19 #include <zircon/types.h>
20 #endif
21 
22 namespace partition_alloc::internal::base {
23 
24 // ProcessHandle is a platform specific type which represents the underlying OS
25 // handle to a process.
26 // ProcessId is a number which identifies the process in the OS.
27 #if BUILDFLAG(IS_WIN)
28 typedef DWORD ProcessId;
29 const ProcessId kNullProcessId = 0;
30 #elif BUILDFLAG(IS_FUCHSIA)
31 typedef zx_koid_t ProcessId;
32 const ProcessId kNullProcessId = ZX_KOID_INVALID;
33 #elif BUILDFLAG(IS_POSIX)
34 // On POSIX, our ProcessHandle will just be the PID.
35 typedef pid_t ProcessId;
36 const ProcessId kNullProcessId = 0;
37 #endif  // BUILDFLAG(IS_WIN)
38 
39 // Returns the id of the current process.
40 // Note that on some platforms, this is not guaranteed to be unique across
41 // processes (use GetUniqueIdForProcess if uniqueness is required).
42 PA_COMPONENT_EXPORT(PARTITION_ALLOC_BASE) ProcessId GetCurrentProcId();
43 
44 }  // namespace partition_alloc::internal::base
45 
46 #endif  // BASE_ALLOCATOR_PARTITION_ALLOCATOR_SRC_PARTITION_ALLOC_PARTITION_ALLOC_BASE_PROCESS_PROCESS_HANDLE_H_
47