glibc might compile for x86 now
authorAndrew Waterman <waterman@parcad.millennium.berkeley.edu>
Fri, 19 Feb 2010 09:50:14 +0000 (01:50 -0800)
committerKevin Klues <klueska@cs.berkeley.edu>
Thu, 3 Nov 2011 00:35:36 +0000 (17:35 -0700)
removed sparc-specific dependencies from sysdeps/ros

55 files changed:
GNUmakefile
kern/arch/i386/ros/hart.h
kern/arch/i386/ros/syscall.h
kern/arch/sparc/ros/syscall.h [new file with mode: 0644]
kern/include/errno.h [new file with mode: 0644]
kern/include/ros/procinfo.h
kern/include/ros/stat.h [new file with mode: 0644]
kern/include/ros/syscall.h
tools/compilers/gcc-glibc/Makefile
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/_exit.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/access.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/brk.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/chdir.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/chmod.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/close.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/execve.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/fcntl.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/fork.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/fxstat.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/fxstat64.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/getcwd.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/getpagesize.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/getpid.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/gettimeofday.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/i386/tls.h [new file with mode: 0644]
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/isatty.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/kill.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/link.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/lowlevellock.h
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/lseek.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/lxstat.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/lxstat64.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/mmap.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/mprotect.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/munmap.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/open.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/read.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/ros_stat.h
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/ros_syscall.h [deleted file]
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/rtld.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/sched_yield.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/sparc/sparc32/tls.h [new file with mode: 0644]
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/start.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/syscall.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/sysconf.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/tcgetattr.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/tcsetattr.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/times.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/tls.h [deleted file]
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/umask.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/unlink.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/waitpid.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/write.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/xstat.c
tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/xstat64.c

index cbd6592..a5a2080 100644 (file)
@@ -75,22 +75,22 @@ PERL    := perl
 
 EXTRAARGS ?= -std=gnu99 -Wno-attributes -fno-stack-protector -fgnu89-inline
 
+# GCC Library path
+ifneq ($(shell which $(CC)),)
+GCC_LIB := $(shell $(CC) -print-libgcc-file-name)
+endif
+
 # Universal compiler flags
 # -fno-builtin is required to avoid refs to undefined functions in the kernel.
 # Only optimize to -O1 to discourage inlining, which complicates backtraces.
 CFLAGS := $(CFLAGS) -D$(TARGET_ARCH) $(EXTRAARGS)
 CFLAGS += -O2 -pipe -MD -fno-builtin -gstabs
 CFLAGS += -Wall -Wno-format -Wno-unused -fno-strict-aliasing
-#CFLAGS += -nostdinc -Igccinclude/$(TARGET_ARCH)
+CFLAGS += -nostdinc -I$(dir $(GCC_LIB))/include
 
 # Universal loader flags
 LDFLAGS := -nostdlib
 
-# GCC Library path 
-ifneq ($(shell which $(CC)),)
-GCC_LIB := $(shell $(CC) -print-libgcc-file-name)
-endif
-
 # List of directories that the */Makefrag makefile fragments will add to
 OBJDIRS :=
 
index 9f5b767..4ecf4c4 100644 (file)
@@ -1,20 +1,22 @@
 #ifndef _ROS_ARCH_HART_H
 #define _ROS_ARCH_HART_H
 
-#include <parlib.h>
+#ifndef ROS_KERNEL
+
+#include <ros/syscall.h>
 
 // The actual hart_self() function is a global symbol that invokes this routine.
 static inline int
 __hart_self()
 {
        // TODO: use some kind of thread-local storage to speed this up!
-       return (int)syscall(SYS_getvcoreid,0,0,0,0,0);
+       return (int)ros_syscall(SYS_getvcoreid,0,0,0,0,0);
 }
 
 static inline void
 __hart_set_stack_pointer(void* sp)
 {
-       FIXME
+       asm volatile ("mov %0,%%esp" : : "r"(sp) : "memory","esp");
 }
 
 static inline void
@@ -31,3 +33,5 @@ __hart_swap(int* addr, int val)
 }
 
 #endif
+
+#endif
index 5107059..f2c506a 100644 (file)
@@ -3,4 +3,74 @@
 
 #define T_SYSCALL      0x80
 
+#ifndef ROS_KERNEL
+
+// TODO: fix sysenter to take all 5 params
+static inline intreg_t syscall_sysenter(uint16_t num, intreg_t a1,
+                                 intreg_t a2, intreg_t a3,
+                                 intreg_t a4, intreg_t a5)
+{
+       intreg_t ret;
+       asm volatile ("  pushl %%ebp;        "
+                     "  pushl %%esi;        "
+                     "  movl %%esp, %%ebp;  "
+                     "  leal 1f, %%esi;     "
+                     "  sysenter;           "
+                     "1:                    "
+                     "  popl %%esi;         "
+                     "  popl %%ebp;         "
+                     : "=a" (ret)
+                     : "a" (num),
+                       "d" (a1),
+                       "c" (a2),
+                       "b" (a3),
+                       "D" (a4)
+                     : "cc", "memory");
+       return ret;
+}
+
+static inline intreg_t syscall_trap(uint16_t num, intreg_t a1,
+                             intreg_t a2, intreg_t a3,
+                             intreg_t a4, intreg_t a5)
+{
+       uint32_t ret;
+
+       // Generic system call: pass system call number in AX,
+       // up to five parameters in DX, CX, BX, DI, SI.
+       // Interrupt kernel with T_SYSCALL.
+       //
+       // The "volatile" tells the assembler not to optimize
+       // this instruction away just because we don't use the
+       // return value.
+       //
+       // The last clause tells the assembler that this can
+       // potentially change the condition codes and arbitrary
+       // memory locations.
+
+       asm volatile("int %1"
+                    : "=a" (ret)
+                    : "i" (T_SYSCALL),
+                      "a" (num),
+                      "d" (a1),
+                      "c" (a2),
+                      "b" (a3),
+                      "D" (a4),
+                      "S" (a5)
+                    : "cc", "memory");
+       return ret;
+}
+
+static inline long __attribute__((always_inline))
+__ros_syscall(long _num, long _a0, long _a1, long _a2, long _a3, long _a4)
+{
+       #ifndef SYSCALL_TRAP
+               return syscall_sysenter(_num, _a1, _a2, _a3, _a4, _a5);
+       #else
+               return syscall_trap(_num, _a1, _a2, _a3, _a4, _a5);
+       #endif
+}
+
+#endif
+
 #endif
+
diff --git a/kern/arch/sparc/ros/syscall.h b/kern/arch/sparc/ros/syscall.h
new file mode 100644 (file)
index 0000000..7b75db4
--- /dev/null
@@ -0,0 +1,30 @@
+#include <errno.h>
+
+#ifndef _ROS_ARCH_SYSCALL_H
+#define _ROS_ARCH_SYSCALL_H
+
+#ifndef ROS_KERNEL
+
+static inline long __attribute__((always_inline))
+__ros_syscall(long _num, long _a0, long _a1, long _a2, long _a3, long _a4)
+{
+       register long num asm("g1") = _num;
+       register long a0 asm("o0") = _a0, a1 asm("o1") = _a1;
+       register long a2 asm("o2") = _a2, a3 asm("o3") = _a3;
+       register long a4 asm("o4") = _a4;
+
+       asm volatile("ta 8" : "=r"(a0),"=r"(a1)
+                    : "r"(num),"0"(a0),"1"(a1),"r"(a2),"r"(a3),"r"(a4));
+
+       // move a1, a2 into regular variables so they're volatile across
+       // procedure calls
+       long ret = a0, err = a1;
+       if(err != 0)
+               __set_errno(err);
+
+        return ret;
+}
+
+#endif /* ifndef ROS_KERNEL */
+
+#endif
diff --git a/kern/include/errno.h b/kern/include/errno.h
new file mode 100644 (file)
index 0000000..be874f6
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef _ERRNO_H
+#define _ERRNO_H
+
+#define __set_errno(x) do { } while(0)
+
+#endif
index ee6216d..7978f1e 100644 (file)
@@ -54,6 +54,11 @@ procinfo_pack_args(procinfo_t* p, char* const* argv, char* const* envp)
        p->argp[nargv+nenvp+1] = 0;
        
        return 0;
-}   
+}
+
+// this is how user programs access the procinfo page
+#ifndef ROS_KERNEL
+# define __procinfo (*(procinfo_t*)UINFO)
+#endif
 
 #endif // !ROS_PROCDATA_H
diff --git a/kern/include/ros/stat.h b/kern/include/ros/stat.h
new file mode 100644 (file)
index 0000000..22ea700
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef _ROS_STAT_H
+#define _ROS_STAT_H
+
+// This matches the stat structure used by the RAMP appserver.
+#include <stdint.h>
+
+struct ros_stat
+{
+   int16_t st_dev;
+  uint32_t st_ino;
+  uint16_t st_mode;
+  uint16_t st_nlink;
+  uint16_t st_uid;
+  uint16_t st_gid;
+   int16_t st_rdev;
+   int32_t st_size;
+   int32_t st_atime;
+   int32_t st_spare1;
+   int32_t st_mtime;
+   int32_t st_spare2;
+   int32_t st_ctime;
+   int32_t st_spare3;
+   int32_t st_blksize;
+   int32_t st_blocks;
+   int32_t st_spare4[2];
+};
+
+#endif
index 1c5e5b0..63366a4 100644 (file)
@@ -71,4 +71,9 @@
 // for system calls that pass filenames
 #define MAX_PATH_LEN 256
 
+// convenience wrapper for __ros_syscall
+#define ros_syscall(which,a0,a1,a2,a3,a4) \
+   __ros_syscall(which,(long)(a0),(long)(a1),(long)(a2),(long)(a3),(long)(a4))
+#include <ros/arch/syscall.h>
+
 #endif /* !ROS_INCLUDE_SYSCALL_H */
index 015b0f0..6d6bae5 100644 (file)
@@ -142,6 +142,8 @@ gcc-$(GCC_VERSION):
 glibc-$(GLIBC_VERSION): 
        rm -rf glibc-$(GLIBC_VERSION)
        tar -jxf glibc-$(GLIBC_VERSION).tar.bz2
+       rm glibc-$(GLIBC_VERSION)/sysdeps/sparc/sparc32/elf/start.S
+       rm glibc-$(GLIBC_VERSION)/sysdeps/i386/elf/start.S
        $(MAKE) .glibc-patch
 
 .glibc-patch: glibc-$(GLIBC_VERSION)
index effe1a4..e85a801 100644 (file)
@@ -21,7 +21,7 @@
 #include <unistd.h>
 #include <sysdep.h>
 #include <abort-instr.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 
 void
 _exit (status)
index a5d41fa..c99f467 100644 (file)
@@ -19,7 +19,7 @@
 #include <errno.h>
 #include <stddef.h>
 #include <unistd.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 
 /* Test for access to FILE.  */
 int
index 1883e16..0d69ea8 100644 (file)
@@ -19,7 +19,7 @@
 #include <errno.h>
 #include <unistd.h>
 #include <bits/libc-lock.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 
 /* sbrk.c expects this.  */
 void *__curbrk;
index 89a8d27..2290dbc 100644 (file)
@@ -19,7 +19,7 @@
 #include <errno.h>
 #include <stddef.h>
 #include <unistd.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 
 /* Change the current directory to PATH.  */
 int
index 0937803..1a45cae 100644 (file)
@@ -20,7 +20,7 @@
 #include <stddef.h>
 #include <sys/stat.h>
 #include <sys/types.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 
 /* Change the protections of FILE to MODE.  */
 int
index 71d73cf..9fa472f 100644 (file)
@@ -20,7 +20,7 @@
 #include <errno.h>
 #include <unistd.h>
 #include <stddef.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 
 /* Write NBYTES of BUF to FD.  Return the number written, or -1.  */
 int
index e2164d0..0cb94b6 100644 (file)
 #include <errno.h>
 #include <stddef.h>
 #include <unistd.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 #include <string.h>
 #include <fcntl.h>
 #include <elf/elf.h>
+#include <ros/procinfo.h>
 
 /* Replace the current process, executing PATH with arguments ARGV and
    environment ENVP.  ARGV and ENVP are terminated by NULL pointers.  */
index 17ff117..48b4ca9 100644 (file)
@@ -20,7 +20,7 @@
 #include <fcntl.h>
 #include <stdarg.h>
 #include <stdlib.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 
 /* Perform file control operations on FD.  */
 int
index 2452b84..8553464 100644 (file)
@@ -20,7 +20,7 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <bits/libc-lock.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 
 __libc_lock_define(,__fork_lock);
 int* child_list = NULL;
index 3a3d667..db9781a 100644 (file)
@@ -21,7 +21,7 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #include <fcntl.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 #include "ros_stat.h"
 
 /* Get information about the file descriptor FD in BUF.  */
@@ -46,7 +46,7 @@ __fxstat (int vers, int fd, struct stat *buf)
     }
 
   
-  struct newlib_stat nst;
+  struct ros_stat nst;
   int ret = (int)ros_syscall(SYS_fstat,fd,&nst,0,0,0);
   __convert_stat(&nst,buf);
   return ret;
index 5f69295..8342ad6 100644 (file)
@@ -21,7 +21,7 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #include <fcntl.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 #include "ros_stat.h"
 
 /* Get information about the file descriptor FD in BUF.  */
index f9e0adf..2a1351e 100644 (file)
@@ -19,7 +19,7 @@
 #include <errno.h>
 #include <unistd.h>
 #include <stddef.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 
 /* Get the pathname of the current working directory,
    and put it in SIZE bytes of BUF.  Returns NULL if the
index 060dd90..77f9c24 100644 (file)
@@ -18,7 +18,8 @@
 
 #include <errno.h>
 #include <unistd.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
+#include <ros/procinfo.h>
 
 /* Get the process ID of the calling process.  */
 int
diff --git a/tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/i386/tls.h b/tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/i386/tls.h
new file mode 100644 (file)
index 0000000..bd2ff77
--- /dev/null
@@ -0,0 +1,481 @@
+/* Definition for thread-local data handling.  nptl/i386 version.
+   Copyright (C) 2002-2007, 2009 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _TLS_H
+#define _TLS_H 1
+
+#include <dl-sysdep.h>
+#ifndef __ASSEMBLER__
+# include <stdbool.h>
+# include <stddef.h>
+# include <stdint.h>
+# include <stdlib.h>
+# include <list.h>
+# include <sysdep.h>
+# include <kernel-features.h>
+
+
+/* Type for the dtv.  */
+typedef union dtv
+{
+  size_t counter;
+  struct
+  {
+    void *val;
+    bool is_static;
+  } pointer;
+} dtv_t;
+
+
+typedef struct
+{
+  void *tcb;           /* Pointer to the TCB.  Not necessarily the
+                          thread descriptor used by libpthread.  */
+  dtv_t *dtv;
+  void *self;          /* Pointer to the thread descriptor.  */
+  int multiple_threads;
+  uintptr_t sysinfo;
+  uintptr_t stack_guard;
+  uintptr_t pointer_guard;
+  int gscope_flag;
+#ifndef __ASSUME_PRIVATE_FUTEX
+  int private_futex;
+#else
+  int __unused1;
+#endif
+  /* Reservation of some values for the TM ABI.  */
+  void *__private_tm[5];
+} tcbhead_t;
+
+# define TLS_MULTIPLE_THREADS_IN_TCB 1
+
+typedef struct rthread {
+    tcbhead_t header;
+} rthread_t;
+
+#else /* __ASSEMBLER__ */
+//# include <tcb-offsets.h>
+#endif
+
+
+/* We require TLS support in the tools.  */
+#ifndef HAVE_TLS_SUPPORT
+# error "TLS support is required."
+#endif
+
+/* Alignment requirement for the stack.  For IA-32 this is governed by
+   the SSE memory functions.  */
+#define STACK_ALIGN    16
+
+#ifndef __ASSEMBLER__
+/* Get system call information.  */
+# include <sysdep.h>
+
+/* The old way: using LDT.  */
+
+/* Structure passed to `modify_ldt', 'set_thread_area', and 'clone' calls.  */
+struct user_desc
+{
+  unsigned int entry_number;
+  unsigned long int base_addr;
+  unsigned int limit;
+  unsigned int seg_32bit:1;
+  unsigned int contents:2;
+  unsigned int read_exec_only:1;
+  unsigned int limit_in_pages:1;
+  unsigned int seg_not_present:1;
+  unsigned int useable:1;
+  unsigned int empty:25;
+};
+
+/* Initializing bit fields is slow.  We speed it up by using a union.  */
+union user_desc_init
+{
+  struct user_desc desc;
+  unsigned int vals[4];
+};
+
+
+/* Get the thread descriptor definition.  */
+# include <nptl/descr.h>
+
+/* This is the size of the initial TCB.  Can't be just sizeof (tcbhead_t),
+   because NPTL getpid, __libc_alloca_cutoff etc. need (almost) the whole
+   struct rthread even when not linked with -lpthread.  */
+# define TLS_INIT_TCB_SIZE sizeof (struct rthread)
+
+/* Alignment requirements for the initial TCB.  */
+# define TLS_INIT_TCB_ALIGN __alignof__ (struct rthread)
+
+/* This is the size of the TCB.  */
+# define TLS_TCB_SIZE sizeof (struct rthread)
+
+/* Alignment requirements for the TCB.  */
+# define TLS_TCB_ALIGN __alignof__ (struct rthread)
+
+/* The TCB can have any size and the memory following the address the
+   thread pointer points to is unspecified.  Allocate the TCB there.  */
+# define TLS_TCB_AT_TP 1
+
+
+/* Install the dtv pointer.  The pointer passed is to the element with
+   index -1 which contain the length.  */
+# define INSTALL_DTV(descr, dtvp) \
+  ((tcbhead_t *) (descr))->dtv = (dtvp) + 1
+
+/* Install new dtv for current thread.  */
+# define INSTALL_NEW_DTV(dtvp) \
+  ({ struct rthread *__pd;                                                   \
+     THREAD_SETMEM (__pd, header.dtv, (dtvp)); })
+
+/* Return dtv of given thread descriptor.  */
+# define GET_DTV(descr) \
+  (((tcbhead_t *) (descr))->dtv)
+
+#define THREAD_SELF_SYSINFO    THREAD_GETMEM (THREAD_SELF, header.sysinfo)
+#define THREAD_SYSINFO(pd)     ((pd)->header.sysinfo)
+
+/* Macros to load from and store into segment registers.  */
+# ifndef TLS_GET_GS
+#  define TLS_GET_GS() \
+  ({ int __seg; __asm ("movw %%gs, %w0" : "=q" (__seg)); __seg & 0xffff; })
+# endif
+# ifndef TLS_SET_GS
+#  define TLS_SET_GS(val) \
+  __asm ("movw %w0, %%gs" :: "q" (val))
+# endif
+
+
+# ifndef __NR_set_thread_area
+#  define __NR_set_thread_area 243
+# endif
+# ifndef TLS_FLAG_WRITABLE
+#  define TLS_FLAG_WRITABLE            0x00000001
+# endif
+
+// XXX Enable for the real world.
+#if 0
+# ifndef __ASSUME_SET_THREAD_AREA
+#  error "we need set_thread_area"
+# endif
+#endif
+
+# ifdef __PIC__
+#  define TLS_EBX_ARG "r"
+#  define TLS_LOAD_EBX "xchgl %3, %%ebx\n\t"
+# else
+#  define TLS_EBX_ARG "b"
+#  define TLS_LOAD_EBX
+# endif
+
+#if defined NEED_DL_SYSINFO
+# define INIT_SYSINFO \
+  _head->sysinfo = GLRO(dl_sysinfo)
+#else
+# define INIT_SYSINFO
+#endif
+
+#ifndef LOCK_PREFIX
+# ifdef UP
+#  define LOCK_PREFIX  /* nothing */
+# else
+#  define LOCK_PREFIX "lock;"
+# endif
+#endif
+
+/* Code to initially initialize the thread pointer.  This might need
+   special attention since 'errno' is not yet available and if the
+   operation can cause a failure 'errno' must not be touched.  */
+# define TLS_INIT_TP(thrdescr, secondcall) \
+  ({ void *_thrdescr = (thrdescr);                                           \
+     tcbhead_t *_head = _thrdescr;                                           \
+     union user_desc_init _segdescr;                                         \
+     int _result;                                                            \
+                                                                             \
+     _head->tcb = _thrdescr;                                                 \
+     /* For now the thread descriptor is at the same address.  */            \
+     _head->self = _thrdescr;                                                \
+     /* New syscall handling support.  */                                    \
+     INIT_SYSINFO;                                                           \
+                                                                             \
+     /* The 'entry_number' field.  Let the kernel pick a value.  */          \
+     if (secondcall)                                                         \
+       _segdescr.vals[0] = TLS_GET_GS () >> 3;                               \
+     else                                                                    \
+       _segdescr.vals[0] = -1;                                               \
+     /* The 'base_addr' field.  Pointer to the TCB.  */                              \
+     _segdescr.vals[1] = (unsigned long int) _thrdescr;                              \
+     /* The 'limit' field.  We use 4GB which is 0xfffff pages.  */           \
+     _segdescr.vals[2] = 0xfffff;                                            \
+     /* Collapsed value of the bitfield:                                     \
+         .seg_32bit = 1                                                      \
+         .contents = 0                                                       \
+         .read_exec_only = 0                                                 \
+         .limit_in_pages = 1                                                 \
+         .seg_not_present = 0                                                \
+         .useable = 1 */                                                     \
+     _segdescr.vals[3] = 0x51;                                               \
+                                                                             \
+     /* Install the TLS.  */                                                 \
+     asm volatile (TLS_LOAD_EBX                                                      \
+                  "int $0x80\n\t"                                            \
+                  TLS_LOAD_EBX                                               \
+                  : "=a" (_result), "=m" (_segdescr.desc.entry_number)       \
+                  : "0" (__NR_set_thread_area),                              \
+                    TLS_EBX_ARG (&_segdescr.desc), "m" (_segdescr.desc));    \
+                                                                             \
+     if (_result == 0)                                                       \
+       /* We know the index in the GDT, now load the segment register.       \
+         The use of the GDT is described by the value 3 in the lower         \
+         three bits of the segment descriptor value.                         \
+                                                                             \
+         Note that we have to do this even if the numeric value of           \
+         the descriptor does not change.  Loading the segment register       \
+         causes the segment information from the GDT to be loaded            \
+         which is necessary since we have changed it.   */                   \
+       TLS_SET_GS (_segdescr.desc.entry_number * 8 + 3);                     \
+                                                                             \
+     _result == 0 ? NULL                                                     \
+     : "set_thread_area failed when setting up thread-local storage\n"; })
+
+
+/* Return the address of the dtv for the current thread.  */
+# define THREAD_DTV() \
+  ({ struct rthread *__pd;                                                   \
+     THREAD_GETMEM (__pd, header.dtv); })
+
+
+/* Return the thread descriptor for the current thread.
+
+   The contained asm must *not* be marked volatile since otherwise
+   assignments like
+        pthread_descr self = thread_self();
+   do not get optimized away.  */
+# define THREAD_SELF \
+  ({ struct rthread *__self;                                                 \
+     asm ("movl %%gs:%c1,%0" : "=r" (__self)                                 \
+         : "i" (offsetof (struct rthread, header.self)));                    \
+     __self;})
+
+/* Magic for libthread_db to know how to do THREAD_SELF.  */
+# define DB_THREAD_SELF \
+  REGISTER_THREAD_AREA (32, offsetof (struct user_regs_struct, xgs), 3) \
+  REGISTER_THREAD_AREA (64, 26 * 8, 3) /* x86-64's user_regs_struct->gs */
+
+
+/* Read member of the thread descriptor directly.  */
+# define THREAD_GETMEM(descr, member) \
+  ({ __typeof (descr->member) __value;                                       \
+     if (sizeof (__value) == 1)                                                      \
+       asm volatile ("movb %%gs:%P2,%b0"                                     \
+                    : "=q" (__value)                                         \
+                    : "0" (0), "i" (offsetof (struct rthread, member)));     \
+     else if (sizeof (__value) == 4)                                         \
+       asm volatile ("movl %%gs:%P1,%0"                                              \
+                    : "=r" (__value)                                         \
+                    : "i" (offsetof (struct rthread, member)));              \
+     else                                                                    \
+       {                                                                     \
+        if (sizeof (__value) != 8)                                           \
+          /* There should not be any value with a size other than 1,         \
+             4 or 8.  */                                                     \
+          abort ();                                                          \
+                                                                             \
+        asm volatile ("movl %%gs:%P1,%%eax\n\t"                              \
+                      "movl %%gs:%P2,%%edx"                                  \
+                      : "=A" (__value)                                       \
+                      : "i" (offsetof (struct rthread, member)),             \
+                        "i" (offsetof (struct rthread, member) + 4));        \
+       }                                                                     \
+     __value; })
+
+
+/* Same as THREAD_GETMEM, but the member offset can be non-constant.  */
+# define THREAD_GETMEM_NC(descr, member, idx) \
+  ({ __typeof (descr->member[0]) __value;                                    \
+     if (sizeof (__value) == 1)                                                      \
+       asm volatile ("movb %%gs:%P2(%3),%b0"                                 \
+                    : "=q" (__value)                                         \
+                    : "0" (0), "i" (offsetof (struct rthread, member[0])),   \
+                    "r" (idx));                                              \
+     else if (sizeof (__value) == 4)                                         \
+       asm volatile ("movl %%gs:%P1(,%2,4),%0"                               \
+                    : "=r" (__value)                                         \
+                    : "i" (offsetof (struct rthread, member[0])),            \
+                      "r" (idx));                                            \
+     else                                                                    \
+       {                                                                     \
+        if (sizeof (__value) != 8)                                           \
+          /* There should not be any value with a size other than 1,         \
+             4 or 8.  */                                                     \
+          abort ();                                                          \
+                                                                             \
+        asm volatile  ("movl %%gs:%P1(,%2,8),%%eax\n\t"                      \
+                       "movl %%gs:4+%P1(,%2,8),%%edx"                        \
+                       : "=&A" (__value)                                     \
+                       : "i" (offsetof (struct rthread, member[0])),         \
+                         "r" (idx));                                         \
+       }                                                                     \
+     __value; })
+
+
+/* Same as THREAD_SETMEM, but the member offset can be non-constant.  */
+# define THREAD_SETMEM(descr, member, value) \
+  ({ if (sizeof (descr->member) == 1)                                        \
+       asm volatile ("movb %b0,%%gs:%P1" :                                   \
+                    : "iq" (value),                                          \
+                      "i" (offsetof (struct rthread, member)));              \
+     else if (sizeof (descr->member) == 4)                                   \
+       asm volatile ("movl %0,%%gs:%P1" :                                    \
+                    : "ir" (value),                                          \
+                      "i" (offsetof (struct rthread, member)));              \
+     else                                                                    \
+       {                                                                     \
+        if (sizeof (descr->member) != 8)                                     \
+          /* There should not be any value with a size other than 1,         \
+             4 or 8.  */                                                     \
+          abort ();                                                          \
+                                                                             \
+        asm volatile ("movl %%eax,%%gs:%P1\n\t"                              \
+                      "movl %%edx,%%gs:%P2" :                                \
+                      : "A" (value),                                         \
+                        "i" (offsetof (struct rthread, member)),             \
+                        "i" (offsetof (struct rthread, member) + 4));        \
+       }})
+
+
+/* Set member of the thread descriptor directly.  */
+# define THREAD_SETMEM_NC(descr, member, idx, value) \
+  ({ if (sizeof (descr->member[0]) == 1)                                     \
+       asm volatile ("movb %b0,%%gs:%P1(%2)" :                               \
+                    : "iq" (value),                                          \
+                      "i" (offsetof (struct rthread, member)),               \
+                      "r" (idx));                                            \
+     else if (sizeof (descr->member[0]) == 4)                                \
+       asm volatile ("movl %0,%%gs:%P1(,%2,4)" :                             \
+                    : "ir" (value),                                          \
+                      "i" (offsetof (struct rthread, member)),               \
+                      "r" (idx));                                            \
+     else                                                                    \
+       {                                                                     \
+        if (sizeof (descr->member[0]) != 8)                                  \
+          /* There should not be any value with a size other than 1,         \
+             4 or 8.  */                                                     \
+          abort ();                                                          \
+                                                                             \
+        asm volatile ("movl %%eax,%%gs:%P1(,%2,8)\n\t"                       \
+                      "movl %%edx,%%gs:4+%P1(,%2,8)" :                       \
+                      : "A" (value),                                         \
+                        "i" (offsetof (struct rthread, member)),             \
+                        "r" (idx));                                          \
+       }})
+
+
+/* Atomic compare and exchange on TLS, returning old value.  */
+#define THREAD_ATOMIC_CMPXCHG_VAL(descr, member, newval, oldval) \
+  ({ __typeof (descr->member) __ret;                                         \
+     __typeof (oldval) __old = (oldval);                                     \
+     if (sizeof (descr->member) == 4)                                        \
+       asm volatile (LOCK_PREFIX "cmpxchgl %2, %%gs:%P3"                     \
+                    : "=a" (__ret)                                           \
+                    : "0" (__old), "r" (newval),                             \
+                      "i" (offsetof (struct rthread, member)));              \
+     else                                                                    \
+       /* Not necessary for other sizes in the moment.  */                   \
+       abort ();                                                             \
+     __ret; })
+
+
+/* Atomic logical and.  */
+#define THREAD_ATOMIC_AND(descr, member, val) \
+  (void) ({ if (sizeof ((descr)->member) == 4)                               \
+             asm volatile (LOCK_PREFIX "andl %1, %%gs:%P0"                   \
+                           :: "i" (offsetof (struct rthread, member)),       \
+                              "ir" (val));                                   \
+           else                                                              \
+             /* Not necessary for other sizes in the moment.  */             \
+             abort (); })
+
+
+/* Atomic set bit.  */
+#define THREAD_ATOMIC_BIT_SET(descr, member, bit) \
+  (void) ({ if (sizeof ((descr)->member) == 4)                               \
+             asm volatile (LOCK_PREFIX "orl %1, %%gs:%P0"                    \
+                           :: "i" (offsetof (struct rthread, member)),       \
+                              "ir" (1 << (bit)));                            \
+           else                                                              \
+             /* Not necessary for other sizes in the moment.  */             \
+             abort (); })
+
+
+/* Call the user-provided thread function.  */
+#define CALL_THREAD_FCT(descr) \
+  ({ void *__res;                                                            \
+     int __ignore1, __ignore2;                                               \
+     asm volatile ("pushl %%eax\n\t"                                         \
+                  "pushl %%eax\n\t"                                          \
+                  "pushl %%eax\n\t"                                          \
+                  "pushl %%gs:%P4\n\t"                                       \
+                  "call *%%gs:%P3\n\t"                                       \
+                  "addl $16, %%esp"                                          \
+                  : "=a" (__res), "=c" (__ignore1), "=d" (__ignore2)         \
+                  : "i" (offsetof (struct rthread, start_routine)),          \
+                    "i" (offsetof (struct rthread, arg)));                   \
+     __res; })
+
+
+/* Set the stack guard field in TCB head.  */
+#define THREAD_SET_STACK_GUARD(value) \
+  THREAD_SETMEM (THREAD_SELF, header.stack_guard, value)
+#define THREAD_COPY_STACK_GUARD(descr) \
+  ((descr)->header.stack_guard                                               \
+   = THREAD_GETMEM (THREAD_SELF, header.stack_guard))
+
+
+/* Set the pointer guard field in the TCB head.  */
+#define THREAD_SET_POINTER_GUARD(value) \
+  THREAD_SETMEM (THREAD_SELF, header.pointer_guard, value)
+#define THREAD_COPY_POINTER_GUARD(descr) \
+  ((descr)->header.pointer_guard                                             \
+   = THREAD_GETMEM (THREAD_SELF, header.pointer_guard))
+
+
+/* Get and set the global scope generation counter in the TCB head.  */
+#define THREAD_GSCOPE_FLAG_UNUSED 0
+#define THREAD_GSCOPE_FLAG_USED   1
+#define THREAD_GSCOPE_FLAG_WAIT   2
+#define THREAD_GSCOPE_RESET_FLAG() \
+  do                                                                         \
+    { int __res;                                                             \
+      asm volatile ("xchgl %0, %%gs:%P1"                                     \
+                   : "=r" (__res)                                            \
+                   : "i" (offsetof (struct rthread, header.gscope_flag)),    \
+                     "0" (THREAD_GSCOPE_FLAG_UNUSED));                       \
+      if (__res == THREAD_GSCOPE_FLAG_WAIT)                                  \
+       lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE);    \
+    }                                                                        \
+  while (0)
+#define THREAD_GSCOPE_SET_FLAG() \
+  THREAD_SETMEM (THREAD_SELF, header.gscope_flag, THREAD_GSCOPE_FLAG_USED)
+#define THREAD_GSCOPE_WAIT() \
+  GL(dl_wait_lookup_done) ()
+
+#endif /* __ASSEMBLER__ */
+
+#endif /* tls.h */
index 0566c65..5d8a18a 100644 (file)
@@ -23,7 +23,7 @@
 #include <stdarg.h>
 #include <string.h>
 #include <sys/stat.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 
 /* Return 1 if FD is a terminal, 0 if not.  */
 int
index d515be4..59f03f7 100644 (file)
@@ -18,7 +18,7 @@
 
 #include <errno.h>
 #include <signal.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 
 /* Send signal SIG to process number PID.  If PID is zero,
    send SIG to all processes in the current process's process group.
index e2214d1..2a42df0 100644 (file)
@@ -19,7 +19,7 @@
 #include <errno.h>
 #include <stddef.h>
 #include <unistd.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 
 /* Make a link to FROM called TO.  */
 int
index a94255e..61b0aba 100644 (file)
@@ -2,6 +2,7 @@
 #define _LOWLEVELLOCK_H
 
 #include <atomic.h>
+#include <ros/arch/hart.h>
 
 #define LLL_PRIVATE 0
 #define LLL_SHARED 1
 
 #define lll_lock(l,p) do { } while(lll_trylock(l))
 #define lll_unlock(l,p) ({ (l) = 0; 0; })
-#define lll_trylock(l) __lll_swap(&(l),1)
+#define lll_trylock(l) __hart_swap(&(l),1)
 
 #define lll_futex_wait(m,v,p) do { assert("NO FUTEX_WAIT FOR YOU!" == 0); } while(0)
 #define lll_futex_wake(m,n,p) do { assert("NO FUTEX_WAKE FOR YOU!" == 0); } while(0)
 
-static inline int __attribute__ ((always_inline))
-__lll_swap(int* addr, int val)
-{
-  __asm__ __volatile__ ("swap %2,%0" : "=r"(val) : "0"(val),"m"(*addr)
-                                       : "memory");
-  return val;
-}
-
 #endif
index 50d0161..ccfe1f6 100644 (file)
@@ -1,7 +1,7 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <errno.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 
 off_t
 __libc_lseek (int fd, off_t offset, int whence)
index 4561fdb..a8a80f0 100644 (file)
@@ -22,7 +22,7 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <assert.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 #include "ros_stat.h"
 
 /* Get file information about FILE in BUF.  */
@@ -35,7 +35,7 @@ __lxstat (int vers, const char *file, struct stat *buf)
     return -1;
   }
 
-  struct newlib_stat nst;
+  struct ros_stat nst;
   int ret = (int)ros_syscall(SYS_lstat,file,&nst,0,0,0);
   __convert_stat(&nst,buf);
   return ret;
index 4e53f79..3e9fa68 100644 (file)
@@ -21,7 +21,7 @@
 #include <stddef.h>
 #include <unistd.h>
 #include <fcntl.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 #include "ros_stat.h"
 
 /* Get file information about FILE in BUF.  */
index a16fc2b..44eeeef 100644 (file)
@@ -19,7 +19,8 @@
 #include <sys/types.h>
 #include <sys/mman.h>
 #include <errno.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
+#include <ros/memlayout.h>
 
 /* Map addresses starting near ADDR and extending for LEN bytes.  From
    OFFSET into the file FD describes according to PROT and FLAGS.  If ADDR
index 94b48fc..46bceac 100644 (file)
@@ -19,7 +19,7 @@
 #include <sys/types.h>
 #include <sys/mman.h>
 #include <errno.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 
 /* Change the memory protection of the region starting at ADDR and
    extending LEN bytes to PROT.  Returns 0 if successful, -1 for errors
index 286f5ef..e9f66fb 100644 (file)
@@ -19,7 +19,7 @@
 #include <sys/types.h>
 #include <sys/mman.h>
 #include <errno.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 
 /* Deallocate any mapping for the region starting at ADDR and extending LEN
    bytes.  Returns 0 if successful, -1 for errors (and sets errno).  */
index 4e5cd8e..c059cb7 100644 (file)
@@ -21,7 +21,7 @@
 #include <stdarg.h>
 #include <stddef.h>
 #include <stdio.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 
 /* Open FILE with access OFLAG.  If OFLAG includes O_CREAT,
    a third argument is the file protection.  */
index 60b9397..5169020 100644 (file)
@@ -20,7 +20,7 @@
 #include <errno.h>
 #include <unistd.h>
 #include <stddef.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 
 /* Write NBYTES of BUF to FD.  Return the number written, or -1.  */
 ssize_t
index 67548de..7d363b4 100644 (file)
@@ -1,31 +1,13 @@
-#ifndef _ROS_STAT_H
-#define _ROS_STAT_H
+#ifndef _ROS_CONVERT_STAT_H
+#define _ROS_CONVERT_STAT_H
 
-struct newlib_stat
-{
-   int16_t st_dev;
-  uint32_t st_ino;
-  uint16_t st_mode;
-  uint16_t st_nlink;
-  uint16_t st_uid;
-  uint16_t st_gid;
-   int16_t st_rdev;
-   int32_t st_size;
-   int32_t st_atime;
-   int32_t st_spare1;
-   int32_t st_mtime;
-   int32_t st_spare2;
-   int32_t st_ctime;
-   int32_t st_spare3;
-   int32_t st_blksize;
-   int32_t st_blocks;
-   int32_t st_spare4[2];
-};
+#include <ros/stat.h>
+
+#define __stat_copy_field(field) \
+  st->st_##field = (typeof(st->st_##field))nst->st_##field
 
-static void __convert_stat(const struct newlib_stat* nst, struct stat* st)
+static void __convert_stat(const struct ros_stat* nst, struct stat* st)
 {
-  #define __stat_copy_field(field) \
-    st->st_##field = (typeof(st->st_##field))nst->st_##field
   __stat_copy_field(dev);
   __stat_copy_field(ino);
   __stat_copy_field(mode);
diff --git a/tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/ros_syscall.h b/tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/ros_syscall.h
deleted file mode 100644 (file)
index cf6c347..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef _ROS_SYSCALL_H
-#define _ROS_SYSCALL_H
-
-#include <sys/stat.h>
-#include <stdint.h>
-#include <errno.h>
-#include <ros/syscall.h>
-#include <ros/memlayout.h>
-#include <ros/procinfo.h>
-
-#define __procinfo (*(procinfo_t*)UINFO)
-
-#define ros_syscall(which,a0,a1,a2,a3,a4) \
-   __ros_syscall(which,(long)(a0),(long)(a1),(long)(a2),(long)(a3),(long)(a4))
-
-static inline long __attribute__((always_inline))
-__ros_syscall(long _num, long _a0, long _a1, long _a2, long _a3, long _a4)
-{
-  register long num asm("g1") = _num;
-  register long a0 asm("o0") = _a0, a1 asm("o1") = _a1;
-  register long a2 asm("o2") = _a2, a3 asm("o3") = _a3;
-  register long a4 asm("o4") = _a4;
-
-  asm volatile("ta 8" : "=r"(a0),"=r"(a1)
-               : "r"(num),"0"(a0),"1"(a1),"r"(a2),"r"(a3),"r"(a4));
-
-  // move a1, a2 longo regular variables so they're volatile across
-  // procedure calls (of which errno is one)
-  long ret = a0, err = a1;
-  if(err != 0)
-    errno = err;
-
-  return ret;
-}
-
-#endif
index 8f588ca..e9dabbf 100644 (file)
@@ -2,7 +2,8 @@
 #include <elf/rtld.c>
 #undef _dl_start
 
-#include "ros_syscall.h"
+#include <ros/syscall.h>
+#include <ros/procinfo.h>
 
 static ElfW(Addr) __attribute_used__ internal_function
 _dl_start(void* arg0)
index 65a7724..a510050 100644 (file)
@@ -18,7 +18,7 @@
 
 #include <errno.h>
 #include <sched.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 
 /* Yield the processor.  */
 int
diff --git a/tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/sparc/sparc32/tls.h b/tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/sparc/sparc32/tls.h
new file mode 100644 (file)
index 0000000..b551c19
--- /dev/null
@@ -0,0 +1,179 @@
+/* Definitions for thread-local data handling.  
+   Copyright (C) 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _TLS_H
+#define _TLS_H
+
+#include <dl-sysdep.h>
+#ifndef __ASSEMBLER__
+# include <stdbool.h>
+# include <stddef.h>
+# include <stdint.h>
+# include <stdlib.h>
+# include <kernel-features.h>
+
+/* Type for the dtv.  */
+typedef union dtv
+{
+  size_t counter;
+  struct
+  {
+    void *val;
+    bool is_static;
+  } pointer;
+} dtv_t;
+
+typedef struct
+{
+  void *tcb;           /* Pointer to the TCB.  Not necessary the
+                          thread descriptor used by librthread.  */
+  dtv_t *dtv;
+  void *self;
+  int multiple_threads;
+#if __WORDSIZE == 64
+  int gscope_flag;
+#endif
+  uintptr_t sysinfo;
+  uintptr_t stack_guard;
+  uintptr_t pointer_guard;
+#if __WORDSIZE != 64
+  int gscope_flag;
+#endif
+#ifndef __ASSUME_PRIVATE_FUTEX
+  int private_futex;
+#endif
+} tcbhead_t;
+
+typedef struct rthread {
+       tcbhead_t header;
+} rthread_t;
+
+#else /* __ASSEMBLER__ */
+//# include <tcb-offsets.h>
+#endif /* __ASSEMBLER__ */
+
+/* We require TLS support in the tools.  */
+#ifndef HAVE_TLS_SUPPORT
+# error "TLS support is required."
+#endif
+
+#ifndef __ASSEMBLER__
+/* Get system call information.  */
+# include <sysdep.h>
+
+register rthread_t *__thread_self __asm__("%g7");
+
+/* This is the size of the initial TCB.  Can't be just sizeof (tcbhead_t),
+   because NPTL getpid, __libc_alloca_cutoff etc. need (almost) the whole
+   struct rthread even when not linked with -lrthread.  */
+# define TLS_INIT_TCB_SIZE sizeof (struct rthread)
+
+/* Alignment requirements for the initial TCB.  */
+# define TLS_INIT_TCB_ALIGN __alignof__ (struct rthread)
+
+/* This is the size of the TCB.  */
+# define TLS_TCB_SIZE sizeof (struct rthread)
+
+/* Alignment requirements for the TCB.  */
+# define TLS_TCB_ALIGN __alignof__ (struct rthread)
+
+/* The TCB can have any size and the memory following the address the
+   thread pointer points to is unspecified.  Allocate the TCB there.  */
+# define TLS_TCB_AT_TP 1
+
+/* Install the dtv pointer.  The pointer passed is to the element with
+   index -1 which contain the length.  */
+# define INSTALL_DTV(descr, dtvp) \
+  ((tcbhead_t *) (descr))->dtv = (dtvp) + 1
+
+/* Install new dtv for current thread.  */
+# define INSTALL_NEW_DTV(DTV) \
+  (((tcbhead_t *) __thread_self)->dtv = (DTV))
+
+/* Return dtv of given thread descriptor.  */
+# define GET_DTV(descr) \
+  (((tcbhead_t *) (descr))->dtv)
+
+/* Code to initially initialize the thread pointer.  */
+# define TLS_INIT_TP(descr, secondcall) \
+  (__thread_self = (__typeof (__thread_self)) (descr), NULL)
+
+/* Return the address of the dtv for the current thread.  */
+# define THREAD_DTV() \
+  (((tcbhead_t *) __thread_self)->dtv)
+
+/* Return the thread descriptor for the current thread.  */
+#define THREAD_SELF  __thread_self
+
+/* Magic for libthread_db to know how to do THREAD_SELF.  */
+# define DB_THREAD_SELF_INCLUDE <sys/ucontext.h>
+# define DB_THREAD_SELF \
+  REGISTER (32, 32, REG_G7 * 4, 0) REGISTER (64, 64, REG_G7 * 8, 0)
+
+/* Access to data in the thread descriptor is easy.  */
+#define THREAD_GETMEM(descr, member) \
+  descr->member
+#define THREAD_GETMEM_NC(descr, member, idx) \
+  descr->member[idx]
+#define THREAD_SETMEM(descr, member, value) \
+  descr->member = (value)
+#define THREAD_SETMEM_NC(descr, member, idx, value) \
+  descr->member[idx] = (value)
+
+/* Set the stack guard field in TCB head.  */
+#define THREAD_SET_STACK_GUARD(value) \
+  THREAD_SETMEM (THREAD_SELF, header.stack_guard, value)
+# define THREAD_COPY_STACK_GUARD(descr) \
+  ((descr)->header.stack_guard \
+   = THREAD_GETMEM (THREAD_SELF, header.stack_guard))
+
+/* Get/set the stack guard field in TCB head.  */
+#define THREAD_GET_POINTER_GUARD() \
+  THREAD_GETMEM (THREAD_SELF, header.pointer_guard)
+#define THREAD_SET_POINTER_GUARD(value) \
+  THREAD_SETMEM (THREAD_SELF, header.pointer_guard, value)
+# define THREAD_COPY_POINTER_GUARD(descr) \
+  ((descr)->header.pointer_guard = THREAD_GET_POINTER_GUARD ())
+
+/* Get and set the global scope generation counter in struct rthread.  */
+#define THREAD_GSCOPE_FLAG_UNUSED 0
+#define THREAD_GSCOPE_FLAG_USED   1
+#define THREAD_GSCOPE_FLAG_WAIT   2
+#define THREAD_GSCOPE_RESET_FLAG() \
+  do                                                                        \
+    { int __res                                                                     \
+       = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag,             \
+                              THREAD_GSCOPE_FLAG_UNUSED);                   \
+      if (__res == THREAD_GSCOPE_FLAG_WAIT)                                 \
+       lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE);   \
+    }                                                                       \
+  while (0)
+#define THREAD_GSCOPE_SET_FLAG() \
+  do                                                                        \
+    {                                                                       \
+      THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED;            \
+      atomic_write_barrier ();                                              \
+    }                                                                       \
+  while (0)
+#define THREAD_GSCOPE_WAIT() \
+  GL(dl_wait_lookup_done) ()
+
+#endif /* !ASSEMBLER */
+
+#endif /* tls.h */
index fb921df..4b997b4 100644 (file)
@@ -2,7 +2,8 @@
 #include <string.h>
 #include <ros/arch/hart.h>
 #include <stdio.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
+#include <ros/procinfo.h>
 
 void** __hart_stack_pointers = NULL;
 weak_alias(__hart_stack_pointers,hart_stack_pointers)
index b225e1a..54725b5 100644 (file)
@@ -20,7 +20,7 @@
 #include <errno.h>
 #include <unistd.h>
 #include <stdarg.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 
 long int
 syscall(long int num, ...)
index 80c4060..1185783 100644 (file)
@@ -26,7 +26,9 @@
 #include <limits.h>
 #include <sys/param.h>
 #include <sys/sysinfo.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
+#include <ros/procinfo.h>
+#include <ros/memlayout.h>
 
 /* Get the value of the system variable NAME.  */
 long int
index dec66e9..95b7e62 100644 (file)
@@ -19,7 +19,7 @@
 #include <errno.h>
 #include <stddef.h>
 #include <termios.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 
 /* Put the state of FD into *TERMIOS_P.  */
 int
index a719157..c63bde9 100644 (file)
@@ -19,7 +19,7 @@
 #include <errno.h>
 #include <stddef.h>
 #include <termios.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 
 /* Set the state of FD to *TERMIOS_P.  */
 int
index 207970f..7eca030 100644 (file)
@@ -20,7 +20,8 @@
 #include <sys/times.h>
 #include <sys/time.h>
 #include <stddef.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
+#include <ros/procinfo.h>
 
 /* Store the CPU time used by this process and all its
    dead children (and their dead children) in BUFFER.
diff --git a/tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/tls.h b/tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/tls.h
deleted file mode 100644 (file)
index b551c19..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-/* Definitions for thread-local data handling.  
-   Copyright (C) 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
-
-#ifndef _TLS_H
-#define _TLS_H
-
-#include <dl-sysdep.h>
-#ifndef __ASSEMBLER__
-# include <stdbool.h>
-# include <stddef.h>
-# include <stdint.h>
-# include <stdlib.h>
-# include <kernel-features.h>
-
-/* Type for the dtv.  */
-typedef union dtv
-{
-  size_t counter;
-  struct
-  {
-    void *val;
-    bool is_static;
-  } pointer;
-} dtv_t;
-
-typedef struct
-{
-  void *tcb;           /* Pointer to the TCB.  Not necessary the
-                          thread descriptor used by librthread.  */
-  dtv_t *dtv;
-  void *self;
-  int multiple_threads;
-#if __WORDSIZE == 64
-  int gscope_flag;
-#endif
-  uintptr_t sysinfo;
-  uintptr_t stack_guard;
-  uintptr_t pointer_guard;
-#if __WORDSIZE != 64
-  int gscope_flag;
-#endif
-#ifndef __ASSUME_PRIVATE_FUTEX
-  int private_futex;
-#endif
-} tcbhead_t;
-
-typedef struct rthread {
-       tcbhead_t header;
-} rthread_t;
-
-#else /* __ASSEMBLER__ */
-//# include <tcb-offsets.h>
-#endif /* __ASSEMBLER__ */
-
-/* We require TLS support in the tools.  */
-#ifndef HAVE_TLS_SUPPORT
-# error "TLS support is required."
-#endif
-
-#ifndef __ASSEMBLER__
-/* Get system call information.  */
-# include <sysdep.h>
-
-register rthread_t *__thread_self __asm__("%g7");
-
-/* This is the size of the initial TCB.  Can't be just sizeof (tcbhead_t),
-   because NPTL getpid, __libc_alloca_cutoff etc. need (almost) the whole
-   struct rthread even when not linked with -lrthread.  */
-# define TLS_INIT_TCB_SIZE sizeof (struct rthread)
-
-/* Alignment requirements for the initial TCB.  */
-# define TLS_INIT_TCB_ALIGN __alignof__ (struct rthread)
-
-/* This is the size of the TCB.  */
-# define TLS_TCB_SIZE sizeof (struct rthread)
-
-/* Alignment requirements for the TCB.  */
-# define TLS_TCB_ALIGN __alignof__ (struct rthread)
-
-/* The TCB can have any size and the memory following the address the
-   thread pointer points to is unspecified.  Allocate the TCB there.  */
-# define TLS_TCB_AT_TP 1
-
-/* Install the dtv pointer.  The pointer passed is to the element with
-   index -1 which contain the length.  */
-# define INSTALL_DTV(descr, dtvp) \
-  ((tcbhead_t *) (descr))->dtv = (dtvp) + 1
-
-/* Install new dtv for current thread.  */
-# define INSTALL_NEW_DTV(DTV) \
-  (((tcbhead_t *) __thread_self)->dtv = (DTV))
-
-/* Return dtv of given thread descriptor.  */
-# define GET_DTV(descr) \
-  (((tcbhead_t *) (descr))->dtv)
-
-/* Code to initially initialize the thread pointer.  */
-# define TLS_INIT_TP(descr, secondcall) \
-  (__thread_self = (__typeof (__thread_self)) (descr), NULL)
-
-/* Return the address of the dtv for the current thread.  */
-# define THREAD_DTV() \
-  (((tcbhead_t *) __thread_self)->dtv)
-
-/* Return the thread descriptor for the current thread.  */
-#define THREAD_SELF  __thread_self
-
-/* Magic for libthread_db to know how to do THREAD_SELF.  */
-# define DB_THREAD_SELF_INCLUDE <sys/ucontext.h>
-# define DB_THREAD_SELF \
-  REGISTER (32, 32, REG_G7 * 4, 0) REGISTER (64, 64, REG_G7 * 8, 0)
-
-/* Access to data in the thread descriptor is easy.  */
-#define THREAD_GETMEM(descr, member) \
-  descr->member
-#define THREAD_GETMEM_NC(descr, member, idx) \
-  descr->member[idx]
-#define THREAD_SETMEM(descr, member, value) \
-  descr->member = (value)
-#define THREAD_SETMEM_NC(descr, member, idx, value) \
-  descr->member[idx] = (value)
-
-/* Set the stack guard field in TCB head.  */
-#define THREAD_SET_STACK_GUARD(value) \
-  THREAD_SETMEM (THREAD_SELF, header.stack_guard, value)
-# define THREAD_COPY_STACK_GUARD(descr) \
-  ((descr)->header.stack_guard \
-   = THREAD_GETMEM (THREAD_SELF, header.stack_guard))
-
-/* Get/set the stack guard field in TCB head.  */
-#define THREAD_GET_POINTER_GUARD() \
-  THREAD_GETMEM (THREAD_SELF, header.pointer_guard)
-#define THREAD_SET_POINTER_GUARD(value) \
-  THREAD_SETMEM (THREAD_SELF, header.pointer_guard, value)
-# define THREAD_COPY_POINTER_GUARD(descr) \
-  ((descr)->header.pointer_guard = THREAD_GET_POINTER_GUARD ())
-
-/* Get and set the global scope generation counter in struct rthread.  */
-#define THREAD_GSCOPE_FLAG_UNUSED 0
-#define THREAD_GSCOPE_FLAG_USED   1
-#define THREAD_GSCOPE_FLAG_WAIT   2
-#define THREAD_GSCOPE_RESET_FLAG() \
-  do                                                                        \
-    { int __res                                                                     \
-       = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag,             \
-                              THREAD_GSCOPE_FLAG_UNUSED);                   \
-      if (__res == THREAD_GSCOPE_FLAG_WAIT)                                 \
-       lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE);   \
-    }                                                                       \
-  while (0)
-#define THREAD_GSCOPE_SET_FLAG() \
-  do                                                                        \
-    {                                                                       \
-      THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED;            \
-      atomic_write_barrier ();                                              \
-    }                                                                       \
-  while (0)
-#define THREAD_GSCOPE_WAIT() \
-  GL(dl_wait_lookup_done) ()
-
-#endif /* !ASSEMBLER */
-
-#endif /* tls.h */
index 305c9c7..24923c8 100644 (file)
@@ -19,7 +19,7 @@
 #include <sys/stat.h>
 #include <errno.h>
 #include <sys/types.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 
 /* Set the file creation mask to MASK, returning the old mask.  */
 mode_t
index 2ca8c30..ba2f9b6 100644 (file)
@@ -19,7 +19,7 @@
 #include <errno.h>
 #include <stddef.h>
 #include <unistd.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 
 /* Remove the link named NAME.  */
 int
index 51d40bd..52f3956 100644 (file)
@@ -21,7 +21,7 @@
 #include <sys/types.h>
 #include <sched.h>
 #include <bits/libc-lock.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 
 /* Wait for a child matching PID to die.
    If PID is greater than 0, match any process whose process ID is PID.
index 3ed5b31..823136f 100644 (file)
@@ -20,7 +20,7 @@
 #include <errno.h>
 #include <unistd.h>
 #include <stddef.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 
 /* Write NBYTES of BUF to FD.  Return the number written, or -1.  */
 ssize_t
index 8151f14..ed22081 100644 (file)
@@ -21,7 +21,7 @@
 #include <stddef.h>
 #include <unistd.h>
 #include <fcntl.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 #include "ros_stat.h"
 
 /* Get file information about FILE in BUF.  */
@@ -34,7 +34,7 @@ __xstat (int vers, const char *file, struct stat *buf)
     return -1;
   }
 
-  struct newlib_stat nst;
+  struct ros_stat nst;
   int ret = (int)ros_syscall(SYS_stat,file,&nst,0,0,0);
   __convert_stat(&nst,buf);
   return ret;
index 809ea66..879e4e3 100644 (file)
@@ -21,7 +21,7 @@
 #include <stddef.h>
 #include <unistd.h>
 #include <fcntl.h>
-#include "ros_syscall.h"
+#include <ros/syscall.h>
 #include "ros_stat.h"
 
 /* Get file information about FILE in BUF.  */