Commit 07ef1c00 authored by Lubomir Bulej's avatar Lubomir Bulej
Browse files

Compile with -std=c11 and update Makefile and list.h accordingly

parent aed53115
......@@ -118,6 +118,7 @@ PROTO_LIB_PROTO_C := $(PROTO_DIR)/src/protobuf-c
PROTO_LIB_SOURCES := $(wildcard $(PROTO_LIB_PROTO_C)/*.c)
PROTO_LIB_OBJECTS := $(addprefix $(BUILD_DIR)/,$(notdir $(PROTO_LIB_SOURCES:%.c=%.o)))
PROTO_LIB_HEADERS := $(PROTO_LIB_SOURCES:%.c=%.h)
PROTO_LIB_CFLAGS := -Wno-unused-but-set-variable
PROTO_SOURCES := $(PROTO_GEN_SOURCES) $(PROTO_LIB_SOURCES)
......@@ -158,8 +159,8 @@ endif
# Generate position independent code
CFLAGS += -fPIC
# Use GNU extensions and warn on most things
CFLAGS += -std=gnu99 -W -Wall -Wextra -Wno-unused-parameter
# Use C11 standard and warn on everything (define exceptions locally)
CFLAGS += -std=c11 -W -Wall -Wextra
# Hide most symbols except those exported
CFLAGS_PARTS += -fvisibility=hidden
......@@ -216,7 +217,7 @@ ifneq (,$(WHOLE))
CFLAGS += $(CFLAGS_WHOLE) -DWHOLE
$(LIBRARY): $(HEADERS) $(SOURCES)
$(CC) $(CC_SHARED) $(CFLAGS) -I$(PROTO_LIB_DIR) -I$(PROTO_GEN_DIR) $(JDK_INCLUDES) $(TARGET_ARCH) $(CFLAGS_LD) $(SOURCES) $(LIBS) $(OUTPUT_OPTION)
$(CC) $(CC_SHARED) $(CFLAGS) $(PROTO_LIB_CFLAGS) -I$(PROTO_LIB_DIR) -I$(PROTO_GEN_DIR) $(JDK_INCLUDES) $(TARGET_ARCH) $(CFLAGS_LD) $(SOURCES) $(LIBS) $(OUTPUT_OPTION)
else
......@@ -232,9 +233,9 @@ $(BUILD_DIR)/%.o: $(PROTO_GEN_AGENT)/%.c
$(CC) $(CFLAGS) -I$(PROTO_LIB_DIR) $(TARGET_ARCH) -c $? $(OUTPUT_OPTION)
$(BUILD_DIR)/%.o: $(PROTO_LIB_PROTO_C)/%.c
$(CC) $(CFLAGS) $(TARGET_ARCH) -c $? $(OUTPUT_OPTION)
$(CC) $(CFLAGS) $(PROTO_LIB_CFLAGS) $(TARGET_ARCH) -c $? $(OUTPUT_OPTION)
$(BUILD_DIR)/%.d: %.c
$(BUILD_DIR)/%.d: %.c $(BUILD_DIR)
@$(CC) -MM $< | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@
-include $(SRCDEPS)
......
......@@ -48,17 +48,6 @@ typedef int (* list_match_fn) (struct list * item, void * data);
| PRIVATE INLINE FUNCTIONS AND MACROS |
\****************************************************************************/
/**
* Calculates an offset of a member in a struct.
*
* @param type
* the type of the container struct a member is embedded in
* @param member
* the name of the member within the struct
*/
#define __offset_of(type, member) offsetof (type, member)
/**
* Calculates the pointer to the containing structure based on the offset
* of the given member in that structure. Casts the resulting pointer to
......@@ -73,8 +62,8 @@ typedef int (* list_match_fn) (struct list * item, void * data);
*/
#define __container_of(ptr, type, member) \
({ \
const typeof (((type *) 0)->member) * __mptr = (ptr); \
(type *) ((char *) __mptr - __offset_of (type, member)); \
const __typeof__ (((type *) 0)->member) * __mptr = (ptr); \
(type *) ((void *) __mptr - offsetof (type, member)); \
})
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment