+// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2000-2003 Silicon Graphics, Inc.
* All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef GLOBAL_H
#include <config.h>
-#ifdef sgi
-#include <../../xfsprogs/include/irix.h>
+#ifdef HAVE_XFS_XFS_H
+#include <xfs/xfs.h>
#endif
#ifdef HAVE_XFS_LIBXFS_H
#ifdef STDC_HEADERS
#include <signal.h>
+#include <stdint.h>
#endif
#ifdef HAVE_STRINGS_H
#include <sys/param.h>
#endif
+#ifdef HAVE_LINUX_FALLOC_H
+#include <linux/falloc.h>
+
+#ifndef FALLOC_FL_KEEP_SIZE
+#define FALLOC_FL_KEEP_SIZE 0x01
+#endif
+
+#ifndef FALLOC_FL_PUNCH_HOLE
+#define FALLOC_FL_PUNCH_HOLE 0x02
+#endif
+
+#ifndef FALLOC_FL_NO_HIDE_STALE
+#define FALLOC_FL_NO_HIDE_STALE 0x04
+#endif
+
+#ifndef FALLOC_FL_COLLAPSE_RANGE
+#define FALLOC_FL_COLLAPSE_RANGE 0x08
+#endif
+
+#ifndef FALLOC_FL_ZERO_RANGE
+#define FALLOC_FL_ZERO_RANGE 0x10
#endif
+
+#ifndef FALLOC_FL_INSERT_RANGE
+#define FALLOC_FL_INSERT_RANGE 0x20
+#endif
+
+#endif /* HAVE_LINUX_FALLOC_H */
+
+#ifdef HAVE_SYS_MMAN_H
+#include <sys/mman.h>
+#endif
+
+static inline unsigned long long
+rounddown_64(unsigned long long x, unsigned int y)
+{
+ x /= y;
+ return x * y;
+}
+
+static inline unsigned long long
+roundup_64(unsigned long long x, unsigned int y)
+{
+ return rounddown_64(x + y - 1, y);
+}
+
+#endif /* GLOBAL_H */