2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #include "hphp/util/vdso.h"
24 namespace HPHP
{ namespace Util
{
25 ///////////////////////////////////////////////////////////////////////////////
29 Vdso::Vdso() : m_handle(nullptr), m_clock_gettime_ns(nullptr) {
30 m_handle
= dlopen("linux-vdso.so.1", RTLD_LAZY
| RTLD_LOCAL
| RTLD_NOLOAD
);
36 (int64_t (*)(clockid_t
))dlsym(m_handle
, "__vdso_clock_gettime_ns");
38 (int (*)(clockid_t
, timespec
*))dlsym(m_handle
, "__vdso_clock_gettime");
47 int64_t Vdso::ClockGetTimeNS(int clk_id
) {
48 return s_vdso
.clockGetTimeNS(clk_id
);
51 int Vdso::ClockGetTime(int clk_id
, timespec
*ts
) {
52 return s_vdso
.clockGetTime(clk_id
, ts
);
55 ALWAYS_INLINE
int64_t Vdso::clockGetTimeNS(int clk_id
) {
56 if (m_clock_gettime_ns
)
57 return m_clock_gettime_ns(clk_id
);
61 ALWAYS_INLINE
int Vdso::clockGetTime(int clk_id
, timespec
*ts
) {
62 if (m_clock_gettime
) {
63 memset(ts
, 0, sizeof(*ts
));
64 return m_clock_gettime(clk_id
, ts
);
69 ///////////////////////////////////////////////////////////////////////////////