chiark / gitweb /
build: basic autoconfization
authorLennart Poettering <lennart@poettering.net>
Wed, 3 Feb 2010 13:21:48 +0000 (14:21 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 3 Feb 2010 13:21:48 +0000 (14:21 +0100)
19 files changed:
.gitignore
Makefile [deleted file]
Makefile.am [new file with mode: 0644]
bootstrap.sh [new file with mode: 0755]
configure.ac [new file with mode: 0644]
dbus-job.c
dbus-manager.c
execute.c
job.h
load-fragment.c
logger.c
m4/attributes.m4 [new file with mode: 0644]
ratelimit.h
service.c
service.h
socket-util.c
timer.h
unit.c
util.c

index 9c5193d27ef88b481db4ca12bee1d9ea2116f295..a1956d5d72c98ee67b53815af7dbc8541204c33e 100644 (file)
@@ -8,3 +8,20 @@ systemctl.c
 systemd-interfaces.c
 systemadm
 systemadm.c
+.deps/
+Makefile.in
+aclocal.m4
+*.cache
+compile
+config.guess
+config.h
+config.h.in
+config.log
+config.status
+config.sub
+configure
+depcomp
+install-sh
+missing
+stamp-*
+*.stamp
diff --git a/Makefile b/Makefile
deleted file mode 100644 (file)
index 41df4e2..0000000
--- a/Makefile
+++ /dev/null
@@ -1,53 +0,0 @@
-CFLAGS=-Wall -Wextra -O0 -g -pipe -D_GNU_SOURCE -fdiagnostics-show-option -Wno-unused-parameter -DUNIT_PATH=\"/tmp/does/not/exist\" `pkg-config --cflags libudev dbus-1`
-LIBS=-lrt -lcap `pkg-config --libs libudev dbus-1`
-
-COMMON= \
-       unit.o \
-       util.o \
-       set.o \
-       hashmap.o \
-       strv.o \
-       job.o \
-       manager.o \
-       conf-parser.o \
-       load-fragment.o \
-       socket-util.o \
-       log.o \
-       service.o \
-       automount.o \
-       mount.o \
-       device.o \
-       target.o \
-       snapshot.o \
-       socket.o \
-       timer.o \
-       load-dropin.o \
-       execute.o \
-       ratelimit.o \
-       dbus.o \
-       dbus-manager.o \
-       dbus-unit.o \
-       dbus-job.o
-
-all: systemd test-engine test-job-type systemd-logger systemctl systemadm
-
-systemd: main.o $(COMMON)
-       $(CC) $(CFLAGS) -o $@ $^  $(LIBS)
-
-systemd-logger: logger.o $(COMMON)
-       $(CC) $(CFLAGS) -o $@ $^  $(LIBS)
-
-test-engine: test-engine.o $(COMMON)
-       $(CC) $(CFLAGS) -o $@ $^  $(LIBS)
-
-test-job-type: test-job-type.o $(COMMON)
-       $(CC) $(CFLAGS) -o $@ $^  $(LIBS)
-
-systemctl: systemctl.vala
-       valac -g --save-temps systemctl.vala systemd-interfaces.vala --pkg=dbus-glib-1 --pkg=posix
-
-systemadm: systemadm.vala
-       valac -g --save-temps systemadm.vala systemd-interfaces.vala --pkg=dbus-glib-1 --pkg=posix --pkg gee-1.0 --pkg gtk+-2.0
-
-clean:
-       rm -f *.o systemd test-engine systemctl systemadm
diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..8ac2c2d
--- /dev/null
@@ -0,0 +1,112 @@
+#  This file is part of systemd.
+#
+#  Copyright 2010 Lennart Poettering
+#
+#  systemd is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  systemd is distributed in the hope that it will be useful, but
+#  WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+#  General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+
+ACLOCAL_AMFLAGS = -I m4
+
+AM_CPPFLAGS = \
+        -include $(top_builddir)/config.h \
+       -DUNIT_PATH=\"/tmp/does/not/exist\"
+
+sbin_PROGRAMS = \
+       systemd
+
+bin_PROGRAMS = \
+       systemctl \
+       systemadm \
+       systemd-logger
+
+noinst_PROGRAMS = \
+       test-engine \
+       test-job-type
+
+BASIC_SOURCES= \
+        util.c \
+        hashmap.c \
+        set.c \
+        strv.c \
+        conf-parser.c \
+        socket-util.c \
+        log.c \
+        ratelimit.c
+
+COMMON_SOURCES= \
+       $(BASIC_SOURCES) \
+       unit.c \
+        job.c \
+        manager.c \
+        load-fragment.c \
+        service.c \
+        automount.c \
+        mount.c \
+        device.c \
+        target.c \
+        snapshot.c \
+        socket.c \
+        timer.c \
+        load-dropin.c \
+        execute.c \
+        dbus.c \
+        dbus-manager.c \
+        dbus-unit.c \
+        dbus-job.c
+
+systemd_SOURCES = \
+       $(COMMON_SOURCES) \
+       main.c
+
+systemd_CPPFLAGS = \
+       $(AM_CPPFLAGS) \
+       $(DBUS_CFLAGS) \
+       $(UDEV_CFLAGS)
+
+systemd_LDADD = \
+       $(DBUS_LIBS) \
+       $(UDEV_LIBS)
+
+test_engine_SOURCES = \
+       $(COMMON_SOURCES) \
+       test-engine.c
+
+test_engine_CPPFLAGS = $(systemd_CPPFLAGS)
+test_engine_LDADD = $(systemd_LDADD)
+
+test_job_type_SOURCES = \
+       $(COMMON_SOURCES) \
+       test-engine.c
+
+test_job_type_CPPFLAGS = $(systemd_CPPFLAGS)
+test_job_type_LDADD = $(systemd_LDADD)
+
+systemd_logger_SOURCES = \
+       $(BASIC_SOURCES) \
+       logger.c
+
+VALAFLAGS = -g --save-temps --pkg=dbus-glib-1 --pkg=posix --pkg gee-1.0 --pkg gtk+-2.0
+
+systemctl_SOURCES = \
+       systemctl.vala \
+       systemd-interfaces.vala
+
+systemctl_CPPFLAGS = $(AM_CPPFLAGS) $(DBUSGLIB_CFLAGS)
+systemctl_LDADD = $(DBUSGLIB_LIBS)
+
+systemadm_SOURCES = \
+       systemadm.vala \
+       systemd-interfaces.vala
+
+systemadm_CPPFLAGS = $(AM_CPPFLAGS) $(DBUSGLIB_CFLAGS) $(GTK_CFLAGS)
+systemadm_LDADD = $(DBUSGLIB_LIBS) $(GTK_LIBS)
diff --git a/bootstrap.sh b/bootstrap.sh
new file mode 100755 (executable)
index 0000000..73243ed
--- /dev/null
@@ -0,0 +1,80 @@
+#!/bin/bash
+
+#  This file is part of systemd.
+#
+#  Copyright 2010 Lennart Poettering
+#
+#  systemd is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  systemd is distributed in the hope that it will be useful, but
+#  WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+#  General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+
+AM_VERSION=1.11
+AC_VERSION=2.63
+
+run_versioned() {
+    local P
+    local V
+
+    V=$(echo "$2" | sed -e 's,\.,,g')
+
+    if [ -e "`which $1$V 2> /dev/null`" ] ; then
+        P="$1$V"
+    else
+        if [ -e "`which $1-$2 2> /dev/null`" ] ; then
+            P="$1-$2"
+        else
+            P="$1"
+        fi
+    fi
+
+    shift 2
+    "$P" "$@"
+}
+
+set -ex
+
+if [ -f .git/hooks/pre-commit.sample -a ! -f .git/hooks/pre-commit ] ; then
+    cp -p .git/hooks/pre-commit.sample .git/hooks/pre-commit && \
+    chmod +x .git/hooks/pre-commit && \
+    echo "Activated pre-commit hook."
+fi
+
+# We check for this here, because if pkg-config is not found in the
+# system, it's likely that the pkg.m4 macro file is also not present,
+# which will make PKG_PROG_PKG_CONFIG be undefined and the generated
+# configure file faulty.
+if ! pkg-config --version &>/dev/null; then
+    echo "pkg-config is required to bootstrap this program" &>/dev/null
+    exit 1
+fi
+
+if type -p colorgcc > /dev/null ; then
+   export CC=colorgcc
+fi
+
+if [ "x$1" = "xam" ] ; then
+    run_versioned automake "$VERSION" -a -c --foreign
+    ./config.status
+else
+    rm -rf autom4te.cache
+    rm -f config.cache
+
+    run_versioned aclocal "$AM_VERSION" -I m4
+    run_versioned autoconf "$AC_VERSION" -Wall
+    run_versioned autoheader "$AC_VERSION"
+    run_versioned automake "$AM_VERSION" --copy --foreign --add-missing
+
+    if [ "x$1" != "xac" ]; then
+        CFLAGS="$CFLAGS -g -O0" ./configure --sysconfdir=/etc --localstatedir=/var "$@"
+        make clean
+    fi
+fi
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..95a9ef5
--- /dev/null
@@ -0,0 +1,75 @@
+#  This file is part of systemd.
+#
+#  Copyright 2010 Lennart Poettering
+#
+#  systemd is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  systemd is distributed in the hope that it will be useful, but
+#  WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+#  General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+
+AC_PREREQ(2.63)
+
+AC_INIT([systemd],[0],[mzflfgrzq (at) 0pointer (dot) net])
+AC_CONFIG_SRCDIR([main.c])
+AC_CONFIG_MACRO_DIR([m4])
+AC_CONFIG_HEADERS([config.h])
+
+AM_INIT_AUTOMAKE([foreign 1.11 -Wall -Wno-portability silent-rules tar-pax])
+
+AC_SUBST(PACKAGE_URL, [http://git.0pointer.de/?p=systemd.git])
+
+AC_CANONICAL_HOST
+
+AM_SILENT_RULES([yes])
+
+AC_CHECK_PROG([STOW], [stow], [yes], [no])
+
+AS_IF([test "x$STOW" = "xyes" && test -d /usr/local/stow], [
+        AC_MSG_NOTICE([*** Found /usr/local/stow: default install prefix set to /usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION} ***])
+        ac_default_prefix="/usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION}"
+])
+
+AC_PROG_CC
+AC_PROG_CC_C99
+AM_PROG_CC_C_O
+AC_PROG_GCC_TRADITIONAL
+AC_USE_SYSTEM_EXTENSIONS
+
+CC_CHECK_CFLAGS_APPEND([-Wall -W -Wextra -pipe -Wno-long-long -Winline -Wvla -Wno-overlength-strings -Wunsafe-loop-optimizations -Wundef -Wformat=2 -Wlogical-op -Wsign-compare -Wformat-security -Wmissing-include-dirs -Wformat-nonliteral -Wold-style-definition -Wpointer-arith -Winit-self -Wdeclaration-after-statement -Wfloat-equal -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-declarations -Wmissing-noreturn -Wshadow -Wendif-labels -Wcast-align -Wstrict-aliasing=2 -Wwrite-strings -Wno-unused-parameter -ffast-math -Wp,-D_FORTIFY_SOURCE=2 -fno-common -fdiagnostics-show-option -Wno-missing-field-initializers])
+
+AC_SEARCH_LIBS([clock_gettime], [rt], [], [AC_MSG_ERROR([*** POSIX RT library not found])])
+AC_SEARCH_LIBS([cap_init], [cap], [], [AC_MSG_ERROR([*** POSIX caps library not found])])
+AC_CHECK_HEADERS([sys/capability.h], [], [AC_MSG_ERROR([*** POSIX caps headers not found])])
+
+PKG_CHECK_MODULES(UDEV, [ libudev ])
+AC_SUBST(UDEV_CFLAGS)
+AC_SUBST(UDEV_LIBS)
+
+PKG_CHECK_MODULES(DBUS, [ dbus-1 ])
+AC_SUBST(DBUS_CFLAGS)
+AC_SUBST(DBUS_LIBS)
+
+PKG_CHECK_MODULES(DBUSGLIB, [ dbus-glib-1 ])
+AC_SUBST(DBUSGLIB_CFLAGS)
+AC_SUBST(DBUSGLIB_LIBS)
+
+PKG_CHECK_MODULES(GEE, [ gee-1.0 ])
+AC_SUBST(GEE_CFLAGS)
+AC_SUBST(GEE_LIBS)
+
+PKG_CHECK_MODULES(GTK, [ gtk+-2.0 ])
+AC_SUBST(GTK_CFLAGS)
+AC_SUBST(GTK_LIBS)
+
+AM_PROG_VALAC()
+AC_SUBST(VAPIDIR)
+
+AC_OUTPUT([Makefile])
index 70dbfd88eb95cf1d74521129b5838851a68a892c..544868fc7619981c09fcd54f37ac2aac6ee70893 100644 (file)
@@ -142,7 +142,7 @@ oom:
         return DBUS_HANDLER_RESULT_NEED_MEMORY;
 }
 
-DBusHandlerResult bus_job_message_handler(DBusConnection  *connection, DBusMessage  *message, void *data) {
+static DBusHandlerResult bus_job_message_handler(DBusConnection  *connection, DBusMessage  *message, void *data) {
         Manager *m = data;
         Job *j;
         int r;
index 03a39300df53a6ff9d2268e880f39231c4302376..bdc82df070aeaff9c8ea205134d2c0378e528107 100644 (file)
@@ -54,7 +54,7 @@
 #define INTROSPECTION_END                                               \
         "</node>"
 
-DBusHandlerResult bus_manager_message_handler(DBusConnection  *connection, DBusMessage *message, void *data) {
+static DBusHandlerResult bus_manager_message_handler(DBusConnection  *connection, DBusMessage *message, void *data) {
         int r;
         Manager *m = data;
         DBusError error;
@@ -172,7 +172,7 @@ DBusHandlerResult bus_manager_message_handler(DBusConnection  *connection, DBusM
                         goto oom;
 
                 HASHMAP_FOREACH_KEY(u, k, m->units, i) {
-                        char *unit_path, *job_path;
+                        char *u_path, *j_path;
                         const char *id, *description, *load_state, *active_state, *job_type;
                         DBusMessageIter sub2;
                         uint32_t job_id;
@@ -188,21 +188,21 @@ DBusHandlerResult bus_manager_message_handler(DBusConnection  *connection, DBusM
                         load_state = unit_load_state_to_string(u->meta.load_state);
                         active_state = unit_active_state_to_string(unit_active_state(u));
 
-                        if (!(unit_path = unit_dbus_path(u)))
+                        if (!(u_path = unit_dbus_path(u)))
                                 goto oom;
 
                         if (u->meta.job) {
                                 job_id = (uint32_t) u->meta.job->id;
 
-                                if (!(job_path = job_dbus_path(u->meta.job))) {
-                                        free(unit_path);
+                                if (!(j_path = job_dbus_path(u->meta.job))) {
+                                        free(u_path);
                                         goto oom;
                                 }
 
                                 job_type = job_type_to_string(u->meta.job->type);
                         } else {
                                 job_id = 0;
-                                job_path = unit_path;
+                                j_path = u_path;
                                 job_type = "";
                         }
 
@@ -210,19 +210,19 @@ DBusHandlerResult bus_manager_message_handler(DBusConnection  *connection, DBusM
                             !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &description) ||
                             !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &load_state) ||
                             !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &active_state) ||
-                            !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_OBJECT_PATH, &unit_path) ||
+                            !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_OBJECT_PATH, &u_path) ||
                             !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_UINT32, &job_id) ||
                             !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &job_type) ||
-                            !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_OBJECT_PATH, &job_path)) {
-                                free(unit_path);
+                            !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_OBJECT_PATH, &j_path)) {
+                                free(u_path);
                                 if (u->meta.job)
-                                        free(job_path);
+                                        free(j_path);
                                 goto oom;
                         }
 
-                        free(unit_path);
+                        free(u_path);
                         if (u->meta.job)
-                                free(job_path);
+                                free(j_path);
 
                         if (!dbus_message_iter_close_container(&sub, &sub2))
                                 goto oom;
@@ -245,7 +245,7 @@ DBusHandlerResult bus_manager_message_handler(DBusConnection  *connection, DBusM
                         goto oom;
 
                 HASHMAP_FOREACH(j, m->jobs, i) {
-                        char *unit_path, *job_path;
+                        char *u_path, *j_path;
                         const char *unit, *state, *type;
                         uint32_t id;
                         DBusMessageIter sub2;
@@ -258,11 +258,11 @@ DBusHandlerResult bus_manager_message_handler(DBusConnection  *connection, DBusM
                         state = job_state_to_string(j->state);
                         type = job_type_to_string(j->type);
 
-                        if (!(job_path = job_dbus_path(j)))
+                        if (!(j_path = job_dbus_path(j)))
                                 goto oom;
 
-                        if (!(unit_path = unit_dbus_path(j->unit))) {
-                                free(job_path);
+                        if (!(u_path = unit_dbus_path(j->unit))) {
+                                free(j_path);
                                 goto oom;
                         }
 
@@ -270,15 +270,15 @@ DBusHandlerResult bus_manager_message_handler(DBusConnection  *connection, DBusM
                             !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &unit) ||
                             !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &type) ||
                             !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &state) ||
-                            !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_OBJECT_PATH, &job_path) ||
-                            !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_OBJECT_PATH, &unit_path)) {
-                                free(job_path);
-                                free(unit_path);
+                            !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_OBJECT_PATH, &j_path) ||
+                            !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_OBJECT_PATH, &u_path)) {
+                                free(j_path);
+                                free(u_path);
                                 goto oom;
                         }
 
-                        free(job_path);
-                        free(unit_path);
+                        free(j_path);
+                        free(u_path);
 
                         if (!dbus_message_iter_close_container(&sub, &sub2))
                                 goto oom;
index 94866ebfa3ccebf4b98c6d6fbe708bca6da60eb1..7bdf1b13b8ec789d259dfdf4caebbd760b5e7ce6 100644 (file)
--- a/execute.c
+++ b/execute.c
@@ -269,7 +269,7 @@ static int setup_output(const ExecContext *context, const char *ident) {
         }
 }
 
-int setup_input(const ExecContext *context) {
+static int setup_input(const ExecContext *context) {
         int r;
 
         assert(context);
diff --git a/job.h b/job.h
index 28ed07dbe4ce363dd7c823b56f421d4a86e35e66..554f9fc9860ed44649ad40d0ac4171bcf7791a31 100644 (file)
--- a/job.h
+++ b/job.h
@@ -124,6 +124,8 @@ bool job_type_is_mergeable(JobType a, JobType b);
 bool job_type_is_superset(JobType a, JobType b);
 bool job_type_is_conflicting(JobType a, JobType b);
 
+bool job_is_runnable(Job *j);
+
 void job_schedule_run(Job *j);
 int job_run_and_invalidate(Job *j);
 int job_finish_and_invalidate(Job *j, bool success);
index 3f1e578f3e23cfef6c1be42d62143a6547fee7e8..10972e43cd534f46a88d20cc8ad47f670b20aeef 100644 (file)
@@ -472,7 +472,7 @@ static int config_parse_service_restart(
         return 0;
 }
 
-int config_parse_bindtodevice(
+static int config_parse_bindtodevice(
                 const char *filename,
                 unsigned line,
                 const char *section,
@@ -501,7 +501,7 @@ int config_parse_bindtodevice(
         return 0;
 }
 
-int config_parse_output(
+static int config_parse_output(
                 const char *filename,
                 unsigned line,
                 const char *section,
@@ -527,7 +527,7 @@ int config_parse_output(
         return 0;
 }
 
-int config_parse_input(
+static int config_parse_input(
                 const char *filename,
                 unsigned line,
                 const char *section,
@@ -553,7 +553,7 @@ int config_parse_input(
         return 0;
 }
 
-int config_parse_facility(
+static int config_parse_facility(
                 const char *filename,
                 unsigned line,
                 const char *section,
@@ -583,7 +583,7 @@ int config_parse_facility(
         return 0;
 }
 
-int config_parse_level(
+static int config_parse_level(
                 const char *filename,
                 unsigned line,
                 const char *section,
@@ -612,7 +612,7 @@ int config_parse_level(
         return 0;
 }
 
-int config_parse_io_class(
+static int config_parse_io_class(
                 const char *filename,
                 unsigned line,
                 const char *section,
@@ -643,7 +643,7 @@ int config_parse_io_class(
         return 0;
 }
 
-int config_parse_io_priority(
+static int config_parse_io_priority(
                 const char *filename,
                 unsigned line,
                 const char *section,
@@ -671,7 +671,7 @@ int config_parse_io_priority(
         return 0;
 }
 
-int config_parse_cpu_sched_policy(
+static int config_parse_cpu_sched_policy(
                 const char *filename,
                 unsigned line,
                 const char *section,
@@ -703,7 +703,7 @@ int config_parse_cpu_sched_policy(
         return 0;
 }
 
-int config_parse_cpu_sched_prio(
+static int config_parse_cpu_sched_prio(
                 const char *filename,
                 unsigned line,
                 const char *section,
@@ -732,7 +732,7 @@ int config_parse_cpu_sched_prio(
         return 0;
 }
 
-int config_parse_cpu_affinity(
+static int config_parse_cpu_affinity(
                 const char *filename,
                 unsigned line,
                 const char *section,
@@ -775,7 +775,7 @@ int config_parse_cpu_affinity(
         return 0;
 }
 
-int config_parse_capabilities(
+static int config_parse_capabilities(
                 const char *filename,
                 unsigned line,
                 const char *section,
@@ -807,7 +807,7 @@ int config_parse_capabilities(
         return 0;
 }
 
-int config_parse_secure_bits(
+static int config_parse_secure_bits(
                 const char *filename,
                 unsigned line,
                 const char *section,
@@ -848,7 +848,7 @@ int config_parse_secure_bits(
         return 0;
 }
 
-int config_parse_bounding_set(
+static int config_parse_bounding_set(
                 const char *filename,
                 unsigned line,
                 const char *section,
index 311458bd2660b4c3776b40f699eca3958f955530..af3293bd7e1812f6b46464e736bd5a8f5deb6b11 100644 (file)
--- a/logger.c
+++ b/logger.c
@@ -155,7 +155,7 @@ static int stream_log(Stream *s, char *p, usec_t timestamp) {
                 IOVEC_SET_STRING(iovec[1], s->process);
                 IOVEC_SET_STRING(iovec[2], header_pid);
                 IOVEC_SET_STRING(iovec[3], p);
-                IOVEC_SET_STRING(iovec[4], "\n");
+                IOVEC_SET_STRING(iovec[4], (char*) "\n");
 
                 if (writev(s->server->kmsg_fd, iovec, ELEMENTSOF(iovec)) < 0)
                         return -errno;
@@ -548,9 +548,9 @@ int main(int argc, char *argv[]) {
 
         for (;;) {
                 struct epoll_event event;
-                int n;
+                int k;
 
-                if ((n = epoll_wait(server.epoll_fd,
+                if ((k = epoll_wait(server.epoll_fd,
                                     &event, 1,
                                     server.n_streams <= 0 ? TIMEOUT : -1)) < 0) {
 
@@ -561,7 +561,7 @@ int main(int argc, char *argv[]) {
                         goto fail;
                 }
 
-                if (n <= 0)
+                if (k <= 0)
                         break;
 
                 if ((r = process_event(&server, &event)) < 0)
diff --git a/m4/attributes.m4 b/m4/attributes.m4
new file mode 100644 (file)
index 0000000..3bf96a3
--- /dev/null
@@ -0,0 +1,311 @@
+dnl Macros to check the presence of generic (non-typed) symbols.
+dnl Copyright (c) 2006-2008 Diego Pettenò <flameeyes@gmail.com>
+dnl Copyright (c) 2006-2008 xine project
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2, or (at your option)
+dnl any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+dnl 02110-1301, USA.
+dnl
+dnl As a special exception, the copyright owners of the
+dnl macro gives unlimited permission to copy, distribute and modify the
+dnl configure scripts that are the output of Autoconf when processing the
+dnl Macro. You need not follow the terms of the GNU General Public
+dnl License when using or distributing such scripts, even though portions
+dnl of the text of the Macro appear in them. The GNU General Public
+dnl License (GPL) does govern all other use of the material that
+dnl constitutes the Autoconf Macro.
+dnl
+dnl This special exception to the GPL applies to versions of the
+dnl Autoconf Macro released by this project. When you make and
+dnl distribute a modified version of the Autoconf Macro, you may extend
+dnl this special exception to the GPL to apply to your modified version as
+dnl well.
+
+dnl Check if the flag is supported by compiler
+dnl CC_CHECK_CFLAGS_SILENT([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
+
+AC_DEFUN([CC_CHECK_CFLAGS_SILENT], [
+  AC_CACHE_VAL(AS_TR_SH([cc_cv_cflags_$1]),
+    [ac_save_CFLAGS="$CFLAGS"
+     CFLAGS="$CFLAGS $1"
+     AC_COMPILE_IFELSE([int a;],
+       [eval "AS_TR_SH([cc_cv_cflags_$1])='yes'"],
+       [eval "AS_TR_SH([cc_cv_cflags_$1])='no'"])
+     CFLAGS="$ac_save_CFLAGS"
+    ])
+
+  AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes],
+    [$2], [$3])
+])
+
+dnl Check if the flag is supported by compiler (cacheable)
+dnl CC_CHECK_CFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
+
+AC_DEFUN([CC_CHECK_CFLAGS], [
+  AC_CACHE_CHECK([if $CC supports $1 flag],
+    AS_TR_SH([cc_cv_cflags_$1]),
+    CC_CHECK_CFLAGS_SILENT([$1]) dnl Don't execute actions here!
+  )
+
+  AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes],
+    [$2], [$3])
+])
+
+dnl CC_CHECK_CFLAG_APPEND(FLAG, [action-if-found], [action-if-not-found])
+dnl Check for CFLAG and appends them to CFLAGS if supported
+AC_DEFUN([CC_CHECK_CFLAG_APPEND], [
+  AC_CACHE_CHECK([if $CC supports $1 flag],
+    AS_TR_SH([cc_cv_cflags_$1]),
+    CC_CHECK_CFLAGS_SILENT([$1]) dnl Don't execute actions here!
+  )
+
+  AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes],
+    [CFLAGS="$CFLAGS $1"; DEBUG_CFLAGS="$DEBUG_CFLAGS $1"; $2], [$3])
+])
+
+dnl CC_CHECK_CFLAGS_APPEND([FLAG1 FLAG2], [action-if-found], [action-if-not])
+AC_DEFUN([CC_CHECK_CFLAGS_APPEND], [
+  for flag in $1; do
+    CC_CHECK_CFLAG_APPEND($flag, [$2], [$3])
+  done
+])
+
+dnl Check if the flag is supported by linker (cacheable)
+dnl CC_CHECK_LDFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
+
+AC_DEFUN([CC_CHECK_LDFLAGS], [
+  AC_CACHE_CHECK([if $CC supports $1 flag],
+    AS_TR_SH([cc_cv_ldflags_$1]),
+    [ac_save_LDFLAGS="$LDFLAGS"
+     LDFLAGS="$LDFLAGS $1"
+     AC_LINK_IFELSE([int main() { return 1; }],
+       [eval "AS_TR_SH([cc_cv_ldflags_$1])='yes'"],
+       [eval "AS_TR_SH([cc_cv_ldflags_$1])="])
+     LDFLAGS="$ac_save_LDFLAGS"
+    ])
+
+  AS_IF([eval test x$]AS_TR_SH([cc_cv_ldflags_$1])[ = xyes],
+    [$2], [$3])
+])
+
+dnl define the LDFLAGS_NOUNDEFINED variable with the correct value for
+dnl the current linker to avoid undefined references in a shared object.
+AC_DEFUN([CC_NOUNDEFINED], [
+  dnl We check $host for which systems to enable this for.
+  AC_REQUIRE([AC_CANONICAL_HOST])
+
+  case $host in
+     dnl FreeBSD (et al.) does not complete linking for shared objects when pthreads
+     dnl are requested, as different implementations are present; to avoid problems
+     dnl use -Wl,-z,defs only for those platform not behaving this way.
+     *-freebsd* | *-openbsd*) ;;
+     *)
+        dnl First of all check for the --no-undefined variant of GNU ld. This allows
+        dnl for a much more readable commandline, so that people can understand what
+        dnl it does without going to look for what the heck -z defs does.
+        for possible_flags in "-Wl,--no-undefined" "-Wl,-z,defs"; do
+          CC_CHECK_LDFLAGS([$possible_flags], [LDFLAGS_NOUNDEFINED="$possible_flags"])
+         break
+        done
+       ;;
+  esac
+
+  AC_SUBST([LDFLAGS_NOUNDEFINED])
+])
+
+dnl Check for a -Werror flag or equivalent. -Werror is the GCC
+dnl and ICC flag that tells the compiler to treat all the warnings
+dnl as fatal. We usually need this option to make sure that some
+dnl constructs (like attributes) are not simply ignored.
+dnl
+dnl Other compilers don't support -Werror per se, but they support
+dnl an equivalent flag:
+dnl  - Sun Studio compiler supports -errwarn=%all
+AC_DEFUN([CC_CHECK_WERROR], [
+  AC_CACHE_CHECK(
+    [for $CC way to treat warnings as errors],
+    [cc_cv_werror],
+    [CC_CHECK_CFLAGS_SILENT([-Werror], [cc_cv_werror=-Werror],
+      [CC_CHECK_CFLAGS_SILENT([-errwarn=%all], [cc_cv_werror=-errwarn=%all])])
+    ])
+])
+
+AC_DEFUN([CC_CHECK_ATTRIBUTE], [
+  AC_REQUIRE([CC_CHECK_WERROR])
+  AC_CACHE_CHECK([if $CC supports __attribute__(( ifelse([$2], , [$1], [$2]) ))],
+    AS_TR_SH([cc_cv_attribute_$1]),
+    [ac_save_CFLAGS="$CFLAGS"
+     CFLAGS="$CFLAGS $cc_cv_werror"
+     AC_COMPILE_IFELSE([$3],
+       [eval "AS_TR_SH([cc_cv_attribute_$1])='yes'"],
+       [eval "AS_TR_SH([cc_cv_attribute_$1])='no'"])
+     CFLAGS="$ac_save_CFLAGS"
+    ])
+
+  AS_IF([eval test x$]AS_TR_SH([cc_cv_attribute_$1])[ = xyes],
+    [AC_DEFINE(
+       AS_TR_CPP([SUPPORT_ATTRIBUTE_$1]), 1,
+         [Define this if the compiler supports __attribute__(( ifelse([$2], , [$1], [$2]) ))]
+         )
+     $4],
+    [$5])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_CONSTRUCTOR], [
+  CC_CHECK_ATTRIBUTE(
+    [constructor],,
+    [void __attribute__((constructor)) ctor() { int a; }],
+    [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_FORMAT], [
+  CC_CHECK_ATTRIBUTE(
+    [format], [format(printf, n, n)],
+    [void __attribute__((format(printf, 1, 2))) printflike(const char *fmt, ...) { fmt = (void *)0; }],
+    [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_FORMAT_ARG], [
+  CC_CHECK_ATTRIBUTE(
+    [format_arg], [format_arg(printf)],
+    [char *__attribute__((format_arg(1))) gettextlike(const char *fmt) { fmt = (void *)0; }],
+    [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_VISIBILITY], [
+  CC_CHECK_ATTRIBUTE(
+    [visibility_$1], [visibility("$1")],
+    [void __attribute__((visibility("$1"))) $1_function() { }],
+    [$2], [$3])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_NONNULL], [
+  CC_CHECK_ATTRIBUTE(
+    [nonnull], [nonnull()],
+    [void __attribute__((nonnull())) some_function(void *foo, void *bar) { foo = (void*)0; bar = (void*)0; }],
+    [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_UNUSED], [
+  CC_CHECK_ATTRIBUTE(
+    [unused], ,
+    [void some_function(void *foo, __attribute__((unused)) void *bar);],
+    [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_SENTINEL], [
+  CC_CHECK_ATTRIBUTE(
+    [sentinel], ,
+    [void some_function(void *foo, ...) __attribute__((sentinel));],
+    [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_DEPRECATED], [
+  CC_CHECK_ATTRIBUTE(
+    [deprecated], ,
+    [void some_function(void *foo, ...) __attribute__((deprecated));],
+    [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_ALIAS], [
+  CC_CHECK_ATTRIBUTE(
+    [alias], [weak, alias],
+    [void other_function(void *foo) { }
+     void some_function(void *foo) __attribute__((weak, alias("other_function")));],
+    [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_MALLOC], [
+  CC_CHECK_ATTRIBUTE(
+    [malloc], ,
+    [void * __attribute__((malloc)) my_alloc(int n);],
+    [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_PACKED], [
+  CC_CHECK_ATTRIBUTE(
+    [packed], ,
+    [struct astructure { char a; int b; long c; void *d; } __attribute__((packed));],
+    [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_CONST], [
+  CC_CHECK_ATTRIBUTE(
+    [const], ,
+    [int __attribute__((const)) twopow(int n) { return 1 << n; } ],
+    [$1], [$2])
+])
+
+AC_DEFUN([CC_FLAG_VISIBILITY], [
+  AC_REQUIRE([CC_CHECK_WERROR])
+  AC_CACHE_CHECK([if $CC supports -fvisibility=hidden],
+    [cc_cv_flag_visibility],
+    [cc_flag_visibility_save_CFLAGS="$CFLAGS"
+     CFLAGS="$CFLAGS $cc_cv_werror"
+     CC_CHECK_CFLAGS_SILENT([-fvisibility=hidden],
+       cc_cv_flag_visibility='yes',
+       cc_cv_flag_visibility='no')
+     CFLAGS="$cc_flag_visibility_save_CFLAGS"])
+
+  AS_IF([test "x$cc_cv_flag_visibility" = "xyes"],
+    [AC_DEFINE([SUPPORT_FLAG_VISIBILITY], 1,
+       [Define this if the compiler supports the -fvisibility flag])
+     $1],
+    [$2])
+])
+
+AC_DEFUN([CC_FUNC_EXPECT], [
+  AC_REQUIRE([CC_CHECK_WERROR])
+  AC_CACHE_CHECK([if compiler has __builtin_expect function],
+    [cc_cv_func_expect],
+    [ac_save_CFLAGS="$CFLAGS"
+     CFLAGS="$CFLAGS $cc_cv_werror"
+     AC_COMPILE_IFELSE(
+       [int some_function() {
+        int a = 3;
+        return (int)__builtin_expect(a, 3);
+       }],
+       [cc_cv_func_expect=yes],
+       [cc_cv_func_expect=no])
+     CFLAGS="$ac_save_CFLAGS"
+    ])
+
+  AS_IF([test "x$cc_cv_func_expect" = "xyes"],
+    [AC_DEFINE([SUPPORT__BUILTIN_EXPECT], 1,
+     [Define this if the compiler supports __builtin_expect() function])
+     $1],
+    [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_ALIGNED], [
+  AC_REQUIRE([CC_CHECK_WERROR])
+  AC_CACHE_CHECK([highest __attribute__ ((aligned ())) supported],
+    [cc_cv_attribute_aligned],
+    [ac_save_CFLAGS="$CFLAGS"
+     CFLAGS="$CFLAGS $cc_cv_werror"
+     for cc_attribute_align_try in 64 32 16 8 4 2; do
+        AC_COMPILE_IFELSE([
+          int main() {
+            static char c __attribute__ ((aligned($cc_attribute_align_try))) = 0;
+            return c;
+          }], [cc_cv_attribute_aligned=$cc_attribute_align_try; break])
+     done
+     CFLAGS="$ac_save_CFLAGS"
+  ])
+
+  if test "x$cc_cv_attribute_aligned" != "x"; then
+     AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX], [$cc_cv_attribute_aligned],
+       [Define the highest alignment supported])
+  fi
+])
index 963b3675bc857fa43457991ab4860b782cd254fb..f61a10a91d4cd0e2e497f78513f3f8d912de235f 100644 (file)
@@ -31,23 +31,23 @@ typedef struct RateLimit {
         usec_t begin;
 } RateLimit;
 
-#define RATELIMIT_DEFINE(_name, _interval, _burst)      \
-        RateLimit _name = {                             \
-                .interval = (_interval),                \
-                .burst = (_burst),                      \
-                .n_printed = 0,                         \
-                .n_missed = 0,                          \
-                .begin = 0                              \
+#define RATELIMIT_DEFINE(_name, _interval, _burst)       \
+        RateLimit _name = {                              \
+                .interval = (_interval),                 \
+                .burst = (_burst),                       \
+                .n_printed = 0,                          \
+                .n_missed = 0,                           \
+                .begin = 0                               \
         }
 
-#define RATELIMIT_INIT(v, _interval, _burst)            \
-        do {                                            \
-                RateLimit *r = &(v);                    \
-                r->interval = (_interval);              \
-                r->burst = (_burst);                    \
-                r->n_printed = 0;                       \
-                r->n_missed = 0;                        \
-                r->begin = 0;                           \
+#define RATELIMIT_INIT(v, _interval, _burst)             \
+        do {                                             \
+                RateLimit *_r = &(v);                    \
+                _r->interval = (_interval);              \
+                _r->burst = (_burst);                    \
+                _r->n_printed = 0;                       \
+                _r->n_missed = 0;                        \
+                _r->begin = 0;                           \
         } while (false);
 
 bool ratelimit_test(RateLimit *r);
index 2427f209731b6c9dda700c72da275ff52317615a..67950d4e649d587cf7f77930c926eee2093da7d7 100644 (file)
--- a/service.c
+++ b/service.c
@@ -130,13 +130,13 @@ static void service_dump(Unit *u, FILE *f, const char *prefix) {
 
         ServiceExecCommand c;
         Service *s = SERVICE(u);
-        char *prefix2;
+        const char *prefix2;
+        char *p2;
 
         assert(s);
 
-        prefix2 = strappend(prefix, "\t");
-        if (!prefix2)
-                prefix2 = "";
+        p2 = strappend(prefix, "\t");
+        prefix2 = p2 ? p2 : prefix;
 
         fprintf(f,
                 "%sService State: %s\n",
@@ -161,7 +161,7 @@ static void service_dump(Unit *u, FILE *f, const char *prefix) {
                 exec_command_dump_list(s->exec_command[c], f, prefix2);
         }
 
-        free(prefix2);
+        free(p2);
 }
 
 static int service_load_pid_file(Service *s) {
@@ -243,7 +243,7 @@ fail:
 static int service_notify_sockets(Service *s) {
         Iterator i;
         Set *set;
-        Socket *socket;
+        Socket *sock;
         int r;
 
         assert(s);
@@ -253,8 +253,8 @@ static int service_notify_sockets(Service *s) {
         if ((r = service_get_sockets(s, &set)) < 0)
                 return r;
 
-        SET_FOREACH(socket, set, i)
-                socket_notify_service_dead(socket);
+        SET_FOREACH(sock, set, i)
+                socket_notify_service_dead(sock);
 
         set_free(set);
 
@@ -338,7 +338,7 @@ static int service_collect_fds(Service *s, int **fds, unsigned *n_fds) {
         int *rfds = NULL;
         unsigned rn_fds = 0;
         Set *set;
-        Socket *socket;
+        Socket *sock;
 
         assert(s);
         assert(fds);
@@ -347,11 +347,11 @@ static int service_collect_fds(Service *s, int **fds, unsigned *n_fds) {
         if ((r = service_get_sockets(s, &set)) < 0)
                 return r;
 
-        SET_FOREACH(socket, set, i) {
+        SET_FOREACH(sock, set, i) {
                 int *cfds;
                 unsigned cn_fds;
 
-                if ((r = socket_collect_fds(socket, &cfds, &cn_fds)) < 0)
+                if ((r = socket_collect_fds(sock, &cfds, &cn_fds)) < 0)
                         goto fail;
 
                 if (!cfds)
index c8e41ba26441fa37c4a005eff95f4f1c4d8ba9f5..fef100bad96d27a9aa1a10752256e802e07d3dde 100644 (file)
--- a/service.h
+++ b/service.h
@@ -102,7 +102,7 @@ struct Service {
         RateLimit ratelimit;
 };
 
-const UnitVTable service_vtable;
+extern const UnitVTable service_vtable;
 
 const char* service_state_to_string(ServiceState i);
 ServiceState service_state_from_string(const char *s);
index c8e8e5975b9b89709799ad8d9b77a8b3f56fd6c2..0f5140ec5b9769a17d963c9e7c19a7dc271e28d6 100644 (file)
@@ -103,7 +103,6 @@ int socket_address_parse(SocketAddress *a, const char *s) {
         } else {
 
                 if ((e = strchr(s, ':'))) {
-                        int r;
 
                         if ((r = safe_atou(e+1, &u)) < 0)
                                 return r;
diff --git a/timer.h b/timer.h
index 5182020125f238de91c15036921d93b86f4f6051..0ec3e0d9bbd071663f00e31f274aeac0934b6c33 100644 (file)
--- a/timer.h
+++ b/timer.h
@@ -44,6 +44,6 @@ struct Timer {
         Service *service;
 };
 
-const UnitVTable timer_vtable;
+extern const UnitVTable timer_vtable;
 
 #endif
diff --git a/unit.c b/unit.c
index bdbcb45c506fcce282696e3926ade9e6ceee2e9a..a14e18ef5b18d05d9c11437b8154cd5c9d7fe006 100644 (file)
--- a/unit.c
+++ b/unit.c
@@ -351,15 +351,15 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) {
         char *t;
         UnitDependency d;
         Iterator i;
-        char *prefix2;
+        char *p2;
+        const char *prefix2;
 
         assert(u);
 
         if (!prefix)
                 prefix = "";
-        prefix2 = strappend(prefix, "\t");
-        if (!prefix2)
-                prefix2 = "";
+        p2 = strappend(prefix, "\t");
+        prefix2 = p2 ? p2 : prefix;
 
         fprintf(f,
                 "%s→ Unit %s:\n"
@@ -397,7 +397,7 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) {
         if (u->meta.job)
                 job_dump(u->meta.job, f, prefix2);
 
-        free(prefix2);
+        free(p2);
 }
 
 /* Common implementation for multiple backends */
diff --git a/util.c b/util.c
index 33b143d3bbcf225c9cc37df3a1206d642cbf4e9d..bf74695854932a79f93d629c8f79a0664a144358 100644 (file)
--- a/util.c
+++ b/util.c
 #include "ioprio.h"
 #include "missing.h"
 
-usec_t now(clockid_t clock) {
+usec_t now(clockid_t clock_id) {
         struct timespec ts;
 
-        assert_se(clock_gettime(clock, &ts) == 0);
+        assert_se(clock_gettime(clock_id, &ts) == 0);
 
         return timespec_load(&ts);
 }
@@ -824,11 +824,11 @@ char *xescape(const char *s, const char *bad) {
 }
 
 char *bus_path_escape(const char *s) {
-        assert(s);
-
         char *r, *t;
         const char *f;
 
+        assert(s);
+
         /* Escapes all chars that D-Bus' object path cannot deal
          * with. Can be reverse with bus_path_unescape() */
 
@@ -853,11 +853,11 @@ char *bus_path_escape(const char *s) {
 }
 
 char *bus_path_unescape(const char *s) {
-        assert(s);
-
         char *r, *t;
         const char *f;
 
+        assert(s);
+
         if (!(r = new(char, strlen(s)+1)))
                 return NULL;