1 /* Common extra functions.
2 Copyright (C) 2016-2017 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 /* This header file should only contain definitions compatible with
20 C90. (Using __attribute__ is fine because <features.h> provides a
27 #include <sys/cdefs.h>
31 /* Write a message to standard output. Can be used in signal
33 void write_message (const char *message
) __attribute__ ((nonnull (1)));
35 /* Avoid all the buffer overflow messages on stderr. */
36 void ignore_stderr (void);
38 /* Set fortification error handler. Used when tests want to verify that bad
39 code is caught by the library. */
40 void set_fortify_handler (void (*handler
) (int sig
));
42 /* Report an out-of-memory error for the allocation of SIZE bytes in
43 FUNCTION, terminating the process. */
44 void oom_error (const char *function
, size_t size
)
45 __attribute__ ((nonnull (1)));
47 /* Return a pointer to a memory region of SIZE bytes. The memory is
48 initialized to zero and will be shared with subprocesses (across
49 fork). The returned pointer must be freed using
50 support_shared_free; it is not compatible with the malloc
52 void *support_shared_allocate (size_t size
);
54 /* Deallocate a pointer returned by support_shared_allocate. */
55 void support_shared_free (void *);
57 /* Write CONTENTS to the file PATH. Create or truncate the file as
58 needed. The file mode is 0666 masked by the umask. Terminate the
60 void support_write_file_string (const char *path
, const char *contents
);
62 /* Error-checking wrapper functions which terminate the process on
65 void *xmalloc (size_t) __attribute__ ((malloc
));
66 void *xcalloc (size_t n
, size_t s
) __attribute__ ((malloc
));
67 void *xrealloc (void *p
, size_t n
);
68 char *xasprintf (const char *format
, ...)
69 __attribute__ ((format (printf
, 1, 2), malloc
));
70 char *xstrdup (const char *);
71 char *xstrndup (const char *, size_t);
75 #endif /* SUPPORT_H */