diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2017-07-29 02:19:46 +1000 |
---|---|---|
committer | Chris Sherlock <chris.sherlock79@gmail.com> | 2017-09-02 15:05:54 +1000 |
commit | a49025afa0fc136be49dd39db2f7058ed9b5c30e (patch) | |
tree | c543102e25fb24fef8484780922d89728674e918 | |
parent | e2353ec31deb0a5895d130711a2b213565f7f5c3 (diff) |
sal workben: demonstrate osl_getProcessInfo()
Change-Id: I366871e6ecc4c768891a6bc9273e84b080cf080c
-rw-r--r-- | Repository.mk | 1 | ||||
-rw-r--r-- | sal/Executable_getprocessinfo.mk | 31 | ||||
-rw-r--r-- | sal/Executable_processworkdir.mk (renamed from sal/Executable_processworkdir) | 0 | ||||
-rw-r--r-- | sal/Module_sal.mk | 1 | ||||
-rw-r--r-- | sal/workben/osl/getprocessinfo.cxx | 40 |
5 files changed, 73 insertions, 0 deletions
diff --git a/Repository.mk b/Repository.mk index e5edc951e435..5f6cd44a31b4 100644 --- a/Repository.mk +++ b/Repository.mk @@ -84,6 +84,7 @@ $(eval $(call gb_Helper_register_executables,NONE, \ alloca \ config \ processworkdir \ + getprocessinfo \ )) $(eval $(call gb_Helper_register_executables_for_install,SDK,sdk, \ diff --git a/sal/Executable_getprocessinfo.mk b/sal/Executable_getprocessinfo.mk new file mode 100644 index 000000000000..9e621b970f10 --- /dev/null +++ b/sal/Executable_getprocessinfo.mk @@ -0,0 +1,31 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Executable_Executable,getprocessinfo)) + +$(eval $(call gb_Executable_set_include,getprocessinfo,\ + $$(INCLUDE) \ + -I$(SRCDIR)/sal/inc \ +)) + +$(eval $(call gb_Library_add_defs,getprocessinfo,\ + -DSAL_DLLIMPLEMENTATION \ +)) + +$(eval $(call gb_Executable_use_libraries,getprocessinfo,\ + sal \ +)) + +$(eval $(call gb_Executable_add_exception_objects,getprocessinfo,\ + sal/workben/osl/getprocessinfo \ +)) + +$(call gb_Executable_get_clean_target,getprocessinfo) : + rm -f $(WORKDIR)/LinkTarget/Executable/getprocessinfo +# vim: set ts=4 sw=4 et: diff --git a/sal/Executable_processworkdir b/sal/Executable_processworkdir.mk index e220aa68b43f..e220aa68b43f 100644 --- a/sal/Executable_processworkdir +++ b/sal/Executable_processworkdir.mk diff --git a/sal/Module_sal.mk b/sal/Module_sal.mk index f14e41978011..6b8e261dee4d 100644 --- a/sal/Module_sal.mk +++ b/sal/Module_sal.mk @@ -26,6 +26,7 @@ $(eval $(call gb_Module_add_targets,sal,\ Executable_alloca \ Executable_config \ Executable_processworkdir \ + Executable_getprocessinfo \ )) $(eval $(call gb_Module_add_check_targets,sal,\ diff --git a/sal/workben/osl/getprocessinfo.cxx b/sal/workben/osl/getprocessinfo.cxx new file mode 100644 index 000000000000..901c66f0a2dd --- /dev/null +++ b/sal/workben/osl/getprocessinfo.cxx @@ -0,0 +1,40 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sal/main.h> +#include <osl/process.h> + +#include <cstdio> + +SAL_IMPLEMENT_MAIN() +{ + oslProcessInfo info; + info.Size = sizeof(info); + + fprintf(stdout, "Getting current process information.\n"); + + osl_getProcessInfo(nullptr, osl_Process_IDENTIFIER | osl_Process_CPUTIMES | osl_Process_HEAPUSAGE, &info); + + fprintf(stdout, " Process ID: %d\n", info.Ident); + fprintf(stdout, " Heap usage: %d%\n", info.HeapUsage); + + return 0; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |