@@ -272,6 +272,7 @@ GCC_VER := $(subst ., ,$(GCC_VER))
GCC_MAJOR_VER ?= $(word 1,$(GCC_VER))
#GCC_MINOR_VER ?= $(word 2,$(GCC_VER))
+ifneq ($(TARGET_ARCH),arc)
ifeq ($(GCC_MAJOR_VER),4)
# shrinks code, results are from 4.0.2
# 0.36%
@@ -284,7 +285,7 @@ OPTIMIZATION += $(CFLAG_-fno-tree-dominator-opts)
$(eval $(call check-gcc-var,-fno-strength-reduce))
OPTIMIZATION += $(CFLAG_-fno-strength-reduce)
endif
-
+endif
# CPU_CFLAGS-y contain options which are not warnings,
# not include or library paths, and not optimizations.
@@ -543,6 +544,11 @@ ifeq ($(TARGET_ARCH),c6x)
CPU_LDFLAGS-y += $(CPU_CFLAGS)
endif
+ifeq ($(TARGET_ARCH),arc)
+ CPU_CFLAGS-$(CONFIG_ARC_CPU_700) += -mA7 -mlock
+ CPU_LDFLAGS-y += $(CPU_CFLAGS) -marclinux
+endif
+
$(eval $(call check-gcc-var,$(PIEFLAG_NAME)))
PIEFLAG := $(CFLAG_$(PIEFLAG_NAME))
ifeq ($(PIEFLAG),)
new file mode 100644
@@ -0,0 +1,23 @@
+#
+# For a description of the syntax of this configuration file,
+# see extra/config/Kconfig-language.txt
+#
+config TARGET_ARCH
+ default "arc"
+
+config FORCE_OPTIONS_FOR_ARCH
+ bool
+ default y
+ select ARCH_ANY_ENDIAN
+
+choice
+ prompt "Target Processor Type"
+ default CONFIG_ARC_CPU_700
+
+config CONFIG_ARC_CPU_700
+ bool "ARC700"
+ select ARCH_HAS_MMU
+ help
+ ARCompact ISA based ARC CPU
+
+endchoice
@@ -12,6 +12,7 @@ config DESIRED_TARGET_ARCH
choice
prompt "Target Architecture"
default TARGET_alpha if DESIRED_TARGET_ARCH = "alpha"
+ default TARGET_arc if DESIRED_TARGET_ARCH = "arc"
default TARGET_arm if DESIRED_TARGET_ARCH = "arm"
default TARGET_avr32 if DESIRED_TARGET_ARCH = "avr32"
default TARGET_bfin if DESIRED_TARGET_ARCH = "bfin"
@@ -43,6 +44,9 @@ choice
config TARGET_alpha
bool "alpha"
+config TARGET_arc
+ bool "arc"
+
config TARGET_arm
bool "arm"
@@ -234,6 +238,10 @@ if TARGET_c6x
source "extra/Configs/Config.c6x"
endif
+if TARGET_arc
+source "extra/Configs/Config.arc"
+endif
+
config TARGET_SUBARCH
string
default "e500" if CONFIG_E500
new file mode 100755
@@ -0,0 +1,13 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+top_srcdir:=../../../
+top_builddir:=../../../
+all: objs
+include $(top_builddir)Rules.mak
+include ../Makefile.in
+include $(top_srcdir)Makerules
new file mode 100644
@@ -0,0 +1,123 @@
+/* Copyright (C) 2007 ARC International (UK) LTD */
+
+#include <bits/asm.h>
+#include <features.h>
+
+#ifdef __LITTLE_ENDIAN__
+#define WORD2 r2
+#define SHIFT r3
+#else /* BIG ENDIAN */
+#define WORD2 r3
+#define SHIFT r2
+#endif
+
+ENTRY(memcmp)
+ or r12,r0,r1
+ asl_s r12,r12,30
+ sub r3,r2,1
+ brls r2,r12,.Lbytewise
+ ld r4,[r0,0]
+ ld r5,[r1,0]
+ lsr.f lp_count,r3,3
+ lpne .Loop_end
+ ld_s WORD2,[r0,4]
+ ld_s r12,[r1,4]
+ brne r4,r5,.Leven
+ ld.a r4,[r0,8]
+ ld.a r5,[r1,8]
+ brne WORD2,r12,.Lodd
+.Loop_end:
+ asl_s SHIFT,SHIFT,3
+ bhs_s .Last_cmp
+ brne r4,r5,.Leven
+ ld r4,[r0,4]
+ ld r5,[r1,4]
+#ifdef __LITTLE_ENDIAN__
+ nop_s
+ ; one more load latency cycle
+.Last_cmp:
+ xor r0,r4,r5
+ bset r0,r0,SHIFT
+ sub_s r1,r0,1
+ bic_s r1,r1,r0
+ norm r1,r1
+ b.d .Leven_cmp
+ and r1,r1,24
+.Leven:
+ xor r0,r4,r5
+ sub_s r1,r0,1
+ bic_s r1,r1,r0
+ norm r1,r1
+ ; slow track insn
+ and r1,r1,24
+.Leven_cmp:
+ asl r2,r4,r1
+ asl r12,r5,r1
+ lsr_s r2,r2,1
+ lsr_s r12,r12,1
+ j_s.d [blink]
+ sub r0,r2,r12
+ .balign 4
+.Lodd:
+ xor r0,WORD2,r12
+ sub_s r1,r0,1
+ bic_s r1,r1,r0
+ norm r1,r1
+ ; slow track insn
+ and r1,r1,24
+ asl_s r2,r2,r1
+ asl_s r12,r12,r1
+ lsr_s r2,r2,1
+ lsr_s r12,r12,1
+ j_s.d [blink]
+ sub r0,r2,r12
+#else /* BIG ENDIAN */
+.Last_cmp:
+ neg_s SHIFT,SHIFT
+ lsr r4,r4,SHIFT
+ lsr r5,r5,SHIFT
+ ; slow track insn
+.Leven:
+ sub.f r0,r4,r5
+ mov.ne r0,1
+ j_s.d [blink]
+ bset.cs r0,r0,31
+.Lodd:
+ cmp_s WORD2,r12
+ mov_s r0,1
+ j_s.d [blink]
+ bset.cs r0,r0,31
+#endif /* ENDIAN */
+ .balign 4
+.Lbytewise:
+ breq r2,0,.Lnil
+ ldb r4,[r0,0]
+ ldb r5,[r1,0]
+ lsr.f lp_count,r3
+ lpne .Lbyte_end
+ ldb_s r3,[r0,1]
+ ldb r12,[r1,1]
+ brne r4,r5,.Lbyte_even
+ ldb.a r4,[r0,2]
+ ldb.a r5,[r1,2]
+ brne r3,r12,.Lbyte_odd
+.Lbyte_end:
+ bcc .Lbyte_even
+ brne r4,r5,.Lbyte_even
+ ldb_s r3,[r0,1]
+ ldb_s r12,[r1,1]
+.Lbyte_odd:
+ j_s.d [blink]
+ sub r0,r3,r12
+.Lbyte_even:
+ j_s.d [blink]
+ sub r0,r4,r5
+.Lnil:
+ j_s.d [blink]
+ mov r0,0
+ENDFUNC(memcmp)
+libc_hidden_def(memcmp)
+
+#ifdef __UCLIBC_SUSV3_LEGACY__
+strong_alias(memcmp,bcmp)
+#endif
new file mode 100644
@@ -0,0 +1,66 @@
+/* Copyright (C) 2007 ARC International (UK) LTD */
+
+#include <bits/asm.h>
+
+/* This memcpy implementation does not support objects of 1GB or larger -
+ the check for alignment does not work then. */
+/* We assume that most sources and destinations are aligned, and
+ that also lengths are mostly a multiple of four, although to a lesser
+ extent. */
+ENTRY(memcpy)
+ or r3,r0,r1
+ asl_s r3,r3,30
+ mov_s r5,r0
+ brls.d r2,r3,.Lcopy_bytewise
+ sub.f r3,r2,1
+ ld_s r12,[r1,0]
+ asr.f lp_count,r3,3
+ bbit0.d r3,2,.Lnox4
+ bmsk_s r2,r2,1
+ st.ab r12,[r5,4]
+ ld.a r12,[r1,4]
+.Lnox4:
+ lppnz .Lendloop
+ ld_s r3,[r1,4]
+ st.ab r12,[r5,4]
+ ld.a r12,[r1,8]
+ st.ab r3,[r5,4]
+.Lendloop:
+ breq r2,0,.Last_store
+ ld r3,[r5,0]
+#ifdef __LITTLE_ENDIAN__
+ add3 r2,-1,r2
+ ; uses long immediate
+ xor_s r12,r12,r3
+ bmsk r12,r12,r2
+ xor_s r12,r12,r3
+#else /* BIG ENDIAN */
+ sub3 r2,31,r2
+ ; uses long immediate
+ xor_s r3,r3,r12
+ bmsk r3,r3,r2
+ xor_s r12,r12,r3
+#endif /* ENDIAN */
+.Last_store:
+ j_s.d [blink]
+ st r12,[r5,0]
+
+ .balign 4
+.Lcopy_bytewise:
+ jcs [blink]
+ ldb_s r12,[r1,0]
+ lsr.f lp_count,r3
+ bhs_s .Lnox1
+ stb.ab r12,[r5,1]
+ ldb.a r12,[r1,1]
+.Lnox1:
+ lppnz .Lendbloop
+ ldb_s r3,[r1,1]
+ stb.ab r12,[r5,1]
+ ldb.a r12,[r1,2]
+ stb.ab r3,[r5,1]
+.Lendbloop:
+ j_s.d [blink]
+ stb r12,[r5,0]
+ENDFUNC(memcpy)
+libc_hidden_def(memcpy)
new file mode 100644
@@ -0,0 +1,46 @@
+/* Copyright (C) 2007 ARC International (UK) LTD */
+
+#include <bits/asm.h>
+
+#define SMALL 7 /* Must be at least 6 to deal with alignment/loop issues. */
+
+ENTRY(memset)
+
+ mov_s r4,r0
+ or r12,r0,r2
+ bmsk.f r12,r12,1
+ extb_s r1,r1
+ asl r3,r1,8
+ beq.d .Laligned
+ or_s r1,r1,r3
+ brls r2,SMALL,.Ltiny
+ add r3,r2,r0
+ stb r1,[r3,-1]
+ bclr_s r3,r3,0
+ stw r1,[r3,-2]
+ bmsk.f r12,r0,1
+ add_s r2,r2,r12
+ sub.ne r2,r2,4
+ stb.ab r1,[r4,1]
+ and r4,r4,-2
+ stw.ab r1,[r4,2]
+ and r4,r4,-4
+.Laligned: ; This code address should be aligned for speed.
+ asl r3,r1,16
+ lsr.f lp_count,r2,2
+ or_s r1,r1,r3
+ lpne .Loop_end
+ st.ab r1,[r4,4]
+.Loop_end:
+ j_s [blink]
+
+
+ .balign 4
+.Ltiny:
+ mov.f lp_count,r2
+ lpne .Ltiny_end
+ stb.ab r1,[r4,1]
+.Ltiny_end:
+ j_s [blink]
+ENDFUNC(memset)
+libc_hidden_def(memset)
new file mode 100644
@@ -0,0 +1,133 @@
+/* Copyright (C) 2007 ARC International (UK) LTD */
+
+#include <bits/asm.h>
+#include <features.h>
+
+/* ARC700 has a relatively long pipeline and branch prediction, so we want
+ to avoid branches that are hard to predict. On the other hand, the
+ presence of the norm instruction makes it easier to operate on whole
+ words branch-free. */
+
+ENTRY(strchr)
+ extb_s r1,r1
+ asl r5,r1,8
+ bmsk r2,r0,1
+ or r5,r5,r1
+ mov_s r3,0x01010101
+ breq.d r2,r0,.Laligned
+ asl r4,r5,16
+ sub_s r0,r0,r2
+ asl r7,r2,3
+ ld_s r2,[r0]
+#ifdef __LITTLE_ENDIAN__
+ asl r7,r3,r7
+#else
+ lsr r7,r3,r7
+#endif
+ or r5,r5,r4
+ ror r4,r3
+ sub r12,r2,r7
+ bic_s r12,r12,r2
+ and r12,r12,r4
+ brne.d r12,0,.Lfound0_ua
+ xor r6,r2,r5
+ ld.a r2,[r0,4]
+ sub r12,r6,r7
+ bic r12,r12,r6
+#ifdef __LITTLE_ENDIAN__
+ and r7,r12,r4
+ breq r7,0,.Loop ; For speed, we want this branch to be unaligned.
+ b .Lfound_char ; Likewise this one.
+#else
+ and r12,r12,r4
+ breq r12,0,.Loop ; For speed, we want this branch to be unaligned.
+ lsr_s r12,r12,7
+ bic r2,r7,r6
+ b.d .Lfound_char_b
+ and_s r2,r2,r12
+#endif
+; /* We require this code address to be unaligned for speed... */
+.Laligned:
+ ld_s r2,[r0]
+ or r5,r5,r4
+ ror r4,r3
+; /* ... so that this code address is aligned, for itself and ... */
+.Loop:
+ sub r12,r2,r3
+ bic_s r12,r12,r2
+ and r12,r12,r4
+ brne.d r12,0,.Lfound0
+ xor r6,r2,r5
+ ld.a r2,[r0,4]
+ sub r12,r6,r3
+ bic r12,r12,r6
+ and r7,r12,r4
+ breq r7,0,.Loop /* ... so that this branch is unaligned. */
+ ; Found searched-for character. r0 has already advanced to next word.
+#ifdef __LITTLE_ENDIAN__
+/* We only need the information about the first matching byte
+ (i.e. the least significant matching byte) to be exact,
+ hence there is no problem with carry effects. */
+.Lfound_char:
+ sub r3,r7,1
+ bic r3,r3,r7
+ norm r2,r3
+ sub_s r0,r0,1
+ asr_s r2,r2,3
+ j.d [blink]
+ sub_s r0,r0,r2
+
+ .balign 4
+.Lfound0_ua:
+ mov r3,r7
+.Lfound0:
+ sub r3,r6,r3
+ bic r3,r3,r6
+ and r2,r3,r4
+ or_s r12,r12,r2
+ sub_s r3,r12,1
+ bic_s r3,r3,r12
+ norm r3,r3
+ add_s r0,r0,3
+ asr_s r12,r3,3
+ asl.f 0,r2,r3
+ sub_s r0,r0,r12
+ j_s.d [blink]
+ mov.pl r0,0
+#else /* BIG ENDIAN */
+.Lfound_char:
+ lsr r7,r7,7
+
+ bic r2,r7,r6
+.Lfound_char_b:
+ norm r2,r2
+ sub_s r0,r0,4
+ asr_s r2,r2,3
+ j.d [blink]
+ add_s r0,r0,r2
+
+.Lfound0_ua:
+ mov_s r3,r7
+.Lfound0:
+ asl_s r2,r2,7
+ or r7,r6,r4
+ bic_s r12,r12,r2
+ sub r2,r7,r3
+ or r2,r2,r6
+ bic r12,r2,r12
+ bic.f r3,r4,r12
+ norm r3,r3
+
+ add.pl r3,r3,1
+ asr_s r12,r3,3
+ asl.f 0,r2,r3
+ add_s r0,r0,r12
+ j_s.d [blink]
+ mov.mi r0,0
+#endif /* ENDIAN */
+ENDFUNC(strchr)
+libc_hidden_def(strchr)
+
+#ifdef __UCLIBC_SUSV3_LEGACY__
+strong_alias(strchr,index)
+#endif
new file mode 100644
@@ -0,0 +1,97 @@
+/* Copyright (C) 2007 ARC International (UK) LTD */
+
+#include <features.h>
+#include <bits/asm.h>
+
+/* This is optimized primarily for the ARC700.
+ It would be possible to speed up the loops by one cycle / word
+ respective one cycle / byte by forcing double source 1 alignment, unrolling
+ by a factor of two, and speculatively loading the second word / byte of
+ source 1; however, that would increase the overhead for loop setup / finish,
+ and strcmp might often terminate early. */
+
+ENTRY(strcmp)
+ or r2,r0,r1
+ bmsk_s r2,r2,1
+ brne r2,0,.Lcharloop
+ mov_s r12,0x01010101
+ ror r5,r12
+.Lwordloop:
+ ld.ab r2,[r0,4]
+ ld.ab r3,[r1,4]
+ nop_s
+ sub r4,r2,r12
+ bic r4,r4,r2
+ and r4,r4,r5
+ brne r4,0,.Lfound0
+ breq r2,r3,.Lwordloop
+#ifdef __LITTLE_ENDIAN__
+ xor r0,r2,r3 ; mask for difference
+ sub_s r1,r0,1
+ bic_s r0,r0,r1 ; mask for least significant difference bit
+ sub r1,r5,r0
+ xor r0,r5,r1 ; mask for least significant difference byte
+ and_s r2,r2,r0
+ and_s r3,r3,r0
+#endif /* LITTLE ENDIAN */
+ cmp_s r2,r3
+ mov_s r0,1
+ j_s.d [blink]
+ bset.lo r0,r0,31
+
+ .balign 4
+#ifdef __LITTLE_ENDIAN__
+.Lfound0:
+ xor r0,r2,r3 ; mask for difference
+ or r0,r0,r4 ; or in zero indicator
+ sub_s r1,r0,1
+ bic_s r0,r0,r1 ; mask for least significant difference bit
+ sub r1,r5,r0
+ xor r0,r5,r1 ; mask for least significant difference byte
+ and_s r2,r2,r0
+ and_s r3,r3,r0
+ sub.f r0,r2,r3
+ mov.hi r0,1
+ j_s.d [blink]
+ bset.lo r0,r0,31
+#else /* BIG ENDIAN */
+ /* The zero-detection above can mis-detect 0x01 bytes as zeroes
+ because of carry-propagateion from a lower significant zero byte.
+ We can compensate for this by checking that bit0 is zero.
+ This compensation is not necessary in the step where we
+ get a low estimate for r2, because in any affected bytes
+ we already have 0x00 or 0x01, which will remain unchanged
+ when bit 7 is cleared. */
+ .balign 4
+.Lfound0:
+ lsr r0,r4,8
+ lsr_s r1,r2
+ bic_s r2,r2,r0 ; get low estimate for r2 and get ...
+ bic_s r0,r0,r1 ; <this is the adjusted mask for zeros>
+ or_s r3,r3,r0 ; ... high estimate r3 so that r2 > r3 will ...
+ cmp_s r3,r2 ; ... be independent of trailing garbage
+ or_s r2,r2,r0 ; likewise for r3 > r2
+ bic_s r3,r3,r0
+ rlc r0,0 ; r0 := r2 > r3 ? 1 : 0
+ cmp_s r2,r3
+ j_s.d [blink]
+ bset.lo r0,r0,31
+#endif /* ENDIAN */
+
+ .balign 4
+.Lcharloop:
+ ldb.ab r2,[r0,1]
+ ldb.ab r3,[r1,1]
+ nop_s
+ breq r2,0,.Lcmpend
+ breq r2,r3,.Lcharloop
+.Lcmpend:
+ j_s.d [blink]
+ sub r0,r2,r3
+ENDFUNC(strcmp)
+libc_hidden_def(strcmp)
+
+#ifndef __UCLIBC_HAS_LOCALE__
+strong_alias(strcmp,strcoll)
+libc_hidden_def(strcoll)
+#endif
new file mode 100644
@@ -0,0 +1,65 @@
+/* Copyright (C) 2007 ARC International (UK) LTD */
+
+#include <bits/asm.h>
+
+/* If dst and src are 4 byte aligned, copy 8 bytes at a time.
+ If the src is 4, but not 8 byte aligned, we first read 4 bytes to get
+ it 8 byte aligned. Thus, we can do a little read-ahead, without
+ dereferencing a cache line that we should not touch.
+ Note that short and long instructions have been scheduled to avoid
+ branch stalls.
+ The beq_s to r3z could be made unaligned & long to avoid a stall
+ there, but the it is not likely to be taken often, and it
+ would also be likey to cost an unaligned mispredict at the next call. */
+
+ENTRY(strcpy)
+ or r2,r0,r1
+ bmsk_s r2,r2,1
+ brne.d r2,0,charloop
+ mov_s r10,r0
+ ld_s r3,[r1,0]
+ mov r8,0x01010101
+ bbit0.d r1,2,loop_start
+ ror r12,r8
+ sub r2,r3,r8
+ bic_s r2,r2,r3
+ tst_s r2,r12
+ bne r3z
+ mov_s r4,r3
+ .balign 4
+loop:
+ ld.a r3,[r1,4]
+ st.ab r4,[r10,4]
+loop_start:
+ ld.a r4,[r1,4]
+ sub r2,r3,r8
+ bic_s r2,r2,r3
+ tst_s r2,r12
+ bne_s r3z
+ st.ab r3,[r10,4]
+ sub r2,r4,r8
+ bic r2,r2,r4
+ tst r2,r12
+ beq loop
+ mov_s r3,r4
+#ifdef __LITTLE_ENDIAN__
+r3z: bmsk.f r1,r3,7
+ lsr_s r3,r3,8
+#else
+r3z: lsr.f r1,r3,24
+ asl_s r3,r3,8
+#endif
+ bne.d r3z
+ stb.ab r1,[r10,1]
+ j_s [blink]
+
+ .balign 4
+charloop:
+ ldb.ab r3,[r1,1]
+
+
+ brne.d r3,0,charloop
+ stb.ab r3,[r10,1]
+ j [blink]
+ENDFUNC(strcpy)
+libc_hidden_def(strcpy)
new file mode 100644
@@ -0,0 +1,78 @@
+/* Copyright (C) 2007 ARC International (UK) LTD */
+
+#include <bits/asm.h>
+
+ENTRY(strlen)
+ or r3,r0,7
+ ld r2,[r3,-7]
+ ld.a r6,[r3,-3]
+ mov r4,0x01010101
+ ; uses long immediate
+#ifdef __LITTLE_ENDIAN__
+ asl_s r1,r0,3
+ btst_s r0,2
+ asl r7,r4,r1
+ ror r5,r4
+ sub r1,r2,r7
+ bic_s r1,r1,r2
+ mov.eq r7,r4
+ sub r12,r6,r7
+ bic r12,r12,r6
+ or.eq r12,r12,r1
+ and r12,r12,r5
+ brne r12,0,.Learly_end
+#else /* BIG ENDIAN */
+ ror r5,r4
+ btst_s r0,2
+ mov_s r1,31
+ sub3 r7,r1,r0
+ sub r1,r2,r4
+ bic_s r1,r1,r2
+ bmsk r1,r1,r7
+ sub r12,r6,r4
+ bic r12,r12,r6
+ bmsk.ne r12,r12,r7
+ or.eq r12,r12,r1
+ and r12,r12,r5
+ brne r12,0,.Learly_end
+#endif /* ENDIAN */
+
+.Loop:
+ ld_s r2,[r3,4]
+ ld.a r6,[r3,8]
+ ; stall for load result
+ sub r1,r2,r4
+ bic_s r1,r1,r2
+ sub r12,r6,r4
+ bic r12,r12,r6
+ or r12,r12,r1
+ and r12,r12,r5
+ breq r12,0,.Loop
+.Lend:
+ and.f r1,r1,r5
+ sub.ne r3,r3,4
+ mov.eq r1,r12
+#ifdef __LITTLE_ENDIAN__
+ sub_s r2,r1,1
+ bic_s r2,r2,r1
+ norm r1,r2
+ sub_s r0,r0,3
+ lsr_s r1,r1,3
+ sub r0,r3,r0
+ j_s.d [blink]
+ sub r0,r0,r1
+#else /* BIG ENDIAN */
+ lsr_s r1,r1,7
+ mov.eq r2,r6
+ bic_s r1,r1,r2
+ norm r1,r1
+ sub r0,r3,r0
+ lsr_s r1,r1,3
+ j_s.d [blink]
+ add r0,r0,r1
+#endif /* ENDIAN */
+.Learly_end:
+ b.d .Lend
+ sub_s.ne r1,r1,r1
+ENDFUNC(strlen)
+libc_hidden_def(strlen)
new file mode 100644
@@ -0,0 +1,13 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+top_srcdir=../../../../
+top_builddir=../../../../
+all: objs
+include $(top_builddir)Rules.mak
+include Makefile.arch
+include $(top_srcdir)Makerules
new file mode 100644
@@ -0,0 +1,11 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+CSRC-y := syscall.c sigaction.c __syscall_error.c cacheflush.c
+
+SSRC-y := sigrestorer.S __longjmp.S setjmp.S bsd-setjmp.S bsd-_setjmp.S \
+ vfork.S clone.S
new file mode 100644
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <bits/asm.h>
+
+;@ r0 = jump buffer from which regs will be restored
+;@ r1 = value that setjmp( ) will return due to this longjmp
+
+ENTRY(__longjmp)
+
+ ld_s r13, [r0]
+ ld_s r14, [r0,4]
+ ld r15, [r0,8]
+ ld r16, [r0,12]
+ ld r17, [r0,16]
+ ld r18, [r0,20]
+ ld r19, [r0,24]
+ ld r20, [r0,28]
+ ld r21, [r0,32]
+ ld r22, [r0,36]
+ ld r23, [r0,40]
+ ld r24, [r0,44]
+ ld r25, [r0,48]
+
+ ld blink, [r0,60] ; load it early enough to not stall the pipeline
+ ld fp, [r0,52]
+ ld sp, [r0,56]
+
+ mov.f r0, r1 ; get the setjmp return value(due to longjmp) in place
+
+ j.d [blink] ; to caller of setjmp location, right after the call
+ mov.z r0, 1 ; can't let setjmp return 0 when it is due to longjmp
+
+ENDFUNC(__longjmp)
+libc_hidden_def(__longjmp)
new file mode 100644
@@ -0,0 +1,15 @@
+/* Wrapper for setting errno.
+ *
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <errno.h>
+#include <sys/syscall.h>
+
+int __syscall_error(int err_no)
+{
+ __set_errno(-err_no);
+ return -1;
+}
new file mode 100644
@@ -0,0 +1,22 @@
+#ifndef _LINUX_ARC_ASM_H
+#define _LINUX_ARC_ASM_H 1
+
+#ifdef __ASSEMBLER__
+
+#ifdef SHARED
+#define PLTJMP(_x) _x##@plt
+#else
+#define PLTJMP(_x) _x
+#endif
+
+#define ENTRY(nm) \
+ .text ` \
+ .align 4 ` \
+ .globl nm ` \
+ .type nm,@function ` \
+nm:
+
+#define ENDFUNC(name) .size name,.-name
+
+#endif /* __ASSEMBLER __*/
+#endif
new file mode 100755
@@ -0,0 +1,11 @@
+/* ARCompact can be either endianness. */
+
+#ifndef _ENDIAN_H
+# error "Never use <bits/endian.h> directly; include <endian.h> instead."
+#endif
+
+#ifdef __BIG_ENDIAN__
+#define __BYTE_ORDER __BIG_ENDIAN
+#else
+#define __BYTE_ORDER __LITTLE_ENDIAN
+#endif
new file mode 100755
@@ -0,0 +1,236 @@
+/* O_*, F_*, FD_* bit values for Linux.
+ Copyright (C) 1995-1998, 2000 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 _FCNTL_H
+# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
+
+
+#include <sys/types.h>
+#ifdef __USE_GNU
+# include <bits/uio.h>
+#endif
+
+/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
+ located on an ext2 file system */
+#define O_ACCMODE 0003
+#define O_RDONLY 00
+#define O_WRONLY 01
+#define O_RDWR 02
+#define O_CREAT 0100 /* not fcntl */
+#define O_EXCL 0200 /* not fcntl */
+#define O_NOCTTY 0400 /* not fcntl */
+#define O_TRUNC 01000 /* not fcntl */
+#define O_APPEND 02000
+#define O_NONBLOCK 04000
+#define O_NDELAY O_NONBLOCK
+#define O_SYNC 010000
+#define O_FSYNC O_SYNC
+#define O_ASYNC 020000
+
+#ifdef __USE_GNU
+# define O_DIRECT 040000 /* Direct disk access. */
+# define O_DIRECTORY 0200000 /* Must be a directory. */
+# define O_NOFOLLOW 0400000 /* Do not follow links. */
+# define O_NOATIME 01000000 /* Do not set atime. */
+# define O_CLOEXEC 02000000 /* Set close_on_exec. */
+#endif
+
+#ifdef __USE_LARGEFILE64
+# define O_LARGEFILE 0100000
+#endif
+
+/* For now Linux has synchronisity options for data and read operations.
+ We define the symbols here but let them do the same as O_SYNC since
+ this is a superset. */
+#if defined __USE_POSIX199309 || defined __USE_UNIX98
+# define O_DSYNC O_SYNC /* Synchronize data. */
+# define O_RSYNC O_SYNC /* Synchronize read operations. */
+#endif
+
+/* Values for the second argument to `fcntl'. */
+#define F_DUPFD 0 /* Duplicate file descriptor. */
+#define F_GETFD 1 /* Get file descriptor flags. */
+#define F_SETFD 2 /* Set file descriptor flags. */
+#define F_GETFL 3 /* Get file status flags. */
+#define F_SETFL 4 /* Set file status flags. */
+
+#ifndef __USE_FILE_OFFSET64
+# define F_GETLK 5 /* Get record locking info. */
+# define F_SETLK 6 /* Set record locking info (non-blocking). */
+# define F_SETLKW 7 /* Set record locking info (blocking). */
+#else
+# define F_GETLK F_GETLK64 /* Get record locking info. */
+# define F_SETLK F_SETLK64 /* Set record locking info (non-blocking).*/
+# define F_SETLKW F_SETLKW64 /* Set record locking info (blocking). */
+#endif
+#define F_GETLK64 12 /* Get record locking info. */
+#define F_SETLK64 13 /* Set record locking info (non-blocking). */
+#define F_SETLKW64 14 /* Set record locking info (blocking). */
+
+#if defined __USE_BSD || defined __USE_XOPEN2K
+# define F_SETOWN 8 /* Get owner of socket (receiver of SIGIO). */
+# define F_GETOWN 9 /* Set owner of socket (receiver of SIGIO). */
+#endif
+
+#ifdef __USE_GNU
+# define F_SETSIG 10 /* Set number of signal to be sent. */
+# define F_GETSIG 11 /* Get number of signal to be sent. */
+#endif
+
+#ifdef __USE_GNU
+# define F_SETLEASE 1024 /* Set a lease. */
+# define F_GETLEASE 1025 /* Enquire what lease is active. */
+# define F_NOTIFY 1026 /* Request notfications on a directory. */
+# define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
+ close-on-exit set on new fd. */
+#endif
+
+/* For F_[GET|SET]FL. */
+#define FD_CLOEXEC 1 /* actually anything with low bit set goes */
+
+/* For posix fcntl() and `l_type' field of a `struct flock' for lockf(). */
+#define F_RDLCK 0 /* Read lock. */
+#define F_WRLCK 1 /* Write lock. */
+#define F_UNLCK 2 /* Remove lock. */
+
+/* For old implementation of bsd flock(). */
+#define F_EXLCK 4 /* or 3 */
+#define F_SHLCK 8 /* or 4 */
+
+#ifdef __USE_BSD
+/* Operations for bsd flock(), also used by the kernel implementation. */
+# define LOCK_SH 1 /* shared lock */
+# define LOCK_EX 2 /* exclusive lock */
+# define LOCK_NB 4 /* or'd with one of the above to prevent
+ blocking */
+# define LOCK_UN 8 /* remove lock */
+#endif
+
+#ifdef __USE_GNU
+# define LOCK_MAND 32 /* This is a mandatory flock: */
+# define LOCK_READ 64 /* ... which allows concurrent read operations. */
+# define LOCK_WRITE 128 /* ... which allows concurrent write operations. */
+# define LOCK_RW 192 /* ... Which allows concurrent read & write operations. */
+#endif
+
+#ifdef __USE_GNU
+/* Types of directory notifications that may be requested with F_NOTIFY. */
+# define DN_ACCESS 0x00000001 /* File accessed. */
+# define DN_MODIFY 0x00000002 /* File modified. */
+# define DN_CREATE 0x00000004 /* File created. */
+# define DN_DELETE 0x00000008 /* File removed. */
+# define DN_RENAME 0x00000010 /* File renamed. */
+# define DN_ATTRIB 0x00000020 /* File changed attibutes. */
+# define DN_MULTISHOT 0x80000000 /* Don't remove notifier. */
+#endif
+
+struct flock
+ {
+ short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
+ short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
+#ifndef __USE_FILE_OFFSET64
+ __off_t l_start; /* Offset where the lock begins. */
+ __off_t l_len; /* Size of the locked area; zero means until EOF. */
+#else
+ __off64_t l_start; /* Offset where the lock begins. */
+ __off64_t l_len; /* Size of the locked area; zero means until EOF. */
+#endif
+ __pid_t l_pid; /* Process holding the lock. */
+ };
+
+#ifdef __USE_LARGEFILE64
+struct flock64
+ {
+ short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
+ short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
+ __off64_t l_start; /* Offset where the lock begins. */
+ __off64_t l_len; /* Size of the locked area; zero means until EOF. */
+ __pid_t l_pid; /* Process holding the lock. */
+ };
+#endif
+
+/* Define some more compatibility macros to be backward compatible with
+ BSD systems which did not managed to hide these kernel macros. */
+#ifdef __USE_BSD
+# define FAPPEND O_APPEND
+# define FFSYNC O_FSYNC
+# define FASYNC O_ASYNC
+# define FNONBLOCK O_NONBLOCK
+# define FNDELAY O_NDELAY
+#endif /* Use BSD. */
+
+/* Advise to `posix_fadvise'. */
+#ifdef __USE_XOPEN2K
+# define POSIX_FADV_NORMAL 0 /* No further special treatment. */
+# define POSIX_FADV_RANDOM 1 /* Expect random page references. */
+# define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */
+# define POSIX_FADV_WILLNEED 3 /* Will need these pages. */
+# define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */
+# define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */
+#endif
+
+#if defined __USE_GNU && defined __UCLIBC_LINUX_SPECIFIC__
+/* Flags for SYNC_FILE_RANGE. */
+# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
+ in the range before performing the
+ write. */
+# define SYNC_FILE_RANGE_WRITE 2 /* Initiate writeout of all those
+ dirty pages in the range which are
+ not presently under writeback. */
+# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
+ the range after performing the
+ write. */
+
+/* Flags for SPLICE and VMSPLICE. */
+# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
+# define SPLICE_F_NONBLOCK 2 /* Don't block on the pipe splicing
+ (but we may still block on the fd
+ we splice from/to). */
+# define SPLICE_F_MORE 4 /* Expect more data. */
+# define SPLICE_F_GIFT 8 /* Pages passed in are a gift. */
+#endif
+
+__BEGIN_DECLS
+
+#if defined __USE_GNU && defined __UCLIBC_LINUX_SPECIFIC__
+
+/* Provide kernel hint to read ahead. */
+extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count)
+ __THROW;
+
+/* Selective file content synch'ing. */
+extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
+ unsigned int __flags);
+
+/* Splice address range into a pipe. */
+extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
+ size_t __count, unsigned int __flags);
+
+/* Splice two files together. */
+extern ssize_t splice (int __fdin, __off64_t *__offin, int __fdout,
+ __off64_t *__offout, size_t __len,
+ unsigned int __flags);
+
+/* In-kernel implementation of tee for pipe buffers. */
+extern ssize_t tee (int __fdin, int __fdout, size_t __len,
+ unsigned int __flags);
+
+#endif
+__END_DECLS
new file mode 100755
@@ -0,0 +1,53 @@
+/* Note that we use the exact same include guard #define names
+ * as asm/posix_types.h. This will avoid gratuitous conflicts
+ * with the posix_types.h kernel header, and will ensure that
+ * our private content, and not the kernel header, will win.
+ * -Erik
+ *
+ * Update: ARC Linux 3.2 ABI change - asm-generic/posix_types.h used now.
+ * for which ARCH wrapper (asm/posix_types.h) is generated, so need to use
+ * the asm-generic file's gaurd.
+ *
+ * Based on asm-generic/stat.h
+ */
+
+#ifndef __ASM_GENERIC_POSIX_TYPES_H
+#define __ASM_GENERIC_POSIX_TYPES_H
+
+typedef unsigned long __kernel_dev_t;
+typedef unsigned long __kernel_ino_t;
+typedef unsigned int __kernel_mode_t;
+typedef unsigned int __kernel_nlink_t;
+typedef long __kernel_off_t;
+typedef int __kernel_pid_t;
+typedef int __kernel_ipc_pid_t;
+typedef unsigned int __kernel_uid_t;
+typedef unsigned int __kernel_gid_t;
+typedef unsigned int __kernel_size_t;
+typedef int __kernel_ssize_t;
+typedef int __kernel_ptrdiff_t;
+typedef long __kernel_time_t;
+typedef long __kernel_suseconds_t;
+typedef long __kernel_clock_t;
+typedef int __kernel_daddr_t;
+typedef char * __kernel_caddr_t;
+typedef unsigned short __kernel_uid16_t;
+typedef unsigned short __kernel_gid16_t;
+typedef __kernel_uid_t __kernel_uid32_t;
+typedef __kernel_gid_t __kernel_gid32_t;
+typedef __kernel_uid_t __kernel_old_uid_t;
+typedef __kernel_gid_t __kernel_old_gid_t;
+typedef long long __kernel_loff_t;
+typedef unsigned int __kernel_old_dev_t;
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
+
+typedef struct {
+#ifdef __USE_ALL
+ int val[2];
+#else
+ int __val[2];
+#endif
+} __kernel_fsid_t;
+
+#endif /* _ASM_ARC_POSIX_TYPES_H */
new file mode 100644
@@ -0,0 +1,16 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#ifndef _BITS_SETJMP_H
+#define _BITS_SETJMP_H 1
+
+#if !defined _SETJMP_H && !defined _PTHREAD_H
+# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
+#endif
+
+typedef int __jmp_buf[13+1+1+1]; /*r13-r25, fp, sp, blink */
+
+#endif
new file mode 100755
@@ -0,0 +1,30 @@
+/* Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/* In general we cannot provide all of this information. */
+
+#include <features.h>
+#define SIGCONTEXT struct sigcontext *
+#define SIGCONTEXT_EXTRA_ARGS
+
+#define GET_PC(ctx) ((void *) ctx->ret)
+#define GET_FRAME(ctx) ((void *) ctx->fp)
+#define GET_STACK(ctx) ((void *) ctx->sp)
+#define CALL_SIGHANDLER(handler, signo, ctx) \
+ (handler)((signo), SIGCONTEXT_EXTRA_ARGS (ctx))
new file mode 100755
@@ -0,0 +1,28 @@
+/* Copyright (C) 1999 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. */
+
+/* This file contains a bit of information about the stack allocation
+ of the processor. */
+
+#ifndef _STACKINFO_H
+#define _STACKINFO_H 1
+
+/* On ARC, the stack grows down. */
+#define _STACK_GROWS_DOWN 1
+
+#endif /* stackinfo.h */
new file mode 100644
@@ -0,0 +1,186 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ *
+ */
+#ifndef _BITS_SYSCALLS_H
+#define _BITS_SYSCALLS_H
+#ifndef _SYSCALL_H
+#error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
+#endif
+
+#ifndef __ASSEMBLER__
+
+#include <errno.h>
+
+/*
+ * Fine tuned code for errno handling in syscall wrappers.
+ *
+ * 1. __syscall_error(raw_syscall_ret_val) is used to set the errno (vs.
+ * the typical __set_errno). This helps elide the generated code for
+ * GOT fetch for __errno_location pointer etc, in each wrapper.
+ *
+ * 2. The call to above is also disguised in inline asm. This elides
+ * unconditional save/restore of a few callee regs which gcc almost
+ * always generates if the call is exposed
+ */
+
+#ifdef IS_IN_rtld
+/* ldso doesn't have real errno */
+#define ERRNO_ERRANDS(_sys_result)
+#else /* !IS_IN_rtld */
+extern int __syscall_error (int);
+#ifdef __PIC__
+#define CALL_ERRNO_SETTER "bl __syscall_error@plt \n\t"
+#else
+#define CALL_ERRNO_SETTER "bl __syscall_error \n\t"
+#endif
+
+#define ERRNO_ERRANDS(_sys_result) \
+ __asm__ volatile ( \
+ "st.a blink, [sp, -4] \n\t" \
+ CALL_ERRNO_SETTER \
+ "ld.ab blink, [sp, 4] \n\t" \
+ :"+r" (_sys_result) \
+ : \
+ :"r1","r2","r3","r4","r5","r6", \
+ "r7","r8","r9","r10","r11","r12" \
+ );
+
+#endif /* IS_IN_rtld */
+
+/* Invoke the syscall and return unprocessed kernel status */
+#define INTERNAL_SYSCALL(nm, err, nr, args...) \
+ INTERNAL_SYSCALL_NCS(SYS_ify (nm), err, nr, args)
+
+/* -1 to -1023 as valid error values will suffice for some time */
+#define INTERNAL_SYSCALL_ERROR_P(val, err) \
+ ((unsigned int) (val) > (unsigned int) -1024)
+
+/*
+ * Standard sycall wrapper:
+ * -"const" syscall number @nm, sets errno, return success/error-codes
+ */
+#define INLINE_SYSCALL(nm, nr_args, args...) \
+({ \
+ register int __res __asm__("r0"); \
+ __res = INTERNAL_SYSCALL(nm, , nr_args, args); \
+ if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P ((__res), ), 0)) \
+ { \
+ ERRNO_ERRANDS(__res); \
+ } \
+ __res; \
+})
+
+/* Non const syscall number @nm
+ * Ideally this could be folded within INLINE_SYSCALL with
+ * __builtin_constant_p in INTERNAL_SYSCALL but that fails for syscall.c
+ */
+#define INLINE_SYSCALL_NCS(nm, nr_args, args...) \
+({ \
+ register int __res __asm__("r0"); \
+ __res = INTERNAL_SYSCALL_NCS(nm, , nr_args, args); \
+ if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P ((__res), ), 0)) \
+ { \
+ ERRNO_ERRANDS(__res); \
+ } \
+ __res; \
+})
+
+#define INLINE_SYSCALL_NOERR(name, nr, args...) \
+ ({ unsigned int _inline_sys_result = INTERNAL_SYSCALL (name, , nr, args);\
+ (int) _inline_sys_result; })
+
+/*-------------------------------------------------------------------------
+ * Mechanics of Trap - specific to ARC700
+ *
+ * Note the memory clobber is not strictly needed for intended semantics of
+ * the inline asm. However some of the cases, such as old-style 6 arg mmap
+ * gcc was generating code for inline syscall ahead of buffer packing needed
+ * for syscall itself.
+ *-------------------------------------------------------------------------*/
+
+#define ARC_TRAP_INSN "trap0 \n\t"
+
+#define INTERNAL_SYSCALL_NCS(nm, err, nr_args, args...) \
+({ \
+ /* Per ABI, r0 is 1st arg and return reg */ \
+ register int __ret __asm__("r0"); \
+ register int _sys_num __asm__("r8"); \
+ \
+ LOAD_ARGS_##nr_args (nm, args) \
+ \
+ __asm__ volatile ( \
+ ARC_TRAP_INSN \
+ : "+r" (__ret) \
+ : "r"(_sys_num) ASM_ARGS_##nr_args \
+ : "memory"); \
+ \
+ __ret; \
+})
+
+/* Macros for setting up inline __asm__ input regs */
+#define ASM_ARGS_0
+#define ASM_ARGS_1 ASM_ARGS_0, "r" (__ret)
+#define ASM_ARGS_2 ASM_ARGS_1, "r" (_arg2)
+#define ASM_ARGS_3 ASM_ARGS_2, "r" (_arg3)
+#define ASM_ARGS_4 ASM_ARGS_3, "r" (_arg4)
+#define ASM_ARGS_5 ASM_ARGS_4, "r" (_arg5)
+#define ASM_ARGS_6 ASM_ARGS_5, "r" (_arg6)
+#define ASM_ARGS_7 ASM_ARGS_6, "r" (_arg7)
+
+/* Macros for converting sys-call wrapper args into sys call args */
+#define LOAD_ARGS_0(nm, arg) \
+ _sys_num = (int) (nm); \
+
+#define LOAD_ARGS_1(nm, arg1) \
+ __ret = (int) (arg1); \
+ LOAD_ARGS_0 (nm, arg1)
+
+/*
+ * Note that the use of _tmpX might look superflous, however it is needed
+ * to ensure that register variables are not clobbered if arg happens to be
+ * a function call itself. e.g. sched_setaffinity() calling getpid() for arg2
+ *
+ * Also this specific order of recursive calling is important to segregate
+ * the tmp args evaluation (function call case described above) and assigment
+ * of register variables
+ */
+#define LOAD_ARGS_2(nm, arg1, arg2) \
+ int _tmp2 = (int) (arg2); \
+ LOAD_ARGS_1 (nm, arg1) \
+ register int _arg2 __asm__ ("r1") = _tmp2;
+
+#define LOAD_ARGS_3(nm, arg1, arg2, arg3) \
+ int _tmp3 = (int) (arg3); \
+ LOAD_ARGS_2 (nm, arg1, arg2) \
+ register int _arg3 __asm__ ("r2") = _tmp3;
+
+#define LOAD_ARGS_4(nm, arg1, arg2, arg3, arg4) \
+ int _tmp4 = (int) (arg4); \
+ LOAD_ARGS_3 (nm, arg1, arg2, arg3) \
+ register int _arg4 __asm__ ("r3") = _tmp4;
+
+#define LOAD_ARGS_5(nm, arg1, arg2, arg3, arg4, arg5) \
+ int _tmp5 = (int) (arg5); \
+ LOAD_ARGS_4 (nm, arg1, arg2, arg3, arg4) \
+ register int _arg5 __asm__ ("r4") = _tmp5;
+
+#define LOAD_ARGS_6(nm, arg1, arg2, arg3, arg4, arg5, arg6) \
+ int _tmp6 = (int) (arg6); \
+ LOAD_ARGS_5 (nm, arg1, arg2, arg3, arg4, arg5) \
+ register int _arg6 __asm__ ("r5") = _tmp6;
+
+#define LOAD_ARGS_7(nm, arg1, arg2, arg3, arg4, arg5, arg6, arg7)\
+ int _tmp7 = (int) (arg7); \
+ LOAD_ARGS_6 (nm, arg1, arg2, arg3, arg4, arg5, arg6) \
+ register int _arg7 __asm__ ("r6") = _tmp7;
+
+#else
+
+#define ARC_TRAP_INSN trap0
+
+#endif /* __ASSEMBLER__ */
+
+#endif /* _BITS_SYSCALLS_H */
new file mode 100755
@@ -0,0 +1,47 @@
+/*
+ * Track misc arch-specific features that aren't config options
+ */
+
+#ifndef _BITS_UCLIBC_ARCH_FEATURES_H
+#define _BITS_UCLIBC_ARCH_FEATURES_H
+
+/* instruction used when calling abort() to kill yourself */
+#define __UCLIBC_ABORT_INSTRUCTION__ "flag 0"
+
+/* can your target use syscall6() for mmap ? */
+#undef __UCLIBC_MMAP_HAS_6_ARGS__
+
+/* does your target use syscall4() for truncate64 ? (32bit arches only) */
+#undef __UCLIBC_TRUNCATE64_HAS_4_ARGS__
+
+/* does your target have a broken create_module() ? */
+#undef __UCLIBC_BROKEN_CREATE_MODULE__
+
+/* does your target have to worry about older [gs]etrlimit() ? */
+#undef __UCLIBC_HANDLE_OLDER_RLIMIT__
+
+/* does your target have an asm .set ? */
+#define __UCLIBC_HAVE_ASM_SET_DIRECTIVE__
+
+/* define if target doesn't like .global */
+#undef __UCLIBC_ASM_GLOBAL_DIRECTIVE__
+
+/* define if target supports .weak */
+#define __UCLIBC_HAVE_ASM_WEAK_DIRECTIVE__
+
+/* define if target supports .weakext */
+#undef __UCLIBC_HAVE_ASM_WEAKEXT_DIRECTIVE__
+
+/* needed probably only for ppc64 */
+#undef __UCLIBC_HAVE_ASM_GLOBAL_DOT_NAME__
+
+/* define if target supports CFI pseudo ops */
+#undef __UCLIBC_HAVE_ASM_CFI_DIRECTIVES__
+
+/* define if target supports IEEE signed zero floats */
+#define __UCLIBC_HAVE_SIGNED_ZERO__
+
+/* The default ';' is a comment on ARC. */
+#define __UCLIBC_ASM_LINE_SEP__ `
+
+#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
new file mode 100755
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#ifndef _UCLIBC_PAGE_H
+#define _UCLIBC_PAGE_H
+
+/*
+ * ARC700/linux supports 4k, 8k, 16k pages (build time).
+ * We rely on the kernel exported header (aka uapi headers since 3.8)
+ * for PAGE_SIZE and friends. This avoids hand-editing here when building
+ * toolchain.
+ *
+ * Although uClibc determines page size dynamically, from kernel's auxv which
+ * ARC Linux does pass, still the generic code needs a fall back
+ * _dl_pagesize = auxvt[AT_PAGESZ].a_un.a_val ? : PAGE_SIZE
+ *
+ */
+#include <asm/page.h>
+
+/* TBD: fix this with runtime value for a PAGE_SIZE agnostic uClibc */
+#define MMAP2_PAGE_SHIFT PAGE_SHIFT
+
+#endif /* _UCLIBC_PAGE_H */
new file mode 100755
@@ -0,0 +1,19 @@
+/* Copyright (C) 1999 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. */
+
+#define __WORDSIZE 32
new file mode 100644
@@ -0,0 +1,32 @@
+/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. ARC version.
+ Copyright (C) 1997, 1998 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. */
+
+/* This just does a tail-call to `__sigsetjmp (ARG, 1)'.
+ We cannot do it in C because it must be a tail-call, so frame-unwinding
+ in setjmp doesn't clobber the state restored by longjmp. */
+
+#include <bits/asm.h>
+
+;@ r0 = jump buffer into which regs will be saved
+
+ENTRY(_setjmp)
+ b.d __sigsetjmp
+ mov r1, 0 ; don't save signals
+ENDFUNC(_setjmp)
+libc_hidden_def(_setjmp)
new file mode 100644
@@ -0,0 +1,32 @@
+/* BSD `setjmp' entry point to `sigsetjmp (..., 1)'. ARC version.
+ Copyright (C) 1997, 1998 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. */
+
+/* This just does a tail-call to `__sigsetjmp (ARG, 1)'.
+ We cannot do it in C because it must be a tail-call, so frame-unwinding
+ in setjmp doesn't clobber the state restored by longjmp. */
+
+#include <bits/asm.h>
+
+;@ r0 = jump buffer into which regs will be saved
+
+ENTRY(setjmp)
+ b.d __sigsetjmp
+ mov r1, 1 ; save signals
+ENDFUNC(setjmp)
+libc_hidden_def(setjmp)
new file mode 100644
@@ -0,0 +1,26 @@
+/*
+ * cacheflush syscall
+ *
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program 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 Library General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#include <sys/syscall.h>
+#include <sys/cachectl.h>
+
+#ifdef __NR_cacheflush
+_syscall3(int, cacheflush, void *, addr, int, nbytes, int, op)
+#endif
new file mode 100644
@@ -0,0 +1,82 @@
+/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Pat Beirne <patb@corelcomputer.com>
+
+ 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. */
+
+#include <asm/errno.h>
+#include <sys/syscall.h>
+#include <bits/asm.h>
+
+; Per man, libc clone( ) is as follows
+;
+; int clone(int (*fn)(void *), void *child_stack,
+; int flags, void *arg, ...
+; /* pid_t *ptid, struct user_desc *tls, pid_t *ctid */);
+;
+; NOTE: I'm assuming that the last 3 args are NOT var-args and in case all
+; 3 are not relevant, caller will nevertheless pass those as NULL.
+; Current (Jul 2012) upstream powerpc/clone.S assumes similarly.
+; Our LTP (from 2007) doesn't seem to have tests to prove otherwise
+
+; clone syscall in kernel
+;
+; int sys_clone(unsigned long clone_flags, unsigned long newsp,
+; int __user *parent_tidptr, void *tls,
+; int __user *child_tidptr)
+
+
+ENTRY(clone)
+ cmp r0, 0 ; @fn can't be NULL
+ cmp.ne r1, 0 ; @child_stack can't be NULL
+ bz .L__sys_err
+
+ ; @fn and @args needed after the syscall for child
+ ; However r3 containing @arg will be clobbered BEFORE syscall
+ ; r0 containg @fn will be clobbered AFTER syscall (with ret val)
+ mov r10, r0
+ mov r11, r3
+
+ ; adjust libc args for syscall
+ mov r0, r2 ; libc @flags is 1st syscall arg
+ mov r2, r4 ; libc @ptid
+ mov r3, r5 ; libc @tls
+ mov r4, r6 ; libc @ctid
+ mov r8, __NR_clone
+ ARC_TRAP_INSN
+
+ cmp r0, 0 ; return code : 0 new process, !0 parent
+ blt .L__sys_err2 ; < 0 (signed) error
+ jnz [blink] ; Parent returns
+
+ ; child jumps off to @fn with @arg as argument
+ j.d [r10]
+ mov r0, r11
+
+ ; falls thru to _exit() with result from @fn (already in r0)
+ b HIDDEN_JUMPTARGET(_exit)
+
+.L__sys_err:
+ mov r0, -EINVAL
+.L__sys_err2:
+ ; (1) No need to make -ve kernel error code as positive errno
+ ; __syscall_error expects the -ve error code returned by kernel
+ ; (2) r0 still had orig -ve kernel error code
+ ; (3) Tail call to __syscall_error so we dont have to come back
+ ; here hence instead of jmp-n-link (reg push/pop) we do jmp
+ b PLTJMP(__syscall_error)
+ENDFUNC(clone)
+libc_hidden_def(clone)
new file mode 100644
@@ -0,0 +1,48 @@
+#include <features.h>
+#include <bits/asm.h>
+
+.text
+
+#ifndef __UCLIBC_CTOR_DTOR__
+ .weak _init
+ .weak _fini
+#endif
+
+/* Stick in a dummy reference to main(), so that if an application
+ * is linking when the main() function is in a static library (.a)
+ * we can be sure that main() actually gets linked in
+ */
+ .type main,@function
+ .type _main,@function
+
+
+/* When we enter this piece of code, the program stack looks like this:
+ argc argument counter (integer)
+ argv[0] program name (pointer)
+ argv[1...N] program args (pointers)
+ argv[argc-1] end of args (integer)
+ NULL
+ env[0...N] environment variables (pointers)
+ NULL
+*/
+ENTRY(__start)
+ mov fp, 0
+ ld_s r1, [sp] ; argc
+
+ mov_s r5, r0 ; rltd_fini
+ add_s r2, sp, 4 ; argv
+
+ mov_s r0, main
+ mov_s r3, _init
+ mov r4, _fini
+
+ and sp, sp, -8
+ mov r6, sp
+
+ /* __uClibc_main (main, argc, argv, init, fini, rtld_fini, stack_end) */
+ bl __uClibc_main
+
+ /* Should never get here.... */
+ flag 1
+ENDFUNC(__start)
+libc_hidden_def(__start)
new file mode 100644
@@ -0,0 +1,30 @@
+___gnu_compiled_c:
+
+ .section .init
+ .align 4
+ .global _init
+ .type _init,@function
+_init:
+ ; BEGIN PROLOGUE ; vars= 0, regs= 0, args= 0, extra= 8
+ st.a blink,[sp,-4]
+ st.a fp,[sp,-4]
+ mov fp,sp
+ ; END PROLOGUE
+
+ .align 4
+
+
+ .section .fini
+ .align 4
+ .global _fini
+ .type _fini,@function
+_fini:
+ ; BEGIN PROLOGUE ; vars= 0, regs= 0, args= 0, extra= 8
+ st.a blink,[sp,-4]
+ st.a fp,[sp,-4]
+ mov fp,sp
+ ; END PROLOGUE
+ .align 4
+
+
+ .ident "GCC: (GNU) 2.95.3-A700-minimal-branch"
new file mode 100644
@@ -0,0 +1,23 @@
+___gnu_compiled_c:
+
+ .section .init
+ .align 4
+ .global _init
+ .type _init,@function
+ ; EPILOGUE
+ ld.ab fp,[sp,4]
+ ld blink,[sp,0]
+ j.d [blink]
+ add sp,sp,4
+; .size _init,.-_init
+
+ .section .fini
+ .align 4
+ .global _fini
+ .type _fini,@function
+ ; EPILOGUE
+ ld.ab fp,[sp,4]
+ ld blink,[sp,0]
+ j.d [blink]
+ add sp,sp,4
+; .size _fini,.-_fini
new file mode 100644
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program 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 Library General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#define __JMP_BUF_SP (13+1)
new file mode 100644
@@ -0,0 +1,13 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <setjmp.h>
+#include <jmpbuf-offsets.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(jmpbuf, address) \
+ ((void *) (address) < (void *) (jmpbuf[__JMP_BUF_SP]))
new file mode 100644
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <bits/asm.h>
+
+;@ r0 = jump buffer into which regs will be saved
+;@ r1 = do we need to save signals
+
+ENTRY(__sigsetjmp)
+
+ st_s r13, [r0]
+ st_s r14, [r0,4]
+ st r15, [r0,8]
+ st r16, [r0,12]
+ st r17, [r0,16]
+ st r18, [r0,20]
+ st r19, [r0,24]
+ st r20, [r0,28]
+ st r21, [r0,32]
+ st r22, [r0,36]
+ st r23, [r0,40]
+ st r24, [r0,44]
+ st r25, [r0,48]
+ st fp, [r0,52]
+ st sp, [r0,56]
+
+ ; make a note of where longjmp will return to.
+ ; that will be right next to this setjmp call-site which will be
+ ; contained in blink, since "C" caller of this routine will do
+ ; a branch-n-link
+
+ st blink, [r0,60]
+ b __sigjmp_save
+
+ENDFUNC(__sigsetjmp)
+libc_hidden_def(__sigsetjmp)
new file mode 100644
@@ -0,0 +1,62 @@
+/* Copyright (C) 1997-2000,2002,2003,2005,2006 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. */
+
+#include <errno.h>
+#include <signal.h>
+#include <string.h>
+#include <sys/syscall.h>
+#include <bits/kernel_sigaction.h>
+
+extern __typeof(sigaction) __libc_sigaction;
+
+extern void __default_rt_sa_restorer(void);
+// TBD: 0.9.32 stable material
+//libc_hidden_proto(__default_rt_sa_restorer);
+
+#define SA_RESTORER 0x04000000
+
+/* If ACT is not NULL, change the action for SIG to *ACT.
+ If OACT is not NULL, put the old action for SIG in *OACT. */
+int
+__libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
+{
+ int result;
+ struct sigaction kact;
+
+ if (act) {
+ memcpy(&kact, act, sizeof(kact));
+
+ if (!(kact.sa_flags & SA_RESTORER)) {
+ kact.sa_restorer = __default_rt_sa_restorer;
+ kact.sa_flags |= SA_RESTORER;
+ }
+ }
+
+ /* XXX The size argument hopefully will have to be changed to the
+ real size of the user-level sigset_t. */
+ result = __syscall_rt_sigaction(sig,
+ act ? &kact : NULL, oact,
+ _NSIG / 8);
+
+ return result;
+}
+
+#ifndef LIBC_SIGACTION
+weak_alias(__libc_sigaction,sigaction)
+libc_hidden_weak(sigaction)
+#endif
new file mode 100644
@@ -0,0 +1,32 @@
+/* Copyright (C) 1999 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. */
+
+#include <bits/asm.h>
+#include <sys/syscall.h>
+
+/* vineetg: July 2009
+ uClibc to provide sigreturn stub, rather than kernel synthesising it on
+ user stack at runtime, fiddling with PTE/TLB flags and expensive
+ Cache line flushes
+*/
+
+ENTRY(__default_rt_sa_restorer)
+ mov r8, __NR_rt_sigreturn
+ ARC_TRAP_INSN
+ENDFUNC(__default_rt_sa_restorer)
+libc_hidden_def(__default_rt_sa_restorer)
new file mode 100644
@@ -0,0 +1,36 @@
+/*
+ * cachectl.h - cacheflush routine
+ *
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program 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 Library General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef _SYS_CACHECTL_H
+#define _SYS_CACHECTL_H 1
+
+/*
+ * Get the kernel definition for the flag bits
+ */
+#include <asm/cachectl.h>
+
+__BEGIN_DECLS
+
+extern int cacheflush(void *addr, int nbytes, int flags);
+
+__END_DECLS
+
+#endif /* sys/cachectl.h */
new file mode 100755
@@ -0,0 +1,120 @@
+/* Copyright (C) 1996, 1997, 1999, 2001 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 _SYS_PROCFS_H
+#define _SYS_PROCFS_H 1
+
+/* This is somewhat modelled after the file of the same name on SVR4
+ systems. It provides a definition of the core file format for ELF
+ used on Linux. It doesn't have anything to do with the /proc file
+ system, even though Linux has one.
+
+ Anyway, the whole purpose of this file is for GDB and GDB only.
+ Don't read too much into it. Don't use it for anything other than
+ GDB unless you know what you are doing. */
+
+#include <features.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/user.h>
+
+__BEGIN_DECLS
+
+/* Type for a general-purpose register. */
+typedef unsigned long elf_greg_t;
+
+/* And the whole bunch of them. We could have used `struct
+ user_regs' directly in the typedef, but tradition says that
+ the register set is an array, which does have some peculiar
+ semantics, so leave it that way. */
+#define ELF_NGREG 20
+typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+
+/* Signal info. */
+struct elf_siginfo
+ {
+ int si_signo; /* Signal number. */
+ int si_code; /* Extra code. */
+ int si_errno; /* Errno. */
+ };
+
+/* Definitions to generate Intel SVR4-like core files. These mostly
+ have the same names as the SVR4 types with "elf_" tacked on the
+ front to prevent clashes with Linux definitions, and the typedef
+ forms have been avoided. This is mostly like the SVR4 structure,
+ but more Linuxy, with things that Linux does not support and which
+ GDB doesn't really use excluded. */
+
+struct elf_prstatus
+ {
+ struct elf_siginfo pr_info; /* Info associated with signal. */
+ short int pr_cursig; /* Current signal. */
+ unsigned long int pr_sigpend; /* Set of pending signals. */
+ unsigned long int pr_sighold; /* Set of held signals. */
+ __pid_t pr_pid;
+ __pid_t pr_ppid;
+ __pid_t pr_pgrp;
+ __pid_t pr_sid;
+ struct timeval pr_utime; /* User time. */
+ struct timeval pr_stime; /* System time. */
+ struct timeval pr_cutime; /* Cumulative user time. */
+ struct timeval pr_cstime; /* Cumulative system time. */
+ elf_gregset_t pr_reg; /* GP registers. */
+ int pr_fpvalid; /* True if math copro being used. */
+ };
+
+
+#define ELF_PRARGSZ (80) /* Number of chars for args. */
+
+struct elf_prpsinfo
+ {
+ char pr_state; /* Numeric process state. */
+ char pr_sname; /* Char for pr_state. */
+ char pr_zomb; /* Zombie. */
+ char pr_nice; /* Nice val. */
+ unsigned long int pr_flag; /* Flags. */
+ unsigned short int pr_uid;
+ unsigned short int pr_gid;
+ int pr_pid, pr_ppid, pr_pgrp, pr_sid;
+ /* Lots missing */
+ char pr_fname[16]; /* Filename of executable. */
+ char pr_psargs[ELF_PRARGSZ]; /* Initial part of arg list. */
+ };
+
+/* The rest of this file provides the types for emulation of the
+ Solaris <proc_service.h> interfaces that should be implemented by
+ users of libthread_db. */
+
+/* Addresses. */
+typedef void *psaddr_t;
+
+/* Register sets. Linux has different names. */
+typedef elf_gregset_t prgregset_t;
+typedef elf_gregset_t prfpregset_t;
+
+/* We don't have any differences between processes and threads,
+ therefore have only one PID type. */
+typedef __pid_t lwpid_t;
+
+/* Process status and info. In the end we do provide typedefs for them. */
+typedef struct elf_prstatus prstatus_t;
+typedef struct elf_prpsinfo prpsinfo_t;
+
+__END_DECLS
+
+#endif /* sys/procfs.h */
new file mode 100755
@@ -0,0 +1,34 @@
+/* Copyright (C) 1997-2000,2002,2003,2005,2006 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 _SYS_UCONTEXT_H
+#define _SYS_UCONTEXT_H 1
+
+#include <features.h>
+#include <signal.h>
+#include <bits/sigcontext.h>
+
+typedef struct ucontext {
+ unsigned long uc_flags;
+ struct ucontext *uc_link;
+ stack_t uc_stack;
+ struct sigcontext uc_mcontext;
+ sigset_t uc_sigmask; /* mask last for extensibility */
+} ucontext_t;
+
+#endif /* sys/ucontext.h */
new file mode 100755
@@ -0,0 +1,35 @@
+/* Copyright (C) 1998, 1999, 2000, 2001 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 _SYS_USER_H
+#define _SYS_USER_H 1
+
+/* The whole purpose of this file is for GDB and GDB only. Don't read
+ too much into it. Don't use it for anything other than GDB unless
+ you know what you are doing. */
+
+
+/* Actually apps like strace also expect a struct user, so it's better to
+ * have a dummy implementation
+ */
+
+struct user {
+ int dummy;
+};
+
+#endif /* sys/user.h */
new file mode 100644
@@ -0,0 +1,31 @@
+ /* syscall for uClibc/ARC
+ *
+ * Copyright (C) 2002 by Erik Andersen <andersen@uclibc.org>
+ * Copyright (C) 2003 by Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program 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 Library General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <features.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+
+extern long syscall(long int sysnum, long a, long b, long c, long d, long e, long f);
+
+long syscall(long int sysnum, long a, long b, long c, long d, long e, long f)
+{
+ return INLINE_SYSCALL_NCS(sysnum, 6, a, b, c, d, e, f);
+}
new file mode 100644
@@ -0,0 +1,44 @@
+/* vfork for uClibc/ARC
+ *
+ * Copyright (C) 2000 by Lineo, inc. and Erik Andersen
+ * Copyright (C) 2000,2001 by Erik Andersen <andersen@uclibc.org>
+ * Copyright (C) 2003 by Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program 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 Library General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <sys/syscall.h>
+#include <bits/asm.h>
+
+/* No legacy syscall ABI means NR_vfork is not available at all, use clone */
+#define _SIGNAL_H
+#include <bits/signum.h> /* For SIGCHLD */
+
+#define CLONE_VM 0x00000100
+#define CLONE_VFORK 0x00004000
+#define CLONE_FLAGS_FOR_VFORK (CLONE_VM|CLONE_VFORK|SIGCHLD)
+
+ENTRY(vfork)
+ mov r0, CLONE_FLAGS_FOR_VFORK
+ mov_s r1, sp
+ mov r8, __NR_clone
+ ARC_TRAP_INSN
+
+ cmp r0, 0
+ jge [blink] ; pid >=0 return, else detour via tailcall to errno
+
+ b PLTJMP(__syscall_error)
+ENDFUNC(vfork)
+libc_hidden_def(vfork)
new file mode 100644
@@ -0,0 +1 @@
+/* We don't need any of this. */
Signed-off-by: Vineet Gupta <vgupta@synopsys.com> --- Rules.mak | 8 +- extra/Configs/Config.arc | 23 ++ extra/Configs/Config.in | 8 + libc/string/arc/Makefile | 13 ++ libc/string/arc/memcmp.S | 123 +++++++++++ libc/string/arc/memcpy.S | 66 ++++++ libc/string/arc/memset.S | 46 ++++ libc/string/arc/strchr.S | 133 ++++++++++++ libc/string/arc/strcmp.S | 97 +++++++++ libc/string/arc/strcpy.S | 65 ++++++ libc/string/arc/strlen.S | 78 +++++++ libc/sysdeps/linux/arc/Makefile | 13 ++ libc/sysdeps/linux/arc/Makefile.arch | 11 + libc/sysdeps/linux/arc/__longjmp.S | 38 ++++ libc/sysdeps/linux/arc/__syscall_error.c | 15 ++ libc/sysdeps/linux/arc/bits/asm.h | 22 ++ libc/sysdeps/linux/arc/bits/endian.h | 11 + libc/sysdeps/linux/arc/bits/fcntl.h | 236 +++++++++++++++++++++ libc/sysdeps/linux/arc/bits/kernel_types.h | 53 +++++ libc/sysdeps/linux/arc/bits/setjmp.h | 16 ++ libc/sysdeps/linux/arc/bits/sigcontextinfo.h | 30 +++ libc/sysdeps/linux/arc/bits/stackinfo.h | 28 +++ libc/sysdeps/linux/arc/bits/syscalls.h | 186 ++++++++++++++++ libc/sysdeps/linux/arc/bits/uClibc_arch_features.h | 47 ++++ libc/sysdeps/linux/arc/bits/uClibc_page.h | 26 +++ libc/sysdeps/linux/arc/bits/wordsize.h | 19 ++ libc/sysdeps/linux/arc/bsd-_setjmp.S | 32 +++ libc/sysdeps/linux/arc/bsd-setjmp.S | 32 +++ libc/sysdeps/linux/arc/cacheflush.c | 26 +++ libc/sysdeps/linux/arc/clone.S | 82 +++++++ libc/sysdeps/linux/arc/crt1.S | 48 +++++ libc/sysdeps/linux/arc/crti.S | 30 +++ libc/sysdeps/linux/arc/crtn.S | 23 ++ libc/sysdeps/linux/arc/jmpbuf-offsets.h | 20 ++ libc/sysdeps/linux/arc/jmpbuf-unwind.h | 13 ++ libc/sysdeps/linux/arc/setjmp.S | 39 ++++ libc/sysdeps/linux/arc/sigaction.c | 62 ++++++ libc/sysdeps/linux/arc/sigrestorer.S | 32 +++ libc/sysdeps/linux/arc/sys/cachectl.h | 36 ++++ libc/sysdeps/linux/arc/sys/procfs.h | 120 +++++++++++ libc/sysdeps/linux/arc/sys/ucontext.h | 34 +++ libc/sysdeps/linux/arc/sys/user.h | 35 +++ libc/sysdeps/linux/arc/syscall.c | 31 +++ libc/sysdeps/linux/arc/vfork.S | 44 ++++ libc/sysdeps/linux/arc/xstatconv.c | 1 + 45 files changed, 2150 insertions(+), 1 deletion(-) create mode 100644 extra/Configs/Config.arc create mode 100755 libc/string/arc/Makefile create mode 100644 libc/string/arc/memcmp.S create mode 100644 libc/string/arc/memcpy.S create mode 100644 libc/string/arc/memset.S create mode 100644 libc/string/arc/strchr.S create mode 100644 libc/string/arc/strcmp.S create mode 100644 libc/string/arc/strcpy.S create mode 100644 libc/string/arc/strlen.S create mode 100644 libc/sysdeps/linux/arc/Makefile create mode 100644 libc/sysdeps/linux/arc/Makefile.arch create mode 100644 libc/sysdeps/linux/arc/__longjmp.S create mode 100644 libc/sysdeps/linux/arc/__syscall_error.c create mode 100644 libc/sysdeps/linux/arc/bits/asm.h create mode 100755 libc/sysdeps/linux/arc/bits/endian.h create mode 100755 libc/sysdeps/linux/arc/bits/fcntl.h create mode 100755 libc/sysdeps/linux/arc/bits/kernel_types.h create mode 100644 libc/sysdeps/linux/arc/bits/setjmp.h create mode 100755 libc/sysdeps/linux/arc/bits/sigcontextinfo.h create mode 100755 libc/sysdeps/linux/arc/bits/stackinfo.h create mode 100644 libc/sysdeps/linux/arc/bits/syscalls.h create mode 100755 libc/sysdeps/linux/arc/bits/uClibc_arch_features.h create mode 100755 libc/sysdeps/linux/arc/bits/uClibc_page.h create mode 100755 libc/sysdeps/linux/arc/bits/wordsize.h create mode 100644 libc/sysdeps/linux/arc/bsd-_setjmp.S create mode 100644 libc/sysdeps/linux/arc/bsd-setjmp.S create mode 100644 libc/sysdeps/linux/arc/cacheflush.c create mode 100644 libc/sysdeps/linux/arc/clone.S create mode 100644 libc/sysdeps/linux/arc/crt1.S create mode 100644 libc/sysdeps/linux/arc/crti.S create mode 100644 libc/sysdeps/linux/arc/crtn.S create mode 100644 libc/sysdeps/linux/arc/jmpbuf-offsets.h create mode 100644 libc/sysdeps/linux/arc/jmpbuf-unwind.h create mode 100644 libc/sysdeps/linux/arc/setjmp.S create mode 100644 libc/sysdeps/linux/arc/sigaction.c create mode 100644 libc/sysdeps/linux/arc/sigrestorer.S create mode 100644 libc/sysdeps/linux/arc/sys/cachectl.h create mode 100755 libc/sysdeps/linux/arc/sys/procfs.h create mode 100755 libc/sysdeps/linux/arc/sys/ucontext.h create mode 100755 libc/sysdeps/linux/arc/sys/user.h create mode 100644 libc/sysdeps/linux/arc/syscall.c create mode 100644 libc/sysdeps/linux/arc/vfork.S create mode 100644 libc/sysdeps/linux/arc/xstatconv.c