]> rtime.felk.cvut.cz Git - lincan.git/commitdiff
Makefile.rules and atomic CMPXCHG handling update to support 2.6.33 kernel.
authorPavel Pisa <pisa@cmp.felk.cvut.cz>
Mon, 29 Mar 2010 08:53:29 +0000 (10:53 +0200)
committerPavel Pisa <pisa@cmp.felk.cvut.cz>
Mon, 29 Mar 2010 08:53:29 +0000 (10:53 +0200)
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
lincan/include/can_queue.h
lincan/include/can_sysdep.h
lincan/src/main.c
omk/rules/linux/Makefile.rules
omk/rules/linux/kernelcfg2mk

index 00ac94c5960775a30dcdf584be524fb543ce7734..bf9486d01ca79769f8776db835f37d40591a1fd2 100644 (file)
@@ -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
index 452afbc41d66d3ce0a2ab062b1f0606552b73190..f6d985d015d90a420853c6780a9480de4a4cf457 100644 (file)
 
 #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
index df2e84cb6be56450d8ea517f0ac6f053491c87bc..5cc522ed65ac829189a77360598e71d4bf3deaa0 100644 (file)
@@ -36,8 +36,6 @@
 #define EXPORT_SYMTAB
 #endif
 
-#include <linux/autoconf.h>
-
 #include <linux/module.h>
 
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/poll.h>
 #include <linux/version.h>
-#include <linux/autoconf.h>
 #include <linux/interrupt.h>
 
 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,0))
+ #include <linux/autoconf.h>
  #include <linux/wrapper.h>
 #else
  #include <linux/device.h>
index 406e45dd9707885946f43bb753c419659cd8873f..2a634d1e735f666744409c7c58aa9ec3557540e6 100644 (file)
@@ -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.
 # 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,<pass name>,<build dir>,<subdir>)
 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,<object_file>,<target_header>)
 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)                     \
index be7d1f54c3db340660182843acc7ab1d6d648b75..3fd50d2f3ee27365ea888538dbaa6116ae821d23 100755 (executable)
@@ -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)