Linux Netfilter development
 help / color / mirror / Atom feed
From: Thomas Jarosch <thomas.jarosch@intra2net.com>
To: netfilter-devel@vger.kernel.org
Cc: Jan Engelhardt <jengelh@medozas.de>, Patrick McHardy <kaber@trash.net>
Subject: Re: [patch] iptables version defines
Date: Mon, 2 Jun 2008 17:32:56 +0200	[thread overview]
Message-ID: <200806021732.57124.thomas.jarosch@intra2net.com> (raw)
In-Reply-To: <alpine.LNX.1.10.0806021646350.4055@fbirervta.pbzchgretzou.qr>

[-- Attachment #1: Type: text/plain, Size: 1550 bytes --]

Jan,

On Monday, 2. June 2008 16:54:57 you wrote:
> > #define XTABLES_VERSION "@PACKAGE_VERSION@"
> >+#define XTABLES_VERSION_CODE (0x10000 * @XTABLES_VERSION_MAJOR@ + 0x100 *
> > @XTABLES_VERSION_MINOR@ + @XTABLES_VERSION_PATCH@) +
> >+#define XTABLES_VERSION_CHECK(x,y,z)    (0x10000*(x) + 0x100*(y) + z)
>
> Mh.... too much arithmetic for my taste, just use bitops like
> linux/version.h. Also, regarding the _CHECK name, I'd propose
> "XTABLES_API_VERSION" instead, which should look nicer on
> 	#if XTABLES_VERSION_CODE < XTABLES_API_VERSION(1,4,0)
> 	#error Upgrade, yo!
> 	#endif
>
>
> #define XTABLES_API_VERSION(a,b,c) (((a) << 16) | ((b) << 8) | (c))

As you already pointed out, it's a matter of taste and neither
of both versions will hurt as it will be expanded at compile time.

Infact, imagine we would add another version level like "(x) << 32",
on x86 it is only valid to do a left shift operation for 0-31 bits
and so it could fail...

> >+#define XTABLES_VERSION_MAJOR(x)  (((x)>>16) & 0xFF)
> >+#define XTABLES_VERSION_MINOR(x)  (((x)>> 8) & 0xFF)
> >+#define XTABLES_VERSION_PATCH(x)  ( (x)      & 0xFF)
>
> I do not see a need for these three. The linux kernel does not
> have such either, so please don't overdesign :)

Well, I've created the same macros as there are already in include/iptables.h.

I'm alright with your proposed change to XTABLES_API_VERSION
and the drop of _MAJOR, _MINOR and _PATCH macros as
one can easily check for same thing via "xyz < XTABLES_API_VERSION(2,6,0)"

Attached is an updated patch.

Thomas

[-- Attachment #2: iptables-add-version.patch --]
[-- Type: text/x-diff, Size: 1792 bytes --]

Add xtables version defines.

Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com>

diff -u -r iptables-1.4.1-rc2/configure.ac iptables.version/configure.ac
--- iptables-1.4.1-rc2/configure.ac	Mon May 26 14:23:58 2008
+++ iptables.version/configure.ac	Mon Jun  2 17:19:42 2008
@@ -1,5 +1,11 @@
+define([_XTABLES_VERSION_MAJOR], 1)
+define([_XTABLES_VERSION_MINOR], 4)
+define([_XTABLES_VERSION_PATCH], 1)
+define([_XTABLES_VERSION_EXTRA], -rc2)
 
-AC_INIT([iptables], [1.4.1-rc2])
+define([_XTABLES_VERSION],_XTABLES_VERSION_MAJOR._XTABLES_VERSION_MINOR._XTABLES_VERSION_PATCH[]_XTABLES_VERSION_EXTRA)
+
+AC_INIT([iptables], _XTABLES_VERSION)
 AC_CONFIG_HEADERS([config.h])
 AC_PROG_INSTALL
 AM_INIT_AUTOMAKE
@@ -56,4 +62,14 @@
 AC_SUBST([kbuilddir])
 AC_SUBST([ksourcedir])
 AC_SUBST([xtlibdir])
+
+XTABLES_VERSION_MAJOR=_XTABLES_VERSION_MAJOR
+XTABLES_VERSION_MINOR=_XTABLES_VERSION_MINOR
+XTABLES_VERSION_PATCH=_XTABLES_VERSION_PATCH
+XTABLES_VERSION_EXTRA=_XTABLES_VERSION_EXTRA
+AC_SUBST([XTABLES_VERSION_MAJOR])
+AC_SUBST([XTABLES_VERSION_MINOR])
+AC_SUBST([XTABLES_VERSION_PATCH])
+AC_SUBST([XTABLES_VERSION_EXTRA])
+
 AC_OUTPUT([Makefile extensions/GNUmakefile libipq/Makefile include/xtables.h])
diff -u -r iptables-1.4.1-rc2/include/xtables.h.in iptables.version/include/xtables.h.in
--- iptables-1.4.1-rc2/include/xtables.h.in	Mon May 26 14:15:40 2008
+++ iptables.version/include/xtables.h.in	Mon Jun  2 17:20:55 2008
@@ -18,6 +18,9 @@
 #endif
 
 #define XTABLES_VERSION "@PACKAGE_VERSION@"
+#define XTABLES_VERSION_CODE (0x10000 * @XTABLES_VERSION_MAJOR@ + 0x100 * @XTABLES_VERSION_MINOR@ + @XTABLES_VERSION_PATCH@)
+
+#define XTABLES_API_VERSION(x,y,z)    (0x10000*(x) + 0x100*(y) + z)
 
 /* Include file for additions: new matches and targets. */
 struct xtables_match

  reply	other threads:[~2008-06-02 15:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-02 13:49 [patch] iptables version defines Thomas Jarosch
2008-06-02 14:54 ` Jan Engelhardt
2008-06-02 15:32   ` Thomas Jarosch [this message]
2008-06-02 17:03     ` Jan Engelhardt
2008-06-03 13:02     ` Patrick McHardy
  -- strict thread matches above, loose matches on Subject: below --
2008-05-30  8:16 Thomas Jarosch
2008-05-30 10:53 ` Jan Engelhardt
2008-06-01 21:13   ` Patrick McHardy
     [not found]     ` <200806021545.23690.thomas.jarosch@intra2net.com>
2008-06-02 13:50       ` [patch] " Patrick McHardy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200806021732.57124.thomas.jarosch@intra2net.com \
    --to=thomas.jarosch@intra2net.com \
    --cc=jengelh@medozas.de \
    --cc=kaber@trash.net \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox