1# $Id: sequence.m4,v 12.3 2005/11/24 00:49:24 bostic Exp $ 2 3# Try and configure sequence support. 4AC_DEFUN(AM_SEQUENCE_CONFIGURE, [ 5 AC_MSG_CHECKING([for 64-bit integral type support for sequences]) 6 7 db_cv_build_sequence="yes" 8 9 # Have to have found 64-bit types to support sequences. If we don't 10 # find the native types, we try and create our own. 11 if test "$ac_cv_type_int64_t" = "no" -a -z "$int64_decl"; then 12 db_cv_build_sequence="no" 13 fi 14 if test "$ac_cv_type_uint64_t" = "no" -a -z "$u_int64_decl"; then 15 db_cv_build_sequence="no" 16 fi 17 18 # Figure out what type is the right size, and set the format. 19 AC_SUBST(INT64_FMT) 20 AC_SUBST(UINT64_FMT) 21 db_cv_seq_type="no" 22 if test "$db_cv_build_sequence" = "yes" -a\ 23 "$ac_cv_sizeof_long" -eq "8"; then 24 db_cv_seq_type="long" 25 db_cv_seq_fmt='"%ld"' 26 db_cv_seq_ufmt='"%lu"' 27 INT64_FMT='#define INT64_FMT "%ld"' 28 UINT64_FMT='#define UINT64_FMT "%lu"' 29 else if test "$db_cv_build_sequence" = "yes" -a\ 30 "$ac_cv_sizeof_long_long" -eq "8"; then 31 db_cv_seq_type="long long" 32 db_cv_seq_fmt='"%lld"' 33 db_cv_seq_ufmt='"%llu"' 34 INT64_FMT='#define INT64_FMT "%lld"' 35 UINT64_FMT='#define UINT64_FMT "%llu"' 36 else 37 db_cv_build_sequence="no" 38 fi 39 fi 40 41 # Test to see if we can declare variables of the appropriate size 42 # and format them. If we're cross-compiling, all we get is a link 43 # test, which won't test for the appropriate printf format strings. 44 if test "$db_cv_build_sequence" = "yes"; then 45 AC_TRY_RUN([ 46 main() { 47 $db_cv_seq_type l; 48 unsigned $db_cv_seq_type u; 49 char buf@<:@100@:>@; 50 51 buf@<:@0@:>@ = 'a'; 52 l = 9223372036854775807LL; 53 (void)snprintf(buf, sizeof(buf), $db_cv_seq_fmt, l); 54 if (strcmp(buf, "9223372036854775807")) 55 return (1); 56 u = 18446744073709551615ULL; 57 (void)snprintf(buf, sizeof(buf), $db_cv_seq_ufmt, u); 58 if (strcmp(buf, "18446744073709551615")) 59 return (1); 60 return (0); 61 }],, [db_cv_build_sequence="no"], 62 AC_TRY_LINK(,[ 63 $db_cv_seq_type l; 64 unsigned $db_cv_seq_type u; 65 char buf@<:@100@:>@; 66 67 buf@<:@0@:>@ = 'a'; 68 l = 9223372036854775807LL; 69 (void)snprintf(buf, sizeof(buf), $db_cv_seq_fmt, l); 70 if (strcmp(buf, "9223372036854775807")) 71 return (1); 72 u = 18446744073709551615ULL; 73 (void)snprintf(buf, sizeof(buf), $db_cv_seq_ufmt, u); 74 if (strcmp(buf, "18446744073709551615")) 75 return (1); 76 return (0); 77 ],, [db_cv_build_sequence="no"])) 78 fi 79 if test "$db_cv_build_sequence" = "yes"; then 80 AC_SUBST(db_seq_decl) 81 db_seq_decl="typedef int64_t db_seq_t;"; 82 83 AC_DEFINE(HAVE_64BIT_TYPES) 84 AH_TEMPLATE(HAVE_64BIT_TYPES, 85 [Define to 1 if 64-bit types are available.]) 86 else 87 # It still has to compile, but it won't run. 88 db_seq_decl="typedef int db_seq_t;"; 89 fi 90 AC_MSG_RESULT($db_cv_build_sequence) 91]) 92