summaryrefslogtreecommitdiffstats
path: root/config/auto-aux/longlong.c
blob: e18f9e28f945a21fce88fa6c7c1c1e22c075f1c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/***********************************************************************/
/*                                                                     */
/*                                OCaml                                */
/*                                                                     */
/*            Xavier Leroy, projet Cristal, INRIA Rocquencourt         */
/*                                                                     */
/*  Copyright 1996 Institut National de Recherche en Informatique et   */
/*  en Automatique.  All rights reserved.  This file is distributed    */
/*  under the terms of the GNU Library General Public License, with    */
/*  the special exception on linking described in file ../../LICENSE.  */
/*                                                                     */
/***********************************************************************/

#include <stdio.h>
#include <string.h>

/* Check for the availability of "long long" type as per ISO C9X */

/* Meaning of return code:
     0   long long OK, printf with %ll
     1   long long OK, printf with %q
     2   long long OK, no printf
     3   long long not suitable */

int main(int argc, char **argv)
{
  long long l;
  unsigned long long u;
  char buffer[64];

  if (sizeof(long long) != 8) return 3;
  l = 123456789123456789LL;
  buffer[0] = '\0';
  sprintf(buffer, "%lld", l);
  if (strcmp(buffer, "123456789123456789") == 0) return 0;
  /* the MacOS X library uses qd to format long longs */
  buffer[0] = '\0';
  sprintf (buffer, "%qd", l);
  if (strcmp (buffer, "123456789123456789") == 0) return 1;
  return 2;
}