Repository.mk | 2 + sal/Executable_getprocessinfo.mk | 31 ++++++++++++++++++++++++ sal/Executable_processworkdir.mk | 31 ++++++++++++++++++++++++ sal/Module_sal.mk | 2 + sal/workben/osl/getprocessinfo.cxx | 40 +++++++++++++++++++++++++++++++ sal/workben/osl/processworkdir.cxx | 47 +++++++++++++++++++++++++++++++++++++ 6 files changed, 153 insertions(+)
New commits: commit d20d2a8a582885b29a14b43b1fcfa225576760e3 Author: Chris Sherlock <chris.sherloc...@gmail.com> Date: Sat Jul 29 02:19:46 2017 +1000 sal workben: demonstrate osl_getProcessInfo() Change-Id: I366871e6ecc4c768891a6bc9273e84b080cf080c diff --git a/Repository.mk b/Repository.mk index a51d3812be32..453fc95c8066 100644 --- a/Repository.mk +++ b/Repository.mk @@ -81,6 +81,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 similarity index 100% rename from sal/Executable_processworkdir rename to 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: */ commit 7b7b7eeb6ac154237821358fe29ef2bb4558751a Author: Chris Sherlock <chris.sherloc...@gmail.com> Date: Sat Jul 29 01:50:38 2017 +1000 sal workben: demonstrate osl_getProcessWorkingDir() Change-Id: I61798ca229bc1078ae075ff119c472d616e995c5 diff --git a/Repository.mk b/Repository.mk index e75122c30800..a51d3812be32 100644 --- a/Repository.mk +++ b/Repository.mk @@ -80,6 +80,7 @@ $(eval $(call gb_Helper_register_executables,NONE, \ macro \ alloca \ config \ + processworkdir \ )) $(eval $(call gb_Helper_register_executables_for_install,SDK,sdk, \ diff --git a/sal/Executable_processworkdir b/sal/Executable_processworkdir new file mode 100644 index 000000000000..e220aa68b43f --- /dev/null +++ b/sal/Executable_processworkdir @@ -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,processworkdir)) + +$(eval $(call gb_Executable_set_include,processworkdir,\ + $$(INCLUDE) \ + -I$(SRCDIR)/sal/inc \ +)) + +$(eval $(call gb_Library_add_defs,processworkdir,\ + -DSAL_DLLIMPLEMENTATION \ +)) + +$(eval $(call gb_Executable_use_libraries,processworkdir,\ + sal \ +)) + +$(eval $(call gb_Executable_add_exception_objects,processworkdir,\ + sal/workben/osl/processworkdir \ +)) + +$(call gb_Executable_get_clean_target,processworkdir) : + rm -f $(WORKDIR)/LinkTarget/Executable/processworkdir +# vim: set ts=4 sw=4 et: diff --git a/sal/Module_sal.mk b/sal/Module_sal.mk index eed06100b3a6..f14e41978011 100644 --- a/sal/Module_sal.mk +++ b/sal/Module_sal.mk @@ -25,6 +25,7 @@ $(eval $(call gb_Module_add_targets,sal,\ Executable_macro \ Executable_alloca \ Executable_config \ + Executable_processworkdir \ )) $(eval $(call gb_Module_add_check_targets,sal,\ diff --git a/sal/workben/osl/processworkdir.cxx b/sal/workben/osl/processworkdir.cxx new file mode 100644 index 000000000000..9a4de8c2ccab --- /dev/null +++ b/sal/workben/osl/processworkdir.cxx @@ -0,0 +1,47 @@ +/* -*- 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 <rtl/string.h> +#include <rtl/ustring.h> +#include <osl/thread.h> + +#include <osl/process.h> + +#include <cstdio> + +SAL_IMPLEMENT_MAIN() +{ + rtl_uString *pustrWorkDir = nullptr; + rtl_String *pstrWorkDir = nullptr; + + osl_getProcessWorkingDir(&pustrWorkDir); + rtl_uString2String(&pstrWorkDir, + rtl_uString_getStr(pustrWorkDir), + rtl_uString_getLength(pustrWorkDir), + osl_getThreadTextEncoding(), + OUSTRING_TO_OSTRING_CVTFLAGS); + sal_Char* pszWorkDir = rtl_string_getStr(pstrWorkDir); + + fprintf(stdout, "Process current working directory: %s\n", pszWorkDir); + + return 0; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits