Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c34ed86

Browse files
committed
Allow long long on BSDI.
1 parent 6d3a548 commit c34ed86

File tree

2 files changed

+47
-4
lines changed

2 files changed

+47
-4
lines changed

src/configure.in

+37-1
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,43 @@ int does_int64_work()
606606
main() {
607607
exit(! does_int64_work());
608608
}],
609-
[AC_DEFINE(HAVE_LONG_LONG_INT_64) AC_MSG_RESULT(yes)],
609+
[AC_DEFINE(HAVE_LONG_LONG_INT_64_Ld) AC_MSG_RESULT(yes)],
610+
AC_MSG_RESULT(no),
611+
AC_MSG_RESULT(assuming not on target machine))
612+
613+
AC_TRY_RUN([#include <stdio.h>
614+
typedef long long int int64;
615+
#define INT64_FORMAT "%qd"
616+
617+
int64 a = 20000001;
618+
int64 b = 40000005;
619+
620+
int does_int64_work()
621+
{
622+
int64 c,d,e;
623+
char buf[100];
624+
625+
if (sizeof(int64) != 8)
626+
return 0; /* doesn't look like the right size */
627+
628+
/* we do perfunctory checks on multiply, divide, sprintf, sscanf */
629+
c = a * b;
630+
sprintf(buf, INT64_FORMAT, c);
631+
if (strcmp(buf, "800000140000005") != 0)
632+
return 0; /* either multiply or sprintf is busted */
633+
if (sscanf(buf, INT64_FORMAT, &d) != 1)
634+
return 0;
635+
if (d != c)
636+
return 0;
637+
e = d / b;
638+
if (e != a)
639+
return 0;
640+
return 1;
641+
}
642+
main() {
643+
exit(! does_int64_work());
644+
}],
645+
[AC_DEFINE(HAVE_LONG_LONG_INT_64_qd) AC_MSG_RESULT(yes)],
610646
AC_MSG_RESULT(no),
611647
AC_MSG_RESULT(assuming not on target machine))
612648

src/include/utils/int8.h

+10-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: int8.h,v 1.4 1998/09/05 01:19:38 thomas Exp $
9+
* $Id: int8.h,v 1.5 1998/09/10 03:27:09 momjian Exp $
1010
*
1111
* NOTES
1212
* These data types are supported on all 64-bit architectures, and may
@@ -29,11 +29,17 @@ typedef long int int64;
2929

3030
#define INT64_FORMAT "%ld"
3131
#else
32-
#ifdef HAVE_LONG_LONG_INT_64
32+
#ifdef HAVE_LONG_LONG_INT_64_Ld
3333
/* We have working support for "long long int", use that */
3434
typedef long long int int64;
3535

36-
#define INT64_FORMAT "%lld"
36+
#define INT64_FORMAT "%Ld"
37+
#else
38+
#ifdef HAVE_LONG_LONG_INT_64_qd
39+
/* We have working support for "long long int", use that */
40+
typedef long long int int64;
41+
42+
#define INT64_FORMAT "%qd"
3743
#else
3844
/* Won't actually work, but fall back to long int so that int8.c compiles */
3945
typedef long int int64;
@@ -42,6 +48,7 @@ typedef long int int64;
4248
#define INT64_IS_BUSTED
4349
#endif
4450
#endif
51+
#endif
4552

4653
extern int64 *int8in(char *str);
4754
extern char *int8out(int64 * val);

0 commit comments

Comments
 (0)