Blame support/support.h

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