From: g0dil Date: Fri, 20 Aug 2010 06:40:25 +0000 (+0000) Subject: Packets/80211Bundle: Fix missing le16toh/le32toh on older libc X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=5083ed2a2fe087df2f981b3f66eaf0fb130243eb;p=senf.git Packets/80211Bundle: Fix missing le16toh/le32toh on older libc git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1694 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/SConfigure b/SConfigure index 5d7dae2..40382e8 100644 --- a/SConfigure +++ b/SConfigure @@ -69,6 +69,37 @@ def CheckValgrindWildcards(context): context.Result( ret[0] ) return ret[0] +@env.ConfTest() +def CheckExpression(context, name, expression, header="", language="C"): + import SCons.Conftest + + lang, suffix, msg = SCons.Conftest._lang2suffix(language) + if msg: + context.Message("Cannot check for header file %s: \n" % header_name) + context.Result(msg) + return False + + text = ("#include \n" + "%s\n" + "int main() {\n" + "%s;\n" + "return 0;\n" + "}\n") % (header, expression) + + context.Message("Checking for valid %s expression %s... " % (lang, expression)) + ret = context.TryLink(text, suffix) + context.Result(ret) + if ret: + import re + key = name.upper() + key = re.sub('[^A-Z0-9_]', '_', key) + context.sconf.Define("HAVE_%s" % key, + 1, + "Define to 1 if the expression `%s' is valid on your system" + % expression) + + return ret + ########################################################################### conf = env.Configure(clean=False, help=False, config_h="#/senf/autoconf.hh") @@ -85,6 +116,10 @@ res = conf.CheckTempBufferStrategy() # Standard library stuff res = conf.CheckFunc("timerfd_create") +res = conf.CheckExpression("le16toh", "le16toh(0)", + "#include ") +res = conf.CheckExpression("le32toh", "le32toh(0)", + "#include ") res = conf.CheckSTLCopyN(); \ conf.env.Fail(condition=not res, message="No 'copy_n' implementation found") diff --git a/senf/Packets/80211Bundle/SConscript b/senf/Packets/80211Bundle/SConscript index 6c532af..6ea2d44 100644 --- a/senf/Packets/80211Bundle/SConscript +++ b/senf/Packets/80211Bundle/SConscript @@ -7,4 +7,5 @@ import SENFSCons SConscript(env.Glob("*/SConscript")) -SENFSCons.AutoPacketBundle(env, '80211Bundle', subdirs=['radiotap']) +SENFSCons.AutoPacketBundle(env, '80211Bundle', + subdirs=['radiotap'], exclude=['radiotap/radiotap.c']) diff --git a/senf/Packets/80211Bundle/radiotap.c b/senf/Packets/80211Bundle/radiotap.c new file mode 100644 index 0000000..f176a55 --- /dev/null +++ b/senf/Packets/80211Bundle/radiotap.c @@ -0,0 +1,44 @@ +// $Id$ +// +// Copyright (C) 2010 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Stefan Bund +// +// This program 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. +// +// This program 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 this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# include +# +# ifndef HAVE_LE16TOH +# define le16toh(x) (x) +# endif +# +# ifndef HAVE_LE32TOH +# define le32toh(x) (x) +# endif +# +# include "radiotap/radiotap.c" + + +// Local Variables: +// mode: c++ +// fill-column: 100 +// comment-column: 40 +// c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// End: diff --git a/senf/Packets/80211Bundle/radiotap/SConscript b/senf/Packets/80211Bundle/radiotap/SConscript index 0b12252..b6757d5 100644 --- a/senf/Packets/80211Bundle/radiotap/SConscript +++ b/senf/Packets/80211Bundle/radiotap/SConscript @@ -4,7 +4,6 @@ Import('env') import SENFSCons env.SetDefault( - RADIOTAP_FILES = env.Glob("*.h") + env.Glob("*.c"), RADIOTAP_URL = 'http://git.sipsolutions.net/radiotap.git', ) @@ -12,9 +11,9 @@ env.PhonyTarget( 'update-radiotap', [], [ Delete('$GITDIR'), 'git clone $RADIOTAP_URL $GITDIR', - 'cp $_RADIOTAP_FILES $HERE', + 'cp $RADIOTAP_FILES $HERE', Delete('$GITDIR') ], - HERE = env.Dir('.'), - GITDIR = env.Dir('radiotap.git'), - _RADIOTAP_FILES = [ env.Dir('radiotap.git').File(f) - for f in env.Flatten(env.subst_list('$RADIOTAP_FILES')) ]) + HERE = env.Dir('.'), + GITDIR = env.Dir('radiotap.git'), + RADIOTAP_FILES = [ env.Dir('radiotap.git').File(f) + for f in env.Glob("*.h") + env.Glob("*.c") ])