about summary refs log tree commit diff
path: root/sysdeps/unix
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix')
-rw-r--r--sysdeps/unix/getlogin_r.c22
-rw-r--r--sysdeps/unix/sysv/linux/Makefile27
-rw-r--r--sysdeps/unix/sysv/linux/configure21
-rw-r--r--sysdeps/unix/sysv/linux/configure.in19
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/Makefile2
-rw-r--r--sysdeps/unix/sysv/linux/s390/Makefile1
-rw-r--r--sysdeps/unix/sysv/linux/sparc/Makefile45
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/Makefile44
8 files changed, 68 insertions, 113 deletions
diff --git a/sysdeps/unix/getlogin_r.c b/sysdeps/unix/getlogin_r.c
index b50776859f..ba7badd054 100644
--- a/sysdeps/unix/getlogin_r.c
+++ b/sysdeps/unix/getlogin_r.c
@@ -25,6 +25,7 @@
 #include <fcntl.h>
 
 #include <utmp.h>
+#include "../login/utmp-private.h"
 
 /* Return at most NAME_LEN characters of the login name of the user in NAME.
    If it cannot be determined or some other error occurred, return the error
@@ -37,7 +38,7 @@ getlogin_r (name, name_len)
 {
   char tty_pathname[2 + 2 * NAME_MAX];
   char *real_tty_path = tty_pathname;
-  int result = 0;
+  int result;
   struct utmp *ut, line, buffer;
 
   /* Get name of tty connected to fd 0.  Return if not a tty or
@@ -56,10 +57,16 @@ getlogin_r (name, name_len)
     return result;
 
   real_tty_path += 5;		/* Remove "/dev/".  */
-
-  __setutent ();
   strncpy (line.ut_line, real_tty_path, sizeof line.ut_line);
-  if (__getutline_r (&line, &buffer, &ut) < 0)
+
+  /* We don't use the normal entry points __setutent et al, because we
+     want setutent + getutline_r + endutent all to happen with the lock
+     held so that our search is thread-safe.  */
+
+  __libc_lock_lock (__libc_utmp_lock);
+  (*__libc_utmp_jump_table->setutent) ();
+  result = (*__libc_utmp_jump_table->getutline_r) (&line, &buffer, &ut);
+  if (result < 0)
     {
       if (errno == ESRCH)
 	/* The caller expects ENOENT if nothing is found.  */
@@ -67,7 +74,11 @@ getlogin_r (name, name_len)
       else
 	result = errno;
     }
-  else
+  (*__libc_utmp_jump_table->endutent) ();
+  __libc_utmp_jump_table = &__libc_utmp_unknown_functions;
+  __libc_lock_unlock (__libc_utmp_lock);
+
+  if (result == 0)
     {
       size_t needed = strlen (ut->ut_user) + 1;
 
@@ -82,7 +93,6 @@ getlogin_r (name, name_len)
 	  result = 0;
 	}
     }
-  __endutent ();
 
   return result;
 }
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 3055e1bd10..17d9238909 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -24,8 +24,9 @@ sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h \
 
 install-others += $(inst_includedir)/bits/syscall.h
 
-ifndef no_syscall_list_h
 # Generate the list of SYS_* macros for the system calls (__NR_* macros).
+# For bi-arch platforms, the CPU/Makefile defines 64bit-predefine and
+# we generate a file that uses <bits/wordsize.h>.
 $(objpfx)syscall-%.h $(objpfx)syscall-%.d: ../sysdeps/unix/sysv/linux/sys/syscall.h
 	rm -f $(@:.h=.d)-t
 	{ \
@@ -36,8 +37,26 @@ $(objpfx)syscall-%.h $(objpfx)syscall-%.d: ../sysdeps/unix/sysv/linux/sys/syscal
 	 echo '#endif'; \
 	 echo ''; \
 	 SUNPRO_DEPENDENCIES='$(@:.h=.d)-t $@' \
-	 $(CC) -E -x c $(sysincludes) $< -D_LIBC -dM | \
-	 sed -n 's@^#define __NR_\([^ ]*\) .*$$@#define SYS_\1 __NR_\1@p'; \
+	 $(CC) -E -x c $(sysincludes) $< $(addprefix -U,$(64bit-predefine)) -D_LIBC -dM | \
+	 sed -n 's@^#define __NR_\([^ ]*\) .*$$@#define SYS_\1 __NR_\1@p' | \
+	 LC_ALL=C sort > $(@:.d=.h).new32; \
+	 SUNPRO_DEPENDENCIES='$(@:.h=.d)-t $@' \
+	 $(CC) -E -x c $(sysincludes) $< $(addprefix -D,$(64bit-predefine)) -D_LIBC -dM | \
+	 sed -n 's@^#define __NR_\([^ ]*\) .*$$@#define SYS_\1 __NR_\1@p' | \
+	 LC_ALL=C sort > $(@:.d=.h).new64; \
+	 if cmp -s $(@:.d=.h).new32 $(@:.d=.h).new64; then \
+	   cat $(@:.d=.h).new32; \
+	 else \
+	   echo '#include <bits/wordsize.h>'; \
+	   echo ''; \
+	   LC_ALL=C comm -12 $(@:.d=.h).new32 $(@:.d=.h).new64; \
+	   echo '#if __WORDSIZE == 64'; \
+	   LC_ALL=C comm -13 $(@:.d=.h).new32 $(@:.d=.h).new64; \
+	   echo '#else'; \
+	   LC_ALL=C comm -23 $(@:.d=.h).new32 $(@:.d=.h).new64; \
+	   echo '#endif'; \
+	 fi; \
+	 rm -f $(@:.d=.h).new32 $(@:.d=.h).new64; \
 	} > $(@:.d=.h).new
 	mv -f $(@:.d=.h).new $(@:.d=.h)
 	sed < $(@:.h=.d)-t > $(@:.h=.d)-t2 \
@@ -45,7 +64,7 @@ $(objpfx)syscall-%.h $(objpfx)syscall-%.d: ../sysdeps/unix/sysv/linux/sys/syscal
 					      $(@:.d=.h) $(@:.h=.d)),'
 	rm -f $(@:.h=.d)-t
 	mv -f $(@:.h=.d)-t2 $(@:.h=.d)
-endif
+
 
 $(inst_includedir)/bits/syscall.h: $(objpfx)syscall-list.h $(+force)
 	$(make-target-directory)
diff --git a/sysdeps/unix/sysv/linux/configure b/sysdeps/unix/sysv/linux/configure
index 82b262cd5e..fda05fe8f5 100644
--- a/sysdeps/unix/sysv/linux/configure
+++ b/sysdeps/unix/sysv/linux/configure
@@ -182,20 +182,22 @@ fi
 # files.  I.e., when the installation prefix is "/usr" we have to place
 # shared library objects and the configuration files on the root partition
 # in /lib and /etc.
-if test "$prefix" = "/usr" -o "$prefix" = "/usr/"; then
-  # 64bit libraries on sparc go to /lib64 and not /lib
-  if test "$machine" = "sparc/sparc64" -o "$machine" = "x86_64" \
-	  -o "$machine" = "powerpc/powerpc64" \
-	  -o "$machine" = "s390/s390-64"; then
+case "$prefix" in
+/usr | /usr/)
+  # 64-bit libraries on bi-arch platforms go in /lib64 instead of /lib
+  case $machine in
+  sparc/sparc64 | x86_64 | powerpc/powerpc64 | s390/s390-64 )
     libc_cv_slibdir="/lib64"
     if test "$libdir" = '${exec_prefix}/lib'; then
       libdir='${exec_prefix}/lib64';
       # Locale data can be shared between 32bit and 64bit libraries
       libc_cv_localedir='${exec_prefix}/lib/locale'
     fi
-  else
+    ;;
+  *)
     libc_cv_slibdir="/lib"
-  fi
+    ;;
+  esac
   # Allow the user to override the path with --sysconfdir
   if test $sysconfdir = '${prefix}/etc'; then
     libc_cv_sysconfdir=/etc
@@ -203,7 +205,8 @@ if test "$prefix" = "/usr" -o "$prefix" = "/usr/"; then
     libc_cv_sysconfdir=$sysconfdir
    fi
   libc_cv_rootsbindir="/sbin"
-fi
+  ;;
+esac
 
 # Under Linux the LinuxThreads or NPTL add-on should be available.
 case $add_ons in
@@ -297,7 +300,7 @@ if test $host = $build; then
     ac_prefix=$ac_default_prefix
   fi
   echo $ac_n "checking for symlinks in ${ac_prefix}/include""... $ac_c" 1>&6
-echo "configure:300: checking for symlinks in ${ac_prefix}/include" >&5
+echo "configure:304: checking for symlinks in ${ac_prefix}/include" >&5
   ac_message=
   if test -L ${ac_prefix}/include/net; then
     ac_message="$ac_message
diff --git a/sysdeps/unix/sysv/linux/configure.in b/sysdeps/unix/sysv/linux/configure.in
index 95c3c620f5..ac900da36c 100644
--- a/sysdeps/unix/sysv/linux/configure.in
+++ b/sysdeps/unix/sysv/linux/configure.in
@@ -152,20 +152,22 @@ fi
 # files.  I.e., when the installation prefix is "/usr" we have to place
 # shared library objects and the configuration files on the root partition
 # in /lib and /etc.
-if test "$prefix" = "/usr" -o "$prefix" = "/usr/"; then
-  # 64bit libraries on sparc go to /lib64 and not /lib
-  if test "$machine" = "sparc/sparc64" -o "$machine" = "x86_64" \
-	  -o "$machine" = "powerpc/powerpc64" \
-	  -o "$machine" = "s390/s390-64"; then
+case "$prefix" in
+/usr | /usr/)
+  # 64-bit libraries on bi-arch platforms go in /lib64 instead of /lib
+  case $machine in
+  sparc/sparc64 | x86_64 | powerpc/powerpc64 | s390/s390-64 )
     libc_cv_slibdir="/lib64"
     if test "$libdir" = '${exec_prefix}/lib'; then
       libdir='${exec_prefix}/lib64';
       # Locale data can be shared between 32bit and 64bit libraries
       libc_cv_localedir='${exec_prefix}/lib/locale'
     fi
-  else
+    ;;
+  *)
     libc_cv_slibdir="/lib"
-  fi
+    ;;
+  esac
   # Allow the user to override the path with --sysconfdir
   if test $sysconfdir = '${prefix}/etc'; then
     libc_cv_sysconfdir=/etc
@@ -173,7 +175,8 @@ if test "$prefix" = "/usr" -o "$prefix" = "/usr/"; then
     libc_cv_sysconfdir=$sysconfdir
    fi
   libc_cv_rootsbindir="/sbin"
-fi
+  ;;
+esac
 
 # Under Linux the LinuxThreads or NPTL add-on should be available.
 case $add_ons in
diff --git a/sysdeps/unix/sysv/linux/powerpc/Makefile b/sysdeps/unix/sysv/linux/powerpc/Makefile
index 9d02acecc4..3db246edc5 100644
--- a/sysdeps/unix/sysv/linux/powerpc/Makefile
+++ b/sysdeps/unix/sysv/linux/powerpc/Makefile
@@ -1,3 +1,5 @@
+64bit-predefine = __powerpc64__
+
 ifeq ($(subdir),signal)
 sysdep_routines += rt_sigsuspend rt_sigprocmask rt_sigtimedwait	\
 		   rt_sigqueueinfo rt_sigaction rt_sigpending
diff --git a/sysdeps/unix/sysv/linux/s390/Makefile b/sysdeps/unix/sysv/linux/s390/Makefile
new file mode 100644
index 0000000000..7a83286d0a
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/s390/Makefile
@@ -0,0 +1 @@
+64bit-predefine = __s390x__
diff --git a/sysdeps/unix/sysv/linux/sparc/Makefile b/sysdeps/unix/sysv/linux/sparc/Makefile
index 9b46a7ea72..29e5406348 100644
--- a/sysdeps/unix/sysv/linux/sparc/Makefile
+++ b/sysdeps/unix/sysv/linux/sparc/Makefile
@@ -1,44 +1 @@
-ifeq ($(subdir),misc)
-
-no_syscall_list_h = 1
-
-# Generate the list of SYS_* macros for the system calls (__NR_* macros).
-$(objpfx)syscall-%.h $(objpfx)syscall-%.d: ../sysdeps/unix/sysv/linux/sys/syscall.h
-	rm -f $(@:.h=.d)-t
-	{ \
-	 echo '/* Generated at libc build time from kernel syscall list.  */';\
-	 echo ''; \
-	 echo '#ifndef _SYSCALL_H'; \
-	 echo '# error "Never use <bits/syscall.h> directly; include <sys/syscall.h> instead."'; \
-	 echo '#endif'; \
-	 echo ''; \
-	 SUNPRO_DEPENDENCIES='$(@:.h=.d)-t $@' \
-	 $(CC) -E -x c $(sysincludes) $< -U__sparc_v9__ -U__arch64__ -D_LIBC -dM | \
-	 sed -n 's@^#define __NR_\([^ ]*\) .*$$@#define SYS_\1 __NR_\1@p' | \
-	 LC_ALL=C sort > $(@:.d=.h).new32; \
-	 SUNPRO_DEPENDENCIES='$(@:.h=.d)-t $@' \
-	 $(CC) -E -x c $(sysincludes) $< -D__sparc_v9__ -D__arch64__ -D_LIBC -dM | \
-	 sed -n 's@^#define __NR_\([^ ]*\) .*$$@#define SYS_\1 __NR_\1@p' | \
-	 LC_ALL=C sort > $(@:.d=.h).new64; \
-	 if cmp -s $(@:.d=.h).new32 $(@:.d=.h).new64; then \
-	   cat $(@:.d=.h).new32; \
-	 else \
-	   echo '#include <bits/wordsize.h>'; \
-	   echo ''; \
-	   comm -12 $(@:.d=.h).new32 $(@:.d=.h).new64; \
-	   echo '#if __WORDSIZE == 64'; \
-	   comm -13 $(@:.d=.h).new32 $(@:.d=.h).new64; \
-	   echo '#else'; \
-	   comm -23 $(@:.d=.h).new32 $(@:.d=.h).new64; \
-	   echo '#endif'; \
-	 fi; \
-	 rm -f $(@:.d=.h).new32 $(@:.d=.h).new64; \
-	} > $(@:.d=.h).new
-	mv -f $(@:.d=.h).new $(@:.d=.h)
-	sed < $(@:.h=.d)-t > $(@:.h=.d)-t2 \
-	    -e 's,$(subst .,\.,$@),$(patsubst $(objpfx)%,$$(objpfx)%,\
-					      $(@:.d=.h) $(@:.h=.d)),'
-	rm -f $(@:.h=.d)-t
-	mv -f $(@:.h=.d)-t2 $(@:.h=.d)
-
-endif
+64bit-predefine = __sparc_v9__ __arch64__
diff --git a/sysdeps/unix/sysv/linux/x86_64/Makefile b/sysdeps/unix/sysv/linux/x86_64/Makefile
index 09745d82d4..86cfd69ad1 100644
--- a/sysdeps/unix/sysv/linux/x86_64/Makefile
+++ b/sysdeps/unix/sysv/linux/x86_64/Makefile
@@ -1,48 +1,8 @@
+64bit-predefine = __x86_64__
+
 ifeq ($(subdir),misc)
 sysdep_routines += ioperm iopl
 sysdep_headers += sys/perm.h sys/reg.h sys/debugreg.h sys/io.h
-
-no_syscall_list_h = 1
-
-# Generate the list of SYS_* macros for the system calls (__NR_* macros).
-$(objpfx)syscall-%.h $(objpfx)syscall-%.d: ../sysdeps/unix/sysv/linux/sys/syscall.h
-	rm -f $(@:.h=.d)-t
-	{ \
-	 echo '/* Generated at libc build time from kernel syscall list.  */';\
-	 echo ''; \
-	 echo '#ifndef _SYSCALL_H'; \
-	 echo '# error "Never use <bits/syscall.h> directly; include <sys/syscall.h> instead."'; \
-	 echo '#endif'; \
-	 echo ''; \
-	 SUNPRO_DEPENDENCIES='$(@:.h=.d)-t $@' \
-	 $(CC) -E -x c $(sysincludes) $< -U__x86_64__ -D_LIBC -dM | \
-	 sed -n 's@^#define __NR_\([^ ]*\) .*$$@#define SYS_\1 __NR_\1@p' | \
-	 LC_ALL=C sort > $(@:.d=.h).new32; \
-	 SUNPRO_DEPENDENCIES='$(@:.h=.d)-t $@' \
-	 $(CC) -E -x c $(sysincludes) $< -D__x86_64 -D_LIBC -dM | \
-	 sed -n 's@^#define __NR_\([^ ]*\) .*$$@#define SYS_\1 __NR_\1@p' | \
-	 LC_ALL=C sort > $(@:.d=.h).new64; \
-	 if cmp -s $(@:.d=.h).new32 $(@:.d=.h).new64; then \
-	   cat $(@:.d=.h).new32; \
-	 else \
-	   echo '#include <bits/wordsize.h>'; \
-	   echo ''; \
-	   comm -12 $(@:.d=.h).new32 $(@:.d=.h).new64; \
-	   echo '#if __WORDSIZE == 64'; \
-	   comm -13 $(@:.d=.h).new32 $(@:.d=.h).new64; \
-	   echo '#else'; \
-	   comm -23 $(@:.d=.h).new32 $(@:.d=.h).new64; \
-	   echo '#endif'; \
-	 fi; \
-	 rm -f $(@:.d=.h).new32 $(@:.d=.h).new64; \
-	} > $(@:.d=.h).new
-	mv -f $(@:.d=.h).new $(@:.d=.h)
-	sed < $(@:.h=.d)-t > $(@:.h=.d)-t2 \
-	    -e 's,$(subst .,\.,$@),$(patsubst $(objpfx)%,$$(objpfx)%,\
-					      $(@:.d=.h) $(@:.h=.d)),'
-	rm -f $(@:.h=.d)-t
-	mv -f $(@:.h=.d)-t2 $(@:.h=.d)
-
 endif
 
 ifeq ($(subdir),stdlib)