Annotation of tme/acinclude.m4, revision 1.1.1.1

1.1       root        1: dnl $Id: acinclude.m4,v 1.4 2003/05/17 20:33:36 fredette Exp $
                      2: 
                      3: dnl acinclude.m4 - additional tme autoconf macros:
                      4: 
                      5: dnl Copyright (c) 2001, 2003 Matt Fredette
                      6: dnl All rights reserved.
                      7: dnl
                      8: dnl Redistribution and use in source and binary forms, with or without
                      9: dnl modification, are permitted provided that the following conditions
                     10: dnl are met:
                     11: dnl 1. Redistributions of source code must retain the above copyright
                     12: dnl    notice, this list of conditions and the following disclaimer.
                     13: dnl 2. Redistributions in binary form must reproduce the above copyright
                     14: dnl    notice, this list of conditions and the following disclaimer in the
                     15: dnl    documentation and/or other materials provided with the distribution.
                     16: dnl 3. All advertising materials mentioning features or use of this software
                     17: dnl    must display the following acknowledgement:
                     18: dnl      This product includes software developed by Matt Fredette.
                     19: dnl 4. The name of the author may not be used to endorse or promote products
                     20: dnl    derived from this software without specific prior written permission.
                     21: dnl
                     22: dnl THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     23: dnl IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
                     24: dnl WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
                     25: dnl DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
                     26: dnl INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
                     27: dnl (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
                     28: dnl SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     29: dnl HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
                     30: dnl STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
                     31: dnl ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     32: dnl POSSIBILITY OF SUCH DAMAGE.
                     33: 
                     34: dnl AC_CHECK_ALIGNOF(BITS)
                     35: AC_DEFUN(AC_CHECK_ALIGNOF,
                     36: [changequote(<<, >>)dnl
                     37: dnl The name to #define.
                     38: define(<<AC_TYPE_NAME>>, translit(alignof_int$1_t, [a-z *], [A-Z_P]))dnl
                     39: dnl The cache variable name.
                     40: define(<<AC_CV_NAME>>, translit(ac_cv_alignof_int$1_t, [ *], [_p]))dnl
                     41: changequote([, ])dnl
                     42: AC_MSG_CHECKING(minimum alignment of int$1_t)
                     43: AC_CACHE_VAL(AC_CV_NAME,
                     44: [AC_TRY_RUN([#include <stdio.h>
                     45: #include <sys/types.h>
                     46: main()
                     47: {
                     48: #if (SIZEOF_SHORT * 8) == $1
                     49: #define _type short
                     50: #elif (SIZEOF_INT * 8) == $1
                     51: #define _type int
                     52: #else
                     53: #define _type long
                     54: #endif
                     55:   char try_align_buffer[sizeof(_type) * 2];
                     56:   int min_align, try_align, status;
                     57:   _type value;
                     58:   FILE *f=fopen("conftestval", "w");
                     59:   if (!f) exit(1);
                     60:   min_align = sizeof(_type);
                     61:   for(try_align = sizeof(_type); try_align-- > 1;) {
                     62:     switch(fork()) {
                     63:     case -1: exit(1);
                     64:     case 0: value = *((_type *) &try_align_buffer[try_align]); 
                     65:       fprintf(stderr, "%d\n", (int) value); exit(0);
                     66:     default: break;
                     67:     }
                     68:     wait(&status);
                     69:     if (!status && try_align < min_align) {
                     70:       min_align = try_align;
                     71:     }
                     72:   }
                     73:   fprintf(f, "%d\n", min_align * 8);
                     74:   exit(0);
                     75: }], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=$1, AC_CV_NAME=$1)])dnl
                     76: AC_CV_NAME=`expr $AC_CV_NAME / 8`
                     77: AC_MSG_RESULT($AC_CV_NAME)
                     78: AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [Define to the minimum alignment, in bytes, of int$1_t.])
                     79: undefine([AC_TYPE_NAME])dnl
                     80: undefine([AC_CV_NAME])dnl
                     81: ])
                     82: 
                     83: dnl AC_CHECK_SHIFTMAX(BITS)
                     84: AC_DEFUN(AC_CHECK_SHIFTMAX,
                     85: [changequote(<<, >>)dnl
                     86: dnl The name to #define.
                     87: define(<<AC_TYPE_NAME>>, translit(shiftmax_int$1_t, [a-z *], [A-Z_P]))dnl
                     88: dnl The cache variable name.
                     89: define(<<AC_CV_NAME>>, translit(ac_cv_shiftmax_int$1_t, [ *], [_p]))dnl
                     90: changequote([, ])dnl
                     91: AC_MSG_CHECKING(maximum shift count for int$1_t)
                     92: AC_CACHE_VAL(AC_CV_NAME,
                     93: [AC_TRY_RUN([#include <stdio.h>
                     94: #include <sys/types.h>
                     95: main()
                     96: {
                     97: #if 8 == $1
                     98: #define _type char
                     99: #elif (SIZEOF_SHORT * 8) == $1
                    100: #define _type short
                    101: #elif (SIZEOF_INT * 8) == $1
                    102: #define _type int
                    103: #elif (SIZEOF_LONG * 8) == $1
                    104: #define _type long
                    105: #endif
                    106:   _type center, right, left;
                    107:   unsigned int shift, max_shift;
                    108:   FILE *f=fopen("conftestval", "w");
                    109:   if (!f) exit(1);
                    110:   center = 3 << ((sizeof(center) * 4) - 1);
                    111:   max_shift = 2047;
                    112:   for (shift = (sizeof(center) * 8);
                    113:        shift < 2048;
                    114:        shift <<= 1) {
                    115:     right = (center >> shift);
                    116:     left = (center << shift);
                    117:     if (right != 0
                    118:        || left != 0) {
                    119:       right = (center >> (shift | 1));
                    120:       left = (center << (shift | 1));
                    121:       max_shift = ((right == (center >> 1)
                    122:                    && left == (center << 1))
                    123:                   ? shift - 1
                    124:                   : (sizeof(center) * 8) - 1);
                    125:       break;
                    126:     }
                    127:   }
                    128:   fprintf(f, "%d\n", max_shift + 1);
                    129:   exit(0);
                    130: }], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=$1, AC_CV_NAME=$1)])dnl
                    131: AC_CV_NAME=`expr $AC_CV_NAME - 1`
                    132: AC_MSG_RESULT($AC_CV_NAME)
                    133: AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [Define to the maximum shift count for a int$1_t.])
                    134: undefine([AC_TYPE_NAME])dnl
                    135: undefine([AC_CV_NAME])dnl
                    136: ])
                    137: 
                    138: dnl The AC_HEADER_CHECK_PROTOTYPE, AC_HEADER_CHECK_PROTOTYPES,
                    139: dnl and AC_SYS_SOCKADDR_SA_LEN macros bear the following copyright:
                    140: dnl
                    141: dnl Copyright (C) 1997,1998,1999 by the Massachusetts Institute of Technology,
                    142: dnl Cambridge, MA, USA.  All Rights Reserved.
                    143: dnl
                    144: dnl This software is being provided to you, the LICENSEE, by the
                    145: dnl Massachusetts Institute of Technology (M.I.T.) under the following
                    146: dnl license.  By obtaining, using and/or copying this software, you agree
                    147: dnl that you have read, understood, and will comply with these terms and
                    148: dnl conditions:
                    149: dnl
                    150: dnl WITHIN THOSE CONSTRAINTS, permission to use, copy, modify and distribute
                    151: dnl this software and its documentation for any purpose and without fee or
                    152: dnl royalty is hereby granted, provided that you agree to comply with the
                    153: dnl following copyright notice and statements, including the disclaimer, and
                    154: dnl that the same appear on ALL copies of the software and documentation,
                    155: dnl including modifications that you make for internal use or for
                    156: dnl distribution:
                    157: dnl
                    158: dnl THIS SOFTWARE IS PROVIDED "AS IS", AND M.I.T. MAKES NO REPRESENTATIONS
                    159: dnl OR WARRANTIES, EXPRESS OR IMPLIED.  By way of example, but not
                    160: dnl limitation, M.I.T. MAKES NO REPRESENTATIONS OR WARRANTIES OF
                    161: dnl MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF
                    162: dnl THE LICENSED SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY
                    163: dnl PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
                    164: dnl
                    165: dnl The name of the Massachusetts Institute of Technology or M.I.T. may NOT
                    166: dnl be used in advertising or publicity pertaining to distribution of the
                    167: dnl software.  Title to copyright in this software and any associated
                    168: dnl documentation shall at all times remain with M.I.T., and USER agrees to
                    169: dnl preserve same.
                    170: 
                    171: dnl AC_HEADER_CHECK_PROTOTYPE(FUNCTION, INCLUDES, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
                    172: AC_DEFUN(AC_HEADER_CHECK_PROTOTYPE, 
                    173: [AC_MSG_CHECKING([for a prototype for $1])
                    174: AC_CACHE_VAL(ac_cv_proto_$1,
                    175: [AC_TRY_COMPILE($2 [
                    176: struct bonch { int a, b; };
                    177: struct bonch $1();
                    178: ], , eval "ac_cv_proto_$1=no", eval "ac_cv_proto_$1=yes")])
                    179: if eval "test \"`echo '$ac_cv_proto_'$1`\" = yes"; then
                    180:   AC_MSG_RESULT(yes)
                    181:   ifelse([$3], , :, [$3])
                    182: else
                    183:   AC_MSG_RESULT(no)
                    184: ifelse([$4], , , [$4
                    185: ])dnl
                    186: fi
                    187: ])
                    188: 
                    189: dnl AC_HEADER_CHECK_PROTOTYPES(INCLUDES, FUNCTION...)
                    190: AC_DEFUN(AC_HEADER_CHECK_PROTOTYPES,
                    191: [for ac_func in $2
                    192: do
                    193: AC_HEADER_CHECK_PROTOTYPE($ac_func, $1, 
                    194: [changequote(, )dnl
                    195:   ac_tr_func=PROTO_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
                    196: changequote([, ])dnl
                    197:   AC_DEFINE_UNQUOTED($ac_tr_func)])dnl
                    198: done
                    199: ])
                    200: 
                    201: dnl AC_SYS_SOCKADDR_SA_LEN
                    202: AC_DEFUN(AC_SYS_SOCKADDR_SA_LEN,
                    203: [AC_MSG_CHECKING([for sa_len in struct sockaddr])
                    204: AC_CACHE_VAL(ac_cv_sys_sockaddr_sa_len,
                    205: [AC_TRY_COMPILE([
                    206: #include <sys/types.h>
                    207: #include <sys/socket.h>
                    208: ], [
                    209: int length;
                    210: struct sockaddr sock;
                    211: length = sock.sa_len;
                    212: ], ac_cv_sys_sockaddr_sa_len=yes, ac_cv_sys_sockaddr_sa_len=no)])dnl
                    213: if test $ac_cv_sys_sockaddr_sa_len = yes; then
                    214:   AC_MSG_RESULT(yes)
                    215:   AC_DEFINE_UNQUOTED(HAVE_SOCKADDR_SA_LEN, [], [Define if your struct sockaddr has sa_len.])
                    216: else
                    217:   AC_MSG_RESULT(no)
                    218: fi
                    219: ])dnl

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.