libixp

git clone git://oldgit.suckless.org/libixp/
Log | Files | Refs | LICENSE

commit fb2a8d8f3f0e5666833e5686f02f907a7651eca7
parent 62fa1579c132a96b51caca15ad65e0daba9b1c8d
Author: Kris Maglione <kris@suckless.org>
Date:   Thu, 17 Jun 2010 18:03:10 -0400

Add IXP_ASSERT_VERSION macro.

Diffstat:
include/ixp.h | 44++++++++++++++++++++++++++++++++++++++------
lib/libixp/convert.c | 2++
man/IXP_ASSERT_VERSION.3 | 23+++++++++++++++++++++++
man/targets.mk | 1+
util/grepdoc | 6+++++-
5 files changed, 69 insertions(+), 7 deletions(-)

diff --git a/include/ixp.h b/include/ixp.h @@ -7,17 +7,49 @@ #include <sys/types.h> #include <sys/select.h> -#define IXP_API 127 +/** + * Macro: IXP_API + * Macro: IXP_NEEDAPI + * Macro: IXP_MAXAPI + * Macro: IXP_ASSERT_VERSION + * + * IXP_API contains the current libixp API revision number. + * + * IXP_NEEDAPI, if defined before ixp.h is included, directs the + * header to present an older version of the libixp API. This allows + * code written for older versions of libixp to compile against + * newer versions without modification. It does not, however, ensure + * that it will link against a different version of libixp than the + * ixp.h header belongs to. + * + * IXP_MAXAPI, if defined before ixp.h is included, prevents code + * from compiling with a newer version of libixp than specified. + * + * When inserted into any function, IXP_ASSERT_VERSION ensures that + * the resulting object will fail to link link against any version + * of libixp with a different API version than it was compiled + * against. + */ +#define IXP_API 129 +#ifndef IXP_NEEDAPI +#define IXP_NEEDAPI IXP_API +#endif +#ifndef IXP_MAXAPI +#define IXP_MAXAPI IXP_API +#endif +#define _IXP_ASSERT_VERSION ixp_version_##129##_required +#define IXP_ASSERT_VERSION do _IXP_ASSERT_VERSION = 0; while(0) +extern int _IXP_ASSERT_VERSION; /* Gunk */ -#if defined(IXP_NEEDAPI) && IXP_API < IXP_NEEDAPI +#if IXP_API < IXP_NEEDAPI # error A newer version of libixp is needed for this compilation. #endif -#if defined(IXP_MAXAPI) && IXP_API > IXP_MAXAPI +#if IXP_API > IXP_MAXAPI # warning This version of libixp has a newer API than this compilation requires. #endif -#if defined(IXP_NEEDAPI) && IXP_NEEDAPI < 127 +#if IXP_NEEDAPI < 127 # undef ushort # undef ulong # undef vlong @@ -372,7 +404,7 @@ struct IxpFTWStat { IxpFHdr hdr; IxpStat stat; }; -#if defined(IXP_NEEDAPI) && IXP_NEEDAPI <= 89 +#if IXP_NEEDAPI <= 89 /* from fcall(3) in plan9port */ typedef struct IxpFcall IxpFcall; /* Deprecated */ struct IxpFcall { /* Deprecated */ @@ -735,7 +767,7 @@ void ixp_werrstr(const char*, ...); void ixp_respond(Ixp9Req*, const char *err); void ixp_serve9conn(IxpConn*); -#if defined(IXP_NEEDAPI) && IXP_NEEDAPI < 127 +#if IXP_NEEDAPI < 127 # define respond ixp_respond # define serve_9pcon ixp_serve9pconn #endif diff --git a/lib/libixp/convert.c b/lib/libixp/convert.c @@ -6,6 +6,8 @@ #include <string.h> #include "ixp_local.h" +int _IXP_ASSERT_VERSION; + enum { SByte = 1, SWord = 2, diff --git a/man/IXP_ASSERT_VERSION.3 b/man/IXP_ASSERT_VERSION.3 @@ -0,0 +1,23 @@ +.TH "IXP_ASSERT_VERSION" 3 "2010 Jun" "libixp Manual" + +.SH NAME +.P +IXP_ASSERT_VERSION + +.SH SYNOPSIS +.nf + #include <ixp.h> + + #define IXP_ASSERT_VERSION ... +.fi + +.SH DESCRIPTION +.P +When inserted into any function, this macro ensures that the +object will fail to link link against any version of libixp with +a different API version than it was compiled against. + + +.\" man code generated by txt2tags 2.5 (http://txt2tags.sf.net) +.\" cmdline: txt2tags -o- IXP_ASSERT_VERSION.man3 + diff --git a/man/targets.mk b/man/targets.mk @@ -1,4 +1,5 @@ MANPAGES = \ + 'IXP_API.3 IXP_NEEDAPI.3 IXP_MAXAPI.3 IXP_ASSERT_VERSION.3' \ 'IxpFcall.3 IxpFType.3 IxpFAttach.3 IxpFError.3 IxpFHdr.3 IxpFIO.3 IxpFRAuth.3 IxpFROpen.3 IxpFRStat.3 IxpFRWalk.3 IxpFTCreate.3 IxpFTFlush.3 IxpFTWStat.3 IxpFTWalk.3 IxpFVersion.3' \ 'IxpFid.3' \ 'IxpThread.3 IxpMutex.3 IxpRWLock.3 IxpRendez.3 ixp_thread.3' \ diff --git a/util/grepdoc b/util/grepdoc @@ -56,6 +56,10 @@ for my $f(@h) { $headers{$1} = $f; push @{$protos{$1}}, $& unless $& =~ m{\Q/* Deprecated */}; } + while(m/^\s*#\s*define\s+(\w+)((?:\(.*?\))?)/gm) { + $headers{$1} = $f; + push @{$protos{$1}}, "#define $1$2 ..."; + } while(m/^(?:enum|struct|union)\s+(\w+).*?^\}/gsm) { $headers{$1} = $f; my $proto = \@{$protos{$1}}; @@ -89,7 +93,7 @@ while(m{(?<=/\*\*\n)(?:[^*]|\*[^/])+}g) { s{^(\w+:.*?)\n\n}{ $header = $1; - $header =~ s{^(?:Function|Type|Variable): (\w+)}{ + $header =~ s{^(?:Function|Type|Variable|Macro): (\w+)}{ push @names, $1; join("\n", @{$protos{$1} or [$1]}) . "\n" }gem;