Hello, This patch adds a definition in nettle-meta.h with nettle's version number. That way applications can be easily modified to support both the 2.7 and the 3.x API. I didn't add for hogweed because it didn't seem to make sense, the API version is fully determined by nettle only.
regards, Nikos
Nikos Mavrogiannopoulos nmav@gnutls.org writes:
This patch adds a definition in nettle-meta.h with nettle's version number. That way applications can be easily modified to support both the 2.7 and the 3.x API. I didn't add for hogweed because it didn't seem to make sense, the API version is fully determined by nettle only.
Sorry for the late reply. It seems reasonable to me to include the package version in some header file. However, I'm not sure nettle-meta.h is the right file.
I'd prefer either a separate file nettle/version.h, or some file like nettle-typs.h included in all other nettle headers. And if we let configure generate a header file, it makes some sense to also move the definition of NETTLE_USE_MINI_GMP there, and move back from bignum-h-in to bignum.h.
And I'm also not sure I like the way major and minor numbers are combined into a single value. Can't they be kept separate, say NETTLE_VERSION, NETTLE_MINOR_VERSION, NETTLE_PATCHLEVEL or so? What do other packages do? E.g., gcc uses
$ echo | cpp -dM -E - |grep GNUC #define __GNUC_PATCHLEVEL__ 2 #define __GNUC__ 4 #define __GNUC_MINOR__ 7
Maybe there should also be correspondingglobal symbols, so that version can be checked also at runtime?
Regards, /Niels
On Sun, Jan 11, 2015 at 3:14 PM, Niels Möller nisse@lysator.liu.se wrote:
I'd prefer either a separate file nettle/version.h, or some file like nettle-typs.h included in all other nettle headers. And if we let configure generate a header file, it makes some sense to also move the definition of NETTLE_USE_MINI_GMP there, and move back from bignum-h-in to bignum.h. And I'm also not sure I like the way major and minor numbers are combined into a single value. Can't they be kept separate, say NETTLE_VERSION, NETTLE_MINOR_VERSION, NETTLE_PATCHLEVEL or so? What do other packages do? E.g., gcc uses $ echo | cpp -dM -E - |grep GNUC #define __GNUC_PATCHLEVEL__ 2 #define __GNUC__ 4 #define __GNUC_MINOR__ 7
I needed the version check in order to have two versions of a program, one for the pre-3 API and one for the post. Having only two definitions would make the complete version check harder. However, if both approaches are present it would be best. For the two definitions approach it would also make sense to associate some guarrantees for them, otherwise using them wouldn't provide much benefit.
Maybe there should also be correspondingglobal symbols, so that version can be checked also at runtime?
libgcrypt defines gcry_check_version() which is a good version checker for runtime. However, given the low-level nature of nettle, I'm not sure whether having such a function would provide much. Such runtime checks are nice on high level APIs which may have an additional feature in some version (e.g. for gcry_cipher_open one could have a runtime check for a particular algorithm). For nettle, the API and ABI are so low-level one can simply check for the specific function.
https://www.gnupg.org/documentation/manuals/gcrypt/Initializing-the-library....
regards, Nikos
On Sun, Jan 11, 2015 at 3:14 PM, Niels Möller nisse@lysator.liu.se wrote:
Nikos Mavrogiannopoulos nmav@gnutls.org writes:
This patch adds a definition in nettle-meta.h with nettle's version number. That way applications can be easily modified to support both the 2.7 and the 3.x API. I didn't add for hogweed because it didn't seem to make sense, the API version is fully determined by nettle only.
Sorry for the late reply. It seems reasonable to me to include the package version in some header file. However, I'm not sure nettle-meta.h is the right file.
I'd prefer either a separate file nettle/version.h [...] And I'm also not sure I like the way major and minor numbers are combined into a single value. Can't they be kept separate, say NETTLE_VERSION, NETTLE_MINOR_VERSION, NETTLE_PATCHLEVEL or so? What do other packages do? E.g., gcc uses
I went this path, and now there is a version.h which defines, NETTLE_VERSION (combo), NETTLE_VERSION_MAJOR and NETTLE_VERSION_MINOR.
regards, Nikos
Nikos Mavrogiannopoulos nmav@gnutls.org writes:
I went this path, and now there is a version.h which defines, NETTLE_VERSION (combo), NETTLE_VERSION_MAJOR and NETTLE_VERSION_MINOR.
Thanks.
--- /dev/null +++ b/version.h.in
...
+#ifndef NETTLE_VERSION_H_INCLUDED +#define NETTLE_VERSION_H_INCLUDED
+#include "nettle-types.h"
Why this include?
+/* The combined version in hex */ +#define NETTLE_VERSION @NUMBER_VERSION@
Any motivation for this particular grouping, and the corresponding
AC_SUBST([NUMBER_VERSION], `printf "0x%02x%02x" $MAJOR_VERSION $MINOR_VERSION`)
Is it a common convention with other libraries? Is there some reason it has to be a hex literal, and not just constructed as
#define NETTLE_VERSION (((NETTLE_VERSION_MAJOR) << 8) | (NETTLE_VERSION_MINOR))
which should produce the same integer? My gut feeling is still that it is better to leave the construction of a combined version number to the applications that need it.
Regards, /Niels
On Tue, Mar 17, 2015 at 3:02 PM, Niels Möller nisse@lysator.liu.se wrote:
Nikos Mavrogiannopoulos nmav@gnutls.org writes:
+#include "nettle-types.h"
Why this include?
Not needed.
+/* The combined version in hex */ +#define NETTLE_VERSION @NUMBER_VERSION@
Any motivation for this particular grouping, and the corresponding
AC_SUBST([NUMBER_VERSION], `printf "0x%02x%02x" $MAJOR_VERSION $MINOR_VERSION`)
Is it a common convention with other libraries? Is there some reason it has to be a hex literal, and not just constructed as #define NETTLE_VERSION (((NETTLE_VERSION_MAJOR) << 8) | (NETTLE_VERSION_MINOR)) which should produce the same integer? My gut feeling is still that it is better to leave the construction of a combined version number to the applications that need it.
I see that in gcc and every application uses different ways to detect its version. Most code is copy paste from others projects, some nasty some pretty good. Is there a reason not to simplify things for the developers? It is just a preprocessor macro it doesn't take any space. Anyway for my purposes I only need the major part to distinguish between 2 and 3, I'll drop the combined macro if you don't want it.
regards, Nikos
Nikos Mavrogiannopoulos nmav@gnutls.org writes:
Anyway for my purposes I only need the major part to distinguish between 2 and 3, I'll drop the combined macro if you don't want it.
I think I'd prefer to drop the combined version number for now. We can add it later if we find (1) a concrete use-case, and (2) an established or otherwise desirable convention on precisely how to combine the version numbers.
Regards, /Niels
Attached.
On Wed, Mar 18, 2015 at 8:54 AM, Niels Möller nisse@lysator.liu.se wrote:
Nikos Mavrogiannopoulos nmav@gnutls.org writes:
Anyway for my purposes I only need the major part to distinguish between 2 and 3, I'll drop the combined macro if you don't want it.
I think I'd prefer to drop the combined version number for now. We can add it later if we find (1) a concrete use-case, and (2) an established or otherwise desirable convention on precisely how to combine the version numbers.
Regards, /Niels
-- Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26. Internet email is subject to wholesale government surveillance. _______________________________________________ nettle-bugs mailing list nettle-bugs@lists.lysator.liu.se http://lists.lysator.liu.se/mailman/listinfo/nettle-bugs
Nikos Mavrogiannopoulos nmav@gnutls.org writes:
Attached.
Both patches applied now.
Thanks!
/Niels
nettle-bugs@lists.lysator.liu.se