Skip to content

Commit

Permalink
macro: add header for shared macros
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
  • Loading branch information
Christian Brauner committed Nov 14, 2016
1 parent 0964892 commit 17e0e36
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
10 changes: 5 additions & 5 deletions Makefile.am
Expand Up @@ -11,15 +11,15 @@ AM_LDFLAGS = $(FUSE_LIBS) -pthread

AM_CFLAGS += -DRUNTIME_PATH=\"$(RUNTIME_PATH)\"

liblxcfs_la_SOURCES = bindings.c cpuset.c bindings.h
liblxcfs_la_SOURCES = macro.h bindings.c cpuset.c bindings.h
liblxcfs_la_CFLAGS = $(AM_CFLAGS)
liblxcfs_la_LDFLAGS = $(AM_CFLAGS) -module -avoid-version -shared

liblxcfstest_la_SOURCES = bindings.c cpuset.c bindings.h
liblxcfstest_la_SOURCES = bindings.c cpuset.c bindings.h macro.h
liblxcfstest_la_CFLAGS = $(AM_CFLAGS) -DRELOADTEST
liblxcfstest_la_LDFLAGS = $(AM_CFLAGS) -module -avoid-version -shared

noinst_HEADERS = bindings.h
noinst_HEADERS = bindings.h macro.h

sodir=$(libdir)
lib_LTLIBRARIES = liblxcfs.la
Expand Down Expand Up @@ -50,11 +50,11 @@ TEST_SYSCALLS: tests/test_syscalls.c

if HAVE_PAM
pam_LTLIBRARIES = pam_cgfs.la
pam_cgfs_la_SOURCES = pam/pam_cgfs.c
pam_cgfs_la_SOURCES = pam/pam_cgfs.c macro.h
pam_cgfs_la_CFLAGS = $(AM_CFLAGS)
pam_cgfs_la_LIBADD = $(AM_LIBS) $(PAM_LIBS) -L$(top_srcdir)
pam_cgfs_la_LDFLAGS = $(AM_LDFLAGS) -module -avoid-version -shared
#pam_cgfs_la_CFLAGS += -DDEBUG
# pam_cgfs_la_CFLAGS += -DDEBUG

install-data-hook: install-pamLTLIBRARIES
rm -f "$(DESTDIR)$(pamdir)/pam_cgfs.la"
Expand Down
18 changes: 3 additions & 15 deletions bindings.h
@@ -1,24 +1,12 @@
#ifndef __LXCFS_BINDINGS_H
#define __LXCFS_BINDINGS_H

#include "macro.h"

/* directory under which we mount the controllers - /run/lxcfs/controllers */
#define BASEDIR RUNTIME_PATH "/lxcfs/controllers"
#define ROOTDIR RUNTIME_PATH "/lxcfs/root"

#define lxcfs_debug_stream(stream, format, ...) \
do { \
fprintf(stream, "%s: %d: %s: " format, __FILE__, __LINE__, \
__func__, __VA_ARGS__); \
} while (false)

#define lxcfs_error(format, ...) lxcfs_debug_stream(stderr, format, __VA_ARGS__)

#ifdef DEBUG
#define lxcfs_debug(format, ...) lxcfs_error(format, __VA_ARGS__)
#else
#define lxcfs_debug(format, ...)
#endif /* DEBUG */

extern int cg_write(const char *path, const char *buf, size_t size, off_t offset,
struct fuse_file_info *fi);
extern int cg_mkdir(const char *path, mode_t mode);
Expand All @@ -45,4 +33,4 @@ extern int proc_read(const char *path, char *buf, size_t size, off_t offset,
struct fuse_file_info *fi);
extern int proc_access(const char *path, int mask);

#endif /* __LXCFS__BINDINGS_H */
#endif /* __LXCFS_BINDINGS_H */
18 changes: 18 additions & 0 deletions macro.h
@@ -0,0 +1,18 @@
#ifndef __LXCFS_MACRO_H
#define __LXCFS_MACRO_H

#define lxcfs_debug_stream(stream, format, ...) \
do { \
fprintf(stream, "%s: %d: %s: " format, __FILE__, __LINE__, \
__func__, __VA_ARGS__); \
} while (false)

#define lxcfs_error(format, ...) lxcfs_debug_stream(stderr, format, __VA_ARGS__)

#ifdef DEBUG
#define lxcfs_debug(format, ...) lxcfs_error(format, __VA_ARGS__)
#else
#define lxcfs_debug(format, ...)
#endif /* DEBUG */

#endif /* __LXCFS_MACRO_H */

0 comments on commit 17e0e36

Please sign in to comment.