Debian Codegraph @

m4/ssize_t.m4

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