Debian Codegraph @

m4/ssize_t.m4

raw
1 # ssize_t.m4
2 # serial 6
3 dnl Copyright (C) 2001-2003, 2006, 2010-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7 dnl This file is offered as-is, without any warranty.
8
9 dnl From Bruno Haible.
10 dnl Define ssize_t if it does not already exist.
11
12 AC_DEFUN([gt_TYPE_SSIZE_T],
13 [
14 AC_CACHE_CHECK([for ssize_t], [gl_cv_ssize_t],
15 [AC_COMPILE_IFELSE(
16 [AC_LANG_PROGRAM(
17 [[#include <sys/types.h>]],
18 [[int x = sizeof (ssize_t *) + sizeof (ssize_t);
19 return !x;]])],
20 [gl_cv_ssize_t=yes], [gl_cv_ssize_t=no])])
21 if test $gl_cv_ssize_t = no; then
22 dnl On 64-bit native Windows, ssize_t needs to be defined as 'long long',
23 dnl for consistency with the 64-bit size_t.
24 AC_CACHE_CHECK([whether size_t is wider than 'long'], [gl_cv_size_t_large],
25 [AC_COMPILE_IFELSE(
26 [AC_LANG_PROGRAM(
27 [[#include <sys/types.h>
28 typedef int array [2 * (sizeof (size_t) > sizeof (long)) - 1];
29 ]])],
30 [gl_cv_size_t_large=yes], [gl_cv_size_t_large=no])])
31 if test $gl_cv_size_t_large = yes; then
32 gl_def_ssize_t='long long'
33 else
34 gl_def_ssize_t='long'
35 fi
36 AC_DEFINE_UNQUOTED([ssize_t], [$gl_def_ssize_t],
37 [Define as a signed type of the same size as size_t.])
38 fi
39 ])