Repository.mk | 2 + sal/Executable_alloca.mk | 31 +++++++++++++++++++++++++ sal/Executable_config.mk | 31 +++++++++++++++++++++++++ sal/Executable_macro.mk | 2 - sal/Module_sal.mk | 2 + sal/workben/alloca.cxx | 58 +++++++++++++++++++++++++++++++++++++++++++++++ sal/workben/config.cxx | 42 ++++++++++++++++++++++++++++++++++ 7 files changed, 167 insertions(+), 1 deletion(-)
New commits: commit 7f7e9b6eab571186ae791d04bc476e808d8e376f Author: Chris Sherlock <[email protected]> Date: Thu Jul 27 22:05:36 2017 +1000 sal workben: sal/config.h example Change-Id: I8ee9196a743aa9d2fe60308b9883d00e2fc21dcc diff --git a/Repository.mk b/Repository.mk index 8b6f1fb66e16..e75122c30800 100644 --- a/Repository.mk +++ b/Repository.mk @@ -79,6 +79,7 @@ $(eval $(call gb_Helper_register_executables,NONE, \ salmainargs \ macro \ alloca \ + config \ )) $(eval $(call gb_Helper_register_executables_for_install,SDK,sdk, \ diff --git a/sal/Executable_config.mk b/sal/Executable_config.mk new file mode 100644 index 000000000000..7b9b548f132f --- /dev/null +++ b/sal/Executable_config.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,config)) + +$(eval $(call gb_Executable_set_include,config,\ + $$(INCLUDE) \ + -I$(SRCDIR)/sal/inc \ +)) + +$(eval $(call gb_Library_add_defs,config,\ + -DSAL_DLLIMPLEMENTATION \ +)) + +$(eval $(call gb_Executable_use_libraries,config,\ + sal \ +)) + +$(eval $(call gb_Executable_add_exception_objects,config,\ + sal/workben/config \ +)) + +$(call gb_Executable_get_clean_target,config) : + rm -f $(WORKDIR)/LinkTarget/Executable/config +# vim: set ts=4 sw=4 et: diff --git a/sal/Module_sal.mk b/sal/Module_sal.mk index c4f968d37b75..eed06100b3a6 100644 --- a/sal/Module_sal.mk +++ b/sal/Module_sal.mk @@ -24,6 +24,7 @@ $(eval $(call gb_Module_add_targets,sal,\ Executable_salmain \ Executable_macro \ Executable_alloca \ + Executable_config \ )) $(eval $(call gb_Module_add_check_targets,sal,\ diff --git a/sal/workben/config.cxx b/sal/workben/config.cxx new file mode 100644 index 000000000000..ff8aa1f6611f --- /dev/null +++ b/sal/workben/config.cxx @@ -0,0 +1,42 @@ +/* -*- 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/config.h> +#include <sal/main.h> + +#include <cstdio> + +// _WIN32 for some reason has no SAL_DLLPREFIX +#ifndef SAL_DLLPREFIX +#define SAL_DLLPREFIX "" +#endif + +SAL_IMPLEMENT_MAIN() +{ + fprintf(stdout, "Platform specific quirks via sal/config.h.\n"); + fprintf(stdout, " Library name: %sexample%s\n", SAL_DLLPREFIX, SAL_DLLEXTENSION); + fprintf(stdout, " Executable name: example%s\n", SAL_EXEEXTENSION); + fprintf(stdout, " PATH syntax: PATH=%cpath%cto%cexecutable1%c%cpath%cto%cexecutable2\n", + SAL_PATHDELIMITER, SAL_PATHDELIMITER, SAL_PATHDELIMITER, SAL_PATHSEPARATOR, + SAL_PATHDELIMITER, SAL_PATHDELIMITER, SAL_PATHDELIMITER); + fprintf(stdout, " Config file: %s\n", SAL_CONFIGFILE("config")); + return 0; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 4d736d57195f0d236b74e829dcd8267c30142575 Author: Chris Sherlock <[email protected]> Date: Thu Jul 27 21:17:23 2017 +1000 sal workben: alloca() example Change-Id: I387b06065d9ceabfba477ac76a34fd6992c654f8 diff --git a/Repository.mk b/Repository.mk index a9a8540fddb8..8b6f1fb66e16 100644 --- a/Repository.mk +++ b/Repository.mk @@ -78,6 +78,7 @@ $(eval $(call gb_Helper_register_executables,NONE, \ salmain \ salmainargs \ macro \ + alloca \ )) $(eval $(call gb_Helper_register_executables_for_install,SDK,sdk, \ diff --git a/sal/Executable_alloca.mk b/sal/Executable_alloca.mk new file mode 100644 index 000000000000..e00b5c5bfa38 --- /dev/null +++ b/sal/Executable_alloca.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,alloca)) + +$(eval $(call gb_Executable_set_include,alloca,\ + $$(INCLUDE) \ + -I$(SRCDIR)/sal/inc \ +)) + +$(eval $(call gb_Library_add_defs,alloca,\ + -DSAL_DLLIMPLEMENTATION \ +)) + +$(eval $(call gb_Executable_use_libraries,alloca,\ + sal \ +)) + +$(eval $(call gb_Executable_add_exception_objects,alloca,\ + sal/workben/alloca \ +)) + +$(call gb_Executable_get_clean_target,alloca) : + rm -f $(WORKDIR)/LinkTarget/Executable/alloca +# vim: set ts=4 sw=4 et: diff --git a/sal/Executable_macro.mk b/sal/Executable_macro.mk index 9aebf4d145ee..cc4014d5578e 100644 --- a/sal/Executable_macro.mk +++ b/sal/Executable_macro.mk @@ -26,6 +26,6 @@ $(eval $(call gb_Executable_add_exception_objects,macro,\ sal/workben/macro \ )) -$(call gb_Executable_get_clean_target,maro) : +$(call gb_Executable_get_clean_target,macro) : rm -f $(WORKDIR)/LinkTarget/Executable/macro # vim: set ts=4 sw=4 et: diff --git a/sal/Module_sal.mk b/sal/Module_sal.mk index 2194273c7348..c4f968d37b75 100644 --- a/sal/Module_sal.mk +++ b/sal/Module_sal.mk @@ -23,6 +23,7 @@ $(eval $(call gb_Module_add_targets,sal,\ Executable_osl_process_child \ Executable_salmain \ Executable_macro \ + Executable_alloca \ )) $(eval $(call gb_Module_add_check_targets,sal,\ diff --git a/sal/workben/alloca.cxx b/sal/workben/alloca.cxx new file mode 100644 index 000000000000..9eb2567937ee --- /dev/null +++ b/sal/workben/alloca.cxx @@ -0,0 +1,58 @@ +/* -*- 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 <sal/alloca.h> + +#include <cstdio> +#include <cstring> + +// cf. https://www.gnu.org/software/libc/manual/html_node/Variable-Size-Automatic.html + +SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) +{ + fprintf(stdout, "Example to show alloca().\n"); + + int len=0; + char *name; + + if (argc > 1) + { + for (int i = 1; i < argc; i++) + len += strlen(argv[i]); + + name = (char*)alloca(len+argc+1); // argc spaces between words, with terminating nullptr + fprintf(stdout, " Just used alloca(%d)\n", len+argc+1); + + for (int i = 1; i < argc; i++) + strcat(strcat(name, argv[i]), " "); + + fprintf(stdout, " Arguments concatenated are \"%s\"\n", name); + } + else + { + fprintf(stderr, "Error, no arguments.\n"); + return 1; + } + + + return 0; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
