Commit Graph

24 Commits

Author SHA1 Message Date
Thomas Haller
5847e70fd6 shared: add _nm_pure/_nm_const define for __attribute__ ((pure))/((const)) 2016-05-16 13:09:02 +02:00
Thomas Haller
b871106e25 macros: define NM_MORE_ASSERTS is not defined
In NetworkManager's configure script we have --with-more-asserts
option which always defines NM_MORE_ASSERTS in config.h.

When reusing the header file outside of NetworkManager, the
NM_MORE_ASSERTS define might be unset. Define it in that case
to avoid compiler warnings about undefined preprocessor define.
2016-05-14 23:11:59 +02:00
Thomas Haller
ba90c9601c all: replace nm_unauto() by g_steal_pointer()
They do essentially the same.
2016-05-12 14:28:44 +02:00
Thomas Haller
ee29228277 shared: add define _nm_unused for __attribute__((unused))
This is both supported by clang and gcc. Using it is nicer then
casting the (void), which requires an additional line of code.
2016-05-12 09:59:09 +02:00
Thomas Haller
9a1e0b97da shared: add _nm_packed macro for __attribute__((packed)) 2016-04-11 11:26:36 +02:00
Thomas Haller
3025bfc8b2 shared: add nm_auto_unset_gvalue macro 2016-03-26 12:10:53 +01:00
Thomas Haller
2c11e23c34 shared: include <stdlib.h> in "nm-macros-internal.h"
"nm-macros-internal.h" uses free() for the "nm_auto_free"
macro. Thus, as long as that code is there, we anyway must
include <stdlib.h> along the line.

Do it in "nm-macros-internal.h" to make the header self-contained.
2016-03-24 10:10:53 +01:00
Thomas Haller
0330a55851 shared: add nm_unauto() helper macro 2016-03-17 15:00:48 +01:00
Thomas Haller
a50d28d4dd shared: add nm_assert_not_reached() 2016-03-17 15:00:48 +01:00
Thomas Haller
4a00bcf5a6 shared: add nm_g_object_ref() and nm_g_object_unref() function 2016-03-13 12:31:04 +01:00
Thomas Haller
7871d850f5 shared: add NM_G_ERROR_MSG() 2016-03-03 18:54:20 +01:00
Thomas Haller
3a81c0f301 macros: add nm_auto() macro to cleanup functions 2016-02-29 14:08:00 +01:00
Thomas Haller
4eb5ba8b02 macros: split macro NM_GOBJECT_PROPERTIES_DEFINE() in two
Sometimes we don't need the _notify() helper which results in a
unused-function warning.
2016-02-19 19:59:05 +01:00
Thomas Haller
6d5e55870a shared: fix nm_sprintf_buf() macro to allow plain string
Use non-portable gcc extension to allow for zero variadic
arguments so that you can pass a plain string as argument.
2016-02-19 01:42:29 +01:00
Thomas Haller
6dc431b0c9 shared: move definition of "bool" to nm-macros-internal.h
"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".
2016-02-16 20:18:25 +01:00
Thomas Haller
c66ee23f73 macros: add nm_auto_free macro
Similar to gs_free to cleanup pointers with free(). Note that
g_free() and free() cannot be used interchangably.
2016-02-16 14:13:25 +01:00
Thomas Haller
dec3a7e58d shared: add nm_streq() and nm_streq0() macro
Using strcmp() to test for string equality is a well known pattern.
However the inverse logic still is still hard to grasp especially in
more complex expressions.

nm_streq() should is an alternative to use strcmp(). And there is a counterpart
nm_streq0() which is based on g_strcmp0().

Kernel and systemd have also similar streq() macros.

https://mail.gnome.org/archives/networkmanager-list/2016-February/msg00047.html
2016-02-15 23:47:14 +01:00
Thomas Haller
e663b88c59 all/trivial: rename STRLEN() macro to NM_STRLEN()
We should not have defines/macros in header files without a nm/NM
prefix. STRLEN() was one of the few offenders.

https://mail.gnome.org/archives/networkmanager-list/2016-February/msg00048.html
2016-02-14 11:34:42 +01:00
Thomas Haller
dc394a6537 macros: add NM_IN_STRSET()
Add macro similar to NM_IN_SET() that checks for C strings.
NULL values are allowed and handled as one would expect.
2016-02-11 17:54:38 +01:00
Thomas Haller
1211b5b631 macros: simplify NM_IN_SET() macro
Also fix NM_IN_SET_SE() to guaranteed return 0 or 1.
2016-02-11 17:54:38 +01:00
Thomas Haller
f427909bf8 shared: add NM_GOBJECT_PROPERTIES_DEFINE()
Helper macros to define GObject property enum,
the obj_properties array, and a _notify() function.

We should move away from invoking property changed notifications by
string, as we already do for signals. This macro simplifies the
implementation of establishes a pattern for naming and usage.
2016-01-19 21:20:36 +01:00
Beniamino Galvani
f96abc8be5 core: always use gulong to store signal handler ids
We inconsistently use gulong,guint,int types to store signal handler
id, but the type returned by g_signal_connect() is a gulong.

This has no practical consequences because a int/guint is enough to
store the value, however it is better to use a consistent type, also
because nm_clear_g_signal_handler() accepts a pointer to the signal id
and thus it must be always called with the same pointer type.
2016-01-06 21:25:55 +01:00
Thomas Haller
c7d4d67d53 include: remove trailing semicolon from _Pragma() call 2015-12-24 11:42:37 +01:00
Thomas Haller
db80ec05ab build: rename directory "include" to "shared"
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".
2015-12-24 11:42:37 +01:00