[Glibc-bsd-commits] r4620 - trunk/glibc-ports/kfreebsd
Petr Salinger
ps-guest at alioth.debian.org
Mon Jul 8 12:47:39 UTC 2013
Author: ps-guest
Date: 2013-06-27 15:47:10 +0000 (Thu, 27 Jun 2013)
New Revision: 4620
Modified:
trunk/glibc-ports/kfreebsd/dl-osinfo.h
Log:
resync dl-osinfo.h with linux version
Modified: trunk/glibc-ports/kfreebsd/dl-osinfo.h
===================================================================
--- trunk/glibc-ports/kfreebsd/dl-osinfo.h 2013-06-27 09:30:58 UTC (rev 4619)
+++ trunk/glibc-ports/kfreebsd/dl-osinfo.h 2013-06-27 15:47:10 UTC (rev 4620)
@@ -17,28 +17,17 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include <string.h>
-#include <fcntl.h>
-#include <sys/sysctl.h>
-#include <sys/utsname.h>
#include <kernel-features.h>
+#include <dl-sysdep.h>
+#include <endian.h>
+#include <fcntl.h>
+#include <stdint.h>
+#include <not-cancel.h>
#ifndef MIN
# define MIN(a,b) (((a)<(b))?(a):(b))
#endif
-#ifdef SHARED
-/* This is the function used in the dynamic linker to print the fatal error
- message. */
-static inline void
-__attribute__ ((__noreturn__))
-dl_fatal (const char *str)
-{
- _dl_dprintf (2, str);
- _exit (1);
-}
-#endif
-
#define DL_SYSDEP_OSCHECK(FATAL) \
do { \
/* Test whether the kernel is new enough. This test is only performed \
@@ -64,22 +53,29 @@
static inline uintptr_t __attribute__ ((always_inline))
_dl_setup_stack_chk_guard (void *dl_random)
{
- uintptr_t ret;
-#ifdef ENABLE_STACKGUARD_RANDOMIZE
- int fd = __open ("/dev/urandom", O_RDONLY);
- if (fd >= 0)
+ union
+ {
+ uintptr_t num;
+ unsigned char bytes[sizeof (uintptr_t)];
+ } ret;
+
{
- ssize_t reslen = __read (fd, &ret, sizeof (ret));
- __close (fd);
- if (reslen == (ssize_t) sizeof (ret))
- return ret;
+ const size_t filllen = sizeof (ret.bytes) - 1;
+ ret.num = 0;
+# ifdef ENABLE_STACKGUARD_RANDOMIZE
+ int fd = open_not_cancel_2 ("/dev/urandom", O_RDONLY);
+ if (fd >= 0)
+ {
+ ssize_t reslen = read_not_cancel (fd, ret.bytes + 1, filllen);
+ close_not_cancel_no_status (fd);
+ if (reslen == (ssize_t) filllen)
+ return ret.num;
+ }
+# endif
+ ret.bytes[filllen] = 255;
+ ret.bytes[filllen - 1] = '\n';
}
-#endif
- ret = 0;
- unsigned char *p = (unsigned char *) &ret;
- p[sizeof (ret) - 1] = 255;
- p[sizeof (ret) - 2] = '\n';
- return ret;
+ return ret.num;
}
static inline uintptr_t __attribute__ ((always_inline))
More information about the Glibc-bsd-commits
mailing list