diff --git a/LGPL-3 b/LGPL-3 new file mode 100644 index 0000000000000000000000000000000000000000..0a041280bd00a9d068f503b8ee7ce35214bd24a1 --- /dev/null +++ b/LGPL-3 @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..a7832c7363c405f0e0ac6657eebf1dd4b188e438 --- /dev/null +++ b/LICENSE @@ -0,0 +1,2 @@ +GNU Lesser General Public License, version 3 or any later version. +See LGPL-3 for the full text of this license. diff --git a/Makefile b/Makefile index b37b15261654f165f87267ab62461e59e42e0920..296e5b0007a97156d4cfb79b215a87136abadf94 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ debug: SMOKE_TEST_NINJA_TARGETS += iwyu -smoke-test: all check-format +smoke-test: all check-format check-license cd build && meson test --suite smoke $(NINJA) -C build $(SMOKE_TEST_NINJA_TARGETS) @@ -52,5 +52,9 @@ distclean: clean check-format: ./tools/check-format +.PHONY: check-license +check-license: + ./tools/check-license + stresstest: test ./stresstest/stresstest.sh build/tests/simplest_fib_test diff --git a/apps/Main.cpp b/apps/Main.cpp index 0d5686088072e8cf3d19eddb1f4192f5557b7c3e..85c91dfed2edda423923f0af73a18fa3dce7bde7 100644 --- a/apps/Main.cpp +++ b/apps/Main.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include <stdlib.h> // for exit, EXIT_SUCCESS #include <iostream> // for basic_ostream::operator<< diff --git a/apps/WorkerSleepExample.cpp b/apps/WorkerSleepExample.cpp index b6e2e0d31d39ff8f2e32a783ff89368d3aeadcd2..06d1ebc9a0310f4e38f354aeaab79be65b45b59a 100644 --- a/apps/WorkerSleepExample.cpp +++ b/apps/WorkerSleepExample.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include <stdlib.h> // for exit, EXIT_SUCCESS #include <chrono> // for milliseconds, operator+, hig... diff --git a/emper/Actor.hpp b/emper/Actor.hpp index e43fd9ed4020d2768d8b169c3fb326d6a035b12d..03719caa09880cfe38dd3bc27713af523caf1de2 100644 --- a/emper/Actor.hpp +++ b/emper/Actor.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include <atomic> diff --git a/emper/BinaryPrivateSemaphore.cpp b/emper/BinaryPrivateSemaphore.cpp index c20e0ea35512ed28f1c262d33028c350ae03b47c..77810cd809eba1c84eed73b6ecfd7f91f643de66 100644 --- a/emper/BinaryPrivateSemaphore.cpp +++ b/emper/BinaryPrivateSemaphore.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include "BinaryPrivateSemaphore.hpp" #include <cassert> // for assert diff --git a/emper/BinaryPrivateSemaphore.hpp b/emper/BinaryPrivateSemaphore.hpp index 7e3083353ddbb74e47d355b32cb577f4371e1aaa..379761b8fb334456350ff8b0e91b5f00eff868bd 100644 --- a/emper/BinaryPrivateSemaphore.hpp +++ b/emper/BinaryPrivateSemaphore.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include <atomic> // for atomic diff --git a/emper/Blockable.hpp b/emper/Blockable.hpp index 61935a31c68ee319aab6e3c27b3b39bda738b512..19311be8b03467b97450d6aaf1808d95944a38bd 100644 --- a/emper/Blockable.hpp +++ b/emper/Blockable.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include "Common.hpp" diff --git a/emper/Common.cpp b/emper/Common.cpp index 99cda0745f5353e6d49ceeeb2a04fc31d010c9ed..a65097be02648b329eda3b52af2e313393f7768b 100644 --- a/emper/Common.cpp +++ b/emper/Common.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include "Common.hpp" #include <cstdio> diff --git a/emper/Common.hpp b/emper/Common.hpp index 43b611fb299ac616021ae038b62986517bc40f32..2e8f778850532bd449e066558602cdefc8348055 100644 --- a/emper/Common.hpp +++ b/emper/Common.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include <functional> diff --git a/emper/Context.cpp b/emper/Context.cpp index 755a125dcc928f36393a50f5a0aa3a21bd2bc051..4071269575eee24960c160d7af5cee6823c08aff 100644 --- a/emper/Context.cpp +++ b/emper/Context.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include "Context.hpp" #include <ostream> diff --git a/emper/Context.hpp b/emper/Context.hpp index 312d60d33357cf943ac8d72725064850394fe0bc..0df18a892724b694c8f8520bd48bb35cdf512c25 100644 --- a/emper/Context.hpp +++ b/emper/Context.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include <stdint.h> // for uintptr_t diff --git a/emper/ContextManager.cpp b/emper/ContextManager.cpp index ea000a87ce55fe3a5d033c64e1ec184c2c169836..e39c00213047b7a541f50aaa5391e0331e0710f5 100644 --- a/emper/ContextManager.cpp +++ b/emper/ContextManager.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include "ContextManager.hpp" #include <assert.h> // for assert diff --git a/emper/ContextManager.hpp b/emper/ContextManager.hpp index 2037b00c4bd5c9ff226690801fb3ed2a23a3b955..8e4e28a73050e0b1720990423d897323fd41859e 100644 --- a/emper/ContextManager.hpp +++ b/emper/ContextManager.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include "Common.hpp" // for func_t diff --git a/emper/CountingPrivateSemaphore.cpp b/emper/CountingPrivateSemaphore.cpp index cae315d93572b3835597708eb66124bad06119f4..7011ac89054aa0dd036772173dfb0b4ed8470a2e 100644 --- a/emper/CountingPrivateSemaphore.cpp +++ b/emper/CountingPrivateSemaphore.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include "CountingPrivateSemaphore.hpp" #include <cassert> // for assert diff --git a/emper/CountingPrivateSemaphore.hpp b/emper/CountingPrivateSemaphore.hpp index 586275932f185c2b5715f9d7baebceb28ae4e1dd..9ed3c3ead9919d3bba172a97e4ec5500f0dfce1c 100644 --- a/emper/CountingPrivateSemaphore.hpp +++ b/emper/CountingPrivateSemaphore.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include <atomic> // for atomic_uint, atomic diff --git a/emper/Debug.cpp b/emper/Debug.cpp index e833074f3a7fec7b0a455ba1c9c2a90712f34665..4079ed80e11f73d297351e32c00a7b7b1d711f3d 100644 --- a/emper/Debug.cpp +++ b/emper/Debug.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include "Debug.hpp" #include <iostream> // for operator<<, cerr, ostream, basic_ostream diff --git a/emper/Debug.hpp b/emper/Debug.hpp index 0fed216b60ee7486ca3db0ce2bb5bea446b2f23e..2880007eb127f6ef4f0c6d72e5310ee1e57e9e47 100644 --- a/emper/Debug.hpp +++ b/emper/Debug.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include <map> // for allocator, map diff --git a/emper/Dispatcher.cpp b/emper/Dispatcher.cpp index cc98a092e3fc53856a6636a48cf962aa9745b1b9..4179b274f436e9b77c76a57fbccaa4d2e3f7b390 100644 --- a/emper/Dispatcher.cpp +++ b/emper/Dispatcher.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include "Dispatcher.hpp" #include <functional> // for _Bind_helper<>::type, bind diff --git a/emper/Dispatcher.hpp b/emper/Dispatcher.hpp index 30e6d52de3e190e71ffb4752bbd578ecc4d4f58d..d85d22853ce119c8bdf3c1da9d07e6a61065d5a9 100644 --- a/emper/Dispatcher.hpp +++ b/emper/Dispatcher.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include <assert.h> // for assert diff --git a/emper/Fiber.cpp b/emper/Fiber.cpp index caa61837c0215e9175cbf18b362b927e94ba4be2..b4b406efeabf0c39bebe02d299958829f3d7700b 100644 --- a/emper/Fiber.cpp +++ b/emper/Fiber.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include "Fiber.hpp" #include <iostream> // for operator<<, basic_ostream, ostream, basic_ostrea... diff --git a/emper/Fiber.hpp b/emper/Fiber.hpp index e3fa62c0c2eec9225643d0c2cfb5a4f53ca969e2..a679352ccb4d18083752e95c66aa986c05f82edf 100644 --- a/emper/Fiber.hpp +++ b/emper/Fiber.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include <atomic> // for atomic_uint, atomic, __atomic_base, memory... diff --git a/emper/FiberManager.cpp b/emper/FiberManager.cpp index 3979bfafa66be6fb48a96e0e60296a0bcff8b780..d13f91cf6ae67dbde126518ef1015a55fd1ab026 100644 --- a/emper/FiberManager.cpp +++ b/emper/FiberManager.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include "FiberManager.hpp" #include <cstdlib> // for abort, free, posix_memalign diff --git a/emper/FiberManager.hpp b/emper/FiberManager.hpp index d9234bd346fb2aa8a5e3c96b98d888b9f481e678..09b6be653c77609800f926b805bfe56e346db152 100644 --- a/emper/FiberManager.hpp +++ b/emper/FiberManager.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include "MemoryManager.hpp" // for MemoryManager diff --git a/emper/MemoryManager.hpp b/emper/MemoryManager.hpp index 7239886f8fe6602f5a972f723eebc28ae81c7dd4..07ee208bb30772548ca2b8a8e446c5764f21aab8 100644 --- a/emper/MemoryManager.hpp +++ b/emper/MemoryManager.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include "Common.hpp" diff --git a/emper/PrivateSemaphore.hpp b/emper/PrivateSemaphore.hpp index ae435ae65b677f5601fca13b2925ad1290c75af6..2b095cdbc078b80a49144bbc06198de780bdc5e6 100644 --- a/emper/PrivateSemaphore.hpp +++ b/emper/PrivateSemaphore.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include "Blockable.hpp" diff --git a/emper/Runtime.cpp b/emper/Runtime.cpp index 0eae91fb3666cca7ec145d60f75a36117e8de14e..830b63924cdec4d30c25cf741ce61b22707bbed7 100644 --- a/emper/Runtime.cpp +++ b/emper/Runtime.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include "Runtime.hpp" #include <errno.h> // for errno diff --git a/emper/Runtime.hpp b/emper/Runtime.hpp index e1a29071a261e45cdb07d62473a2b4d344282794..e573a9a1ffe14c57747566fa6ce089d910178d89 100644 --- a/emper/Runtime.hpp +++ b/emper/Runtime.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include <pthread.h> // for pthread_t diff --git a/emper/RuntimeStrategy.hpp b/emper/RuntimeStrategy.hpp index 76c32d48c40f855c0f00fff2b9dc64037c0143c1..77217e846d1a6f4113eebedf76123e8b218ca864 100644 --- a/emper/RuntimeStrategy.hpp +++ b/emper/RuntimeStrategy.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once class Runtime; diff --git a/emper/RuntimeStrategyStats.hpp b/emper/RuntimeStrategyStats.hpp index 27f581a9f5ce85c2ef7622eb9442bdb1cd6b3623..df1aeb7f1b394371fe0f747a24c575c1110dc19e 100644 --- a/emper/RuntimeStrategyStats.hpp +++ b/emper/RuntimeStrategyStats.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once class RuntimeStrategyStats { diff --git a/emper/Scheduler.cpp b/emper/Scheduler.cpp index 156a7a698fa163c1164e7eb8838dad291fcd8075..cda111cfea8158c7b4c4e4c2512438ee9a0e56d6 100644 --- a/emper/Scheduler.cpp +++ b/emper/Scheduler.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include "Scheduler.hpp" #include "Runtime.hpp" diff --git a/emper/Scheduler.hpp b/emper/Scheduler.hpp index 9c13b5f05d20be4cc64ee0ac620b1136121052e0..d735c771a0890c5fe757757deea450427d4d6aea 100644 --- a/emper/Scheduler.hpp +++ b/emper/Scheduler.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include <functional> // for function diff --git a/emper/Semaphore.cpp b/emper/Semaphore.cpp index 00df3cab21e7744b9b9fb52ba9b4418a212e5726..c5cea22cf9840d15e334386b0f242f334a7a1d1f 100644 --- a/emper/Semaphore.cpp +++ b/emper/Semaphore.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include "Semaphore.hpp" #include <iostream> // for operator<<, basic_ostream, basic_o... diff --git a/emper/Semaphore.hpp b/emper/Semaphore.hpp index 1f32b0e35037f306f4cf67fed0e15f47d6864c34..bfb3e018a5136faa3216ee1a910274a484ed4d91 100644 --- a/emper/Semaphore.hpp +++ b/emper/Semaphore.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include <mutex> diff --git a/emper/SynchronizedFiber.hpp b/emper/SynchronizedFiber.hpp index d666530b6850fd427f812b930cee8a7055b20d59..844d78b8ec367f4ab8348d3120d3fc25161c8df0 100644 --- a/emper/SynchronizedFiber.hpp +++ b/emper/SynchronizedFiber.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include "BinaryPrivateSemaphore.hpp" diff --git a/emper/UnboundedBlockingMpscQueue.hpp b/emper/UnboundedBlockingMpscQueue.hpp index aee0caa5355d7955d5c7e775ba79aa6d465476bc..3ffc90737c5f19a4bf3e8abbe32dfc371a7b47d0 100644 --- a/emper/UnboundedBlockingMpscQueue.hpp +++ b/emper/UnboundedBlockingMpscQueue.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include <mutex> diff --git a/emper/c_emper.cpp b/emper/c_emper.cpp index dc2bb84547d9995dabb5a80f72f260d8753c8d3f..61e7ee8049a6e5ebfc13463c054a5b9df6aae91d 100644 --- a/emper/c_emper.cpp +++ b/emper/c_emper.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include <new> // for operator new #include "BinaryPrivateSemaphore.hpp" // for BinaryPrivateSemaphore, BPS diff --git a/emper/include/emper-common.h b/emper/include/emper-common.h index f73f8cc420f3f4ed238434a1a685f3e3226fe256..38d57a445857835cdb108862bd81fe3506f64043 100644 --- a/emper/include/emper-common.h +++ b/emper/include/emper-common.h @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #ifdef __cplusplus diff --git a/emper/include/emper.h b/emper/include/emper.h index 4c5c5d5dfb8dd7026814ce9e27e3a055e52321d4..5b16f7970c30b99d23a43560927c0edd7ca6a1cb 100644 --- a/emper/include/emper.h +++ b/emper/include/emper.h @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include "emper-common.h" diff --git a/emper/include/emper.hpp b/emper/include/emper.hpp index a59e6647fc9b633f4daef8ec744d415297bb8cba..17ce953001c5f37dcbc54abc03858cb29bc9be8d 100644 --- a/emper/include/emper.hpp +++ b/emper/include/emper.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include <cassert> diff --git a/emper/lib/DebugUtil.cpp b/emper/lib/DebugUtil.cpp index 11569f56a914c03b0147830725a7d99637030b64..bcc87a864cb8929ea747f168ef6fadd1b68a87f2 100644 --- a/emper/lib/DebugUtil.cpp +++ b/emper/lib/DebugUtil.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include "DebugUtil.hpp" #include <execinfo.h> diff --git a/emper/lib/DebugUtil.hpp b/emper/lib/DebugUtil.hpp index e2ab57aa1558e1a7151e158a6025c53ba0e50085..9bfe9a80057437382a19be88a341114be556f9c1 100644 --- a/emper/lib/DebugUtil.hpp +++ b/emper/lib/DebugUtil.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once void enableStacktraceOnAborts(); diff --git a/emper/lib/adt/BoundedBumpArray.hpp b/emper/lib/adt/BoundedBumpArray.hpp index a744c92ab9d239a3bcaa672b4bd163d6fd5a56e4..7487991a3b3a766cad3cf3a455a4991e126eb52a 100644 --- a/emper/lib/adt/BoundedBumpArray.hpp +++ b/emper/lib/adt/BoundedBumpArray.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once namespace adt { diff --git a/emper/lib/adt/LockedQueue.hpp b/emper/lib/adt/LockedQueue.hpp index 267653e63d5a174df6a9d103c76c94f582bd97b3..4b10b7f204740aa66ed40f803158d16f752b0d56 100644 --- a/emper/lib/adt/LockedQueue.hpp +++ b/emper/lib/adt/LockedQueue.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include <deque> diff --git a/emper/lib/adt/LockedUnboundedQueue.hpp b/emper/lib/adt/LockedUnboundedQueue.hpp index 8c5100011a02023c5ccd41a5c8dca9d442537a42..d858333e798c772a98d4535228141175b13ae100 100644 --- a/emper/lib/adt/LockedUnboundedQueue.hpp +++ b/emper/lib/adt/LockedUnboundedQueue.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once namespace adt { diff --git a/emper/lib/adt/MpscQueue.hpp b/emper/lib/adt/MpscQueue.hpp index 536c99360af13145a7fb264c96f630d2b07bdaab..be344337a33439dbe0cdfacfd5b68e3f6e232af9 100644 --- a/emper/lib/adt/MpscQueue.hpp +++ b/emper/lib/adt/MpscQueue.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include <atomic> diff --git a/emper/lib/adt/WsClQueue.hpp b/emper/lib/adt/WsClQueue.hpp index 2d8700b0ae93679251c7a26770982c6142aeb2a5..a695055621dfbf67fe7caa497c90d803af29e366 100644 --- a/emper/lib/adt/WsClQueue.hpp +++ b/emper/lib/adt/WsClQueue.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include <atomic> diff --git a/emper/lib/adt/WsClV2Queue.hpp b/emper/lib/adt/WsClV2Queue.hpp index e080a299d033ed0bc6d76df2212ca361573533eb..6f392f8bd3e2ce081a73c1d51b1be5ccb911cea1 100644 --- a/emper/lib/adt/WsClV2Queue.hpp +++ b/emper/lib/adt/WsClV2Queue.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include <atomic> diff --git a/emper/lib/sync/Latch.hpp b/emper/lib/sync/Latch.hpp index d13ee083961fff5cc8012ef29ec060f5b899674f..bc7dd180f11ad94c922a684341254f4af4613009 100644 --- a/emper/lib/sync/Latch.hpp +++ b/emper/lib/sync/Latch.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include <atomic> diff --git a/emper/lib/sync/Semaphore.hpp b/emper/lib/sync/Semaphore.hpp index a5d43ef14ed4435e2919f17f2f4be9d5a3a66e7d..13fa714b504a1aacdc44a463c37cf3fd24722139 100644 --- a/emper/lib/sync/Semaphore.hpp +++ b/emper/lib/sync/Semaphore.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include <condition_variable> diff --git a/emper/strategies/laws/LawsDispatcher.cpp b/emper/strategies/laws/LawsDispatcher.cpp index fa6c27bfcd0db86399c18b83ef71595f273fafe1..a935e55bdd11bf6a76fc38fa3d85553c2795a3a1 100644 --- a/emper/strategies/laws/LawsDispatcher.cpp +++ b/emper/strategies/laws/LawsDispatcher.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include "LawsDispatcher.hpp" #include "LawsStrategy.hpp" // IWYU pragma: keep diff --git a/emper/strategies/laws/LawsDispatcher.hpp b/emper/strategies/laws/LawsDispatcher.hpp index 80446a12cc6d94fbc54d959d7697e3d659480f49..32b649955508c65e81f39d0604301e02dcf965a1 100644 --- a/emper/strategies/laws/LawsDispatcher.hpp +++ b/emper/strategies/laws/LawsDispatcher.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include "Dispatcher.hpp" diff --git a/emper/strategies/laws/LawsScheduler.cpp b/emper/strategies/laws/LawsScheduler.cpp index c29f36c7f6225ea407c42e4ef72e43f97731c2c9..83f270ec08d7319773f270c5849bf4d71f19dac0 100644 --- a/emper/strategies/laws/LawsScheduler.cpp +++ b/emper/strategies/laws/LawsScheduler.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include "LawsScheduler.hpp" #include "Common.hpp" diff --git a/emper/strategies/laws/LawsScheduler.hpp b/emper/strategies/laws/LawsScheduler.hpp index 07b4f3d3297ec3f38cc4b99cf90a4985eb471b79..61b95288cf80821fe260073a135e4803ce4eef64 100644 --- a/emper/strategies/laws/LawsScheduler.hpp +++ b/emper/strategies/laws/LawsScheduler.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include <stddef.h> diff --git a/emper/strategies/laws/LawsStrategy.cpp b/emper/strategies/laws/LawsStrategy.cpp index c5fc5f6424f7f775b539a392159dedda5095e117..eba0340a6701832de1bbbb770c13747ab4371fe6 100644 --- a/emper/strategies/laws/LawsStrategy.cpp +++ b/emper/strategies/laws/LawsStrategy.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include "LawsStrategy.hpp" #include "strategies/laws/LawsDispatcher.hpp" // for LawsDispatcher diff --git a/emper/strategies/laws/LawsStrategy.hpp b/emper/strategies/laws/LawsStrategy.hpp index 4d6a6b13fe585ad6aac29ffbc3c3008ea19170be..a65027a486bf5ff05da25fafc080537fe420cec3 100644 --- a/emper/strategies/laws/LawsStrategy.hpp +++ b/emper/strategies/laws/LawsStrategy.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include <atomic> diff --git a/emper/strategies/laws/LawsStrategyStats.cpp b/emper/strategies/laws/LawsStrategyStats.cpp index 5d7365483669ff22c229979ecce827050e12635f..16e42c3df980baa38faefed21cbc2bdf8db86c4b 100644 --- a/emper/strategies/laws/LawsStrategyStats.cpp +++ b/emper/strategies/laws/LawsStrategyStats.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include "LawsStrategyStats.hpp" #include <atomic> diff --git a/emper/strategies/laws/LawsStrategyStats.hpp b/emper/strategies/laws/LawsStrategyStats.hpp index d8cf7cf1dc1a7334111c991d1ee76ddb1ed0c3c4..c3231d5230ebb3b133558b7b0ec0db0ff1688386 100644 --- a/emper/strategies/laws/LawsStrategyStats.hpp +++ b/emper/strategies/laws/LawsStrategyStats.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include <cstdint> diff --git a/emper/strategies/ws/WsDispatcher.cpp b/emper/strategies/ws/WsDispatcher.cpp index 80de76fb7251d8c0ac4e69c161ca0460bd93173b..14202e7bce39766a4aec7abb1d111fbcb42cadde 100644 --- a/emper/strategies/ws/WsDispatcher.cpp +++ b/emper/strategies/ws/WsDispatcher.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include "WsDispatcher.hpp" #include "Runtime.hpp" // for Runtime diff --git a/emper/strategies/ws/WsDispatcher.hpp b/emper/strategies/ws/WsDispatcher.hpp index b754d672095b1f42d3ce7be1f33227a0c5fba8da..134925f09cd6822b7a4f4fe9e980f18f91a8d7ba 100644 --- a/emper/strategies/ws/WsDispatcher.hpp +++ b/emper/strategies/ws/WsDispatcher.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include "Dispatcher.hpp" diff --git a/emper/strategies/ws/WsScheduler.cpp b/emper/strategies/ws/WsScheduler.cpp index 2083376f8dbe318da48923ec72cf3ecffb34b2b0..73c9dacdad565797043224aa0e27dda32b25c020 100644 --- a/emper/strategies/ws/WsScheduler.cpp +++ b/emper/strategies/ws/WsScheduler.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include "WsScheduler.hpp" #include <ostream> diff --git a/emper/strategies/ws/WsScheduler.hpp b/emper/strategies/ws/WsScheduler.hpp index 3286f6da1e3ffc2ecd8d6c1e9555ebbc5e4da86e..06d4590056c919ac09662b09cf285775eb66a36c 100644 --- a/emper/strategies/ws/WsScheduler.hpp +++ b/emper/strategies/ws/WsScheduler.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include <stddef.h> // for size_t diff --git a/emper/strategies/ws/WsStrategy.cpp b/emper/strategies/ws/WsStrategy.cpp index 3162da16d5d0b911edceab41a8846fe37b587b25..54138fc27725825cc8476a03f8754de64d1bdb9f 100644 --- a/emper/strategies/ws/WsStrategy.cpp +++ b/emper/strategies/ws/WsStrategy.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include "WsStrategy.hpp" #include "WsDispatcher.hpp" diff --git a/emper/strategies/ws/WsStrategy.hpp b/emper/strategies/ws/WsStrategy.hpp index 8386b5a25c3783abf943679d9ea32ca978daf2d7..24451bc0833fc6337d89153a4940f9338af50e44 100644 --- a/emper/strategies/ws/WsStrategy.hpp +++ b/emper/strategies/ws/WsStrategy.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include <atomic> diff --git a/emper/strategies/ws/WsStrategyStats.cpp b/emper/strategies/ws/WsStrategyStats.cpp index e5a50e8893e0e48000e5bae778545e87211051ea..41cb6ae53c870d2131f7b0aae83566b3996d1017 100644 --- a/emper/strategies/ws/WsStrategyStats.cpp +++ b/emper/strategies/ws/WsStrategyStats.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include "WsStrategyStats.hpp" #include <atomic> diff --git a/emper/strategies/ws/WsStrategyStats.hpp b/emper/strategies/ws/WsStrategyStats.hpp index cb5a14ad3d5f66a97a5cd219e5ca3141008af350..ba92b37a73a89e3a06e643d3ee3290d29604e896 100644 --- a/emper/strategies/ws/WsStrategyStats.hpp +++ b/emper/strategies/ws/WsStrategyStats.hpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #include <cstdint> diff --git a/eval/SpawnALot.cpp b/eval/SpawnALot.cpp index eff5cf35be3ef4a35e35bad1ba85b0e7ef547945..4f0b0a90dc0c00661e6c67f1cfe78c574c4cee50 100644 --- a/eval/SpawnALot.cpp +++ b/eval/SpawnALot.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include <stdint.h> // for uint8_t, uint64_t #include <stdlib.h> // for EXIT_SUCCESS diff --git a/eval/TimeToSpawn.cpp b/eval/TimeToSpawn.cpp index 488c1e304b48b1fd1eea20d19de559d6e1353f3a..69792336f371efb234dd3089de165029aeda31f3 100644 --- a/eval/TimeToSpawn.cpp +++ b/eval/TimeToSpawn.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include <chrono> // for nanoseconds, duration_cast #include <iostream> // for operator<<, basic_ostream, endl #include <mutex> // for mutex diff --git a/scripts/versionManager.sh b/scripts/versionManager.sh index 73cb903cce00e9afbd3821ecea4d039e8968a84e..594b110966ffc1618649d9b53f64138afa548b12 100755 --- a/scripts/versionManager.sh +++ b/scripts/versionManager.sh @@ -73,6 +73,8 @@ checkVersionHeader() { fi cat <<EOF > "$versionHeader" +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #pragma once #define EMPER_MAJOR_VERSION ${EMPER_MAJOR_VERSION} diff --git a/tests/CppApiTest.cpp b/tests/CppApiTest.cpp index 954ad76ce784b2b9ca01f4d2697c6db6a5de1b70..71864a750bd61ab3f639c33333cfc0e3e3309dbb 100644 --- a/tests/CppApiTest.cpp +++ b/tests/CppApiTest.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include <stdlib.h> // for exit, EXIT_FAILURE, EXIT_SUC... #include <atomic> // for atomic_uint, __atomic_base diff --git a/tests/SimpleActorTest.cpp b/tests/SimpleActorTest.cpp index d00480a6919cf97a7757a9ee76bb97b3df05f290..92e5491a107a4f00f73add8ed9d6f748ce06382c 100644 --- a/tests/SimpleActorTest.cpp +++ b/tests/SimpleActorTest.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include <stdlib.h> // for exit, EXIT_FAILURE, EXIT_SUC... #include <atomic> // for atomic_thread_fence, memory_... diff --git a/tests/SimpleFibTest.cpp b/tests/SimpleFibTest.cpp index 1ac4a78687721577c26ec052ae4dce1d0ab4cafb..f97f947649133ce0aca4a3ba0d8698ad08ccbad5 100644 --- a/tests/SimpleFibTest.cpp +++ b/tests/SimpleFibTest.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include <stdlib.h> // for exit, EXIT_FAILURE, EXIT_SUC... #include "BinaryPrivateSemaphore.hpp" // for BPS diff --git a/tests/SimpleLawsTest.cpp b/tests/SimpleLawsTest.cpp index 98ad269ff46b70471a79bf3ea09422a70fbf9231..ca524c35d7e6f3d350755088d145e13c8dbf4cf4 100644 --- a/tests/SimpleLawsTest.cpp +++ b/tests/SimpleLawsTest.cpp @@ -1,8 +1,22 @@ -#include <random> - -#include "Fiber.hpp" -#include "emper.hpp" -#include "strategies/laws/LawsStrategy.hpp" +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus +#include <stdint.h> // for uint64_t, UINT64_MAX +#include <stdlib.h> // for free, exit, EXIT_FAILURE +#include <string.h> // for memset + +#include <atomic> // for atomic, __atomic_base +#include <iostream> // for operator<<, endl, basic_... +#include <new> // for operator new[] +#include <random> // for mt19937_64, random_device + +#include "Common.hpp" // for ALIGN_TO_CACHE_LINE +#include "CountingPrivateSemaphore.hpp" // for CPS +#include "Fiber.hpp" // for Fiber, Fiber::NOT_AFFINE +#include "Runtime.hpp" // for Runtime +#include "emper-common.h" // for UNUSED_ARG, workeraffini... +#include "strategies/laws/LawsStrategy.hpp" // for LawsStrategy, LawsStrate... + +class RuntimeStrategy; static const unsigned int ROUND_COUNT = 10; static const unsigned int FIBER_LOOPS = 10; diff --git a/tests/SimplestFibTest.cpp b/tests/SimplestFibTest.cpp index 3f5a5a95312adeda02058cb1cf603905f39c452d..3e5c5f4cc41ca0b6ae967a976e4d5403b08e95d7 100644 --- a/tests/SimplestFibTest.cpp +++ b/tests/SimplestFibTest.cpp @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include <cstdlib> // for abort, exit, EXIT_SUCCESS #include <iostream> // for operator<<, basic_ostream::o... diff --git a/tests/c_api_test.c b/tests/c_api_test.c index 2cfbbd92d25fe7f744dc322f0f257a52db6d1dae..a9ef015d60f693cd4c4d1bdcf1b830f8b716fb83 100644 --- a/tests/c_api_test.c +++ b/tests/c_api_test.c @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus #include <stdlib.h> #include "emper-common.h" diff --git a/tools/check-license b/tools/check-license new file mode 100755 index 0000000000000000000000000000000000000000..f77900e277629d5a192f78a9aecc57feeac42573 --- /dev/null +++ b/tools/check-license @@ -0,0 +1,117 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Pretty fancy method to get reliable the absolute path of a shell +# script, *even if it is sourced*. Credits go to GreenFox on +# stackoverflow: http://stackoverflow.com/a/12197518/194894 +pushd . > /dev/null +SCRIPTDIR="${BASH_SOURCE[0]}"; +while([ -h "${SCRIPTDIR}" ]); do + cd "`dirname "${SCRIPTDIR}"`" + SCRIPTDIR="$(readlink "`basename "${SCRIPTDIR}"`")"; +done +cd "`dirname "${SCRIPTDIR}"`" > /dev/null +SCRIPTDIR="`pwd`"; +popd > /dev/null + +echoerr() { echo "$@" 1>&2; } + +AUTOFIX=false +VERBOSE=false + +while getopts :dfv OPT; do + case $OPT in + d) + set -x + ;; + f) + AUTOFIX=true + ;; + v) + VERBOSE=true + ;; + *) + echo "usage: ${0##*/} [-d]" + exit 2 + esac +done +shift $(( OPTIND - 1 )) +OPTIND=1 + +export ROOTDIR +ROOTDIR=$(readlink -f "${SCRIPTDIR}/..") + +export CHECKED_FILES_FILE +CHECKED_FILES_FILE=$(mktemp) +export INVALID_LICENSE_FILES_FILE +INVALID_LICENSE_FILES_FILE=$(mktemp) + +function cleanup() { + rm "${CHECKED_FILES_FILE}" + rm "${INVALID_LICENSE_FILES_FILE}" +} +trap cleanup EXIT + +# Safely call bash function from xargs +# https://stackoverflow.com/questions/11003418/calling-shell-functions-with-xargs/11003457#11003457 +check_license() { + echo "${1}" >> "${CHECKED_FILES_FILE}" + + local license_identifier=".*SPDX-License-Identifier: LGPL-3.0-or-later" + local copyright_regex=".*Copyright (© )?[0-9]{4}(-[0-9]{4})?( \w)+.*" + local sed_cmd="{N; N; /^${license_identifier}\n${copyright_regex}\n.+$/!{q1}}" + + local full_path="${ROOTDIR}/${1}" + if ! head --lines=3 "${full_path}" |\ + sed --regexp-extended --quiet "${sed_cmd}" >/dev/null + then + echo "${1}" >> "${INVALID_LICENSE_FILES_FILE}" + return 1 + fi +} +export -f check_license + + +MAX_PROCS=$(nproc) + +cd "${ROOTDIR}" + +set +e +find . \( -path '*/\.*' -o -path "./build*" -o -path "./test/3rd-party*" \) -prune -o \ + -type f -regextype posix-extended -regex '.*\.(c|h|cpp|hpp)' -print0 |\ + xargs --null --max-args=1 --max-procs="${MAX_PROCS}" -I {} \ + bash -c 'check_license "$@"' _ "{}" +readonly CHECK_RETURN_VALUE="$?" +set -e + +if [[ $CHECK_RETURN_VALUE -ne 0 ]]; then + mapfile -t < "${INVALID_LICENSE_FILES_FILE}" + echoerr "The following ${#MAPFILE[@]} files have a missing or invalid license header:" + for INVALID_LICENSE_FILE in "${MAPFILE[@]}"; do + echoerr "- ${INVALID_LICENSE_FILE}" + done + + if $AUTOFIX; then + echo "Autofixing enabled, prepending default header to those files" + for INVALID_LICENSE_FILE in "${MAPFILE[@]}"; do + TMPFILE=$(mktemp) + + cat <<EOF > "${TMPFILE}" +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus +EOF + cat "${INVALID_LICENSE_FILE}" >> "${TMPFILE}" + mv "${TMPFILE}" "${INVALID_LICENSE_FILE}" + done + fi + exit "${CHECK_RETURN_VALUE}" +fi + +FILE_COUNT=$(<"${CHECKED_FILES_FILE}" wc -l) +echo "Checked ${FILE_COUNT} files for license headers" +if $VERBOSE; then + mapfile -t < "${CHECKED_FILES_FILE}" + for FILE in "${MAPFILE[@]}"; do + echo "- ${FILE}" + done +fi