1 /* System dependent declarations.
3 Copyright (C) 1988-1989, 1992-1995, 1998, 2001-2002, 2004, 2006, 2009-2013,
4 2015-2025 Free Software Foundation, Inc.
6 This file is part of GNU DIFF.
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
25 #include <sys/types.h>
28 #include <stat-macros.h>
29 #include <stat-size.h>
30 #include <stat-time.h>
41 #ifndef _D_EXACT_NAMLEN
42 # define _D_EXACT_NAMLEN(dp) strlen ((dp)->d_name)
51 #include <stdckdint.h>
58 # define textdomain(Domainname) /* empty */
59 # undef bindtextdomain
60 # define bindtextdomain(Domainname, Dirname) /* empty */
63 #define _(msgid) gettext (msgid)
64 #define N_(msgid) msgid
69 #if !defined SIGCHLD && defined SIGCLD
70 # define SIGCHLD SIGCLD
73 #include <attribute.h>
77 #include <propername.h>
78 #include <same-inode.h>
82 /* Evaluate an assertion E that is guaranteed to be true.
83 E should not crash, loop forever, or have side effects. */
84 #if defined DDEBUG && !defined NDEBUG
85 /* Abort the program if E is false. */
87 # define dassert(e) assert (e)
89 /* The compiler can assume E, as behavior is undefined otherwise. */
90 # define dassert(e) assume (e)
94 # define SYSTEM_INLINE _GL_INLINE
97 _GL_INLINE_HEADER_BEGIN
99 /* Type used for fast comparison of several bytes at a time.
100 The type is a pointer to an incomplete struct,
101 so that its values are less likely to be misused.
102 This used to be uintmax_t, but changing it to the size of a pointer
103 made plain 'cmp' 90% faster (GCC 4.8.1, x86). */
106 typedef struct incomplete
*word
;
109 /* The signed integer type of a line number. Since files are read
110 into main memory, ptrdiff_t should be wide enough. pI is for
111 printing line numbers. */
113 typedef ptrdiff_t lin
;
114 #define LIN_MAX PTRDIFF_MAX
116 static_assert (LIN_MAX
== IDX_MAX
);
118 /* This section contains POSIX-compliant defaults for macros
119 that are meant to be overridden by hand in config.h as needed. */
121 #ifndef file_name_cmp
122 # define file_name_cmp strcmp
125 #ifndef initialize_main
126 # define initialize_main(argcp, argvp)
130 # define NULL_DEVICE "/dev/null"
133 #define STREQ(a, b) (strcmp (a, b) == 0)
135 /* Return the floor of the log base 2 of N. Return -1 if N is zero. */
136 SYSTEM_INLINE
int floor_log2 (idx_t n
)
138 static_assert (IDX_MAX
<= SIZE_MAX
);
140 int w
= stdc_bit_width (s
);
144 _GL_INLINE_HEADER_END
146 extern bool same_file (struct stat
const *, struct stat
const *)
148 extern off_t
stat_size (struct stat
const *)