VirtualBox

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

Last change on this file since 7360 was 7360, checked in by vboxsync, 17 years ago

quick adaption of system-os2.cpp into mp-os2.cpp.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.8 KB
Line 
1/* $Id: mp-os2.cpp 7360 2008-03-07 13:23:19Z vboxsync $ */
2/** @file
3 * innotek Portable Runtime - Multiprocessor, OS/2.
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek GmbH
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.215389.xyz. 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 ? 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) RTMpIsCpuOnline(RTCPUID idCpu)
61{
62 RTCPUSET Set;
63 return RTCpuSetIsMember(RTMpGetOnlineSet(&Set), idCpu);
64}
65
66
67RTDECL(bool) RTMpDoesCpuExist(RTCPUID idCpu)
68{
69 RTCPUSET Set;
70 return RTCpuSetIsMember(RTMpGetSet(&Set), idCpu);
71}
72
73
74RTDECL(PRTCPUSET) RTMpGetSet(PRTCPUSET pSet)
75{
76 RTCPUID idCpu = RTMpGetCount();
77 RTCpuSetEmpty(pSet);
78 while (idCpu-- > 0)
79 RTCpuSetAdd(pSet, idCpu);
80 return pSet;
81}
82
83
84RTDECL(RTCPUID) RTMpGetCount(void)
85{
86 ULONG cCpus = 1;
87 int rc = DosQuerySysInfo(QSV_NUMPROCESSORS, QSV_NUMPROCESSORS, &cCpus, sizeof(cCpus));
88 if (rc || !cCpus)
89 cCpus = 1;
90 return cCpus;
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.

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