VirtualBox

source: vbox/trunk/src/VBox/Runtime/r3/os2/mp-os2.cpp@ 87007

Last change on this file since 87007 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 2.9 KB
Line 
1/* $Id: mp-os2.cpp 82968 2020-02-04 10:35:17Z vboxsync $ */
2/** @file
3 * IPRT - Multiprocessor, OS/2.
4 */
5
6/*
7 * Copyright (C) 2006-2020 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27
28/*********************************************************************************************************************************
29* Header Files *
30*********************************************************************************************************************************/
31#define INCL_BASE
32#define INCL_ERRORS
33#include <os2.h>
34#undef RT_MAX
35
36#include <iprt/mp.h>
37#include <iprt/cpuset.h>
38#include <iprt/assert.h>
39
40/** @todo RTMpCpuId() */
41
42RTDECL(int) RTMpCpuIdToSetIndex(RTCPUID idCpu)
43{
44 return idCpu < RTCPUSET_MAX_CPUS ? (int) idCpu : -1;
45}
46
47
48RTDECL(RTCPUID) RTMpCpuIdFromSetIndex(int iCpu)
49{
50 return (unsigned)iCpu < RTCPUSET_MAX_CPUS ? iCpu : NIL_RTCPUID;
51}
52
53
54RTDECL(RTCPUID) RTMpGetMaxCpuId(void)
55{
56 return RTCPUSET_MAX_CPUS;
57}
58
59
60RTDECL(bool) RTMpIsCpuPossible(RTCPUID idCpu)
61{
62 RTCPUSET Set;
63 return RTCpuSetIsMember(RTMpGetSet(&Set), idCpu);
64}
65
66
67RTDECL(PRTCPUSET) RTMpGetSet(PRTCPUSET pSet)
68{
69 RTCPUID idCpu = RTMpGetCount();
70 RTCpuSetEmpty(pSet);
71 while (idCpu-- > 0)
72 RTCpuSetAdd(pSet, idCpu);
73 return pSet;
74}
75
76
77RTDECL(RTCPUID) RTMpGetCount(void)
78{
79 ULONG cCpus = 1;
80 int rc = DosQuerySysInfo(QSV_NUMPROCESSORS, QSV_NUMPROCESSORS, &cCpus, sizeof(cCpus));
81 if (rc || !cCpus)
82 cCpus = 1;
83 return cCpus;
84}
85
86
87RTDECL(bool) RTMpIsCpuOnline(RTCPUID idCpu)
88{
89 RTCPUSET Set;
90 return RTCpuSetIsMember(RTMpGetOnlineSet(&Set), idCpu);
91}
92
93
94RTDECL(PRTCPUSET) RTMpGetOnlineSet(PRTCPUSET pSet)
95{
96 union
97 {
98 uint64_t u64;
99 MPAFFINITY mpaff;
100 } u;
101
102 int rc = DosQueryThreadAffinity(AFNTY_SYSTEM, &u.mpaff);
103 if (rc)
104 u.u64 = 1;
105 return RTCpuSetFromU64(pSet, u.u64);
106}
107
108
109RTDECL(RTCPUID) RTMpGetOnlineCount(void)
110{
111 RTCPUSET Set;
112 RTMpGetOnlineSet(&Set);
113 return RTCpuSetCount(&Set);
114}
115
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette