Debian Codegraph @

tools/gnulib/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
8 dnl From Bruno Haible.
9 dnl Define ssize_t if it does not already exist.
10
11 AC_DEFUN([gt_TYPE_SSIZE_T],
12 [
13 AC_CACHE_CHECK([for ssize_t], [gl_cv_ssize_t],
14 [AC_COMPILE_IFELSE(
15 [AC_LANG_PROGRAM(
16 [[#include <sys/types.h>]],
17 [[int x = sizeof (ssize_t *) + sizeof (ssize_t);
18 return !x;]])],
19 [gl_cv_ssize_t=yes], [gl_cv_ssize_t=no])])
20 if test $gl_cv_ssize_t = no; then
21 dnl On 64-bit native Windows, ssize_t needs to be defined as 'long long',
22 dnl for consistency with the 64-bit size_t.
23 AC_CACHE_CHECK([whether size_t is wider than 'long'], [gl_cv_size_t_large],
24 [AC_COMPILE_IFELSE(
25 [AC_LANG_PROGRAM(
26 [[#include <sys/types.h>
27 typedef int array [2 * (sizeof (size_t) > sizeof (long)) - 1];
28 ]])],
29 [gl_cv_size_t_large=yes], [gl_cv_size_t_large=no])])
30 if test $gl_cv_size_t_large = yes; then
31 gl_def_ssize_t='long long'
32 else
33 gl_def_ssize_t='long'
34 fi
35 AC_DEFINE_UNQUOTED([ssize_t], [$gl_def_ssize_t],
36 [Define as a signed type of the same size as size_t.])
37 fi
38 ])