From: Pavel Pisa Date: Mon, 29 Mar 2010 08:53:29 +0000 (+0200) Subject: Makefile.rules and atomic CMPXCHG handling update to support 2.6.33 kernel. X-Git-Url: http://rtime.felk.cvut.cz/gitweb/lincan.git/commitdiff_plain/5b1805652b70bcf8f56c827e09b18fbf5a77bea6 Makefile.rules and atomic CMPXCHG handling update to support 2.6.33 kernel. Signed-off-by: Pavel Pisa --- diff --git a/lincan/include/can_queue.h b/lincan/include/can_queue.h index 00ac94c..bf9486d 100644 --- a/lincan/include/can_queue.h +++ b/lincan/include/can_queue.h @@ -646,11 +646,13 @@ void canque_edge_decref(struct canque_edge_t *edge) if(x<=1) return __canque_edge_decref(edge); y=x; + #ifdef CAN_HAVE_ATOMIC_CMPXCHG + atomic_cmpxchg(&edge->edge_used, x, x-1); + #else /* workaround for case that atomic_cmpxchg is not defined */ /* This code strongly depends on the definition of atomic_t !!!! */ - /* x=cmpxchg(&edge->edge_used, x, x-1); */ - /* Next alternative could be more portable */ x=__cmpxchg(&edge->edge_used, x, x-1, sizeof(atomic_t)); /* If even this does not help, comment out CAN_HAVE_ARCH_CMPXCHG in can_sysdep.h */ + #endif } while(x!=y); } #endif diff --git a/lincan/include/can_sysdep.h b/lincan/include/can_sysdep.h index 452afbc..f6d985d 100644 --- a/lincan/include/can_sysdep.h +++ b/lincan/include/can_sysdep.h @@ -213,6 +213,9 @@ #ifdef __HAVE_ARCH_CMPXCHG #define CAN_HAVE_ARCH_CMPXCHG + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) + #define CAN_HAVE_ATOMIC_CMPXCHG + #endif #endif #ifndef CAN_WITH_RTL diff --git a/lincan/src/main.c b/lincan/src/main.c index df2e84c..5cc522e 100644 --- a/lincan/src/main.c +++ b/lincan/src/main.c @@ -36,8 +36,6 @@ #define EXPORT_SYMTAB #endif -#include - #include #include @@ -45,10 +43,10 @@ #include #include #include -#include #include #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,0)) + #include #include #else #include diff --git a/omk/rules/linux/Makefile.rules b/omk/rules/linux/Makefile.rules index 406e45d..2a634d1 100644 --- a/omk/rules/linux/Makefile.rules +++ b/omk/rules/linux/Makefile.rules @@ -1,10 +1,10 @@ # Makefile.rules - OCERA make framework common project rules -*- makefile-gmake -*- #OMK:base.omk # -# (C) Copyright 2003 by Pavel Pisa - OCERA team member -# (C) Copyright 2006 by Michal Sojka - Czech Technical University, FEE, DCE +# (C) Copyright 2003, 2006, 2007, 2008, 2009 by Pavel Pisa - OCERA team member +# (C) Copyright 2006, 2007, 2008, 2009, 2010 by Michal Sojka - Czech Technical University, FEE, DCE # # Homepage: http://rtime.felk.cvut.cz/omk/ -# Version: 0.1-88-g324e3bf +# Version: 0.2-12-g881199c # # The OMK build system is distributed under the GNU General Public # License. See file COPYING for details. @@ -63,12 +63,6 @@ # QTDIR .. where QT resides OMK_RULES_TYPE=linux #OMK:Makefile.rules.linux@ #OMK:base.omk@Makefile.rules.linux -# We need to ensure definition of sources directory first -ifndef SOURCES_DIR -# Only shell built-in pwd understands -L -SOURCES_DIR := $(shell ( pwd -L ) ) -endif - # If we are not called by OMK leaf Makefile... ifndef MAKERULES_DIR MAKERULES_DIR := $(abspath $(dir $(filter %Makefile.rules,$(MAKEFILE_LIST)))) @@ -81,6 +75,15 @@ ifndef OUTPUT_DIR OUTPUT_DIR := $(MAKERULES_DIR) endif +# We need to ensure definition of sources directory first +ifndef SOURCES_DIR +# Only shell built-in pwd understands -L +SOURCES_DIR := $(shell ( pwd -L ) ) +INVOCATION_DIR := $(SOURCES_DIR:$(OUTPUT_DIR)%=%) +INVOCATION_DIR := $(INVOCATION_DIR:/%=%) +INVOCATION_DIR := $(INVOCATION_DIR:\\%=%) +endif + .PHONY: all default check-make-ver omkize ifdef W @@ -142,7 +145,7 @@ endif #$(CONFIG_FILE_OK) CONFIG_FILES ?= $(wildcard $(CONFIG_FILE)-default) $(wildcard $(OUTPUT_DIR)/config.target) $(wildcard $(CONFIG_FILE)) -export SOURCES_DIR MAKERULES_DIR RELATIVE_DIR +export SOURCES_DIR MAKERULES_DIR RELATIVE_DIR INVOCATION_DIR export CONFIG_FILE CONFIG_FILES OMK_SERIALIZE_INCLUDED OMK_VERBOSE OMK_SILENT # OMK_SERIALIZE_INCLUDED has to be exported to submakes because passes # must to be serialized only in the toplevel make. @@ -243,11 +246,14 @@ endif pass = $(strip $(1)) +unexport SUBDIRS + # Call a pass in a subdirectory # Usage: $(call omk_pass_subdir_template,,,) define omk_pass_subdir_template .PHONY: $(pass)-$(3)-subdir $(pass)-submakes: $(pass)-$(3)-subdir +$(pass)-$(3)-subdir: MAKEOVERRIDES:=$(filter-out SUBDIRS=%,$(MAKEOVERRIDES)) $(pass)-$(3)-subdir: @$(call mkdir_def,$(2)/$(3)) +@$(MAKE) SOURCES_DIR=$(SOURCES_DIR)/$(3) $(NO_PRINT_DIRECTORY) \ @@ -463,6 +469,7 @@ LIB_CPPFLAGS += $(CPPFLAGS) LIB_CFLAGS += $(CFLAGS) ifeq ($(TARGET_OS),win32) + EXE_SUFFIX = .exe SOLIB_EXT = dll else SOLIB_EXT = so @@ -568,6 +575,7 @@ $(2): $(1) $$(GEN_HEADERS) fi endef +NM ?= nm # Syntax: $(call CMETRIC_o_h_template,,) define CMETRIC_o_h_template @@ -576,15 +584,22 @@ $(2): $(1) $(Q)if [ -n `dirname $$@` ] ; then \ if [ ! -e `dirname $$@` ] ; then \ mkdir -p `dirname $$@` ; fi ; fi - $(Q)echo >$$@ '/* Automatically generated from $$< */' - $(Q)echo >>$$@ '/* Conditionals to control compilation */' - $(Q)set -o pipefail ; $(NM) $$< \ + $(Q)echo >$$@.tmp '/* Automatically generated from $$< */' + $(Q)echo >>$$@.tmp '/* Conditionals to control compilation */' +# Bellow, the tricks with redirection are for shells without set -o pipefail +# (see http://www.mail-archive.com/dash@vger.kernel.org/msg00149.html) + $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) $$<; echo $$$$? >&4; }\ | sed -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2cond_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \ - | sort >>$$@ - $(Q)echo >>$$@ '/* Defines from the values defined to symbols */' - $(Q)set -o pipefail ; $(NM) $$< \ + | sort >>$$@.tmp` && exit $$$$status + $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols in hexadecimal format */' + $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) $$<; echo $$$$? >&4; }\ | sed -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2def_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \ - | sort >>$$@ + | sort >>$$@.tmp` && exit $$$$status + $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols in decimal format */' + $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) -td $$<; echo $$$$? >&4; }\ + | sed -n 's/^ *0*\(0\|[1-9][0-9]*\) *A *_cmetric2defdec_\([A-Za-z_0-9]*\) */#define \2 \1/p' \ + | sort >>$$@.tmp` && exit $$$$status + $(Q)mv $$@.tmp $$@ endef @@ -1244,7 +1259,7 @@ define qt_project_template # FIXME: Handle multiple .pro files correctly $(LOCAL_BUILD_DIR)/$(dir $(1))Makefile: $(SOURCES_DIR)/$(1) $(Q)mkdir -p $$(dir $$(@)) && cd $$(dir $$(@)) && \ - $(QTDIR:%=%/bin/)qmake \ + $(if $(QMAKE),$(QMAKE),$(QTDIR:%=%/bin/)qmake) \ TOP_DIR=$(OUTPUT_DIR) \ RELATIVE_DIR=$(RELATIVE_PREFIX)$(dir $(1)) \ $(QTDIR:%=QTDIR=%) CC=$(CC) CXX=$(CXX) \ diff --git a/omk/rules/linux/kernelcfg2mk b/omk/rules/linux/kernelcfg2mk index be7d1f5..3fd50d2 100755 --- a/omk/rules/linux/kernelcfg2mk +++ b/omk/rules/linux/kernelcfg2mk @@ -54,6 +54,10 @@ if [ -z "$LINUX_VERSION" ] ; then LINUX_VERSION=$(grep UTS_RELEASE ${LINUX_DIR}/include/linux/utsrelease.h | \ sed 's/[^"]*"\(.*\)\{1\}"/\1/') fi +if [ -z "$LINUX_VERSION" ] ; then + LINUX_VERSION=$(grep UTS_RELEASE ${LINUX_DIR}/include/generated/utsrelease.h | \ + sed 's/[^"]*"\(.*\)\{1\}"/\1/') +fi LINUX_VERSION_MAJOR=$(echo ${LINUX_VERSION} | cut -d. -f1) LINUX_VERSION_MINOR=$(echo ${LINUX_VERSION} | cut -d. -f2)