From: Theodore Tso Date: Sat, 14 Feb 1998 08:18:56 +0000 (+0000) Subject: asn1buf.h (asn1buf_insert_octet): Use static inline function to define X-Git-Tag: krb5-1.1-beta1~816 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7a96456c8e81c48f4ce5a8a1ddca37e7fafec33b;p=krb5.git asn1buf.h (asn1buf_insert_octet): Use static inline function to define asn1_insert_octet, since the GCC specific hack we're using doesn't work on GCC compilers that also have Objective C enabled. asn1buf.c: define ASN1BUF_OMIT_INLINE_FUNCS before including asn1buf.h, since we don't want inline functions declared when we're defining the linkable version of the functions. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@10457 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/asn.1/ChangeLog b/src/lib/krb5/asn.1/ChangeLog index 63c9715fb..28ccda3f5 100644 --- a/src/lib/krb5/asn.1/ChangeLog +++ b/src/lib/krb5/asn.1/ChangeLog @@ -1,3 +1,14 @@ +Fri Feb 13 22:32:06 1998 Theodore Y. Ts'o + + * asn1buf.h (asn1buf_insert_octet): Use static inline function to + define asn1_insert_octet, since the GCC specific hack + we're using doesn't work on GCC compilers that also have + Objective C enabled. + + * asn1buf.c: define ASN1BUF_OMIT_INLINE_FUNCS before including + asn1buf.h, since we don't want inline functions declared + when we're defining the linkable version of the functions. + Mon Feb 2 17:02:29 1998 Theodore Ts'o * Makefile.in: Define BUILDTOP and thisconfigdir in the Makefile diff --git a/src/lib/krb5/asn.1/asn1buf.c b/src/lib/krb5/asn.1/asn1buf.c index c7226a11d..30dad8b49 100644 --- a/src/lib/krb5/asn.1/asn1buf.c +++ b/src/lib/krb5/asn.1/asn1buf.c @@ -48,7 +48,9 @@ but no further. (The bound should move out in response to being crossed by next.)) */ +#define ASN1BUF_OMIT_INLINE_FUNCS #include "asn1buf.h" +#undef ASN1BUF_OMIT_INLINE_FUNCS #include asn1_error_code asn1buf_create(buf) diff --git a/src/lib/krb5/asn.1/asn1buf.h b/src/lib/krb5/asn.1/asn1buf.h index 1aad777cb..8103b9e03 100644 --- a/src/lib/krb5/asn.1/asn1buf.h +++ b/src/lib/krb5/asn.1/asn1buf.h @@ -9,6 +9,57 @@ typedef struct code_buffer_rep { char *base, *bound, *next; } asn1buf; + +/**************** Private Procedures ****************/ + +int asn1buf_size + PROTOTYPE((const asn1buf *buf)); +/* requires *buf has been created and not destroyed + effects Returns the total size + PROTOTYPE((in octets) of buf's octet buffer. */ +#define asn1buf_size(buf) \ + (((buf) == NULL || (buf)->base == NULL) \ + ? 0 \ + : ((buf)->bound - (buf)->base + 1)) + +int asn1buf_free + PROTOTYPE((const asn1buf *buf)); +/* requires *buf is allocated + effects Returns the number of unused, allocated octets in *buf. */ +#define asn1buf_free(buf) \ + (((buf) == NULL || (buf)->base == NULL) \ + ? 0 \ + : ((buf)->bound - (buf)->next + 1)) + + +asn1_error_code asn1buf_ensure_space + PROTOTYPE((asn1buf *buf, const int amount)); +/* requires *buf is allocated + modifies *buf + effects If buf has less than amount octets of free space, then it is + expanded to have at least amount octets of free space. + Returns ENOMEM memory is exhausted. */ +#define asn1buf_ensure_space(buf,amount) \ + ((asn1buf_free(buf) < (amount)) \ + ? (asn1buf_expand((buf), (amount)-asn1buf_free(buf))) \ + : 0) + + +asn1_error_code asn1buf_expand + PROTOTYPE((asn1buf *buf, int inc)); +/* requires *buf is allocated + modifies *buf + effects Expands *buf by allocating space for inc more octets. + Returns ENOMEM if memory is exhausted. */ + +int asn1buf_len + PROTOTYPE((const asn1buf *buf)); +/* requires *buf is allocated + effects Returns the length of the encoding in *buf. */ +#define asn1buf_len(buf) ((buf)->next - (buf)->base) + +/****** End of private procedures *****/ + /* Overview @@ -82,11 +133,19 @@ asn1_error_code asn1buf_insert_octet /* requires *buf is allocated effects Inserts o into the buffer *buf, expanding the buffer if necessary. Returns ENOMEM memory is exhausted. */ -#if __GNUC__ >= 2 -#define asn1buf_insert_octet(BUF,O) \ - (asn1buf_ensure_space ((BUF),1) \ - ? /* leave this empty -- gcc returns value of first operand */ \ - : (*(BUF)->next++ = (O), 0)) +#if ((__GNUC__ >= 2) && !defined(ASN1BUF_OMIT_INLINE_FUNCS)) +extern inline asn1_error_code asn1buf_insert_octet(buf, o) + asn1buf * buf; + const int o; +{ + asn1_error_code retval; + + retval = asn1buf_ensure_space(buf,1); + if(retval) return retval; + *(buf->next) = (char)o; + (buf->next)++; + return 0; +} #endif asn1_error_code asn1buf_insert_octetstring @@ -158,52 +217,4 @@ int asn1buf_remains modifies *buf effects Returns the number of unprocessed octets remaining in *buf. */ -/**************** Private Procedures ****************/ - -int asn1buf_size - PROTOTYPE((const asn1buf *buf)); -/* requires *buf has been created and not destroyed - effects Returns the total size - PROTOTYPE((in octets) of buf's octet buffer. */ -#define asn1buf_size(buf) \ - (((buf) == NULL || (buf)->base == NULL) \ - ? 0 \ - : ((buf)->bound - (buf)->base + 1)) - -int asn1buf_free - PROTOTYPE((const asn1buf *buf)); -/* requires *buf is allocated - effects Returns the number of unused, allocated octets in *buf. */ -#define asn1buf_free(buf) \ - (((buf) == NULL || (buf)->base == NULL) \ - ? 0 \ - : ((buf)->bound - (buf)->next + 1)) - - -asn1_error_code asn1buf_ensure_space - PROTOTYPE((asn1buf *buf, const int amount)); -/* requires *buf is allocated - modifies *buf - effects If buf has less than amount octets of free space, then it is - expanded to have at least amount octets of free space. - Returns ENOMEM memory is exhausted. */ -#define asn1buf_ensure_space(buf,amount) \ - ((asn1buf_free(buf) < (amount)) \ - ? (asn1buf_expand((buf), (amount)-asn1buf_free(buf))) \ - : 0) - - -asn1_error_code asn1buf_expand - PROTOTYPE((asn1buf *buf, int inc)); -/* requires *buf is allocated - modifies *buf - effects Expands *buf by allocating space for inc more octets. - Returns ENOMEM if memory is exhausted. */ - -int asn1buf_len - PROTOTYPE((const asn1buf *buf)); -/* requires *buf is allocated - effects Returns the length of the encoding in *buf. */ -#define asn1buf_len(buf) ((buf)->next - (buf)->base) - #endif