blob: 258b925127d618ea4fb277fc1c361ceeb077455d [file] [log] [blame]
Dave Barach4d1a8662018-09-10 12:31:15 -04001/*
2 * Copyright (c) 2018 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef included_clib_pmc_h
17#define included_clib_pmc_h
18
19#if defined (__x86_64__)
20
21always_inline u64
22clib_rdpmc (int counter_id)
23{
24 u32 a, d;
25
26 asm volatile ("rdpmc":"=a" (a), "=d" (d):"c" (counter_id));
27 return (u64) a + ((u64) d << (u64) 32);
28}
29
30#else
31always_inline u64
32clib_rdpmc (int counter_id)
33{
34 return 0ULL;
35}
36#endif /* __aarch64__ */
37
38#endif /* included_clib_pmc_h */
39
40/*
41 * fd.io coding-style-patch-verification: ON
42 *
43 * Local Variables:
44 * eval: (c-set-style "gnu")
45 * End:
46 */