(nis_list): Don't try the next server if network is unreachable.
[glibc/history.git] / elf / dl-misc.c
blobd5b1464a6b9a49377a81a532e94e46f3d74aaba8
1 /* Miscellaneous support functions for dynamic linker
2 Copyright (C) 1997 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 Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 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 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
20 #include <assert.h>
21 #include <fcntl.h>
22 #include <unistd.h>
23 #include <stdarg.h>
24 #include <string.h>
25 #include <sys/mman.h>
26 #include <sys/stat.h>
28 #ifndef MAP_ANON
29 /* This is the only dl-sysdep.c function that is actually needed at run-time
30 by _dl_map_object. */
32 int
33 _dl_sysdep_open_zero_fill (void)
35 return __open ("/dev/zero", O_RDONLY);
37 #endif
39 /* Read the whole contents of FILE into new mmap'd space with given
40 protections. *SIZEP gets the size of the file. */
42 void *
43 _dl_sysdep_read_whole_file (const char *file, size_t *sizep, int prot)
45 void *result;
46 struct stat st;
47 int fd = __open (file, O_RDONLY);
48 if (fd < 0)
49 return NULL;
50 if (__fxstat (_STAT_VER, fd, &st) < 0)
51 result = NULL;
52 else
54 /* Map a copy of the file contents. */
55 result = __mmap (0, st.st_size, prot,
56 #ifdef MAP_COPY
57 MAP_COPY
58 #else
59 MAP_PRIVATE
60 #endif
61 #ifdef MAP_FILE
62 | MAP_FILE
63 #endif
64 , fd, 0);
65 if (result == (void *) -1)
66 result = NULL;
67 else
68 *sizep = st.st_size;
70 __close (fd);
71 return result;
75 void
76 _dl_sysdep_fatal (const char *msg, ...)
78 va_list ap;
80 va_start (ap, msg);
83 size_t len = strlen (msg);
84 __write (STDERR_FILENO, msg, len);
85 msg = va_arg (ap, const char *);
86 } while (msg);
87 va_end (ap);
89 _exit (127);
93 void
94 _dl_sysdep_error (const char *msg, ...)
96 va_list ap;
98 va_start (ap, msg);
101 size_t len = strlen (msg);
102 __write (STDERR_FILENO, msg, len);
103 msg = va_arg (ap, const char *);
104 } while (msg);
105 va_end (ap);
109 void
110 _dl_sysdep_message (const char *msg, ...)
112 va_list ap;
114 va_start (ap, msg);
117 size_t len = strlen (msg);
118 __write (STDOUT_FILENO, msg, len);
119 msg = va_arg (ap, const char *);
120 } while (msg);
121 va_end (ap);