summaryrefslogtreecommitdiff
path: root/shared/nm-default.h
Commit message (Collapse)AuthorAgeFilesLines
* logging: make nm-logging.c independent of other core componentsth/move-to-sharedThomas Haller2018-10-171-0/+1
| | | | | "nm-logging.c" now no longer depends on anything particularly special from NM core.
* Fix typosRafael Fontenelle2018-09-301-1/+1
| | | | | | | https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/21 [thaller@redhat.com: fix generated clients/common/settings-docs.h.in file and fix wrong change in src/systemd/src/libsystemd/sd-event/sd-event.c]
* build: create "config-extra.h" header instead of passing directory variables ↵Thomas Haller2018-07-171-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | via CFLAGS 1) the command line gets shorter. I frequently run `make V=1` to see the command line arguments for the compiler, and there is a lot of noise. 2) define each of these variables at one place. This makes it easy to verify that for all compilation units, a particular define has the same value. Previously that was not obvious or even not the case (see commit e5d1a71396e107d1909744d26ad401f206c0c915 and commit d63cf1ef2faba57595112a82e962b9643cce4718). The point is to avoid redundancy. 3) not all compilation units need all defines. In fact, most modules would only need a few of these defines. We aimed to pass the necessary minium of defines to each compilation unit, but that was non-obvious to get right and often we set a define that wasn't used. See for example "src_settings_plugins_ibft_cppflags" which needlessly had "-DSYSCONFDIR". This question is now entirely avoided by just defining all variables in a header. We don't care to find the minimum, because every component gets anyway all defines from the header. 4) this also avoids the situation, where a module that previously did not use a particular define gets modified to require it. Previously, that would have required to identify the missing define, and add it to the CFLAGS of the complation unit. Since every compilation now includes "config-extra.h", all defines are available everywhere. 5) the fact that each define is now available in all compilation units could be perceived as a downside. But it isn't, because these defines should have a unique name and one specific value. Defining the same name with different values, or refer to the same value by different names is a bug, not a desirable feature. Since these defines should be unique accross the entire tree, there is no problem in providing them to every compilation unit. 6) the reason why we generate "config-extra.h" this way, instead of using AC_DEFINE() in configure.ac, is due to the particular handling of autoconf for directory variables. See [1]. With meson, it would be trivial to put them into "config.h.meson". While that is not easy with autoconf, the "config-extra.h" workaround seems still preferable to me. [1] https://www.gnu.org/software/autoconf/manual/autoconf-2.63/html_node/Installation-Directory-Variables.html
* shared: don't validate type-string in G_VARIANT_TYPE() cast macro in ↵Thomas Haller2018-03-121-0/+29
| | | | production code
* version: drop NM_VERSION_MAX_ALLOWED defines for internal buildThomas Haller2018-01-231-1/+0
| | | | | | It already defaults to the right value. We only need to define NM_VERSION_MIN_REQUIRED, so that parts of our internal build can make use of deprecated API.
* version: combine NM_VERSION_CUR_STABLE and NM_VERSION_NEXT_STABLEThomas Haller2018-01-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We don't need to have two version defines "CUR" and "NEXT". The main purpose of these macros (if not their only), is to make NM_AVAILABLE_IN_* and NM_DEPRECATED_IN_* macros work. 1) At the precise commit of a release, "CUR" and "NEXT" must be identical, because whenever the user configures NM_VERSION_MIN_REQUIRED and NM_VERSION_MAX_ALLOWED, then they both compare against the current version, at which point "CUR" == "NEXT". 2) Every other commit aside the release, is a development version that leads up the the next coming release. But as far as versioning is concerned, such a development version should be treated like that future release. It's unstable API and it may or may not be close to later API of the release. But we shall treat it as that version. Hence, also in this case, we want to set both "NM_VERSION_CUR_STABLE" and again NEXT to the future version. This makes NM_VERSION_NEXT_STABLE redundant. Previously, the separation between current and next version would for example allow that NM_VERSION_CUR_STABLE is the previously release stable API, and NM_VERSION_NEXT_STABLE is the version of the next upcoming stable API. So, we could allow "examples" to make use of development API, but other(?) internal code still restrict to unstable API. But it's unclear which other code would want to avoid current development. Also, the points 1) and 2) were badly understood. Note that for our previousy releases, we usually didn't bump the macros at the stable release (and if we did, we didn't set them to be the same). While using two macros might be more powerful, it is hard to grok and easy to forget to bump the macros a the right time. One macro shall suffice. All this also means, that *immediately* after making a new release, we shall bump the version number in `configure.ac` and "NM_VERSION_CUR_STABLE".
* build: refine the NETWORKMANAGER_COMPILATION defineThomas Haller2018-01-081-29/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | | Note that: - we compile some source files multiple times. Most notably those under "shared/". - we include a default header "shared/nm-default.h" in every source file. This header is supposed to setup a common environment by defining and including parts that are commonly used. As we always include the same header, the header must behave differently depending one whether the compilation is for libnm-core, NetworkManager or libnm-glib. E.g. it must include <glib/gi18n.h> or <glib/gi18n-lib.h> depending on whether we compile a library or an application. For that, the source files need the NETWORKMANAGER_COMPILATION #define to behave accordingly. Extend the define to be composed of flags. These flags are all named NM_NETWORKMANAGER_COMPILATION_WITH_*, they indicate which part of the build are available. E.g. when building libnm-core.la itself, then WITH_LIBNM_CORE, WITH_LIBNM_CORE_INTERNAL, and WITH_LIBNM_CORE_PRIVATE are available. When building NetworkManager, WITH_LIBNM_CORE_PRIVATE is not available but the internal parts are still accessible. When building nmcli, only WITH_LIBNM_CORE (the public part) is available. This granularily controls the build.
* all: include "nm-utils/nm-hash-utils.h" by defaultThomas Haller2017-11-161-0/+4
| | | | | | | | | Next we will use siphash24() instead of the glib version g_direct_hash() or g_str_hash(). Hence, the "nm-utils/nm-hash-utils.h" header becomes very fundamental and will be needed basically everywhere. Instead of requiring the users to include them, let it be included via "nm-default.h" header.
* build: disable type checks in G_TYPE_CHECK_INSTANCE_CAST() macros (bgo#771120)Thomas Haller2016-09-121-4/+57
| | | | | | | Avoid the pointless overhead. Even glib disables them unless you build with --enable-debug. https://bugzilla.gnome.org/show_bug.cgi?id=771120
* build: cleanup src/Makefile.amThomas Haller2016-08-111-1/+2
| | | | | | | | | | | | | - reorder entries in src/Makefile.am so that general names are all at the beginning (AM_CPPFLAGS, sbin_PROGRAMS) and the names for a certain library/binary are grouped together - have libNetworkManager.la reuse libNetworkManagerBase.la. - let all components in src/Makefile.am use the same AM_CPPFLAGS, except libsystem-nm.la. - move callouts/nm-dispatcher-api.h to shared/ directory. It is obviously not internal API to callouts, and callouts is not a library. Thus, the right place is shared/.
* shared: drop function name from g_return_val_if_reached()Thomas Haller2016-07-051-0/+24
| | | | | | When using g_return_val_if_reached(), the default macro would include the function name. This name is increasing the binary size. Replace it in non-debug builds.
* shared: include "nm-glib.h" from "nm-macros-internal.h"Thomas Haller2016-06-161-2/+1
| | | | | "nm-glib.h" is our most basic header. "nm-macros-internal.h" extends on that. Thus, let "nm-macros-internal.h" include "nm-glib.h".
* shared: include "gsystem-local-alloc.h" from "nm-glib.h"Thomas Haller2016-06-161-1/+0
| | | | | | | | | "nm-glib.h" is the most basic header, the one we cannot do without. ("nm-default.h", is already more generic, the one which every common source file in NetworkManager repository should include). Let "gsystem-local-alloc.h" be included by "nm-glib.h" and nowhere else.
* shared: move shared files to subdirectory "shared/nm-utils/"Thomas Haller2016-06-161-4/+4
| | | | | | | | | | | | | The "shared" directory contains files that are possibly used by all components of NetworkManager repository. Some of these files are even copied as-is to other projects (VPN plugins, nm-applet) and used there without modification. Move those files to a separate directory. By moving them to a common directory, it is clearer that they belong together. Also, you can easier compare the copied versions to their original via $ diff -r ./shared/nm-utils/ /path/to/nm-vpn-plugin/shared/nm-utils/
* build: remove assertion messages in non-debug buildThomas Haller2016-06-091-0/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | Assertions like g_assert*() and g_return_*() contain the stringified test expression. This string ends up in the binary and increases its size. We usually don't have failing assertions. These string are a waste, instead the file and line number shall suffice. It reduces the striped size of the NetworkManager binary from 2500k to 2392k, that is -108k, -4.3%. This changes - "g_assert (1 == 2);" from: NetworkManager:ERROR:source.c:347:some_function: assertion failed: (1 == 2) to: NetworkManager:ERROR:source.c:347:<unknown-fcn>: assertion failed: (<dropped>) - "g_return_if_fail (1 == 2);" from: (process:21024): NetworkManager-CRITICAL **: some_function: assertion '1 == 2' failed to: (process:21024): NetworkManager-CRITICAL **: ((source.c:347)): assertion '<dropped>' failed When doing a non-debug build, those string are now removed. Debug-builds can be enabled by setting --with-more-assert=$LEVEL to larger then zero. https://bugzilla.gnome.org/show_bug.cgi?id=767296
* build: disable deprecation checks for internal compilationThomas Haller2016-04-051-0/+6
| | | | | | | | | | | | For internal compilation we want to be able to use deprecated API without warnings. Define the version min/max macros to effectively disable deprecation warnings. However, don't do it via CFLAGS option in the makefiles, instead hack it to "nm-default.h". After all, *every* source file that is for internal compilation needs to include this header as first.
* shared: include "nm-shared-utils.h"Thomas Haller2016-03-261-0/+1
| | | | Include it via "nm-default.h" to all projects.
* all: cleanup includes and let "nm-default.h" include "config.h"Thomas Haller2016-02-191-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | - All internal source files (except "examples", which are not internal) should include "config.h" first. As also all internal source files should include "nm-default.h", let "config.h" be included by "nm-default.h" and include "nm-default.h" as first in every source file. We already wanted to include "nm-default.h" before other headers because it might contains some fixes (like "nm-glib.h" compatibility) that is required first. - After including "nm-default.h", we optinally allow for including the corresponding header file for the source file at hand. The idea is to ensure that each header file is self contained. - Don't include "config.h" or "nm-default.h" in any header file (except "nm-sd-adapt.h"). Public headers anyway must not include these headers, and internal headers are never included after "nm-default.h", as of the first previous point. - Include all internal headers with quotes instead of angle brackets. In practice it doesn't matter, because in our public headers we must include other headers with angle brackets. As we use our public headers also to compile our interal source files, effectively the result must be the same. Still do it for consistency. - Except for <config.h> itself. Include it with angle brackets as suggested by https://www.gnu.org/software/autoconf/manual/autoconf.html#Configuration-Headers
* shared: move definition of "bool" to nm-macros-internal.hThomas Haller2016-02-161-47/+0
| | | | | | | | "nm-default.h" should only include all the relevant header files based on NETWORKMANAGER_COMPILATION. It should not contain definitions on it's own. Move the definition of "bool" to "nm-macros-internal.h".
* macros: add nm_auto_free macroThomas Haller2016-02-161-0/+2
| | | | | Similar to gs_free to cleanup pointers with free(). Note that g_free() and free() cannot be used interchangably.
* build: cleanup default includesThomas Haller2016-02-121-0/+1
| | | | | | | | | | | | | | | | | | | - "gsystem-local-alloc.h" and <gio/gio.h> are already included via "nm-default.h". No need to include them separately. - include "nm-macros-internal.h" via "nm-default.h" and drop all explict includes. - in the modified files, ensure that we always include "config.h" and "nm-default.h" first. As second, include the header file for the current source file (if applicable). Then follow external includes and finally internal nm includes. - include nm headers inside source code files with quotes - internal header files don't need to include default headers. They can savely assume that "nm-default.h" is already included and with it glib, nm-glib.h, nm-macros-internal.h, etc.
* build: rename directory "include" to "shared"Thomas Haller2015-12-241-0/+121
Up to now, the "include" directory contained (only) header files that were used project-wide by libs, core, clients, et al. Since the directory now also contains a non-header file, the "include" name is misleading. Instead of adding yet another directory that is project-wide, with non-header-only content, rename the "include" directory to "shared".