diff options
author | Keith Packard <keithp@keithp.com> | 2012-03-21 12:55:09 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2012-03-21 13:54:42 -0700 |
commit | 9838b7032ea9792bec21af424c53c07078636d21 (patch) | |
tree | b72d0827dac50f0f3b8eab29b3b7639546d735d7 /glx/indirect_util.c | |
parent | 75199129c603fc8567185ac31866c9518193cb78 (diff) |
Introduce a consistent coding style
This is strictly the application of the script 'x-indent-all.sh'
from util/modular. Compared to the patch that Daniel posted in
January, I've added a few indent flags:
-bap
-psl
-T PrivatePtr
-T pmWait
-T _XFUNCPROTOBEGIN
-T _XFUNCPROTOEND
-T _X_EXPORT
The typedefs were needed to make the output of sdksyms.sh match the
previous output, otherwise, the code is formatted badly enough that
sdksyms.sh generates incorrect output.
The generated code was compared with the previous version and found to
be essentially identical -- "assert" line numbers and BUILD_TIME were
the only differences found.
The comparison was done with this script:
dir1=$1
dir2=$2
for dir in $dir1 $dir2; do
(cd $dir && find . -name '*.o' | while read file; do
dir=`dirname $file`
base=`basename $file .o`
dump=$dir/$base.dump
objdump -d $file > $dump
done)
done
find $dir1 -name '*.dump' | while read dump; do
otherdump=`echo $dump | sed "s;$dir1;$dir2;"`
diff -u $dump $otherdump
done
Signed-off-by: Keith Packard <keithp@keithp.com>
Acked-by: Daniel Stone <daniel@fooishbar.org>
Acked-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'glx/indirect_util.c')
-rw-r--r-- | glx/indirect_util.c | 251 |
1 files changed, 117 insertions, 134 deletions
diff --git a/glx/indirect_util.c b/glx/indirect_util.c index 46a270695..a54f70aee 100644 --- a/glx/indirect_util.c +++ b/glx/indirect_util.c @@ -47,28 +47,25 @@ #include "indirect_table.h" #include "indirect_util.h" - #define __GLX_PAD(a) (((a)+3)&~3) extern xGLXSingleReply __glXReply; - GLint -__glGetBooleanv_variable_size( GLenum e ) +__glGetBooleanv_variable_size(GLenum e) { - if ( e == GL_COMPRESSED_TEXTURE_FORMATS ) { - GLint temp; + if (e == GL_COMPRESSED_TEXTURE_FORMATS) { + GLint temp; - CALL_GetIntegerv( GET_DISPATCH(), - (GL_NUM_COMPRESSED_TEXTURE_FORMATS, & temp) ); - return temp; + CALL_GetIntegerv(GET_DISPATCH(), + (GL_NUM_COMPRESSED_TEXTURE_FORMATS, &temp)); + return temp; } else { - return 0; + return 0; } } - /** * Get a properly aligned buffer to hold reply data. * @@ -77,36 +74,35 @@ __glGetBooleanv_variable_size( GLenum e ) * It also assumes that \c alignment is a power of two. */ void * -__glXGetAnswerBuffer( __GLXclientState * cl, size_t required_size, - void * local_buffer, size_t local_size, unsigned alignment ) +__glXGetAnswerBuffer(__GLXclientState * cl, size_t required_size, + void *local_buffer, size_t local_size, unsigned alignment) { - void * buffer = local_buffer; + void *buffer = local_buffer; const unsigned mask = alignment - 1; - if ( local_size < required_size ) { + if (local_size < required_size) { const size_t worst_case_size = required_size + alignment; - intptr_t temp_buf; - - if ( cl->returnBufSize < worst_case_size ) { - void * temp = realloc( cl->returnBuf, worst_case_size ); - - if ( temp == NULL ) { - return NULL; - } - - cl->returnBuf = temp; - cl->returnBufSize = worst_case_size; - } - - temp_buf = (intptr_t) cl->returnBuf; - temp_buf = (temp_buf + mask) & ~mask; - buffer = (void *) temp_buf; + intptr_t temp_buf; + + if (cl->returnBufSize < worst_case_size) { + void *temp = realloc(cl->returnBuf, worst_case_size); + + if (temp == NULL) { + return NULL; + } + + cl->returnBuf = temp; + cl->returnBufSize = worst_case_size; + } + + temp_buf = (intptr_t) cl->returnBuf; + temp_buf = (temp_buf + mask) & ~mask; + buffer = (void *) temp_buf; } return buffer; } - /** * Send a GLX reply to the client. * @@ -117,24 +113,23 @@ __glXGetAnswerBuffer( __GLXclientState * cl, size_t required_size, * harm to clients, but it does make the server-side code much more compact. */ void -__glXSendReply( ClientPtr client, const void * data, size_t elements, - size_t element_size, GLboolean always_array, CARD32 retval ) +__glXSendReply(ClientPtr client, const void *data, size_t elements, + size_t element_size, GLboolean always_array, CARD32 retval) { size_t reply_ints = 0; - if ( __glXErrorOccured() ) { + if (__glXErrorOccured()) { elements = 0; } - else if ( (elements > 1) || always_array ) { + else if ((elements > 1) || always_array) { reply_ints = bytes_to_int32(elements * element_size); } - __glXReply.length = reply_ints; - __glXReply.type = X_Reply; + __glXReply.length = reply_ints; + __glXReply.type = X_Reply; __glXReply.sequenceNumber = client->sequence; - __glXReply.size = elements; - __glXReply.retval = retval; - + __glXReply.size = elements; + __glXReply.retval = retval; /* It is faster on almost always every architecture to just copy the 8 * bytes, even when not necessary, than check to see of the value of @@ -142,15 +137,14 @@ __glXSendReply( ClientPtr client, const void * data, size_t elements, * harm. */ - (void) memcpy( & __glXReply.pad3, data, 8 ); - WriteToClient( client, sz_xGLXSingleReply, (char *) & __glXReply ); + (void) memcpy(&__glXReply.pad3, data, 8); + WriteToClient(client, sz_xGLXSingleReply, (char *) &__glXReply); - if ( reply_ints != 0 ) { - WriteToClient( client, reply_ints * 4, (char *) data ); + if (reply_ints != 0) { + WriteToClient(client, reply_ints * 4, (char *) data); } } - /** * Send a GLX reply to the client. * @@ -165,24 +159,23 @@ __glXSendReply( ClientPtr client, const void * data, size_t elements, * by the caller if necessary. */ void -__glXSendReplySwap( ClientPtr client, const void * data, size_t elements, - size_t element_size, GLboolean always_array, CARD32 retval ) +__glXSendReplySwap(ClientPtr client, const void *data, size_t elements, + size_t element_size, GLboolean always_array, CARD32 retval) { size_t reply_ints = 0; - if ( __glXErrorOccured() ) { + if (__glXErrorOccured()) { elements = 0; } - else if ( (elements > 1) || always_array ) { + else if ((elements > 1) || always_array) { reply_ints = bytes_to_int32(elements * element_size); } - __glXReply.length = bswap_32( reply_ints ); - __glXReply.type = X_Reply; - __glXReply.sequenceNumber = bswap_16( client->sequence ); - __glXReply.size = bswap_32( elements ); - __glXReply.retval = bswap_32( retval ); - + __glXReply.length = bswap_32(reply_ints); + __glXReply.type = X_Reply; + __glXReply.sequenceNumber = bswap_16(client->sequence); + __glXReply.size = bswap_32(elements); + __glXReply.retval = bswap_32(retval); /* It is faster on almost always every architecture to just copy the 8 * bytes, even when not necessary, than check to see of the value of @@ -190,81 +183,73 @@ __glXSendReplySwap( ClientPtr client, const void * data, size_t elements, * harm. */ - (void) memcpy( & __glXReply.pad3, data, 8 ); - WriteToClient( client, sz_xGLXSingleReply, (char *) & __glXReply ); + (void) memcpy(&__glXReply.pad3, data, 8); + WriteToClient(client, sz_xGLXSingleReply, (char *) &__glXReply); - if ( reply_ints != 0 ) { - WriteToClient( client, reply_ints * 4, (char *) data ); + if (reply_ints != 0) { + WriteToClient(client, reply_ints * 4, (char *) data); } } - static int -get_decode_index(const struct __glXDispatchInfo *dispatch_info, - unsigned opcode) +get_decode_index(const struct __glXDispatchInfo *dispatch_info, unsigned opcode) { int remaining_bits; int next_remain; - const int_fast16_t * const tree = dispatch_info->dispatch_tree; + const int_fast16_t *const tree = dispatch_info->dispatch_tree; int_fast16_t index; - remaining_bits = dispatch_info->bits; if (opcode >= (1U << remaining_bits)) { - return -1; + return -1; } - - index = 0; - for (/* empty */; remaining_bits > 0; remaining_bits = next_remain) { - unsigned mask; - unsigned child_index; - - /* Calculate the slice of bits used by this node. - * - * If remaining_bits = 8 and tree[index] = 3, the mask of just the - * remaining bits is 0x00ff and the mask for the remaining bits after - * this node is 0x001f. By taking 0x00ff & ~0x001f, we get 0x00e0. - * This masks the 3 bits that we would want for this node. - */ - - next_remain = remaining_bits - tree[index]; - mask = ((1 << remaining_bits) - 1) & - ~((1 << next_remain) - 1); - - - /* Using the mask, calculate the index of the opcode in the node. - * With that index, fetch the index of the next node. - */ - - child_index = (opcode & mask) >> next_remain; - index = tree[index + 1 + child_index]; - - - /* If the next node is an empty leaf, the opcode is for a non-existant - * function. We're done. - * - * If the next node is a non-empty leaf, look up the function pointer - * and return it. - */ - - if (index == EMPTY_LEAF) { - return -1; - } - else if (IS_LEAF_INDEX(index)) { - unsigned func_index; - - - /* The value stored in the tree for a leaf node is the base of - * the function pointers for that leaf node. The offset for the - * function for a particular opcode is the remaining bits in the - * opcode. - */ - - func_index = -index; - func_index += opcode & ((1 << next_remain) - 1); - return func_index; - } + index = 0; + for ( /* empty */ ; remaining_bits > 0; remaining_bits = next_remain) { + unsigned mask; + unsigned child_index; + + /* Calculate the slice of bits used by this node. + * + * If remaining_bits = 8 and tree[index] = 3, the mask of just the + * remaining bits is 0x00ff and the mask for the remaining bits after + * this node is 0x001f. By taking 0x00ff & ~0x001f, we get 0x00e0. + * This masks the 3 bits that we would want for this node. + */ + + next_remain = remaining_bits - tree[index]; + mask = ((1 << remaining_bits) - 1) & ~((1 << next_remain) - 1); + + /* Using the mask, calculate the index of the opcode in the node. + * With that index, fetch the index of the next node. + */ + + child_index = (opcode & mask) >> next_remain; + index = tree[index + 1 + child_index]; + + /* If the next node is an empty leaf, the opcode is for a non-existant + * function. We're done. + * + * If the next node is a non-empty leaf, look up the function pointer + * and return it. + */ + + if (index == EMPTY_LEAF) { + return -1; + } + else if (IS_LEAF_INDEX(index)) { + unsigned func_index; + + /* The value stored in the tree for a leaf node is the base of + * the function pointers for that leaf node. The offset for the + * function for a particular opcode is the remaining bits in the + * opcode. + */ + + func_index = -index; + func_index += opcode & ((1 << next_remain) - 1); + return func_index; + } } /* We should *never* get here!!! @@ -272,38 +257,36 @@ get_decode_index(const struct __glXDispatchInfo *dispatch_info, return -1; } - void * __glXGetProtocolDecodeFunction(const struct __glXDispatchInfo *dispatch_info, - int opcode, int swapped_version) + int opcode, int swapped_version) { const int func_index = get_decode_index(dispatch_info, opcode); - return (func_index < 0) - ? NULL - : (void *) dispatch_info->dispatch_functions[func_index][swapped_version]; + return (func_index < 0) + ? NULL + : (void *) dispatch_info-> + dispatch_functions[func_index][swapped_version]; } - int __glXGetProtocolSizeData(const struct __glXDispatchInfo *dispatch_info, - int opcode, __GLXrenderSizeData *data) + int opcode, __GLXrenderSizeData * data) { if (dispatch_info->size_table != NULL) { - const int func_index = get_decode_index(dispatch_info, opcode); + const int func_index = get_decode_index(dispatch_info, opcode); - if ((func_index >= 0) - && (dispatch_info->size_table[func_index][0] != 0)) { - const int var_offset = - dispatch_info->size_table[func_index][1]; + if ((func_index >= 0) + && (dispatch_info->size_table[func_index][0] != 0)) { + const int var_offset = dispatch_info->size_table[func_index][1]; - data->bytes = dispatch_info->size_table[func_index][0]; - data->varsize = (var_offset != ~0) - ? dispatch_info->size_func_table[var_offset] - : NULL; + data->bytes = dispatch_info->size_table[func_index][0]; + data->varsize = (var_offset != ~0) + ? dispatch_info->size_func_table[var_offset] + : NULL; - return 0; - } + return 0; + } } return -1; |