Blame support/support.h

Packit 6c4009
/* Common extra functions.
Packit 6c4009
   Copyright (C) 2016-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
/* This header file should only contain definitions compatible with
Packit 6c4009
   C90.  (Using __attribute__ is fine because <features.h> provides a
Packit 6c4009
   fallback.)  */
Packit 6c4009
Packit 6c4009
#ifndef SUPPORT_H
Packit 6c4009
#define SUPPORT_H
Packit 6c4009
Packit 6c4009
#include <stddef.h>
Packit 6c4009
#include <sys/cdefs.h>
Packit Service f9020f
/* For mode_t.  */
Packit Service f9020f
#include <sys/stat.h>
Packit Service f9020f
/* For ssize_t and off64_t.  */
Packit Service f9020f
#include <sys/types.h>
Packit 6c4009
Packit 6c4009
__BEGIN_DECLS
Packit 6c4009
Packit 6c4009
/* Write a message to standard output.  Can be used in signal
Packit 6c4009
   handlers.  */
Packit 6c4009
void write_message (const char *message) __attribute__ ((nonnull (1)));
Packit 6c4009
Packit 6c4009
/* Avoid all the buffer overflow messages on stderr.  */
Packit 6c4009
void ignore_stderr (void);
Packit 6c4009
Packit 6c4009
/* Set fortification error handler.  Used when tests want to verify that bad
Packit 6c4009
   code is caught by the library.  */
Packit 6c4009
void set_fortify_handler (void (*handler) (int sig));
Packit 6c4009
Packit 6c4009
/* Report an out-of-memory error for the allocation of SIZE bytes in
Packit 6c4009
   FUNCTION, terminating the process.  */
Packit 6c4009
void oom_error (const char *function, size_t size)
Packit 6c4009
  __attribute__ ((nonnull (1)));
Packit 6c4009
Packit 6c4009
/* Return a pointer to a memory region of SIZE bytes.  The memory is
Packit 6c4009
   initialized to zero and will be shared with subprocesses (across
Packit 6c4009
   fork).  The returned pointer must be freed using
Packit 6c4009
   support_shared_free; it is not compatible with the malloc
Packit 6c4009
   functions.  */
Packit 6c4009
void *support_shared_allocate (size_t size);
Packit 6c4009
Packit 6c4009
/* Deallocate a pointer returned by support_shared_allocate.  */
Packit 6c4009
void support_shared_free (void *);
Packit 6c4009
Packit 6c4009
/* Write CONTENTS to the file PATH.  Create or truncate the file as
Packit 6c4009
   needed.  The file mode is 0666 masked by the umask.  Terminate the
Packit 6c4009
   process on error.  */
Packit 6c4009
void support_write_file_string (const char *path, const char *contents);
Packit 6c4009
Packit 6c4009
/* Quote the contents of the byte array starting at BLOB, of LENGTH
Packit 6c4009
   bytes, in such a way that the result string can be included in a C
Packit 6c4009
   literal (in single/double quotes, without putting the quotes into
Packit 6c4009
   the result).  */
Packit 6c4009
char *support_quote_blob (const void *blob, size_t length);
Packit 6c4009
Packit Service cbe085
/* Quote the contents of the string, in such a way that the result
Packit Service 5bdb7c
   string can be included in a C literal (in single/double quotes,
Packit Service 5bdb7c
   without putting the quotes into the result).  */
Packit Service cbe085
char *support_quote_string (const char *);
Packit Service 5bdb7c
Packit Service f9020f
/* Returns non-zero if the file descriptor is a regular file on a file
Packit Service f9020f
   system which supports holes (that is, seeking and writing does not
Packit Service f9020f
   allocate storage for the range of zeros).  FD must refer to a
Packit Service f9020f
   regular file open for writing, and initially empty.  */
Packit Service f9020f
int support_descriptor_supports_holes (int fd);
Packit Service f9020f
Packit 6c4009
/* Error-checking wrapper functions which terminate the process on
Packit 6c4009
   error.  */
Packit 6c4009
Packit 6c4009
void *xmalloc (size_t) __attribute__ ((malloc));
Packit 6c4009
void *xcalloc (size_t n, size_t s) __attribute__ ((malloc));
Packit 6c4009
void *xrealloc (void *p, size_t n);
Packit Service aef6f8
void *xposix_memalign (size_t alignment, size_t n);
Packit 6c4009
char *xasprintf (const char *format, ...)
Packit 6c4009
  __attribute__ ((format (printf, 1, 2), malloc));
Packit 6c4009
char *xstrdup (const char *);
Packit 6c4009
char *xstrndup (const char *, size_t);
Packit Service 5ee691
char *xsetlocale (int category, const char *locale);
Packit Service 0b245c
Packit Service f9020f
/* These point to the TOP of the source/build tree, not your (or
Packit Service f9020f
   support's) subdirectory.  */
Packit Service f9020f
extern const char support_srcdir_root[];
Packit Service f9020f
extern const char support_objdir_root[];
Packit Service f9020f
Packit Service f9020f
/* Corresponds to the path to the runtime linker used by the testsuite,
Packit Service f9020f
   e.g. OBJDIR_PATH/elf/ld-linux-x86-64.so.2  */
Packit Service f9020f
extern const char support_objdir_elf_ldso[];
Packit Service f9020f
Packit Service f9020f
/* Corresponds to the --prefix= passed to configure.  */
Packit Service f9020f
extern const char support_install_prefix[];
Packit Service f9020f
/* Corresponds to the install's lib/ or lib64/ directory.  */
Packit Service f9020f
extern const char support_libdir_prefix[];
Packit Service 07c846
/* Corresponds to the install's bin/ directory.  */
Packit Service 07c846
extern const char support_bindir_prefix[];
Packit Service 5d5c26
/* Corresponds to the install's sbin/ directory.  */
Packit Service 01bccb
extern const char support_sbindir_prefix[];
Packit Service 8c1c84
/* Corresponds to the install's system /lib or /lib64 directory.  */
Packit Service 8c1c84
extern const char support_slibdir_prefix[];
Packit Service 01bccb
/* Corresponds to the install's sbin/ directory (without prefix).  */
Packit Service 5d5c26
extern const char support_install_rootsbindir[];
Packit Service 505274
/* Corresponds to the install's compiled locale directory.  */
Packit Service 505274
extern const char support_complocaledir_prefix[];
Packit Service f9020f
Packit Service 5c3bcc
/* Copies the file at the path FROM to TO.  If TO does not exist, it
Packit Service 5c3bcc
   is created.  If TO is a regular file, it is truncated before
Packit Service 5c3bcc
   copying.  The file mode is copied, but the permissions are not.  */
Packit Service 5c3bcc
extern void support_copy_file (const char *from, const char *to);
Packit Service 5c3bcc
Packit Service f9020f
extern ssize_t support_copy_file_range (int, off64_t *, int, off64_t *,
Packit Service f9020f
					size_t, unsigned int);
Packit Service f9020f
Packit 6c4009
__END_DECLS
Packit 6c4009
Packit 6c4009
#endif /* SUPPORT_H */