Merge branch 'upstream-master'
This commit is contained in:
commit
1680e696ac
132
COPYING.NEWLIB
132
COPYING.NEWLIB
|
@ -403,7 +403,7 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
(20) DJ Delorie (i386)
|
||||
(20) DJ Delorie (i386 / arm)
|
||||
Copyright (C) 1991 DJ Delorie
|
||||
All rights reserved.
|
||||
|
||||
|
@ -1049,3 +1049,133 @@ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
|
||||
(46) embedded brains - RTEMS targets
|
||||
|
||||
Copyright (c) 2017 embedded brains GmbH
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
|
||||
(47) John Baldwin - RTEMS targets
|
||||
|
||||
Copyright (c) 2015 John Baldwin <jhb@FreeBSD.org>.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the author nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
|
||||
|
||||
(48) Jeffrey Roberson - RTEMS targets
|
||||
|
||||
Copyright (c) 2008, Jeffrey Roberson <jeff@freebsd.org>
|
||||
All rights reserved.
|
||||
|
||||
Copyright (c) 2008 Nokia Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice unmodified, this list of conditions, and the following
|
||||
disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
(49) - SiFive Inc. (riscv-* targets)
|
||||
|
||||
Copyright (c) 2017 SiFive Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use,
|
||||
modify, copy, or redistribute it subject to the terms and conditions
|
||||
of the BSD License. This program is distributed in the hope that
|
||||
it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
|
||||
including the implied warranties of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. A copy of this license is available at
|
||||
http://www.opensource.org/licenses.
|
||||
|
||||
(50) Michael R. Neilly (riscv-* targets)
|
||||
|
||||
(c) Copyright 2017 Michael R. Neilly
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the names of the copyright holders nor the names of their
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
|
|
@ -52,8 +52,11 @@ MULTISRCTOP =
|
|||
MULTIBUILDTOP =
|
||||
MULTIDIRS =
|
||||
MULTISUBDIR =
|
||||
MULTILIBNAME =
|
||||
MULTIDO = true
|
||||
MULTICLEAN = true
|
||||
MULTI_FLAGS_FOR_TARGET = MULTI_DEFAULT_FLAGS
|
||||
MULTI_DEFAULT_FLAGS = -DSEMIHOST_V2
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
|
@ -77,11 +80,12 @@ OBJS = ftruncate.o libcfunc.o syscalls.o truncate.o _exit.o _kill.o
|
|||
CRT0 = crt0.o
|
||||
CRT0_INSTALL = install-crt0
|
||||
|
||||
CRT0_INSTALL = install-crt0
|
||||
RDIMON_CRT0 = rdimon-crt0.o
|
||||
RDIMON_BSP = librdimon.a
|
||||
RDIMON_CRT0 = rdimon-crt0${${MULTILIBNAME}}.o
|
||||
RDIMON_BSP = librdimon${${MULTILIBNAME}}.a
|
||||
RDIMON_OBJS = $(patsubst %,rdimon-%,$(OBJS))
|
||||
RDIMON_SCRIPTS = rdimon.specs aem-ve.specs aem-validation.specs
|
||||
RDIMON_SCRIPTS = rdimon${${MULTILIBNAME}}.specs \
|
||||
aem-ve${${MULTILIBNAME}}.specs \
|
||||
aem-validation${${MULTILIBNAME}}.specs
|
||||
RDIMON_INSTALL = install-rdimon
|
||||
|
||||
CFLAGS = -g
|
||||
|
@ -93,6 +97,7 @@ CFLAGS = -g
|
|||
# build a test program for each target board. Just trying to get
|
||||
# it to link is a good test, so we ignore all the errors for now.
|
||||
#
|
||||
|
||||
all: ${CRT0} ${RDIMON_CRT0} ${RDIMON_BSP} ${RDIMON_SCRIPTS}
|
||||
@rootpre=`pwd`/; export rootpre; \
|
||||
srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \
|
||||
|
@ -103,6 +108,7 @@ all: ${CRT0} ${RDIMON_CRT0} ${RDIMON_BSP} ${RDIMON_SCRIPTS}
|
|||
else true; fi; \
|
||||
else true; fi; \
|
||||
done
|
||||
$(MAKE) $(AM_MAKEFLAGS) all-recursive
|
||||
|
||||
#
|
||||
# here's where we build the test programs for each target
|
||||
|
@ -112,35 +118,53 @@ test:
|
|||
|
||||
#
|
||||
crt0.o: crt0.S
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $($(MULTI_FLAGS_FOR_TARGET)) $(CFLAGS) $(INCLUDES) -o $@ -c $<
|
||||
|
||||
rdimon-crt0.o: crt0.S
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
rdimon-crt0${${MULTILIBNAME}}.o: crt0.S
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $($(MULTI_FLAGS_FOR_TARGET)) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
|
||||
#rdimon-trap.o: trap.S
|
||||
# $(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
# $(CC) $(CFLAGS_FOR_TARGET) $($(MULTI_FLAGS_FOR_TARGET)) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
|
||||
rdimon-_exit.o: _exit.c
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $($(MULTI_FLAGS_FOR_TARGET)) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
|
||||
rdimon-ftruncate.o: ftruncate.c
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $($(MULTI_FLAGS_FOR_TARGET)) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
|
||||
rdimon-_kill.o: _kill.c
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $($(MULTI_FLAGS_FOR_TARGET)) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
|
||||
rdimon-libcfunc.o: libcfunc.c
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $($(MULTI_FLAGS_FOR_TARGET)) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
|
||||
rdimon-syscalls.o: syscalls.c
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $($(MULTI_FLAGS_FOR_TARGET)) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
|
||||
rdimon-truncate.o: truncate.c
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $($(MULTI_FLAGS_FOR_TARGET)) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
|
||||
$(RDIMON_BSP): $(RDIMON_OBJS)
|
||||
${AR} ${ARFLAGS} $@ $^
|
||||
${RANLIB} $@
|
||||
|
||||
# Multilib support.
|
||||
.PHONY: multi-do all-multi clean-multi install-multi
|
||||
|
||||
all-recursive: all-multi
|
||||
clean-recursive: clean-multi
|
||||
install-recursive: install-multi
|
||||
|
||||
# The $(MAKE) comments below are to enable parallel building.
|
||||
all-multi:
|
||||
$(MAKE) $(AM_MAKEFLAGS) DO=all multi-do
|
||||
|
||||
clean-multi:
|
||||
$(MAKE) $(AM_MAKEFLAGS) DO=clean multi-do
|
||||
|
||||
install-multi:
|
||||
$(MAKE) $(AM_MAKEFLAGS) DO=install multi-do
|
||||
|
||||
clean mostlyclean:
|
||||
rm -f a.out core *.i *.o *-test *.srec *.dis *.x $(SIM_BSP) ${RDIMON_SCRIPTS}
|
||||
@rootpre=`pwd`/; export rootpre; \
|
||||
|
@ -152,6 +176,7 @@ clean mostlyclean:
|
|||
else true; fi; \
|
||||
else true; fi; \
|
||||
done
|
||||
$(MAKE) $(AM_MAKEFLAGS) clean-recursive
|
||||
|
||||
distclean maintainer-clean realclean: clean
|
||||
rm -f Makefile config.status *~
|
||||
|
@ -167,6 +192,7 @@ install: ${CRT0_INSTALL} ${RDIMON_INSTALL}
|
|||
else true; fi; \
|
||||
else true; fi; \
|
||||
done
|
||||
$(MAKE) $(AM_MAKEFLAGS) install-recursive
|
||||
|
||||
install-crt0:
|
||||
${INSTALL_DATA} ${CRT0} $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x
|
||||
|
@ -189,3 +215,5 @@ Makefile: Makefile.in config.status @host_makefile_frag_path@
|
|||
|
||||
config.status: configure
|
||||
$(SHELL) config.status --recheck
|
||||
|
||||
include $(srcdir)/../multi-build.in
|
|
@ -36,6 +36,12 @@ _exit (int status)
|
|||
param_block_t block[2];
|
||||
block[0] = ADP_Stopped_ApplicationExit;
|
||||
block[1] = status;
|
||||
do_AngelSVC (AngelSVC_Reason_ReportException, block);
|
||||
|
||||
#if SEMIHOST_V2
|
||||
if (_has_ext_exit_extended ())
|
||||
do_AngelSVC (AngelSVC_Reason_ReportExceptionExtended, block);
|
||||
else
|
||||
#endif
|
||||
do_AngelSVC (AngelSVC_Reason_ReportException, block);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,5 +45,11 @@ _kill (int pid, int sig)
|
|||
|
||||
block[0] = ADP_Stopped_RunTimeError;
|
||||
block[1] = sig;
|
||||
return do_AngelSVC (AngelSVC_Reason_ReportException, block);
|
||||
|
||||
#if SEMIHOST_V2
|
||||
if (_has_ext_exit_extended ())
|
||||
return do_AngelSVC (AngelSVC_Reason_ReportExceptionExtended, block);
|
||||
else
|
||||
#endif
|
||||
return do_AngelSVC (AngelSVC_Reason_ReportException, block);
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@
|
|||
FUNC_START _start
|
||||
|
||||
/* Start by setting up a stack */
|
||||
|
||||
#ifdef ARM_RDI_MONITOR
|
||||
/* Issue Angel SVC to read memory info.
|
||||
|
||||
ptr to ptr to 4 words to receive data. */
|
||||
|
@ -101,6 +101,10 @@
|
|||
exposed here in the HeapInfo Angel call. */
|
||||
ldr x0, .LC0 /* point at returned values */
|
||||
ldr x1, [x0, #8] /* get heap_limit */
|
||||
#else
|
||||
/* Set up the stack pointer to a fixed value. */
|
||||
ldr x1, .Lstack
|
||||
#endif
|
||||
#ifdef __ILP32__
|
||||
/* Sanity check on the heap base. */
|
||||
ldr x0, [x0] /* get heap_base */
|
||||
|
@ -144,8 +148,10 @@
|
|||
sub x2, x2, x0 /* Third arg: length of block */
|
||||
bl FUNCTION (memset)
|
||||
|
||||
#ifdef ARM_RDI_MONITOR
|
||||
/* Need to set up standard file handles */
|
||||
bl FUNCTION (initialise_monitor_handles)
|
||||
#endif
|
||||
|
||||
/* .init and .fini sections are used to create constructors
|
||||
and destructors. Here we call the _init function and arrange
|
||||
|
@ -155,11 +161,13 @@
|
|||
|
||||
bl FUNCTION (_init)
|
||||
|
||||
#ifdef ARM_RDI_MONITOR
|
||||
/* Fetch and parse the command line. */
|
||||
adr x1, .Lcmdline /* Command line descriptor. */
|
||||
ldr x1, .Lcmdline /* Command line descriptor. */
|
||||
mov w0, #AngelSVC_Reason_GetCmdLine
|
||||
AngelSVCAsm AngelSVC
|
||||
ldr x8, .Lcmdline
|
||||
ldr x8, [x8]
|
||||
|
||||
mov x0, #0 /* argc */
|
||||
mov x1, sp /* argv */
|
||||
|
@ -216,6 +224,11 @@
|
|||
and x4, x1, ~15
|
||||
mov sp, x4
|
||||
|
||||
#else
|
||||
mov x0, #0 /* argc = 0 */
|
||||
mov x1, #0 /* argv = NULL */
|
||||
#endif
|
||||
|
||||
bl FUNCTION (main)
|
||||
|
||||
b FUNCTION (exit) /* Cannot return. */
|
||||
|
@ -228,20 +241,26 @@ FUNCTION (_cpu_init_hook):
|
|||
ret
|
||||
|
||||
.align 3
|
||||
#ifdef ARM_RDI_MONITOR
|
||||
.LC0:
|
||||
GEN_DWORD HeapBase
|
||||
#else
|
||||
.Lstack:
|
||||
GEN_DWORD __stack
|
||||
|
||||
.weak __stack
|
||||
#endif
|
||||
.LC1:
|
||||
GEN_DWORD __bss_start__
|
||||
.LC2:
|
||||
GEN_DWORD __bss_end__
|
||||
.Lfini:
|
||||
GEN_DWORD FUNCTION(_fini)
|
||||
#ifdef ARM_RDI_MONITOR
|
||||
.Lenvp:
|
||||
GEN_DWORD env
|
||||
.Lcmdline:
|
||||
GEN_DWORD CommandLine
|
||||
.dword 255
|
||||
|
||||
GEN_DWORD AngelSVCArgs
|
||||
/* Workspace for Angel calls. */
|
||||
.data
|
||||
.align 3
|
||||
|
@ -258,3 +277,7 @@ StackBase: .dword 0
|
|||
StackLimit: .dword 0
|
||||
env: .dword 0 /* Dummy environment array */
|
||||
CommandLine: .space 256,0 /* Maximum length of 255 chars handled. */
|
||||
AngelSVCArgs:
|
||||
GEN_DWORD CommandLine
|
||||
.dword 255
|
||||
#endif
|
|
@ -1,7 +1,7 @@
|
|||
# aem-ve.specs
|
||||
#
|
||||
# Spec file for AArch64 baremetal newlib, libgloss on the validation platform
|
||||
# with AngelAPI semi-hosting.
|
||||
# with version 2 of AngelAPI semi-hosting.
|
||||
|
||||
%rename lib libc
|
||||
|
||||
|
@ -10,3 +10,6 @@
|
|||
|
||||
*lib:
|
||||
cpu-init/rdimon-aem-el3.o%s --start-group %(libc) %(libgloss) --end-group
|
||||
|
||||
*startfile:
|
||||
crti%O%s crtbegin%O%s %{!pg:rdimon-crt0%O%s} %{pg:rdimon-crt0%O%s}
|
|
@ -1,7 +1,7 @@
|
|||
# aem-ve.specs
|
||||
#
|
||||
# Spec file for AArch64 baremetal newlib, libgloss on VE platform with AngelAPI
|
||||
# semi-hosting.
|
||||
# Spec file for AArch64 baremetal newlib, libgloss on VE platform with version 2
|
||||
# of AngelAPI semi-hosting.
|
||||
#
|
||||
# This Spec file is also appropriate for the foundation model.
|
||||
|
||||
|
@ -17,3 +17,6 @@
|
|||
|
||||
*lib:
|
||||
cpu-init/rdimon-aem-el3.o%s --start-group %(libc) %(libgloss) --end-group
|
||||
|
||||
*startfile:
|
||||
crti%O%s crtbegin%O%s %{!pg:rdimon-crt0%O%s} %{pg:rdimon-crt0%O%s}
|
|
@ -1,3 +1,8 @@
|
|||
# rdimon.specs
|
||||
#
|
||||
# Spec file for AArch64 baremetal newlib with version 2 of the
|
||||
# AngelAPI semi-hosting.
|
||||
|
||||
%rename lib libc
|
||||
|
||||
*libgloss:
|
||||
|
@ -5,3 +10,6 @@
|
|||
|
||||
*lib:
|
||||
--start-group %(libc) %(libgloss) --end-group
|
||||
|
||||
*startfile:
|
||||
crti%O%s crtbegin%O%s %{!pg:rdimon-crt0%O%s} %{pg:rdimon-crt0%O%s}
|
|
@ -23,37 +23,59 @@
|
|||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#include <_ansi.h>
|
||||
|
||||
/* Now the SWI numbers and reason codes for RDI (Angel) monitors. */
|
||||
#define AngelSVC 0xF000
|
||||
#define AngelSVCInsn "hlt"
|
||||
#define AngelSVCAsm hlt
|
||||
#define AngelSVC 0xF000
|
||||
#define AngelSVCInsn "hlt"
|
||||
#define AngelSVCAsm hlt
|
||||
|
||||
/* The reason codes: */
|
||||
#define AngelSVC_Reason_Open 0x01
|
||||
#define AngelSVC_Reason_Close 0x02
|
||||
#define AngelSVC_Reason_WriteC 0x03
|
||||
#define AngelSVC_Reason_Write0 0x04
|
||||
#define AngelSVC_Reason_Write 0x05
|
||||
#define AngelSVC_Reason_Read 0x06
|
||||
#define AngelSVC_Reason_ReadC 0x07
|
||||
#define AngelSVC_Reason_IsTTY 0x09
|
||||
#define AngelSVC_Reason_Seek 0x0A
|
||||
#define AngelSVC_Reason_FLen 0x0C
|
||||
#define AngelSVC_Reason_TmpNam 0x0D
|
||||
#define AngelSVC_Reason_Remove 0x0E
|
||||
#define AngelSVC_Reason_Rename 0x0F
|
||||
#define AngelSVC_Reason_Clock 0x10
|
||||
#define AngelSVC_Reason_Time 0x11
|
||||
#define AngelSVC_Reason_System 0x12
|
||||
#define AngelSVC_Reason_Errno 0x13
|
||||
#define AngelSVC_Reason_GetCmdLine 0x15
|
||||
#define AngelSVC_Reason_HeapInfo 0x16
|
||||
#define AngelSVC_Reason_EnterSVC 0x17
|
||||
#define AngelSVC_Reason_ReportException 0x18
|
||||
#define AngelSVC_Reason_SyncCacheRange 0x19
|
||||
#define AngelSVC_Reason_Elapsed 0x30
|
||||
#define ADP_Stopped_ApplicationExit ((2 << 16) + 38)
|
||||
#define ADP_Stopped_RunTimeError ((2 << 16) + 35)
|
||||
#define AngelSVC_Reason_Open 0x01
|
||||
#define AngelSVC_Reason_Close 0x02
|
||||
#define AngelSVC_Reason_WriteC 0x03
|
||||
#define AngelSVC_Reason_Write0 0x04
|
||||
#define AngelSVC_Reason_Write 0x05
|
||||
#define AngelSVC_Reason_Read 0x06
|
||||
#define AngelSVC_Reason_ReadC 0x07
|
||||
#define AngelSVC_Reason_IsError 0x08
|
||||
#define AngelSVC_Reason_IsTTY 0x09
|
||||
#define AngelSVC_Reason_Seek 0x0A
|
||||
#define AngelSVC_Reason_FLen 0x0C
|
||||
#define AngelSVC_Reason_TmpNam 0x0D
|
||||
#define AngelSVC_Reason_Remove 0x0E
|
||||
#define AngelSVC_Reason_Rename 0x0F
|
||||
#define AngelSVC_Reason_Clock 0x10
|
||||
#define AngelSVC_Reason_Time 0x11
|
||||
#define AngelSVC_Reason_System 0x12
|
||||
#define AngelSVC_Reason_Errno 0x13
|
||||
#define AngelSVC_Reason_GetCmdLine 0x15
|
||||
#define AngelSVC_Reason_HeapInfo 0x16
|
||||
#define AngelSVC_Reason_EnterSVC 0x17
|
||||
#define AngelSVC_Reason_ReportException 0x18
|
||||
#define AngelSVC_Reason_SyncCacheRange 0x19
|
||||
#define AngelSVC_Reason_ReportExceptionExtended 0x20
|
||||
#define AngelSVC_Reason_Elapsed 0x30
|
||||
#define AngelSVC_Reason_TickFreq 0x31
|
||||
#define ADP_Stopped_ApplicationExit ((2 << 16) + 38)
|
||||
#define ADP_Stopped_RunTimeError ((2 << 16) + 35)
|
||||
|
||||
/* Semihosting feature magic numbers. */
|
||||
#define NUM_SHFB_MAGIC 4
|
||||
#define SHFB_MAGIC_0 0x53
|
||||
#define SHFB_MAGIC_1 0x48
|
||||
#define SHFB_MAGIC_2 0x46
|
||||
#define SHFB_MAGIC_3 0x42
|
||||
|
||||
/* Semihosting extensions. */
|
||||
#define SH_EXT_EXIT_EXTENDED_BITNUM 0x0
|
||||
#define SH_EXT_STDOUT_STDERR_BITNUM 0x1
|
||||
|
||||
#if !defined (__ASSEMBLER__)
|
||||
extern int _get_semihosting_exts _PARAMS ((char*, int, int));
|
||||
extern int _has_ext_exit_extended _PARAMS ((void));
|
||||
extern int _has_ext_stdout_stderr _PARAMS ((void));
|
||||
#endif
|
||||
|
||||
#if defined(ARM_RDI_MONITOR) && !defined(__ASSEMBLER__)
|
||||
|
||||
|
|
|
@ -76,6 +76,9 @@ static int checkerror _PARAMS ((int));
|
|||
static int error _PARAMS ((int));
|
||||
static int get_errno _PARAMS ((void));
|
||||
|
||||
/* Semihosting utilities. */
|
||||
static void initialise_semihosting_exts _PARAMS ((void));
|
||||
|
||||
/* Struct used to keep track of the file position, just so we
|
||||
can implement fseek(fh,x,SEEK_CUR). */
|
||||
struct fdent
|
||||
|
@ -130,6 +133,9 @@ static int monitor_stdin;
|
|||
static int monitor_stdout;
|
||||
static int monitor_stderr;
|
||||
|
||||
static int supports_ext_exit_extended = -1;
|
||||
static int supports_ext_stdout_stderr = -1;
|
||||
|
||||
/* Return a pointer to the structure associated with
|
||||
the user file descriptor fd. */
|
||||
static struct fdent *
|
||||
|
@ -188,32 +194,131 @@ initialise_monitor_handles (void)
|
|||
block[1] = 0; /* mode "r" */
|
||||
monitor_stdin = do_AngelSVC (AngelSVC_Reason_Open, block);
|
||||
|
||||
block[0] = POINTER_TO_PARAM_BLOCK_T (":tt");
|
||||
block[2] = 3; /* length of filename */
|
||||
block[1] = 4; /* mode "w" */
|
||||
monitor_stdout = do_AngelSVC (AngelSVC_Reason_Open, block);
|
||||
for (i = 0; i < MAX_OPEN_FILES; i++)
|
||||
openfiles[i].handle = -1;;
|
||||
|
||||
block[0] = POINTER_TO_PARAM_BLOCK_T (":tt");
|
||||
block[2] = 3; /* length of filename */
|
||||
block[1] = 8; /* mode "a" */
|
||||
monitor_stderr = do_AngelSVC (AngelSVC_Reason_Open, block);
|
||||
if (_has_ext_stdout_stderr ())
|
||||
{
|
||||
block[0] = POINTER_TO_PARAM_BLOCK_T (":tt");
|
||||
block[2] = 3; /* length of filename */
|
||||
block[1] = 4; /* mode "w" */
|
||||
monitor_stdout = do_AngelSVC (AngelSVC_Reason_Open, block);
|
||||
|
||||
block[0] = POINTER_TO_PARAM_BLOCK_T (":tt");
|
||||
block[2] = 3; /* length of filename */
|
||||
block[1] = 8; /* mode "a" */
|
||||
monitor_stderr = do_AngelSVC (AngelSVC_Reason_Open, block);
|
||||
}
|
||||
|
||||
/* If we failed to open stderr, redirect to stdout. */
|
||||
if (monitor_stderr == -1)
|
||||
monitor_stderr = monitor_stdout;
|
||||
|
||||
for (i = 0; i < MAX_OPEN_FILES; i++)
|
||||
openfiles[i].handle = -1;
|
||||
|
||||
openfiles[0].handle = monitor_stdin;
|
||||
openfiles[0].flags = _FREAD;
|
||||
openfiles[0].pos = 0;
|
||||
openfiles[1].handle = monitor_stdout;
|
||||
openfiles[0].flags = _FWRITE;
|
||||
openfiles[1].pos = 0;
|
||||
openfiles[2].handle = monitor_stderr;
|
||||
openfiles[0].flags = _FWRITE;
|
||||
openfiles[2].pos = 0;
|
||||
|
||||
if (_has_ext_stdout_stderr ())
|
||||
{
|
||||
openfiles[1].handle = monitor_stdout;
|
||||
openfiles[0].flags = _FWRITE;
|
||||
openfiles[1].pos = 0;
|
||||
openfiles[2].handle = monitor_stderr;
|
||||
openfiles[0].flags = _FWRITE;
|
||||
openfiles[2].pos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
_has_ext_exit_extended (void)
|
||||
{
|
||||
if (supports_ext_exit_extended < 0)
|
||||
{
|
||||
initialise_semihosting_exts ();
|
||||
}
|
||||
|
||||
return supports_ext_exit_extended;
|
||||
}
|
||||
|
||||
int
|
||||
_has_ext_stdout_stderr (void)
|
||||
{
|
||||
if (supports_ext_stdout_stderr < 0)
|
||||
{
|
||||
initialise_semihosting_exts ();
|
||||
}
|
||||
|
||||
return supports_ext_stdout_stderr;
|
||||
}
|
||||
|
||||
static void
|
||||
initialise_semihosting_exts (void)
|
||||
{
|
||||
supports_ext_exit_extended = 0;
|
||||
supports_ext_stdout_stderr = 1;
|
||||
|
||||
#if SEMIHOST_V2
|
||||
char features[1];
|
||||
if (_get_semihosting_exts (features, 0, 1) > 0)
|
||||
{
|
||||
supports_ext_exit_extended
|
||||
= features[0] & (1 << SH_EXT_EXIT_EXTENDED_BITNUM);
|
||||
supports_ext_stdout_stderr
|
||||
= features[0] & (1 << SH_EXT_STDOUT_STDERR_BITNUM);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
_get_semihosting_exts (char* features, int offset, int num)
|
||||
{
|
||||
int fd = _open (":semihosting-features", O_RDONLY);
|
||||
memset (features, 0, num);
|
||||
|
||||
if (fd == -1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct fdent *pfd;
|
||||
pfd = findslot (fd);
|
||||
|
||||
param_block_t block[1];
|
||||
block[0] = pfd->handle;
|
||||
|
||||
int len = do_AngelSVC (AngelSVC_Reason_FLen, block);
|
||||
|
||||
if (len < NUM_SHFB_MAGIC
|
||||
|| num > (len - NUM_SHFB_MAGIC))
|
||||
{
|
||||
_close (fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
char buffer[NUM_SHFB_MAGIC];
|
||||
int n_read = _read (fd, buffer, NUM_SHFB_MAGIC);
|
||||
|
||||
if (n_read < NUM_SHFB_MAGIC
|
||||
|| buffer[0] != SHFB_MAGIC_0
|
||||
|| buffer[1] != SHFB_MAGIC_1
|
||||
|| buffer[2] != SHFB_MAGIC_2
|
||||
|| buffer[3] != SHFB_MAGIC_3)
|
||||
{
|
||||
_close (fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (_lseek (fd, offset, SEEK_CUR) < 0)
|
||||
{
|
||||
_close (fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
n_read = _read (fd, features, num);
|
||||
|
||||
_close (fd);
|
||||
|
||||
return checkerror (n_read);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -47,14 +47,15 @@ OBJCOPY = `if [ -f ${objroot}/../binutils/objcopy ] ; \
|
|||
then echo ${objroot}/../binutils/objcopy ; \
|
||||
else t='$(program_transform_name)'; echo objcopy | sed -e $$t ; fi`
|
||||
|
||||
CRT0 = crt0.o
|
||||
CRT0 = gcrt0.o crt0.o
|
||||
CRT0_INSTALL = install-crt0
|
||||
|
||||
NSIM_BSP = libnsim.a
|
||||
NSIM_OBJS = \
|
||||
libcfunc.o \
|
||||
nsim-syscalls.o \
|
||||
sbrk.o
|
||||
libcfunc.o \
|
||||
nsim-syscalls.o \
|
||||
sbrk.o \
|
||||
mcount.o
|
||||
NSIM_INSTALL = install-nsim
|
||||
NSIM_SCRIPTS = nsim.specs
|
||||
|
||||
|
@ -75,9 +76,9 @@ $(NSIM_BSP): $(NSIM_OBJS)
|
|||
libcfunc.o: libcfunc.c
|
||||
nsim-syscalls.o: nsim-syscalls.c
|
||||
sbrk.o: sbrk.c
|
||||
|
||||
#
|
||||
$(CRT0): crt0.S
|
||||
mcount.o: mcount.c
|
||||
gcrt0.o: gcrt0.S crt0.S
|
||||
crt0.o: crt0.S
|
||||
|
||||
clean mostlyclean:
|
||||
rm -f *.o *.a
|
||||
|
@ -95,7 +96,10 @@ install: $(CRT0_INSTALL) $(NSIM_INSTALL) $(NANO_INSTALL)
|
|||
|
||||
$(CRT0_INSTALL):
|
||||
$(mkinstalldirs) $(DESTDIR)${tooldir}/lib${MULTISUBDIR}
|
||||
${INSTALL_DATA} ${CRT0} $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$(CRT0)
|
||||
for c in $(CRT0); do \
|
||||
b=`basename $$c`; \
|
||||
${INSTALL_DATA} $$c $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$b ;\
|
||||
done
|
||||
|
||||
$(NSIM_INSTALL):
|
||||
$(mkinstalldirs) $(DESTDIR)${tooldir}/lib${MULTISUBDIR}
|
||||
|
|
|
@ -142,6 +142,11 @@ __start:
|
|||
bset r2, r2, 19
|
||||
flag r2
|
||||
#endif
|
||||
|
||||
#if defined (__ARC_CODE_DENSITY__)
|
||||
;; Initialize jli_base
|
||||
sr @__JLI_TABLE__,[jli_base]
|
||||
#endif
|
||||
mov gp, @__SDATA_BEGIN__
|
||||
mov_s r2, @__sbss_start ; r2 = start of the bss section
|
||||
sub r3, @_end, r2 ; r3 = size of the bss section in bytes
|
||||
|
@ -189,11 +194,18 @@ __start:
|
|||
mov_s r0, 1
|
||||
st_s r0, [r1, 4] ; _GLOBAL_REENT->atexit0._ind
|
||||
; branch to _init
|
||||
#if defined (__EM__) || defined (__HS__)
|
||||
#if defined (__ARCEM__) || defined (__ARCHS__)
|
||||
jl @_init
|
||||
#else
|
||||
bl @_init
|
||||
#endif /* __ARCEM__ || __ARCHS__ */
|
||||
|
||||
#ifdef PROFILE_SUPPORT /* Defined in gcrt0.S. */
|
||||
mov r0,@__start
|
||||
mov r1,@_etext
|
||||
jl @_monstartup
|
||||
#endif /* PROFILE_SUPPORT */
|
||||
|
||||
mov_s r0, r13
|
||||
mov_s r1, r14
|
||||
; branch to main
|
||||
|
@ -204,6 +216,13 @@ __start:
|
|||
bl.d @main
|
||||
mov fp, 0 ; initialize frame pointer
|
||||
#endif /* __ARCEM__ || __ARCHS__ */
|
||||
|
||||
#ifdef PROFILE_SUPPORT
|
||||
mov r13, r0 ; Save return code
|
||||
jl @_mcleanup
|
||||
mov r0, r13
|
||||
#endif /* PROFILE_SUPPORT */
|
||||
|
||||
; r0 contains exit code
|
||||
j @exit
|
||||
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
Copyright (c) 2016, Synopsys, Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1) Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2) Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3) Neither the name of the Synopsys, Inc., nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#define PROFILE_SUPPORT 1
|
||||
|
||||
#include "crt0.S"
|
||||
|
||||
.global __mcount
|
||||
.type __mcount, @function
|
||||
.align 4
|
||||
__mcount:
|
||||
;; When a function is compiled for profiling, gcc will insert
|
||||
;; a call to __mcount without checking for resources. Hence,
|
||||
;; we need save all of the argument registers and temp registers,
|
||||
;; extract the address of <func_name>, and call the _mcount_internal
|
||||
;; to do the real work. Finally, restore all the argument registers
|
||||
;; before returning.
|
||||
push_s blink
|
||||
push_s r0
|
||||
push_s r1
|
||||
push_s r2
|
||||
push_s r3
|
||||
#ifndef __ARC_RF16__
|
||||
push r4
|
||||
push r5
|
||||
push r6
|
||||
push r7
|
||||
push r8
|
||||
push r9
|
||||
#endif
|
||||
push r10
|
||||
push r11
|
||||
push r12
|
||||
mov r0,blink
|
||||
jl @_mcount_internal
|
||||
pop r12
|
||||
pop r11
|
||||
pop r10
|
||||
#ifndef __ARC_RF16__
|
||||
pop r9
|
||||
pop r8
|
||||
pop r7
|
||||
pop r6
|
||||
pop r5
|
||||
pop r4
|
||||
#endif
|
||||
pop_s r3
|
||||
pop_s r2
|
||||
pop_s r1
|
||||
pop_s r0
|
||||
pop_s blink
|
||||
j_s [blink]
|
||||
.size __mcount, . - __mcount
|
|
@ -0,0 +1,422 @@
|
|||
/*-
|
||||
* Copyright (c) 1983, 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* This file implements a subset of the profiling support functions.
|
||||
It has been copied and adapted from mcount.c, gmon.c and gmon.h in
|
||||
the glibc sources.
|
||||
Since we do not have access to a timer interrupt in the simulator
|
||||
the histogram and basic block information is not generated. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
/* Fraction of text space to allocate for histogram counters here, 1/2. */
|
||||
#define HISTFRACTION 2
|
||||
|
||||
/* Fraction of text space to allocate for from hash buckets.
|
||||
The value of HASHFRACTION is based on the minimum number of bytes
|
||||
of separation between two subroutine call points in the object code.
|
||||
Given MIN_SUBR_SEPARATION bytes of separation the value of
|
||||
HASHFRACTION is calculated as:
|
||||
|
||||
HASHFRACTION = MIN_SUBR_SEPARATION / (2 * sizeof (short) - 1);
|
||||
|
||||
For example, on the VAX, the shortest two call sequence is:
|
||||
|
||||
calls $0,(r0)
|
||||
calls $0,(r0)
|
||||
|
||||
which is separated by only three bytes, thus HASHFRACTION is
|
||||
calculated as:
|
||||
|
||||
HASHFRACTION = 3 / (2 * 2 - 1) = 1
|
||||
|
||||
Note that the division above rounds down, thus if MIN_SUBR_FRACTION
|
||||
is less than three, this algorithm will not work!
|
||||
|
||||
In practice, however, call instructions are rarely at a minimal
|
||||
distance. Hence, we will define HASHFRACTION to be 2 across all
|
||||
architectures. This saves a reasonable amount of space for
|
||||
profiling data structures without (in practice) sacrificing
|
||||
any granularity. */
|
||||
#define HASHFRACTION 2
|
||||
|
||||
/* Percent of text space to allocate for tostructs.
|
||||
This is a heuristic; we will fail with a warning when profiling
|
||||
programs with a very large number of very small functions, but
|
||||
that's normally OK.
|
||||
2 is probably still a good value for normal programs.
|
||||
Profiling a test case with 64000 small functions will work if
|
||||
you raise this value to 3 and link statically (which bloats the
|
||||
text size, thus raising the number of arcs expected by the heuristic). */
|
||||
#define ARCDENSITY 3
|
||||
|
||||
/* Always allocate at least this many tostructs. This hides the
|
||||
inadequacy of the ARCDENSITY heuristic, at least for small programs. */
|
||||
#define MINARCS 50
|
||||
|
||||
/* Maximum number of arcs we want to allow.
|
||||
Used to be max representable value of ARCINDEX minus 2, but now
|
||||
that ARCINDEX is a long, that's too large; we don't really want
|
||||
to allow a 48 gigabyte table.
|
||||
The old value of 1<<16 wasn't high enough in practice for large C++
|
||||
programs; will 1<<20 be adequate for long? FIXME */
|
||||
#define MAXARCS (1L << 20)
|
||||
|
||||
#define SCALE_1_TO_1 0x10000L
|
||||
|
||||
#define GMON_MAGIC "gmon" /* Magic cookie. */
|
||||
#define GMON_VERSION 1 /* Version number. */
|
||||
|
||||
|
||||
/* General rounding functions. */
|
||||
#define ROUNDDOWN(x ,y) (((x) / (y)) * (y))
|
||||
#define ROUNDUP(x, y) ((((x) + (y) - 1) / (y)) * (y))
|
||||
|
||||
struct tostruct
|
||||
{
|
||||
unsigned long selfpc;
|
||||
unsigned long count;
|
||||
unsigned long link;
|
||||
};
|
||||
|
||||
/* Possible states of profiling. */
|
||||
enum profiling_state
|
||||
{
|
||||
GMON_PROF_OFF,
|
||||
GMON_PROF_ON,
|
||||
GMON_PROF_BUSY,
|
||||
GMON_PROF_ERROR
|
||||
};
|
||||
|
||||
/* The profiling data structures are housed in this structure. */
|
||||
struct gmonparam
|
||||
{
|
||||
enum profiling_state state;
|
||||
unsigned short * kcount;
|
||||
unsigned long kcountsize;
|
||||
unsigned long * froms;
|
||||
unsigned long fromssize;
|
||||
struct tostruct * tos;
|
||||
unsigned long tossize;
|
||||
long tolimit;
|
||||
unsigned long lowpc;
|
||||
unsigned long highpc;
|
||||
unsigned long textsize;
|
||||
unsigned long hashfraction;
|
||||
long log_hashfraction;
|
||||
};
|
||||
|
||||
/* Raw header as it appears in the gmon.out file (without padding).
|
||||
This header always comes first and is then followed by a series
|
||||
records defined below. */
|
||||
struct gmon_hdr
|
||||
{
|
||||
char cookie[4];
|
||||
char version[4];
|
||||
char spare[3 * 4];
|
||||
};
|
||||
|
||||
/* Types of records in this file. */
|
||||
typedef enum
|
||||
{
|
||||
GMON_TAG_TIME_HIST = 0,
|
||||
GMON_TAG_CG_ARC = 1,
|
||||
} GMON_Record_Tag;
|
||||
|
||||
struct gmon_cg_arc_record
|
||||
{
|
||||
char tag; /* Set to GMON_TAG_CG_ARC. */
|
||||
char from_pc[sizeof (char *)]; /* Address within caller's body. */
|
||||
char self_pc[sizeof (char *)]; /* Address within callee's body. */
|
||||
char count[4]; /* Number of arc traversals. */
|
||||
};
|
||||
|
||||
|
||||
/* Forward declarations. */
|
||||
void _mcount_internal (unsigned long);
|
||||
void _monstartup (unsigned long, unsigned long);
|
||||
void _mcleanup (void);
|
||||
|
||||
static struct gmonparam _gmonparam;
|
||||
|
||||
void
|
||||
_mcount_internal (unsigned long frompc)
|
||||
{
|
||||
unsigned long selfpc = frompc;
|
||||
unsigned long * frompcindex;
|
||||
struct tostruct * top;
|
||||
struct tostruct * prevtop;
|
||||
struct gmonparam * p;
|
||||
unsigned long toindex;
|
||||
int i;
|
||||
|
||||
p = & _gmonparam;
|
||||
|
||||
/* Check that we are profiling and that we aren't recursively invoked.
|
||||
NB/ This version is not thread-safe. */
|
||||
if (p->state != GMON_PROF_ON)
|
||||
return;
|
||||
p->state = GMON_PROF_BUSY;
|
||||
|
||||
/* Check that frompcindex is a reasonable pc value.
|
||||
For example: signal catchers get called from the stack,
|
||||
not from text space. Too bad. */
|
||||
frompc -= p->lowpc;
|
||||
if (frompc > p->textsize)
|
||||
goto done;
|
||||
|
||||
i = frompc >> p->log_hashfraction;
|
||||
|
||||
frompcindex = p->froms + i;
|
||||
toindex = * frompcindex;
|
||||
|
||||
if (toindex == 0)
|
||||
{
|
||||
/* First time traversing this arc. */
|
||||
toindex = ++ p->tos[0].link;
|
||||
if (toindex >= p->tolimit)
|
||||
/* Halt further profiling. */
|
||||
goto overflow;
|
||||
|
||||
* frompcindex = toindex;
|
||||
top = p->tos + toindex;
|
||||
top->selfpc = selfpc;
|
||||
top->count = 1;
|
||||
top->link = 0;
|
||||
goto done;
|
||||
}
|
||||
|
||||
top = p->tos + toindex;
|
||||
|
||||
if (top->selfpc == selfpc)
|
||||
{
|
||||
/* Arc at front of chain: usual case. */
|
||||
top->count ++;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Have to go looking down chain for it.
|
||||
Top points to what we are looking at,
|
||||
prevtop points to previous top.
|
||||
We know it is not at the head of the chain. */
|
||||
for (;;)
|
||||
{
|
||||
if (top->link == 0)
|
||||
{
|
||||
/* Top is end of the chain and none of the chain
|
||||
had top->selfpc == selfpc. So we allocate a
|
||||
new tostruct and link it to the head of the
|
||||
chain. */
|
||||
toindex = ++ p->tos[0].link;
|
||||
if (toindex >= p->tolimit)
|
||||
goto overflow;
|
||||
|
||||
top = p->tos + toindex;
|
||||
top->selfpc = selfpc;
|
||||
top->count = 1;
|
||||
top->link = * frompcindex;
|
||||
* frompcindex = toindex;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Otherwise, check the next arc on the chain. */
|
||||
prevtop = top;
|
||||
top = p->tos + top->link;
|
||||
|
||||
if (top->selfpc == selfpc)
|
||||
{
|
||||
/* There it is. Increment its count
|
||||
move it to the head of the chain. */
|
||||
top->count ++;
|
||||
toindex = prevtop->link;
|
||||
prevtop->link = top->link;
|
||||
top->link = * frompcindex;
|
||||
* frompcindex = toindex;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
p->state = GMON_PROF_ON;
|
||||
return;
|
||||
|
||||
overflow:
|
||||
p->state = GMON_PROF_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
_monstartup (unsigned long lowpc, unsigned long highpc)
|
||||
{
|
||||
char * cp;
|
||||
struct gmonparam * p = & _gmonparam;
|
||||
|
||||
/* If the calloc() function has been instrumented we must make sure
|
||||
that it is not profiled until we are ready. */
|
||||
p->state = GMON_PROF_BUSY;
|
||||
|
||||
/* Round lowpc and highpc to multiples of the density we're using
|
||||
so the rest of the scaling (here and in gprof) stays in ints. */
|
||||
p->lowpc = ROUNDDOWN (lowpc, HISTFRACTION * sizeof (* p->kcount));
|
||||
p->highpc = ROUNDUP (highpc, HISTFRACTION * sizeof (* p->kcount));
|
||||
p->textsize = p->highpc - p->lowpc;
|
||||
p->kcountsize = ROUNDUP (p->textsize / HISTFRACTION, sizeof (*p->froms));
|
||||
p->hashfraction = HASHFRACTION;
|
||||
p->log_hashfraction = -1;
|
||||
p->log_hashfraction = ffs (p->hashfraction * sizeof (*p->froms)) - 1;
|
||||
p->fromssize = p->textsize / HASHFRACTION;
|
||||
p->tolimit = p->textsize * ARCDENSITY / 100;
|
||||
|
||||
if (p->tolimit < MINARCS)
|
||||
p->tolimit = MINARCS;
|
||||
else if (p->tolimit > MAXARCS)
|
||||
p->tolimit = MAXARCS;
|
||||
|
||||
p->tossize = p->tolimit * sizeof (struct tostruct);
|
||||
|
||||
cp = calloc (p->kcountsize + p->fromssize + p->tossize, 1);
|
||||
if (cp == NULL)
|
||||
{
|
||||
write (2, "monstartup: out of memory\n", 26);
|
||||
p->tos = NULL;
|
||||
p->state = GMON_PROF_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
p->tos = (struct tostruct *) cp;
|
||||
cp += p->tossize;
|
||||
p->kcount = (unsigned short *) cp;
|
||||
cp += p->kcountsize;
|
||||
p->froms = (unsigned long *) cp;
|
||||
|
||||
p->tos[0].link = 0;
|
||||
p->state = GMON_PROF_ON;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
write_call_graph (int fd)
|
||||
{
|
||||
#define NARCS_PER_WRITE 32
|
||||
|
||||
struct gmon_cg_arc_record raw_arc[NARCS_PER_WRITE]
|
||||
__attribute__ ((aligned (__alignof__ (char *))));
|
||||
unsigned long from_index;
|
||||
unsigned long to_index;
|
||||
unsigned long from_len;
|
||||
unsigned long frompc;
|
||||
int nfilled;
|
||||
|
||||
for (nfilled = 0; nfilled < NARCS_PER_WRITE; ++ nfilled)
|
||||
raw_arc[nfilled].tag = GMON_TAG_CG_ARC;
|
||||
|
||||
nfilled = 0;
|
||||
from_len = _gmonparam.fromssize / sizeof (*_gmonparam.froms);
|
||||
|
||||
for (from_index = 0; from_index < from_len; ++from_index)
|
||||
{
|
||||
if (_gmonparam.froms[from_index] == 0)
|
||||
continue;
|
||||
|
||||
frompc = _gmonparam.lowpc;
|
||||
frompc += (from_index * _gmonparam.hashfraction
|
||||
* sizeof (*_gmonparam.froms));
|
||||
|
||||
for (to_index = _gmonparam.froms[from_index];
|
||||
to_index != 0;
|
||||
to_index = _gmonparam.tos[to_index].link)
|
||||
{
|
||||
struct gmon_cg_arc_record * arc = raw_arc + nfilled;
|
||||
|
||||
memcpy (arc->from_pc, & frompc, sizeof (arc->from_pc));
|
||||
memcpy (arc->self_pc, & _gmonparam.tos[to_index].selfpc, sizeof (arc->self_pc));
|
||||
memcpy (arc->count, & _gmonparam.tos[to_index].count, sizeof (arc->count));
|
||||
|
||||
if (++ nfilled == NARCS_PER_WRITE)
|
||||
{
|
||||
write (fd, raw_arc, sizeof raw_arc);
|
||||
nfilled = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nfilled > 0)
|
||||
write (fd, raw_arc, nfilled * sizeof (raw_arc[0]));
|
||||
}
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
static void
|
||||
write_gmon (void)
|
||||
{
|
||||
struct gmon_hdr ghdr __attribute__ ((aligned (__alignof__ (int))));
|
||||
int fd;
|
||||
|
||||
fd = open ("gmon.out", O_CREAT|O_TRUNC|O_WRONLY, 0666);
|
||||
if (fd < 0)
|
||||
{
|
||||
write (2, "_mcleanup: could not create gmon.out\n", 37);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Write gmon.out header: */
|
||||
memset (& ghdr, '\0', sizeof (ghdr));
|
||||
memcpy (ghdr.cookie, GMON_MAGIC, sizeof (ghdr.cookie));
|
||||
* (unsigned long *) ghdr.version = GMON_VERSION;
|
||||
write (fd, & ghdr, sizeof (ghdr));
|
||||
|
||||
/* We do not have histogram or basic block information,
|
||||
so we do not generate these parts of the gmon.out file. */
|
||||
|
||||
/* Write call-graph. */
|
||||
write_call_graph (fd);
|
||||
|
||||
close (fd);
|
||||
}
|
||||
|
||||
void
|
||||
_mcleanup (void)
|
||||
{
|
||||
if (_gmonparam.state != GMON_PROF_ERROR)
|
||||
{
|
||||
_gmonparam.state = GMON_PROF_OFF;
|
||||
write_gmon ();
|
||||
}
|
||||
|
||||
/* Free the memory. */
|
||||
if (_gmonparam.tos != NULL)
|
||||
{
|
||||
free (_gmonparam.tos);
|
||||
_gmonparam.tos = NULL;
|
||||
}
|
||||
}
|
|
@ -29,8 +29,15 @@ MULTISRCTOP =
|
|||
MULTIBUILDTOP =
|
||||
MULTIDIRS =
|
||||
MULTISUBDIR =
|
||||
MULTILIBNAME =
|
||||
MULTIDO = true
|
||||
MULTICLEAN = true
|
||||
MULTI_FLAGS_FOR_TARGET = MULTI_DEFAULT_FLAGS
|
||||
MULTI_DEFAULT_FLAGS = -DSEMIHOST_V2
|
||||
|
||||
MULTIDIRS += semihv2m
|
||||
MULTIDIR_semihv2m_FLAGS = $(MULTI_DEFAULT_FLAGS) -DSEMIHOST_V2_MIXED_MODE
|
||||
MULTIDIR_semihv2m_NAME = -v2m
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
|
@ -75,10 +82,12 @@ RDPMON_OBJS = ftruncate.o libcfunc.o syscalls.o trap.o truncate.o _exit.o _kill.
|
|||
RDPMON_SCRIPTS = rdpmon.specs
|
||||
RDPMON_INSTALL = install-rdpmon
|
||||
|
||||
RDIMON_CRT0 = rdimon-crt0.o
|
||||
RDIMON_BSP = librdimon.a
|
||||
RDIMON_CRT0 = rdimon-crt0${${MULTILIBNAME}}.o
|
||||
RDIMON_BSP = librdimon${${MULTILIBNAME}}.a
|
||||
RDIMON_OBJS = $(patsubst %,rdimon-%,$(RDPMON_OBJS))
|
||||
RDIMON_SCRIPTS = rdimon.specs aprofile-validation.specs aprofile-ve.specs
|
||||
RDIMON_SCRIPTS = rdimon${${MULTILIBNAME}}.specs \
|
||||
aprofile-validation${${MULTILIBNAME}}.specs \
|
||||
aprofile-ve${${MULTILIBNAME}}.specs
|
||||
RDIMON_INSTALL = install-rdimon
|
||||
|
||||
CFLAGS = -g
|
||||
|
@ -110,6 +119,7 @@ all: ${CRT0} ${LINUX_CRT0} ${LINUX_BSP} ${REDBOOT_CRT0} ${REDBOOT_OBJS} ${RDPMON
|
|||
else true; fi; \
|
||||
else true; fi; \
|
||||
done
|
||||
$(MAKE) $(AM_MAKEFLAGS) all-recursive
|
||||
|
||||
#
|
||||
# here's where we build the test programs for each target
|
||||
|
@ -121,33 +131,34 @@ test:
|
|||
crt0.o: crt0.S
|
||||
redboot-crt0.o: redboot-crt0.S
|
||||
redboot-syscalls.o: redboot-syscalls.c $(srcdir)/../syscall.h
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $($(MULTI_FLAGS_FOR_TARGET)) $(CFLAGS) $(INCLUDES) -o $@ -c $<
|
||||
|
||||
rdpmon-crt0.o: crt0.S
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -DARM_RDP_MONITOR -o $@ -c $<
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $($(MULTI_FLAGS_FOR_TARGET)) $(CFLAGS) $(INCLUDES) -DARM_RDP_MONITOR -o $@ -c $<
|
||||
|
||||
rdimon-crt0.o: crt0.S
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
rdimon-crt0${${MULTILIBNAME}}.o: crt0.S
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $($(MULTI_FLAGS_FOR_TARGET)) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
|
||||
rdimon-ftruncate.o: ftruncate.c
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $($(MULTI_FLAGS_FOR_TARGET)) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
|
||||
rdimon-trap.o: trap.S
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $($(MULTI_FLAGS_FOR_TARGET)) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
|
||||
rdimon-truncate.o: truncate.c
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $($(MULTI_FLAGS_FOR_TARGET)) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
|
||||
rdimon-_exit.o: _exit.c
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $($(MULTI_FLAGS_FOR_TARGET)) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
|
||||
rdimon-_kill.o: _kill.c
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $($(MULTI_FLAGS_FOR_TARGET)) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
|
||||
rdimon-syscalls.o: syscalls.c
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $($(MULTI_FLAGS_FOR_TARGET)) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
|
||||
rdimon-libcfunc.o: libcfunc.c
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $($(MULTI_FLAGS_FOR_TARGET)) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
|
||||
|
||||
$(LINUX_BSP): $(LINUX_OBJS)
|
||||
${AR} ${ARFLAGS} $@ $^
|
||||
|
@ -161,6 +172,23 @@ $(RDIMON_BSP): $(RDIMON_OBJS)
|
|||
${AR} ${ARFLAGS} $@ $^
|
||||
${RANLIB} $@
|
||||
|
||||
# Multilib support.
|
||||
.PHONY: multi-do all-multi clean-multi install-multi
|
||||
|
||||
all-recursive: all-multi
|
||||
clean-recursive: clean-multi
|
||||
install-recursive: install-multi
|
||||
|
||||
# The $(MAKE) comments below are to enable parallel building.
|
||||
all-multi:
|
||||
$(MAKE) $(AM_MAKEFLAGS) DO=all multi-do
|
||||
|
||||
clean-multi:
|
||||
$(MAKE) $(AM_MAKEFLAGS) DO=clean multi-do
|
||||
|
||||
install-multi:
|
||||
$(MAKE) $(AM_MAKEFLAGS) DO=install multi-do
|
||||
|
||||
clean mostlyclean:
|
||||
rm -f a.out core *.i *.o *-test *.srec *.dis *.x $(SIM_BSP) $(IQ80310_BSP)
|
||||
@rootpre=`pwd`/; export rootpre; \
|
||||
|
@ -172,6 +200,7 @@ clean mostlyclean:
|
|||
else true; fi; \
|
||||
else true; fi; \
|
||||
done
|
||||
$(MAKE) $(AM_MAKEFLAGS) clean-recursive
|
||||
|
||||
distclean maintainer-clean realclean: clean
|
||||
rm -f Makefile config.status *~
|
||||
|
@ -187,6 +216,7 @@ install: ${CRT0_INSTALL} ${LINUX_INSTALL} ${REDBOOT_INSTALL} ${RDPMON_INSTALL} $
|
|||
else true; fi; \
|
||||
else true; fi; \
|
||||
done
|
||||
$(MAKE) $(AM_MAKEFLAGS) install-recursive
|
||||
|
||||
install-nano:
|
||||
set -e; for x in ${NANO_SCRIPTS}; do ${INSTALL_DATA} ${srcdir}/${objtype}$$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; done
|
||||
|
@ -228,3 +258,5 @@ Makefile: Makefile.in config.status @host_makefile_frag_path@
|
|||
|
||||
config.status: configure
|
||||
$(SHELL) config.status --recheck
|
||||
|
||||
include $(srcdir)/../multi-build.in
|
|
@ -10,15 +10,36 @@ _kill (int pid, int sig)
|
|||
(void) pid; (void) sig;
|
||||
#ifdef ARM_RDI_MONITOR
|
||||
/* Note: The pid argument is thrown away. */
|
||||
int block[2];
|
||||
block[1] = sig;
|
||||
int insn;
|
||||
|
||||
#if SEMIHOST_V2
|
||||
if (_has_ext_exit_extended ())
|
||||
{
|
||||
insn = AngelSWI_Reason_ReportExceptionExtended;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
insn = AngelSWI_Reason_ReportException;
|
||||
}
|
||||
|
||||
switch (sig)
|
||||
{
|
||||
case SIGABRT:
|
||||
return do_AngelSWI (AngelSWI_Reason_ReportException,
|
||||
(void *) ADP_Stopped_RunTimeError);
|
||||
{
|
||||
block[0] = ADP_Stopped_RunTimeError;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return do_AngelSWI (AngelSWI_Reason_ReportException,
|
||||
(void *) ADP_Stopped_ApplicationExit);
|
||||
{
|
||||
block[0] = ADP_Stopped_ApplicationExit;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return do_AngelSWI (insn, block);
|
||||
#else
|
||||
asm ("swi %a0" :: "i" (SWI_Exit));
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
# rdimon-v2m.specs
|
||||
#
|
||||
# Spec file for AArch64 baremetal newlib with version 2 of the
|
||||
# AngelAPI semi-hosting. This version is intended for AArch64/AArch32
|
||||
# mixed mode executables and as such uses the HLT trap instructions.
|
||||
#
|
||||
# This version supports extensibility through an extension mechanism.
|
||||
|
||||
%rename link old_link
|
||||
|
||||
*link:
|
||||
%(old_link) -lrdimon-v2m
|
||||
|
||||
*startfile:
|
||||
rdimon-crt0-v2m%O%s
|
||||
|
|
@ -1,3 +1,10 @@
|
|||
# rdimon.specs
|
||||
#
|
||||
# Spec file for AArch64 baremetal newlib with version 2 of the
|
||||
# AngelAPI semi-hosting using the SVC trap instruction.
|
||||
#
|
||||
# This version supports extensibility through an extension mechanism.
|
||||
|
||||
%rename link old_link
|
||||
|
||||
*link:
|
||||
|
|
|
@ -296,9 +296,10 @@ __change_mode:
|
|||
movs r1, r0
|
||||
#else
|
||||
movs r0, #AngelSWI_Reason_GetCmdLine
|
||||
adr r1, .LC30 /* Space for command line */
|
||||
ldr r1, .LC30 /* Space for command line */
|
||||
AngelSWIAsm AngelSWI
|
||||
ldr r1, .LC30
|
||||
ldr r1, [r1]
|
||||
#endif
|
||||
/* Parse string at r1 */
|
||||
movs r0, #0 /* count of arguments so far */
|
||||
|
@ -505,8 +506,7 @@ change_back:
|
|||
#endif
|
||||
#ifdef ARM_RDI_MONITOR
|
||||
.LC30:
|
||||
.word CommandLine
|
||||
.word 255
|
||||
.word AngelSWIArgs
|
||||
.LC31:
|
||||
.word __end__
|
||||
|
||||
|
@ -519,6 +519,9 @@ HeapLimit: .word 0
|
|||
__stack_base__: .word 0
|
||||
StackLimit: .word 0
|
||||
CommandLine: .space 256,0 /* Maximum length of 255 chars handled. */
|
||||
AngelSWIArgs:
|
||||
.word CommandLine
|
||||
.word 255
|
||||
#endif
|
||||
|
||||
#ifdef __pe__
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
# aprofile-validation-v2m.specs
|
||||
#
|
||||
# Spec file for AArch32 A profile baremetal newlib, libgloss on
|
||||
# VALIDATION platform with AngelAPI semi-hosting version 2 using the HLT
|
||||
# trap instruction.
|
||||
#
|
||||
# This Spec file is also appropriate for the foundation model.
|
||||
|
||||
%rename link old_link
|
||||
|
||||
*link:
|
||||
--defsym=_rdimon_vector_base=0x00000000 -Ttext-segment=0x00010000 %(old_link)
|
||||
|
||||
%rename lib libc
|
||||
|
||||
*libgloss:
|
||||
-lrdimon-v2m
|
||||
|
||||
*lib:
|
||||
cpu-init/rdimon-aem.o%s --start-group %(libc) %(libgloss) --end-group
|
||||
|
||||
*startfile:
|
||||
crti%O%s crtbegin%O%s %{!pg:rdimon-crt0-v2m%O%s} %{pg:rdimon-crt0-v2m%O%s}
|
|
@ -1,7 +1,8 @@
|
|||
# aem-validation.specs
|
||||
# aprofile-validation.specs
|
||||
#
|
||||
# Spec file for AArch32 A profile baremetal newlib, libgloss on
|
||||
# VALIDATION platform with AngelAPI semi-hosting.
|
||||
# VALIDATION platform with AngelAPI semi-hosting version 2 using the SVC
|
||||
# trap instruction.
|
||||
#
|
||||
# This Spec file is also appropriate for the foundation model.
|
||||
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
# aprofile-ve-v2m.specs
|
||||
#
|
||||
# Spec file for AArch32 A profile baremetal newlib, libgloss on VE platform with AngelAPI
|
||||
# semi-hosting version 2 using the HLT trap instruction.
|
||||
#
|
||||
# This Spec file is also appropriate for the foundation model.
|
||||
|
||||
%rename link old_link
|
||||
|
||||
*link:
|
||||
--defsym=_rdimon_vector_base=0x80000000 -Ttext-segment=0x80010000 %(old_link)
|
||||
|
||||
%rename lib libc
|
||||
|
||||
*libgloss:
|
||||
-lrdimon-v2m
|
||||
|
||||
*lib:
|
||||
cpu-init/rdimon-aem.o%s --start-group %(libc) %(libgloss) --end-group
|
||||
|
||||
*startfile:
|
||||
crti%O%s crtbegin%O%s %{!pg:rdimon-crt0-v2m%O%s} %{pg:rdimon-crt0-v2m%O%s}
|
|
@ -1,7 +1,7 @@
|
|||
# aem-ve.specs
|
||||
# aprofile-ve.specs
|
||||
#
|
||||
# Spec file for AArch32 A profile baremetal newlib, libgloss on VE platform with AngelAPI
|
||||
# semi-hosting.
|
||||
# semi-hosting version 2 using the SVC trap instruction.
|
||||
#
|
||||
# This Spec file is also appropriate for the foundation model.
|
||||
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
# rdimon-v2m.specs
|
||||
#
|
||||
# Spec file for AArch64 baremetal newlib with version 2 of the
|
||||
# AngelAPI semi-hosting. This version is intended for AArch64/AArch32
|
||||
# mixed mode executables and as such uses the HLT trap instruction.
|
||||
#
|
||||
# This version supports extensibility through an extension mechanism.
|
||||
|
||||
%rename link_gcc_c_sequence rdimon_link_gcc_c_sequence
|
||||
|
||||
*rdimon_libc:
|
||||
%{!specs=nano.specs:-lc} %{specs=nano.specs:-lc_nano}
|
||||
|
||||
*rdimon_libgloss:
|
||||
%{!specs=nano.specs:-lrdimon-v2m} %{specs=nano.specs:-lrdimon_nano}
|
||||
|
||||
*link_gcc_c_sequence:
|
||||
%(rdimon_link_gcc_c_sequence) --start-group %G %(rdimon_libc) %(rdimon_libgloss) --end-group
|
||||
|
||||
*startfile:
|
||||
crti%O%s crtbegin%O%s %{!pg:rdimon-crt0-v2m%O%s} %{pg:rdimon-crt0-v2m%O%s}
|
||||
|
|
@ -1,3 +1,10 @@
|
|||
# rdimon.specs
|
||||
#
|
||||
# Spec file for AArch64 baremetal newlib with version 2 of the
|
||||
# AngelAPI semi-hosting using the SVC trap instruction.
|
||||
#
|
||||
# This version supports extensibility through an extension mechanism.
|
||||
|
||||
%rename link_gcc_c_sequence rdimon_link_gcc_c_sequence
|
||||
|
||||
*rdimon_libc:
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "arm.h"
|
||||
#include <_ansi.h>
|
||||
|
||||
/* SWI numbers for RDP (Demon) monitor. */
|
||||
#define SWI_WriteC 0x0
|
||||
|
@ -29,45 +30,76 @@
|
|||
|
||||
|
||||
/* Now the SWI numbers and reason codes for RDI (Angel) monitors. */
|
||||
#define AngelSWI_ARM 0x123456
|
||||
#ifdef __thumb__
|
||||
#define AngelSWI 0xAB
|
||||
#else
|
||||
#define AngelSWI AngelSWI_ARM
|
||||
#endif
|
||||
#if defined (SEMIHOST_V2) && defined (SEMIHOST_V2_MIXED_MODE)
|
||||
#define AngelSWI_ARM 0xF000 /* HLT A32. */
|
||||
#ifdef __thumb__
|
||||
#define AngelSWI 0x3C /* HLT T32. */
|
||||
#else /* __thumb__. */
|
||||
#define AngelSWI AngelSWI_ARM
|
||||
#endif /* __thumb__. */
|
||||
#else /* SEMIHOST_V2. */
|
||||
#define AngelSWI_ARM 0x123456 /* SVC A32. */
|
||||
#ifdef __thumb__
|
||||
#define AngelSWI 0xAB /* SVC T32. */
|
||||
#else /* __thumb__. */
|
||||
#define AngelSWI AngelSWI_ARM
|
||||
#endif /* __thumb__. */
|
||||
#endif /* SEMIHOST_V2. */
|
||||
|
||||
/* For thumb only architectures use the BKPT instruction instead of SWI. */
|
||||
#ifdef THUMB_VXM
|
||||
#define AngelSWIInsn "bkpt"
|
||||
#define AngelSWIAsm bkpt
|
||||
#define AngelSWIInsn "bkpt"
|
||||
#define AngelSWIAsm bkpt
|
||||
#else
|
||||
#define AngelSWIInsn "swi"
|
||||
#define AngelSWIAsm swi
|
||||
#define AngelSWIInsn "swi"
|
||||
#define AngelSWIAsm swi
|
||||
#endif
|
||||
|
||||
/* The reason codes: */
|
||||
#define AngelSWI_Reason_Open 0x01
|
||||
#define AngelSWI_Reason_Close 0x02
|
||||
#define AngelSWI_Reason_WriteC 0x03
|
||||
#define AngelSWI_Reason_Write0 0x04
|
||||
#define AngelSWI_Reason_Write 0x05
|
||||
#define AngelSWI_Reason_Read 0x06
|
||||
#define AngelSWI_Reason_ReadC 0x07
|
||||
#define AngelSWI_Reason_IsTTY 0x09
|
||||
#define AngelSWI_Reason_Seek 0x0A
|
||||
#define AngelSWI_Reason_FLen 0x0C
|
||||
#define AngelSWI_Reason_TmpNam 0x0D
|
||||
#define AngelSWI_Reason_Remove 0x0E
|
||||
#define AngelSWI_Reason_Rename 0x0F
|
||||
#define AngelSWI_Reason_Clock 0x10
|
||||
#define AngelSWI_Reason_Time 0x11
|
||||
#define AngelSWI_Reason_System 0x12
|
||||
#define AngelSWI_Reason_Errno 0x13
|
||||
#define AngelSWI_Reason_GetCmdLine 0x15
|
||||
#define AngelSWI_Reason_HeapInfo 0x16
|
||||
#define AngelSWI_Reason_EnterSVC 0x17
|
||||
#define AngelSWI_Reason_ReportException 0x18
|
||||
#define ADP_Stopped_ApplicationExit ((2 << 16) + 38)
|
||||
#define ADP_Stopped_RunTimeError ((2 << 16) + 35)
|
||||
#define AngelSWI_Reason_Open 0x01
|
||||
#define AngelSWI_Reason_Close 0x02
|
||||
#define AngelSWI_Reason_WriteC 0x03
|
||||
#define AngelSWI_Reason_Write0 0x04
|
||||
#define AngelSWI_Reason_Write 0x05
|
||||
#define AngelSWI_Reason_Read 0x06
|
||||
#define AngelSWI_Reason_ReadC 0x07
|
||||
#define AngelSWI_Reason_IsError 0x08
|
||||
#define AngelSWI_Reason_IsTTY 0x09
|
||||
#define AngelSWI_Reason_Seek 0x0A
|
||||
#define AngelSWI_Reason_FLen 0x0C
|
||||
#define AngelSWI_Reason_TmpNam 0x0D
|
||||
#define AngelSWI_Reason_Remove 0x0E
|
||||
#define AngelSWI_Reason_Rename 0x0F
|
||||
#define AngelSWI_Reason_Clock 0x10
|
||||
#define AngelSWI_Reason_Time 0x11
|
||||
#define AngelSWI_Reason_System 0x12
|
||||
#define AngelSWI_Reason_Errno 0x13
|
||||
#define AngelSWI_Reason_GetCmdLine 0x15
|
||||
#define AngelSWI_Reason_HeapInfo 0x16
|
||||
#define AngelSWI_Reason_EnterSVC 0x17
|
||||
#define AngelSWI_Reason_ReportException 0x18
|
||||
#define AngelSWI_Reason_ReportExceptionExtended 0x20
|
||||
#define AngelSWI_Reason_Elapsed 0x30
|
||||
#define AngelSWI_Reason_TickFreq 0x31
|
||||
#define ADP_Stopped_ApplicationExit ((2 << 16) + 38)
|
||||
#define ADP_Stopped_RunTimeError ((2 << 16) + 35)
|
||||
|
||||
/* Semihosting feature magic numbers. */
|
||||
#define NUM_SHFB_MAGIC 4
|
||||
#define SHFB_MAGIC_0 0x53
|
||||
#define SHFB_MAGIC_1 0x48
|
||||
#define SHFB_MAGIC_2 0x46
|
||||
#define SHFB_MAGIC_3 0x42
|
||||
|
||||
/* Semihosting extensions. */
|
||||
#define SH_EXT_EXIT_EXTENDED_BITNUM 0x0
|
||||
#define SH_EXT_STDOUT_STDERR_BITNUM 0x1
|
||||
|
||||
#if !defined (__ASSEMBLER__)
|
||||
extern int _get_semihosting_exts _PARAMS ((char*, int, int));
|
||||
extern int _has_ext_exit_extended _PARAMS ((void));
|
||||
extern int _has_ext_stdout_stderr _PARAMS ((void));
|
||||
#endif
|
||||
|
||||
#if defined(ARM_RDI_MONITOR) && !defined(__ASSEMBLER__)
|
||||
|
||||
|
|
|
@ -47,6 +47,9 @@ static int checkerror _PARAMS ((int));
|
|||
static int error _PARAMS ((int));
|
||||
static int get_errno _PARAMS ((void));
|
||||
|
||||
/* Semihosting utilities. */
|
||||
static void initialise_semihosting_exts _PARAMS ((void));
|
||||
|
||||
/* Struct used to keep track of the file position, just so we
|
||||
can implement fseek(fh,x,SEEK_CUR). */
|
||||
struct fdent
|
||||
|
@ -95,6 +98,9 @@ static int monitor_stdin;
|
|||
static int monitor_stdout;
|
||||
static int monitor_stderr;
|
||||
|
||||
static int supports_ext_exit_extended = -1;
|
||||
static int supports_ext_stdout_stderr = -1;
|
||||
|
||||
/* Return a pointer to the structure associated with
|
||||
the user file descriptor fd. */
|
||||
static struct fdent*
|
||||
|
@ -154,15 +160,21 @@ initialise_monitor_handles (void)
|
|||
block[1] = 0; /* mode "r" */
|
||||
monitor_stdin = do_AngelSWI (AngelSWI_Reason_Open, (void *) block);
|
||||
|
||||
block[0] = (int) ":tt";
|
||||
block[2] = 3; /* length of filename */
|
||||
block[1] = 4; /* mode "w" */
|
||||
monitor_stdout = do_AngelSWI (AngelSWI_Reason_Open, (void *) block);
|
||||
for (i = 0; i < MAX_OPEN_FILES; i ++)
|
||||
openfiles[i].handle = -1;
|
||||
|
||||
block[0] = (int) ":tt";
|
||||
block[2] = 3; /* length of filename */
|
||||
block[1] = 8; /* mode "a" */
|
||||
monitor_stderr = do_AngelSWI (AngelSWI_Reason_Open, (void *) block);
|
||||
if (_has_ext_stdout_stderr ())
|
||||
{
|
||||
block[0] = (int) ":tt";
|
||||
block[2] = 3; /* length of filename */
|
||||
block[1] = 4; /* mode "w" */
|
||||
monitor_stdout = do_AngelSWI (AngelSWI_Reason_Open, (void *) block);
|
||||
|
||||
block[0] = (int) ":tt";
|
||||
block[2] = 3; /* length of filename */
|
||||
block[1] = 8; /* mode "a" */
|
||||
monitor_stderr = do_AngelSWI (AngelSWI_Reason_Open, (void *) block);
|
||||
}
|
||||
#else
|
||||
int fh;
|
||||
const char * name;
|
||||
|
@ -174,34 +186,135 @@ initialise_monitor_handles (void)
|
|||
: "r0","r1");
|
||||
monitor_stdin = fh;
|
||||
|
||||
name = ":tt";
|
||||
asm ("mov r0,%2; mov r1, #4; swi %a1; mov %0, r0"
|
||||
: "=r"(fh)
|
||||
: "i" (SWI_Open),"r"(name)
|
||||
: "r0","r1");
|
||||
monitor_stdout = fh;
|
||||
if (_has_ext_stdout_stderr ())
|
||||
{
|
||||
name = ":tt";
|
||||
asm ("mov r0,%2; mov r1, #4; swi %a1; mov %0, r0"
|
||||
: "=r"(fh)
|
||||
: "i" (SWI_Open),"r"(name)
|
||||
: "r0","r1");
|
||||
monitor_stdout = fh;
|
||||
|
||||
name = ":tt";
|
||||
asm ("mov r0,%2; mov r1, #8; swi %a1; mov %0, r0"
|
||||
: "=r"(fh)
|
||||
: "i" (SWI_Open),"r"(name)
|
||||
: "r0","r1");
|
||||
monitor_stderr = fh;
|
||||
name = ":tt";
|
||||
asm ("mov r0,%2; mov r1, #8; swi %a1; mov %0, r0"
|
||||
: "=r"(fh)
|
||||
: "i" (SWI_Open),"r"(name)
|
||||
: "r0","r1");
|
||||
monitor_stderr = fh;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If we failed to open stderr, redirect to stdout. */
|
||||
if (monitor_stderr == -1)
|
||||
monitor_stderr = monitor_stdout;
|
||||
|
||||
for (i = 0; i < MAX_OPEN_FILES; i ++)
|
||||
openfiles[i].handle = -1;
|
||||
|
||||
openfiles[0].handle = monitor_stdin;
|
||||
openfiles[0].pos = 0;
|
||||
openfiles[1].handle = monitor_stdout;
|
||||
openfiles[1].pos = 0;
|
||||
openfiles[2].handle = monitor_stderr;
|
||||
openfiles[2].pos = 0;
|
||||
|
||||
if (_has_ext_stdout_stderr ())
|
||||
{
|
||||
openfiles[1].handle = monitor_stdout;
|
||||
openfiles[1].pos = 0;
|
||||
openfiles[2].handle = monitor_stderr;
|
||||
openfiles[2].pos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
_has_ext_exit_extended (void)
|
||||
{
|
||||
if (supports_ext_exit_extended < 0)
|
||||
{
|
||||
initialise_semihosting_exts ();
|
||||
}
|
||||
|
||||
return supports_ext_exit_extended;
|
||||
}
|
||||
|
||||
int
|
||||
_has_ext_stdout_stderr (void)
|
||||
{
|
||||
if (supports_ext_stdout_stderr < 0)
|
||||
{
|
||||
initialise_semihosting_exts ();
|
||||
}
|
||||
|
||||
return supports_ext_stdout_stderr;
|
||||
}
|
||||
|
||||
static void
|
||||
initialise_semihosting_exts (void)
|
||||
{
|
||||
supports_ext_exit_extended = 0;
|
||||
supports_ext_stdout_stderr = 1;
|
||||
|
||||
#if SEMIHOST_V2
|
||||
char features[1];
|
||||
if (_get_semihosting_exts (features, 0, 1) > 0)
|
||||
{
|
||||
supports_ext_exit_extended
|
||||
= features[0] & (1 << SH_EXT_EXIT_EXTENDED_BITNUM);
|
||||
supports_ext_stdout_stderr
|
||||
= features[0] & (1 << SH_EXT_STDOUT_STDERR_BITNUM);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
_get_semihosting_exts (char* features, int offset, int num)
|
||||
{
|
||||
int len;
|
||||
struct fdent *pfd;
|
||||
int fd = _open (":semihosting-features", O_RDONLY);
|
||||
memset (features, 0, num);
|
||||
|
||||
if (fd == -1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
pfd = findslot (fd);
|
||||
|
||||
#ifdef ARM_RDI_MONITOR
|
||||
len = checkerror (do_AngelSWI (AngelSWI_Reason_FLen, &pfd->handle));
|
||||
#else
|
||||
asm ("mov r0,%2; swi %a1; mov %0, r0"
|
||||
: "=r"(len)
|
||||
: "i" (SWI_Flen),"r"(pfd->handle)
|
||||
: "r0");
|
||||
#endif
|
||||
|
||||
if (len < NUM_SHFB_MAGIC
|
||||
|| num > (len - NUM_SHFB_MAGIC))
|
||||
{
|
||||
_close (fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
char buffer[NUM_SHFB_MAGIC];
|
||||
int n_read = _read (fd, buffer, NUM_SHFB_MAGIC);
|
||||
|
||||
if (n_read < NUM_SHFB_MAGIC
|
||||
|| buffer[0] != SHFB_MAGIC_0
|
||||
|| buffer[1] != SHFB_MAGIC_1
|
||||
|| buffer[2] != SHFB_MAGIC_2
|
||||
|| buffer[3] != SHFB_MAGIC_3)
|
||||
{
|
||||
_close (fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (_lseek (fd, offset, SEEK_CUR) < 0)
|
||||
{
|
||||
_close (fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
n_read = _read (fd, features, num);
|
||||
|
||||
_close (fd);
|
||||
|
||||
return checkerror (n_read);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -679,6 +679,7 @@ sparc_leon
|
|||
sparc
|
||||
wince
|
||||
mips
|
||||
riscv
|
||||
rs6000
|
||||
mn10200
|
||||
mn10300
|
||||
|
@ -2455,6 +2456,10 @@ case "${target}" in
|
|||
mips*-*-*)
|
||||
subdirs="$subdirs mips"
|
||||
|
||||
;;
|
||||
riscv*-*-*)
|
||||
subdirs="$subdirs riscv"
|
||||
|
||||
;;
|
||||
powerpc-*-*|powerpcle-*-*)
|
||||
subdirs="$subdirs rs6000"
|
||||
|
|
|
@ -78,6 +78,9 @@ case "${target}" in
|
|||
mips*-*-*)
|
||||
AC_CONFIG_SUBDIRS([mips])
|
||||
;;
|
||||
riscv*-*-*)
|
||||
AC_CONFIG_SUBDIRS([riscv])
|
||||
;;
|
||||
powerpc-*-*|powerpcle-*-*)
|
||||
AC_CONFIG_SUBDIRS([rs6000])
|
||||
;;
|
||||
|
|
|
@ -55,5 +55,5 @@ write (int fd, char *buf, int len)
|
|||
len -= l;
|
||||
buf += l;
|
||||
}
|
||||
return c;
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
PWD_COMMAND=$${PWDCMD-pwd}
|
||||
|
||||
# FIXME: There should be an @-sign in front of the `if'.
|
||||
# Leave out until this is tested a bit more.
|
||||
multi-do:
|
||||
if [ -z "$(MULTIDIRS)" ]; then \
|
||||
true; \
|
||||
else \
|
||||
rootpre=`${PWD_COMMAND}`/; export rootpre; \
|
||||
srcrootpre=`cd $(srcdir); ${PWD_COMMAND}`/; export srcrootpre; \
|
||||
lib=`echo "$${rootpre}" | sed -e 's,^.*/\([^/][^/]*\)/$$,\1,'`; export lib; \
|
||||
compiler="$(CC)"; \
|
||||
for dir in $(MULTIDIRS); do \
|
||||
if [ "$${dir}" = "." ]; then \
|
||||
true; \
|
||||
else \
|
||||
destpre=`echo $${rootpre}/$${dir}`/; export destpre; \
|
||||
if ! test -d $${destpre} ; then \
|
||||
mkdir -p $${destpre}; \
|
||||
cp config.status $${destpre}; \
|
||||
cd $${destpre}; \
|
||||
$(SHELL) config.status; \
|
||||
sed -e "s:^MULTIDIRS[[:space:]]*+=.*$$:MULTIDIRS = :" \
|
||||
-e "s:^MULTILIBNAME[[:space:]]*=.*$$:MULTILIBNAME = MULTIDIR_$${dir}_NAME:" \
|
||||
-e "s:^MULTI_FLAGS_FOR_TARGET[[:space:]]*=.*$$:MULTI_FLAGS_FOR_TARGET = MULTIDIR_$${dir}_FLAGS:" \
|
||||
-e "s:^objdir[[:space:]]*=.*$$:objdir = ..:" \
|
||||
Makefile > Makefile.tem; \
|
||||
rm -f Makefile; \
|
||||
mv Makefile.tem Makefile; \
|
||||
else \
|
||||
cd $${destpre}; \
|
||||
fi; \
|
||||
if ($(MAKE) $(FLAGS_TO_PASS) \
|
||||
CFLAGS="$(CFLAGS)" \
|
||||
CCASFLAGS="$(CCASFLAGS)" \
|
||||
FCFLAGS="$(FCFLAGS)" \
|
||||
FFLAGS="$(FFLAGS)" \
|
||||
ADAFLAGS="$(ADAFLAGS)" \
|
||||
prefix="$(prefix)" \
|
||||
exec_prefix="$(exec_prefix)" \
|
||||
GCJFLAGS="$(GCJFLAGS)" \
|
||||
GOCFLAGS="$(GOCFLAGS)" \
|
||||
CXXFLAGS="$(CXXFLAGS)" \
|
||||
LIBCFLAGS="$(LIBCFLAGS)" \
|
||||
LIBCXXFLAGS="$(LIBCXXFLAGS)" \
|
||||
LDFLAGS="$(LDFLAGS)" \
|
||||
MULTIFLAGS="" \
|
||||
DESTDIR="$(DESTDIR)" \
|
||||
SOURCE="${srcdir}/" \
|
||||
INSTALL="$(INSTALL)" \
|
||||
INSTALL_DATA="$(INSTALL_DATA)" \
|
||||
INSTALL_PROGRAM="$(INSTALL_PROGRAM)" \
|
||||
INSTALL_SCRIPT="$(INSTALL_SCRIPT)" \
|
||||
$(DO)); then \
|
||||
cd $${rootpre}; \
|
||||
else \
|
||||
exit 1; \
|
||||
fi; \
|
||||
fi; \
|
||||
done; \
|
||||
fi
|
|
@ -0,0 +1,200 @@
|
|||
#-------------------------------------------------------------------------
|
||||
# Source files
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
gloss_hdrs = \
|
||||
machine/syscall.h \
|
||||
|
||||
gloss_srcs = \
|
||||
syscalls.c \
|
||||
|
||||
# Extra files
|
||||
|
||||
crt0_asm = crt0.S
|
||||
|
||||
# Multilib support variables.
|
||||
# TOP is used instead of MULTI{BUILD,SRC}TOP.
|
||||
|
||||
MULTIDIRS =
|
||||
MULTISUBDIR =
|
||||
MULTIDO = true
|
||||
MULTICLEAN = true
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Basic setup
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
# Remove all default implicit rules since they can cause subtle bugs
|
||||
# and they just make things run slower
|
||||
|
||||
.SUFFIXES:
|
||||
% : %,v
|
||||
% : RCS/%,v
|
||||
% : RCS/%
|
||||
% : s.%
|
||||
% : SCCS/s.%
|
||||
|
||||
# Default is to build the prereqs of the all target (defined at bottom)
|
||||
|
||||
default : all
|
||||
.PHONY : default
|
||||
|
||||
# Source directory
|
||||
|
||||
obj_dir := .
|
||||
src_dir := @srcdir@
|
||||
VPATH := $(src_dir) $(src_dir)/machine
|
||||
|
||||
# Installation directories
|
||||
|
||||
prefix := @prefix@
|
||||
DESTDIR ?= $(prefix)
|
||||
|
||||
install_hdrs_dir := $(DESTDIR)$(prefix)/$(target_alias)/include/machine
|
||||
install_libs_dir = $(DESTDIR)$(prefix)/$(target_alias)/lib${MULTISUBDIR}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Programs and flags
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
# C compiler
|
||||
|
||||
CC := @CC@
|
||||
CFLAGS := @CFLAGS@
|
||||
CPPFLAGS := -I$(obj_dir) -I$(src_dir)
|
||||
COMPILE := $(CC) -MMD -MP $(CPPFLAGS) $(CFLAGS)
|
||||
|
||||
# Library creation
|
||||
|
||||
AR := @AR@
|
||||
RANLIB := @RANLIB@
|
||||
|
||||
# Installation
|
||||
|
||||
INSTALL := @INSTALL@
|
||||
INSTALL_DATA := @INSTALL_DATA@
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Build Object Files from C Source
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
gloss_c_srcs = $(filter %.c, $(gloss_srcs))
|
||||
gloss_c_objs = $(patsubst %.c, %.o, $(notdir $(gloss_c_srcs)))
|
||||
gloss_c_deps = $(patsubst %.c, %.d, $(notdir $(gloss_c_srcs)))
|
||||
|
||||
$(gloss_c_objs) : %.o : %.c
|
||||
$(COMPILE) -c $<
|
||||
|
||||
objs += $(gloss_c_objs)
|
||||
deps += $(gloss_c_deps)
|
||||
junk += $(gloss_c_deps) $(gloss_c_objs)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Build Object Files from Assembly Source
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
gloss_asm_srcs = $(filter %.S, $(gloss_srcs))
|
||||
gloss_asm_objs = $(patsubst %.S, %.o, $(notdir $(gloss_asm_srcs)))
|
||||
gloss_asm_deps = $(patsubst %.S, %.d, $(notdir $(gloss_asm_srcs)))
|
||||
|
||||
$(gloss_asm_objs) : %.o : %.S
|
||||
$(COMPILE) -c $<
|
||||
|
||||
objs += $(gloss_asm_objs)
|
||||
deps += $(gloss_asm_deps)
|
||||
junk += $(gloss_asm_deps) $(gloss_asm_objs)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Build libgloss.a
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
gloss_lib = libgloss.a
|
||||
$(gloss_lib) : $(objs)
|
||||
$(AR) rcv $@ $^
|
||||
$(RANLIB) $@
|
||||
|
||||
junk += $(gloss_libs)
|
||||
|
||||
install_hdrs += $(gloss_hdrs)
|
||||
install_libs += $(gloss_lib)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Build crt0.o
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
crt0_obj = $(patsubst %.S, %.o, $(crt0_asm))
|
||||
crt0_deps = $(patsubst %.S, %.d, $(crt0_asm))
|
||||
|
||||
$(crt0_obj) : %.o : %.S
|
||||
$(COMPILE) -c $<
|
||||
|
||||
deps += $(crt0_deps)
|
||||
junk += $(crt0_deps) $(crt0_obj)
|
||||
|
||||
install_libs += $(crt0_obj)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Autodependency files
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
-include $(deps)
|
||||
|
||||
deps : $(deps)
|
||||
.PHONY : deps
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Installation
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
install_hdrs_wdir += $(addprefix $(src_dir)/, $(install_hdrs))
|
||||
install-hdrs : $(install_hdrs_wdir)
|
||||
test -d $(install_hdrs_dir) || mkdir -p $(install_hdrs_dir)
|
||||
for file in $^; do \
|
||||
$(INSTALL_DATA) $$file $(install_hdrs_dir)/; \
|
||||
done
|
||||
|
||||
install-libs : $(install_libs)
|
||||
test -d $(install_libs_dir) || mkdir -p $(install_libs_dir)
|
||||
for file in $^; do \
|
||||
$(INSTALL_DATA) $$file $(install_libs_dir)/$$file; \
|
||||
done
|
||||
|
||||
install : install-hdrs install-libs
|
||||
.PHONY : install install-hdrs install-libs
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Regenerate configure information
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
configure_prereq = \
|
||||
$(src_dir)/configure.in \
|
||||
|
||||
$(src_dir)/configure : $(configure_prereq)
|
||||
cd $(src_dir) && autoconf
|
||||
|
||||
config.status : $(src_dir)/configure
|
||||
./config.status --recheck
|
||||
|
||||
Makefile : $(src_dir)/Makefile.in config.status
|
||||
./config.status
|
||||
|
||||
dist_junk += config.status Makefile config.log
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Default
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
all : $(install_libs)
|
||||
.PHONY : all
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Clean up junk
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
clean :
|
||||
rm -rf *~ \#* $(junk)
|
||||
|
||||
distclean :
|
||||
rm -rf *~ \#* $(junk) $(dist_junk)
|
||||
|
||||
.PHONY : clean distclean
|
|
@ -0,0 +1,72 @@
|
|||
#=========================================================================
|
||||
# aclocal.m4 for maven libgloss
|
||||
#=========================================================================
|
||||
# We cannot use the normal AC_PROG_CC since that macro will try and do a
|
||||
# link with the found compiler. Since we don't have all the startup
|
||||
# files setup yet (that's what we are compiling in libgloss!) we want to
|
||||
# find a compiler without actually doing a link. So the LIB_AC_PROG_CC
|
||||
# check is copied from xcc/src/libgloss/acinclude.m4
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# LIB_AC_PROG_CC_GNU
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
AC_DEFUN([LIB_AC_PROG_CC_GNU],
|
||||
[
|
||||
AC_CACHE_CHECK(whether we are using GNU C, ac_cv_prog_gcc,
|
||||
[dnl The semicolon is to pacify NeXT's syntax-checking cpp.
|
||||
|
||||
cat > conftest.c <<EOF
|
||||
#ifdef __GNUC__
|
||||
yes;
|
||||
#endif
|
||||
EOF
|
||||
|
||||
if AC_TRY_COMMAND(${CC-cc} -E conftest.c) | egrep yes >/dev/null 2>&1; then
|
||||
ac_cv_prog_gcc=yes
|
||||
else
|
||||
ac_cv_prog_gcc=no
|
||||
fi
|
||||
|
||||
])
|
||||
])
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# LIB_AC_PROG_CC
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
AC_DEFUN([LIB_AC_PROG_CC],
|
||||
[
|
||||
AC_BEFORE([$0],[AC_PROG_CPP])dnl
|
||||
AC_CHECK_PROG(CC, gcc, gcc)
|
||||
|
||||
if test -z "$CC"; then
|
||||
AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
|
||||
test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
|
||||
fi
|
||||
|
||||
LIB_AC_PROG_CC_GNU
|
||||
|
||||
if test $ac_cv_prog_gcc = yes; then
|
||||
GCC=yes
|
||||
dnl Check whether -g works, even if CFLAGS is set, in case the package
|
||||
dnl plays around with CFLAGS (such as to build both debugging and
|
||||
dnl normal versions of a library), tasteless as that idea is.
|
||||
ac_test_CFLAGS="${CFLAGS+set}"
|
||||
ac_save_CFLAGS="$CFLAGS"
|
||||
CFLAGS=
|
||||
_AC_PROG_CC_G
|
||||
if test "$ac_test_CFLAGS" = set; then
|
||||
CFLAGS="$ac_save_CFLAGS"
|
||||
elif test $ac_cv_prog_cc_g = yes; then
|
||||
CFLAGS="-g -O2"
|
||||
else
|
||||
CFLAGS="-O2"
|
||||
fi
|
||||
else
|
||||
GCC=
|
||||
test "${CFLAGS+set}" = set || CFLAGS="-g"
|
||||
fi
|
||||
|
||||
])
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,45 @@
|
|||
#=========================================================================
|
||||
# configure.ac for riscv libgloss and crt0
|
||||
#=========================================================================
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Setup
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
AC_INIT([crt0.S])
|
||||
AC_CONFIG_SRCDIR([crt0.S])
|
||||
AC_CONFIG_AUX_DIR([${srcdir}/../..])
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Checks for programs
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
LIB_AC_PROG_CC
|
||||
AC_CHECK_TOOL([AR],[ar])
|
||||
AC_CHECK_TOOL([RANLIB],[ranlib])
|
||||
AC_PROG_INSTALL
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Output
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
if test "$srcdir" = "." ; then
|
||||
if test "${with_target_subdir}" != "." ; then
|
||||
libgloss_topdir="${srcdir}/${with_multisrctop}../../.."
|
||||
else
|
||||
libgloss_topdir="${srcdir}/${with_multisrctop}../.."
|
||||
fi
|
||||
else
|
||||
libgloss_topdir="${srcdir}/../.."
|
||||
fi
|
||||
AC_CONFIG_AUX_DIR($libgloss_topdir)
|
||||
AC_CONFIG_FILES(Makefile,
|
||||
. ${libgloss_topdir}/config-ml.in,
|
||||
srcdir=${srcdir}
|
||||
target=${target}
|
||||
with_multisubdir=${with_multisubdir}
|
||||
ac_configure_args="${ac_configure_args} --enable-multilib"
|
||||
CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
|
||||
libgloss_topdir=${libgloss_topdir}
|
||||
)
|
||||
AC_OUTPUT
|
|
@ -0,0 +1,54 @@
|
|||
/* Copyright (c) 2017 SiFive Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use,
|
||||
modify, copy, or redistribute it subject to the terms and conditions
|
||||
of the BSD License. This program is distributed in the hope that
|
||||
it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
|
||||
including the implied warranties of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. A copy of this license is available at
|
||||
http://www.opensource.org/licenses.
|
||||
*/
|
||||
|
||||
#=========================================================================
|
||||
# crt0.S : Entry point for RISC-V user programs
|
||||
#=========================================================================
|
||||
|
||||
.text
|
||||
.global _start
|
||||
.type _start, @function
|
||||
_start:
|
||||
# Initialize global pointer
|
||||
.option push
|
||||
.option norelax
|
||||
1:auipc gp, %pcrel_hi(__global_pointer$)
|
||||
addi gp, gp, %pcrel_lo(1b)
|
||||
.option pop
|
||||
|
||||
# Clear the bss segment
|
||||
la a0, _edata
|
||||
la a2, _end
|
||||
sub a2, a2, a0
|
||||
li a1, 0
|
||||
call memset
|
||||
|
||||
la a0, __libc_fini_array # Register global termination functions
|
||||
call atexit # to be called upon exit
|
||||
call __libc_init_array # Run global initialization functions
|
||||
|
||||
lw a0, 0(sp) # a0 = argc
|
||||
addi a1, sp, __SIZEOF_POINTER__ # a1 = argv
|
||||
li a2, 0 # a2 = envp = NULL
|
||||
call main
|
||||
tail exit
|
||||
.size _start, .-_start
|
||||
|
||||
.global _init
|
||||
.type _init, @function
|
||||
.global _fini
|
||||
.type _fini, @function
|
||||
_init:
|
||||
_fini:
|
||||
# These don't have to do anything since we use init_array/fini_array.
|
||||
ret
|
||||
.size _init, .-_init
|
||||
.size _fini, .-_fini
|
|
@ -0,0 +1,82 @@
|
|||
/* Copyright (c) 2017 SiFive Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use,
|
||||
modify, copy, or redistribute it subject to the terms and conditions
|
||||
of the BSD License. This program is distributed in the hope that
|
||||
it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
|
||||
including the implied warranties of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. A copy of this license is available at
|
||||
http://www.opensource.org/licenses.
|
||||
*/
|
||||
|
||||
#ifndef _MACHINE_SYSCALL_H
|
||||
#define _MACHINE_SYSCALL_H
|
||||
|
||||
#define SYS_getcwd 17
|
||||
#define SYS_dup 23
|
||||
#define SYS_fcntl 25
|
||||
#define SYS_faccessat 48
|
||||
#define SYS_chdir 49
|
||||
#define SYS_openat 56
|
||||
#define SYS_close 57
|
||||
#define SYS_getdents 61
|
||||
#define SYS_lseek 62
|
||||
#define SYS_read 63
|
||||
#define SYS_write 64
|
||||
#define SYS_writev 66
|
||||
#define SYS_pread 67
|
||||
#define SYS_pwrite 68
|
||||
#define SYS_fstatat 79
|
||||
#define SYS_fstat 80
|
||||
#define SYS_exit 93
|
||||
#define SYS_exit_group 94
|
||||
#define SYS_kill 129
|
||||
#define SYS_rt_sigaction 134
|
||||
#define SYS_times 153
|
||||
#define SYS_uname 160
|
||||
#define SYS_gettimeofday 169
|
||||
#define SYS_getpid 172
|
||||
#define SYS_getuid 174
|
||||
#define SYS_geteuid 175
|
||||
#define SYS_getgid 176
|
||||
#define SYS_getegid 177
|
||||
#define SYS_brk 214
|
||||
#define SYS_munmap 215
|
||||
#define SYS_mremap 216
|
||||
#define SYS_mmap 222
|
||||
#define SYS_open 1024
|
||||
#define SYS_link 1025
|
||||
#define SYS_unlink 1026
|
||||
#define SYS_mkdir 1030
|
||||
#define SYS_access 1033
|
||||
#define SYS_stat 1038
|
||||
#define SYS_lstat 1039
|
||||
#define SYS_time 1062
|
||||
#define SYS_getmainvars 2011
|
||||
|
||||
extern long __syscall_error(long);
|
||||
|
||||
static inline long
|
||||
__internal_syscall(long n, long _a0, long _a1, long _a2, long _a3)
|
||||
{
|
||||
register long a0 asm("a0") = _a0;
|
||||
register long a1 asm("a1") = _a1;
|
||||
register long a2 asm("a2") = _a2;
|
||||
register long a3 asm("a3") = _a3;
|
||||
|
||||
#ifdef __riscv_32e
|
||||
register long syscall_id asm("t0") = n;
|
||||
#else
|
||||
register long syscall_id asm("a7") = n;
|
||||
#endif
|
||||
|
||||
asm volatile ("scall"
|
||||
: "+r"(a0) : "r"(a1), "r"(a2), "r"(a3), "r"(syscall_id));
|
||||
|
||||
if (a0 < 0)
|
||||
return __syscall_error (a0);
|
||||
else
|
||||
return a0;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,419 @@
|
|||
/* Copyright (c) 2017 SiFive Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use,
|
||||
modify, copy, or redistribute it subject to the terms and conditions
|
||||
of the BSD License. This program is distributed in the hope that
|
||||
it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
|
||||
including the implied warranties of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. A copy of this license is available at
|
||||
http://www.opensource.org/licenses.
|
||||
|
||||
========================================================================
|
||||
syscalls.c : Newlib operating system interface
|
||||
========================================================================
|
||||
This is the maven implementation of the narrow newlib operating
|
||||
system interface. It is based on the minimum stubs in the newlib
|
||||
documentation, the error stubs in libnosys, and the previous scale
|
||||
implementation. Please do not include any additional system calls or
|
||||
other functions in this file. Additional header and source files
|
||||
should be in the machine subdirectory.
|
||||
|
||||
Here is a list of the functions which make up the operating system
|
||||
interface. The file management instructions execute syscall assembly
|
||||
instructions so that a proxy kernel (or the simulator) can marshal up
|
||||
the request to the host machine. The process management functions are
|
||||
mainly just stubs since for now maven only supports a single process.
|
||||
|
||||
- File management functions
|
||||
+ open : (v) open file
|
||||
+ lseek : (v) set position in file
|
||||
+ read : (v) read from file
|
||||
+ write : (v) write to file
|
||||
+ fstat : (z) status of an open file
|
||||
+ stat : (z) status of a file by name
|
||||
+ close : (z) close a file
|
||||
+ link : (z) rename a file
|
||||
+ unlink : (z) remote file's directory entry
|
||||
|
||||
- Process management functions
|
||||
+ execve : (z) transfer control to new proc
|
||||
+ fork : (z) create a new process
|
||||
+ getpid : (v) get process id
|
||||
+ kill : (z) send signal to child process
|
||||
+ wait : (z) wait for a child process
|
||||
|
||||
- Misc functions
|
||||
+ isatty : (v) query whether output stream is a terminal
|
||||
+ times : (z) timing information for current process
|
||||
+ sbrk : (v) increase program data space
|
||||
+ _exit : (-) exit program without cleaning up files
|
||||
|
||||
There are two types of system calls. Those which return a value when
|
||||
everything is okay (marked with (v) in above list) and those which
|
||||
return a zero when everything is okay (marked with (z) in above
|
||||
list). On an error (ie. when the error flag is 1) the return value is
|
||||
always an errno which should correspond to the numbers in
|
||||
newlib/libc/include/sys/errno.h
|
||||
|
||||
See the newlib documentation for more information
|
||||
http://sourceware.org/newlib/libc.html#Syscalls
|
||||
*/
|
||||
|
||||
#include <machine/syscall.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/times.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/timeb.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <utime.h>
|
||||
|
||||
#define syscall_errno(n, a, b, c, d) \
|
||||
__internal_syscall(n, (long)(a), (long)(b), (long)(c), (long)(d))
|
||||
|
||||
long
|
||||
__syscall_error(long a0)
|
||||
{
|
||||
errno = -a0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Open a file. */
|
||||
int
|
||||
_open(const char *name, int flags, int mode)
|
||||
{
|
||||
return syscall_errno (SYS_open, name, flags, mode, 0);
|
||||
}
|
||||
|
||||
/* Open file relative to given directory. */
|
||||
int
|
||||
_openat(int dirfd, const char *name, int flags, int mode)
|
||||
{
|
||||
return syscall_errno (SYS_openat, dirfd, name, flags, mode);
|
||||
}
|
||||
|
||||
/* Set position in a file. */
|
||||
off_t
|
||||
_lseek(int file, off_t ptr, int dir)
|
||||
{
|
||||
return syscall_errno (SYS_lseek, file, ptr, dir, 0);
|
||||
}
|
||||
|
||||
/* Read from a file. */
|
||||
ssize_t
|
||||
_read(int file, void *ptr, size_t len)
|
||||
{
|
||||
return syscall_errno (SYS_read, file, ptr, len, 0);
|
||||
}
|
||||
|
||||
/* Write to a file. */
|
||||
ssize_t
|
||||
_write(int file, const void *ptr, size_t len)
|
||||
{
|
||||
return syscall_errno (SYS_write, file, ptr, len, 0);
|
||||
}
|
||||
|
||||
struct kernel_stat
|
||||
{
|
||||
unsigned long long st_dev;
|
||||
unsigned long long st_ino;
|
||||
unsigned int st_mode;
|
||||
unsigned int st_nlink;
|
||||
unsigned int st_uid;
|
||||
unsigned int st_gid;
|
||||
unsigned long long st_rdev;
|
||||
unsigned long long __pad1;
|
||||
long long st_size;
|
||||
int st_blksize;
|
||||
int __pad2;
|
||||
long long st_blocks;
|
||||
struct timespec st_atim;
|
||||
struct timespec st_mtim;
|
||||
struct timespec st_ctim;
|
||||
int __glibc_reserved[2];
|
||||
};
|
||||
|
||||
/* Convert linux's stat64 sturct to newlib's stat. */
|
||||
static void
|
||||
conv_stat (struct stat *st, struct kernel_stat *kst)
|
||||
{
|
||||
st->st_dev = kst->st_dev;
|
||||
st->st_ino = kst->st_ino;
|
||||
st->st_mode = kst->st_mode;
|
||||
st->st_nlink = kst->st_nlink;
|
||||
st->st_uid = kst->st_uid;
|
||||
st->st_gid = kst->st_gid;
|
||||
st->st_rdev = kst->st_rdev;
|
||||
st->st_size = kst->st_size;
|
||||
st->st_blocks = kst->st_blocks;
|
||||
st->st_blksize = kst->st_blksize;
|
||||
st->st_atime = kst->st_atim.tv_sec;
|
||||
st->st_mtime = kst->st_mtim.tv_sec;
|
||||
st->st_ctime = kst->st_ctim.tv_sec;
|
||||
}
|
||||
|
||||
/* Status of an open file. The sys/stat.h header file required is
|
||||
distributed in the include subdirectory for this C library. */
|
||||
int
|
||||
_fstat(int file, struct stat *st)
|
||||
{
|
||||
struct kernel_stat kst;
|
||||
int rv = syscall_errno (SYS_fstat, file, &kst, 0, 0);
|
||||
conv_stat (st, &kst);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* Status of a file (by name). */
|
||||
int
|
||||
_stat(const char *file, struct stat *st)
|
||||
{
|
||||
struct kernel_stat kst;
|
||||
int rv = syscall_errno (SYS_stat, file, &kst, 0, 0);
|
||||
conv_stat (st, &kst);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* Status of a link (by name). */
|
||||
int
|
||||
_lstat(const char *file, struct stat *st)
|
||||
{
|
||||
struct kernel_stat kst;
|
||||
int rv = syscall_errno (SYS_lstat, file, &kst, 0, 0);
|
||||
conv_stat (st, &kst);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* Status of a file (by name) in a given directory. */
|
||||
int
|
||||
_fstatat(int dirfd, const char *file, struct stat *st, int flags)
|
||||
{
|
||||
struct kernel_stat kst;
|
||||
int rv = syscall_errno (SYS_fstatat, dirfd, file, &kst, flags);
|
||||
conv_stat (st, &kst);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* Permissions of a file (by name). */
|
||||
int
|
||||
_access(const char *file, int mode)
|
||||
{
|
||||
return syscall_errno (SYS_access, file, mode, 0, 0);
|
||||
}
|
||||
|
||||
/* Permissions of a file (by name) in a given directory. */
|
||||
int
|
||||
_faccessat(int dirfd, const char *file, int mode, int flags)
|
||||
{
|
||||
return syscall_errno (SYS_faccessat, dirfd, file, mode, flags);
|
||||
}
|
||||
|
||||
/* Close a file. */
|
||||
int
|
||||
_close(int file)
|
||||
{
|
||||
return syscall_errno (SYS_close, file, 0, 0, 0);
|
||||
}
|
||||
|
||||
/* Establish a new name for an existing file. */
|
||||
int
|
||||
_link(const char *old_name, const char *new_name)
|
||||
{
|
||||
return syscall_errno (SYS_link, old_name, new_name, 0, 0);
|
||||
}
|
||||
|
||||
/* Remove a file's directory entry. */
|
||||
int
|
||||
_unlink(const char *name)
|
||||
{
|
||||
return syscall_errno (SYS_unlink, name, 0, 0, 0);
|
||||
}
|
||||
|
||||
/* Transfer control to a new process. Minimal implementation for a
|
||||
system without processes from newlib documentation. */
|
||||
int
|
||||
_execve(const char *name, char *const argv[], char *const env[])
|
||||
{
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Create a new process. Minimal implementation for a system without
|
||||
processes from newlib documentation. */
|
||||
|
||||
int
|
||||
_fork()
|
||||
{
|
||||
errno = EAGAIN;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Get process id. This is sometimes used to generate strings unlikely
|
||||
to conflict with other processes. Minimal implementation for a
|
||||
system without processes just returns 1. */
|
||||
|
||||
int
|
||||
_getpid()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Send a signal. Minimal implementation for a system without processes
|
||||
just causes an error. */
|
||||
|
||||
int
|
||||
_kill(int pid, int sig)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Wait for a child process. Minimal implementation for a system without
|
||||
processes just causes an error. */
|
||||
|
||||
int
|
||||
_wait(int *status)
|
||||
{
|
||||
errno = ECHILD;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Query whether output stream is a terminal. For consistency with the
|
||||
other minimal implementations, which only support output to stdout,
|
||||
this minimal implementation is suggested by the newlib docs. */
|
||||
|
||||
int
|
||||
_isatty(int file)
|
||||
{
|
||||
struct stat s;
|
||||
int ret = _fstat (file, &s);
|
||||
return ret == -1 ? -1 : !!(s.st_mode & S_IFCHR);
|
||||
}
|
||||
|
||||
/* Get the current time. Only relatively correct. */
|
||||
|
||||
int
|
||||
_gettimeofday(struct timeval *tp, void *tz)
|
||||
{
|
||||
return syscall_errno (SYS_gettimeofday, tp, 0, 0, 0);
|
||||
}
|
||||
|
||||
/* Timing information for current process. From
|
||||
newlib/libc/include/sys/times.h the tms struct fields are as follows:
|
||||
|
||||
- clock_t tms_utime : user clock ticks
|
||||
- clock_t tms_stime : system clock ticks
|
||||
- clock_t tms_cutime : children's user clock ticks
|
||||
- clock_t tms_cstime : children's system clock ticks
|
||||
|
||||
Since maven does not currently support processes we set both of the
|
||||
children's times to zero. Eventually we might want to separately
|
||||
account for user vs system time, but for now we just return the total
|
||||
number of cycles since starting the program. */
|
||||
clock_t
|
||||
_times(struct tms *buf)
|
||||
{
|
||||
// when called for the first time, initialize t0
|
||||
static struct timeval t0;
|
||||
if(t0.tv_sec == 0)
|
||||
_gettimeofday (&t0,0);
|
||||
|
||||
struct timeval t;
|
||||
_gettimeofday (&t, 0);
|
||||
|
||||
long long utime = (t.tv_sec - t0.tv_sec) * 1000000 + (t.tv_usec - t0.tv_usec);
|
||||
buf->tms_utime = utime * CLOCKS_PER_SEC / 1000000;
|
||||
buf->tms_stime = buf->tms_cstime = buf->tms_cutime = 0;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Get the current time. Only relatively correct. */
|
||||
int
|
||||
_ftime(struct timeb *tp)
|
||||
{
|
||||
tp->time = tp->millitm = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Stub. */
|
||||
int
|
||||
_utime(const char *path, const struct utimbuf *times)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Stub. */
|
||||
int
|
||||
_chown(const char *path, uid_t owner, gid_t group)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Stub. */
|
||||
int
|
||||
_chmod(const char *path, mode_t mode)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Stub. */
|
||||
int
|
||||
_chdir(const char *path)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Stub. */
|
||||
char *
|
||||
_getcwd(char *buf, size_t size)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Get configurable system variables. */
|
||||
|
||||
long
|
||||
_sysconf(int name)
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case _SC_CLK_TCK:
|
||||
return CLOCKS_PER_SEC;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Increase program data space. As malloc and related functions depend
|
||||
on this, it is useful to have a working implementation. The following
|
||||
is suggested by the newlib docs and suffices for a standalone
|
||||
system. */
|
||||
void *
|
||||
_sbrk(ptrdiff_t incr)
|
||||
{
|
||||
static unsigned long heap_end;
|
||||
|
||||
if (heap_end == 0)
|
||||
{
|
||||
long brk = syscall_errno (SYS_brk, 0, 0, 0, 0);
|
||||
if (brk == -1)
|
||||
return (void *)-1;
|
||||
heap_end = brk;
|
||||
}
|
||||
|
||||
if (syscall_errno (SYS_brk, heap_end + incr, 0, 0, 0) != heap_end + incr)
|
||||
return (void *)-1;
|
||||
|
||||
heap_end += incr;
|
||||
return (void *)(heap_end - incr);
|
||||
}
|
||||
|
||||
/* Exit a program without cleaning up files. */
|
||||
|
||||
void
|
||||
_exit(int exit_status)
|
||||
{
|
||||
syscall_errno (SYS_exit, exit_status, 0, 0, 0);
|
||||
while (1);
|
||||
}
|
|
@ -45,6 +45,13 @@ aarch64 Richard Earnshaw richard.earnshaw@arm.com
|
|||
msp430 DJ Delorie dj@redhat.com
|
||||
Nick Clifton nickc@redhat.com
|
||||
|
||||
OS Port Maintainers (OS alphabetical order)
|
||||
|
||||
OS port maintainers may make changes in OS-specific directories, as
|
||||
well as OS-specific portions of the build system, without approval.
|
||||
|
||||
RTEMS Joel Sherrill joel.sherrill@oarcorp.com
|
||||
Sebastian Huber sebastian.huber@embedded-brains.de
|
||||
|
||||
Write After Approval
|
||||
|
||||
|
@ -56,3 +63,5 @@ Jim Wilson wilson@specifixinc.com
|
|||
Nick Clifton nickc@redhat.com
|
||||
Eric Blake eblake@redhat.com
|
||||
Will Newton will.newton@linaro.org
|
||||
Sebastian Huber sebastian.huber@embedded-brains.de
|
||||
Joel Sherrill joel.sherrill@oarcorp.com
|
||||
|
|
|
@ -297,6 +297,12 @@ One feature can be enabled by specifying `--enable-FEATURE=yes' or
|
|||
is not referenced.
|
||||
Disabled by default.
|
||||
|
||||
`--enable-newlib-global-stdio-streams'
|
||||
Enable to move the stdio stream FILE objects out of struct _reent and make
|
||||
them global. The stdio stream pointers of struct _reent are initialized
|
||||
to point to the global stdio FILE stream objects.
|
||||
Disabled by default.
|
||||
|
||||
`--enable-newlib-reent-small'
|
||||
Enable small reentrant struct support.
|
||||
Disabled by default.
|
||||
|
|
|
@ -795,6 +795,7 @@ enable_newlib_iconv_external_ccs
|
|||
enable_newlib_atexit_dynamic_alloc
|
||||
enable_newlib_global_atexit
|
||||
enable_newlib_reent_small
|
||||
enable_newlib_global_stdio_streams
|
||||
enable_newlib_fvwrite_in_streamio
|
||||
enable_newlib_fseek_optimization
|
||||
enable_newlib_wide_orient
|
||||
|
@ -1467,6 +1468,7 @@ Optional Features:
|
|||
--disable-newlib-atexit-dynamic-alloc disable dynamic allocation of atexit entries
|
||||
--enable-newlib-global-atexit enable atexit data structure as global
|
||||
--enable-newlib-reent-small enable small reentrant struct support
|
||||
--enable-newlib-global-stdio-streams enable global stdio streams
|
||||
--disable-newlib-fvwrite-in-streamio disable iov in streamio
|
||||
--disable-newlib-fseek-optimization disable fseek optimization
|
||||
--disable-newlib-wide-orient Turn off wide orientation in streamio
|
||||
|
@ -2387,6 +2389,17 @@ else
|
|||
newlib_reent_small=
|
||||
fi
|
||||
|
||||
# Check whether --enable-newlib-global-stdio-streams was given.
|
||||
if test "${enable_newlib_global_stdio_streams+set}" = set; then :
|
||||
enableval=$enable_newlib_global_stdio_streams; case "${enableval}" in
|
||||
yes) newlib_global_stdio_streams=yes;;
|
||||
no) newlib_global_stdio_streams=no ;;
|
||||
*) as_fn_error $? "bad value ${enableval} for newlib-global-stdio-streams option" "$LINENO" 5 ;;
|
||||
esac
|
||||
else
|
||||
newlib_global_stdio_streams=
|
||||
fi
|
||||
|
||||
# Check whether --enable-newlib-fvwrite-in-streamio was given.
|
||||
if test "${enable_newlib_fvwrite_in_streamio+set}" = set; then :
|
||||
enableval=$enable_newlib_fvwrite_in_streamio; if test "${newlib_fvwrite_in_streamio+set}" != set; then
|
||||
|
@ -11794,7 +11807,7 @@ else
|
|||
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
||||
lt_status=$lt_dlunknown
|
||||
cat > conftest.$ac_ext <<_LT_EOF
|
||||
#line 11797 "configure"
|
||||
#line 11810 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
#if HAVE_DLFCN_H
|
||||
|
@ -11900,7 +11913,7 @@ else
|
|||
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
||||
lt_status=$lt_dlunknown
|
||||
cat > conftest.$ac_ext <<_LT_EOF
|
||||
#line 11903 "configure"
|
||||
#line 11916 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
#if HAVE_DLFCN_H
|
||||
|
@ -12347,6 +12360,13 @@ _ACEOF
|
|||
|
||||
fi
|
||||
|
||||
if test "${newlib_global_stdio_streams}" = "yes"; then
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define _WANT_REENT_GLOBAL_STDIO_STREAMS 1
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
|
||||
if test "${newlib_mb}" = "yes"; then
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define _MB_CAPABLE 1
|
||||
|
|
|
@ -255,6 +255,12 @@ case "${host_cpu}" in
|
|||
powerpc*)
|
||||
machine_dir=powerpc
|
||||
;;
|
||||
riscv*)
|
||||
libm_machine_dir=riscv
|
||||
machine_dir=riscv
|
||||
newlib_cflags="${newlib_cflags}"
|
||||
default_newlib_atexit_dynamic_alloc="no"
|
||||
;;
|
||||
rl78)
|
||||
machine_dir=rl78
|
||||
newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -DSMALL_MEMORY"
|
||||
|
@ -816,6 +822,9 @@ case "${host}" in
|
|||
newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DHAVE_FCNTL -D_NO_POSIX_SPAWN"
|
||||
syscall_dir=syscalls
|
||||
;;
|
||||
riscv*-*-*)
|
||||
syscall_dir=syscalls
|
||||
;;
|
||||
sh*-*-*)
|
||||
default_newlib_io_long_long="yes"
|
||||
syscall_dir=syscalls
|
||||
|
|
|
@ -136,6 +136,15 @@ AC_ARG_ENABLE(newlib-reent-small,
|
|||
no) newlib_reent_small=no ;;
|
||||
*) AC_MSG_ERROR(bad value ${enableval} for newlib-reent-small option) ;;
|
||||
esac], [newlib_reent_small=])dnl
|
||||
|
||||
dnl Support --enable-newlib-global-stdio-streams
|
||||
AC_ARG_ENABLE(newlib-global-stdio-streams,
|
||||
[ --enable-newlib-global-stdio-streams enable global stdio streams],
|
||||
[case "${enableval}" in
|
||||
yes) newlib_global_stdio_streams=yes;;
|
||||
no) newlib_global_stdio_streams=no ;;
|
||||
*) AC_MSG_ERROR(bad value ${enableval} for newlib-global-stdio-streams option) ;;
|
||||
esac], [newlib_global_stdio_streams=])dnl
|
||||
|
||||
dnl Support --disable-newlib-fvwrite-in-streamio
|
||||
AC_ARG_ENABLE(newlib-fvwrite-in-streamio,
|
||||
|
@ -400,6 +409,10 @@ if test "${newlib_reent_small}" = "yes"; then
|
|||
AC_DEFINE_UNQUOTED(_WANT_REENT_SMALL)
|
||||
fi
|
||||
|
||||
if test "${newlib_global_stdio_streams}" = "yes"; then
|
||||
AC_DEFINE_UNQUOTED(_WANT_REENT_GLOBAL_STDIO_STREAMS)
|
||||
fi
|
||||
|
||||
if test "${newlib_mb}" = "yes"; then
|
||||
AC_DEFINE_UNQUOTED(_MB_CAPABLE)
|
||||
AC_DEFINE_UNQUOTED(_MB_LEN_MAX,8)
|
||||
|
|
|
@ -24,10 +24,12 @@ float complex cacosf(float complex);
|
|||
/* 7.3.5.2 The casin functions */
|
||||
double complex casin(double complex);
|
||||
float complex casinf(float complex);
|
||||
long double complex casinl(long double complex);
|
||||
|
||||
/* 7.3.5.1 The catan functions */
|
||||
double complex catan(double complex);
|
||||
float complex catanf(float complex);
|
||||
long double complex catanl(long double complex);
|
||||
|
||||
/* 7.3.5.1 The ccos functions */
|
||||
double complex ccos(double complex);
|
||||
|
@ -74,6 +76,7 @@ float complex cexpf(float complex);
|
|||
/* 7.3.7.2 The clog functions */
|
||||
double complex clog(double complex);
|
||||
float complex clogf(float complex);
|
||||
long double complex clogl(long double complex);
|
||||
|
||||
/* 7.3.8 Power and absolute-value functions */
|
||||
/* 7.3.8.1 The cabs functions */
|
||||
|
@ -94,11 +97,13 @@ float complex cpowf(float complex, float complex);
|
|||
/* 7.3.8.3 The csqrt functions */
|
||||
double complex csqrt(double complex);
|
||||
float complex csqrtf(float complex);
|
||||
long double complex csqrtl(long double complex);
|
||||
|
||||
/* 7.3.9 Manipulation functions */
|
||||
/* 7.3.9.1 The carg functions */
|
||||
double carg(double complex);
|
||||
float cargf(float complex);
|
||||
long double cargl(long double complex);
|
||||
|
||||
/* 7.3.9.2 The cimag functions */
|
||||
double cimag(double complex);
|
||||
|
@ -125,8 +130,6 @@ float complex clog10f(float complex);
|
|||
|
||||
#if defined(__CYGWIN__)
|
||||
long double complex cacosl(long double complex);
|
||||
long double complex casinl(long double complex);
|
||||
long double complex catanl(long double complex);
|
||||
long double complex ccosl(long double complex);
|
||||
long double complex csinl(long double complex);
|
||||
long double complex ctanl(long double complex);
|
||||
|
@ -137,10 +140,7 @@ long double complex ccoshl(long double complex);
|
|||
long double complex csinhl(long double complex);
|
||||
long double complex ctanhl(long double complex);
|
||||
long double complex cexpl(long double complex);
|
||||
long double complex clogl(long double complex);
|
||||
long double complex cpowl(long double complex, long double complex);
|
||||
long double complex csqrtl(long double complex);
|
||||
long double cargl(long double complex);
|
||||
long double complex conjl(long double complex);
|
||||
long double complex cprojl(long double complex);
|
||||
#if __GNU_VISIBLE
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -16,10 +16,15 @@
|
|||
#include <newlib.h>
|
||||
#include <sys/config.h>
|
||||
#include <sys/_intsup.h>
|
||||
#include "_ansi.h"
|
||||
#include <stdint.h>
|
||||
#define __need_wchar_t
|
||||
#include <stddef.h>
|
||||
|
||||
#if __BSD_VISIBLE
|
||||
#include <xlocale.h>
|
||||
#endif
|
||||
|
||||
#define __STRINGIFY(a) #a
|
||||
|
||||
/* 8-bit types */
|
||||
|
@ -309,6 +314,8 @@ typedef struct {
|
|||
intmax_t rem;
|
||||
} imaxdiv_t;
|
||||
|
||||
struct _reent;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -316,9 +323,20 @@ extern "C" {
|
|||
extern intmax_t imaxabs(intmax_t j);
|
||||
extern imaxdiv_t imaxdiv(intmax_t numer, intmax_t denomer);
|
||||
extern intmax_t strtoimax(const char *__restrict, char **__restrict, int);
|
||||
extern intmax_t _strtoimax_r(struct _reent *, const char *__restrict, char **__restrict, int);
|
||||
extern uintmax_t strtoumax(const char *__restrict, char **__restrict, int);
|
||||
extern uintmax_t _strtoumax_r(struct _reent *, const char *__restrict, char **__restrict, int);
|
||||
extern intmax_t wcstoimax(const wchar_t *__restrict, wchar_t **__restrict, int);
|
||||
extern intmax_t _wcstoimax_r(struct _reent *, const wchar_t *__restrict, wchar_t **__restrict, int);
|
||||
extern uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int);
|
||||
extern uintmax_t _wcstoumax_r(struct _reent *, const wchar_t *__restrict, wchar_t **__restrict, int);
|
||||
|
||||
#if __BSD_VISIBLE
|
||||
extern intmax_t strtoimax_l(const char *__restrict, char **_restrict, int, locale_t);
|
||||
extern uintmax_t strtoumax_l(const char *__restrict, char **_restrict, int, locale_t);
|
||||
extern intmax_t wcstoimax_l(const wchar_t *__restrict, wchar_t **_restrict, int, locale_t);
|
||||
extern uintmax_t wcstoumax_l(const wchar_t *__restrict, wchar_t **_restrict, int, locale_t);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -170,6 +170,10 @@
|
|||
#define __IEEE_LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
#ifdef __riscv
|
||||
#define __IEEE_LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
#ifdef __i960__
|
||||
#define __IEEE_LITTLE_ENDIAN
|
||||
#endif
|
||||
|
|
|
@ -358,6 +358,15 @@ _BEGIN_STD_C
|
|||
#define _JBLEN 12
|
||||
#endif
|
||||
|
||||
#ifdef __riscv
|
||||
#define _JBTYPE long
|
||||
#ifdef __riscv_32e
|
||||
#define _JBLEN ((4*sizeof(long))/sizeof(long))
|
||||
#else
|
||||
#define _JBLEN ((14*sizeof(long) + 12*sizeof(double))/sizeof(long))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _JBLEN
|
||||
#ifdef _JBTYPE
|
||||
typedef _JBTYPE jmp_buf[_JBLEN];
|
||||
|
@ -368,7 +377,7 @@ typedef int jmp_buf[_JBLEN];
|
|||
|
||||
_END_STD_C
|
||||
|
||||
#if defined(__CYGWIN__) || defined(__rtems__)
|
||||
#if (defined(__CYGWIN__) || defined(__rtems__)) && __POSIX_VISIBLE
|
||||
#include <signal.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -450,4 +459,4 @@ extern int _setjmp (jmp_buf);
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __CYGWIN__ or __rtems__ */
|
||||
#endif /* (__CYGWIN__ or __rtems__) and __POSIX_VISIBLE */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef _MACHTIME_H_
|
||||
#define _MACHTIME_H_
|
||||
|
||||
#if defined(__rtems__) || defined(__VISIUM__)
|
||||
#if defined(__rtems__) || defined(__VISIUM__) || defined(__riscv)
|
||||
#define _CLOCKS_PER_SEC_ 1000000
|
||||
#elif defined(__aarch64__) || defined(__arm__) || defined(__thumb__)
|
||||
#define _CLOCKS_PER_SEC_ 100
|
||||
|
|
|
@ -718,6 +718,7 @@ _ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
|
|||
#define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
|
||||
#define __sfileno(p) ((p)->_file)
|
||||
|
||||
#ifndef __cplusplus
|
||||
#ifndef _REENT_SMALL
|
||||
#define feof(p) __sfeof(p)
|
||||
#define ferror(p) __sferror(p)
|
||||
|
@ -734,12 +735,36 @@ _ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
|
|||
#define fileno(p) __sfileno(p)
|
||||
#endif
|
||||
|
||||
#ifndef __CYGWIN__
|
||||
#ifndef lint
|
||||
#define getc(fp) __sgetc_r(_REENT, fp)
|
||||
#define putc(x, fp) __sputc_r(_REENT, x, fp)
|
||||
#endif /* lint */
|
||||
#endif /* __CYGWIN__ */
|
||||
static __inline int
|
||||
_getchar_unlocked(void)
|
||||
{
|
||||
struct _reent *_ptr;
|
||||
|
||||
_ptr = _REENT;
|
||||
return (__sgetc_r(_ptr, _stdin_r(_ptr)));
|
||||
}
|
||||
|
||||
static __inline int
|
||||
_putchar_unlocked(int _c)
|
||||
{
|
||||
struct _reent *_ptr;
|
||||
|
||||
_ptr = _REENT;
|
||||
return (__sputc_r(_ptr, _c, _stdout_r(_ptr)));
|
||||
}
|
||||
|
||||
#ifdef __SINGLE_THREAD__
|
||||
#define getc(_p) __sgetc_r(_REENT, _p)
|
||||
#define putc(_c, _p) __sputc_r(_REENT, _c, _p)
|
||||
#define getchar() _getchar_unlocked()
|
||||
#define putchar(_c) _putchar_unlocked(_c)
|
||||
#endif /* __SINGLE_THREAD__ */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#if __MISC_VISIBLE || __POSIX_VISIBLE
|
||||
#define getchar_unlocked() _getchar_unlocked()
|
||||
#define putchar_unlocked(_c) _putchar_unlocked(_c)
|
||||
#endif
|
||||
|
||||
#if __MISC_VISIBLE
|
||||
/* fast always-buffered version, true iff error */
|
||||
|
@ -754,7 +779,7 @@ _ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
|
|||
#define L_ctermid 16
|
||||
#endif
|
||||
|
||||
#endif /* !__CUSTOM_FILE_IO__ */
|
||||
#else /* __CUSTOM_FILE_IO__ */
|
||||
|
||||
#define getchar() getc(stdin)
|
||||
#define putchar(x) putc(x, stdout)
|
||||
|
@ -764,6 +789,8 @@ _ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
|
|||
#define putchar_unlocked(x) putc_unlocked(x, stdout)
|
||||
#endif
|
||||
|
||||
#endif /* !__CUSTOM_FILE_IO__ */
|
||||
|
||||
_END_STD_C
|
||||
|
||||
#endif /* _STDIO_H_ */
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
#include <xlocale.h>
|
||||
#endif
|
||||
|
||||
#if __BSD_VISIBLE
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
_BEGIN_STD_C
|
||||
|
||||
_PTR _EXFUN(memchr,(const _PTR, int, size_t));
|
||||
|
@ -52,27 +56,13 @@ int strcoll_l (const char *, const char *, locale_t);
|
|||
char *strerror_l (int, locale_t);
|
||||
size_t strxfrm_l (char *__restrict, const char *__restrict, size_t, locale_t);
|
||||
#endif
|
||||
#if __GNU_VISIBLE
|
||||
int strcasecmp_l (const char *, const char *, locale_t);
|
||||
int strncasecmp_l (const char *, const char *, size_t, locale_t);
|
||||
#endif
|
||||
#if __MISC_VISIBLE || __POSIX_VISIBLE
|
||||
char *_EXFUN(strtok_r,(char *__restrict, const char *__restrict, char **__restrict));
|
||||
#endif
|
||||
#if __BSD_VISIBLE /* POSIX declaration is in <strings.h> */
|
||||
int _EXFUN(bcmp,(const void *, const void *, size_t));
|
||||
void _EXFUN(bcopy,(const void *, void *, size_t));
|
||||
void _EXFUN(bzero,(void *, size_t));
|
||||
#endif
|
||||
#if __BSD_VISIBLE
|
||||
void _EXFUN(explicit_bzero,(void *, size_t));
|
||||
int _EXFUN(timingsafe_bcmp,(const void *, const void *, size_t));
|
||||
int _EXFUN(timingsafe_memcmp,(const void *, const void *, size_t));
|
||||
#endif
|
||||
#if __BSD_VISIBLE /* POSIX declaration is in <strings.h> */
|
||||
int _EXFUN(ffs,(int));
|
||||
char *_EXFUN(index,(const char *, int));
|
||||
#endif
|
||||
#if __MISC_VISIBLE || __POSIX_VISIBLE
|
||||
_PTR _EXFUN(memccpy,(_PTR __restrict, const _PTR __restrict, int, size_t));
|
||||
#endif
|
||||
|
@ -82,16 +72,10 @@ _PTR _EXFUN(memmem, (const _PTR, size_t, const _PTR, size_t));
|
|||
_PTR _EXFUN(memrchr,(const _PTR, int, size_t));
|
||||
_PTR _EXFUN(rawmemchr,(const _PTR, int));
|
||||
#endif
|
||||
#if __BSD_VISIBLE /* POSIX declaration is in <strings.h> */
|
||||
char *_EXFUN(rindex,(const char *, int));
|
||||
#endif
|
||||
#if __POSIX_VISIBLE >= 200809
|
||||
char *_EXFUN(stpcpy,(char *__restrict, const char *__restrict));
|
||||
char *_EXFUN(stpncpy,(char *__restrict, const char *__restrict, size_t));
|
||||
#endif
|
||||
#if __BSD_VISIBLE /* POSIX declaration is in <strings.h> */
|
||||
int _EXFUN(strcasecmp,(const char *, const char *));
|
||||
#endif
|
||||
#if __GNU_VISIBLE
|
||||
char *_EXFUN(strcasestr,(const char *, const char *));
|
||||
char *_EXFUN(strchrnul,(const char *, int));
|
||||
|
@ -105,11 +89,6 @@ char *_EXFUN(strndup,(const char *, size_t));
|
|||
#endif
|
||||
char *_EXFUN(_strndup_r,(struct _reent *, const char *, size_t));
|
||||
|
||||
#if __GNU_VISIBLE
|
||||
int _EXFUN(ffsl,(long));
|
||||
int _EXFUN(ffsll, (long long));
|
||||
#endif
|
||||
|
||||
/* There are two common strerror_r variants. If you request
|
||||
_GNU_SOURCE, you get the GNU version; otherwise you get the POSIX
|
||||
version. POSIX requires that #undef strerror_r will still let you
|
||||
|
@ -136,9 +115,6 @@ char * _EXFUN(_strerror_r, (struct _reent *, int, int, int *));
|
|||
size_t _EXFUN(strlcat,(char *, const char *, size_t));
|
||||
size_t _EXFUN(strlcpy,(char *, const char *, size_t));
|
||||
#endif
|
||||
#if __BSD_VISIBLE /* POSIX declaration is in <strings.h> */
|
||||
int _EXFUN(strncasecmp,(const char *, const char *, size_t));
|
||||
#endif
|
||||
#if __POSIX_VISIBLE >= 200809
|
||||
size_t _EXFUN(strnlen,(const char *, size_t));
|
||||
#endif
|
||||
|
@ -159,18 +135,22 @@ char *_EXFUN(strsignal, (int __signo));
|
|||
int _EXFUN(strtosigno, (const char *__name));
|
||||
#endif
|
||||
|
||||
#if __GNU_VISIBLE
|
||||
int _EXFUN(strverscmp,(const char *, const char *));
|
||||
#endif
|
||||
|
||||
#if __GNU_VISIBLE && defined(__GNUC__)
|
||||
#define strdupa(__s) \
|
||||
(__extension__ ({const char *__in = (__s); \
|
||||
size_t __len = strlen (__in) + 1; \
|
||||
char * __out = (char *) __builtin_alloca (__len); \
|
||||
(char *) memcpy (__out, __in, __len);}))
|
||||
(__extension__ ({const char *__sin = (__s); \
|
||||
size_t __len = strlen (__sin) + 1; \
|
||||
char * __sout = (char *) __builtin_alloca (__len); \
|
||||
(char *) memcpy (__sout, __sin, __len);}))
|
||||
#define strndupa(__s, __n) \
|
||||
(__extension__ ({const char *__in = (__s); \
|
||||
size_t __len = strnlen (__in, (__n)) + 1; \
|
||||
char *__out = (char *) __builtin_alloca (__len); \
|
||||
__out[__len-1] = '\0'; \
|
||||
(char *) memcpy (__out, __in, __len-1);}))
|
||||
(__extension__ ({const char *__sin = (__s); \
|
||||
size_t __len = strnlen (__sin, (__n)) + 1; \
|
||||
char *__sout = (char *) __builtin_alloca (__len); \
|
||||
__sout[__len-1] = '\0'; \
|
||||
(char *) memcpy (__sout, __sin, __len-1);}))
|
||||
#endif /* __GNU_VISIBLE && __GNUC__ */
|
||||
|
||||
/* There are two common basename variants. If you do NOT #include <libgen.h>
|
||||
|
|
|
@ -1,49 +1,76 @@
|
|||
/*
|
||||
* strings.h
|
||||
/*-
|
||||
* Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Definitions for string operations.
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD: head/include/strings.h 272673 2014-10-07 04:54:11Z delphij $
|
||||
*/
|
||||
|
||||
#ifndef _STRINGS_H_
|
||||
#define _STRINGS_H_
|
||||
#define _STRINGS_H_
|
||||
|
||||
/* These functions are already declared in <string.h> with __BSD_VISIBLE */
|
||||
#if !(defined(_STRING_H_) && __BSD_VISIBLE)
|
||||
|
||||
#include "_ansi.h"
|
||||
#include <sys/reent.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h> /* for size_t */
|
||||
#include <sys/_types.h>
|
||||
|
||||
#if __POSIX_VISIBLE >= 200809
|
||||
#include <xlocale.h>
|
||||
#endif
|
||||
|
||||
_BEGIN_STD_C
|
||||
#ifndef _SIZE_T_DECLARED
|
||||
typedef __size_t size_t;
|
||||
#define _SIZE_T_DECLARED
|
||||
#endif
|
||||
|
||||
#if __BSD_VISIBLE || (__POSIX_VISIBLE && __POSIX_VISIBLE < 200809)
|
||||
/*
|
||||
* Marked LEGACY in Open Group Base Specifications Issue 6/IEEE Std 1003.1-2004
|
||||
* Removed from Open Group Base Specifications Issue 7/IEEE Std 1003.1-2008
|
||||
*/
|
||||
int _EXFUN(bcmp,(const void *, const void *, size_t));
|
||||
void _EXFUN(bcopy,(const void *, void *, size_t));
|
||||
void _EXFUN(bzero,(void *, size_t));
|
||||
char *_EXFUN(index,(const char *, int));
|
||||
char *_EXFUN(rindex,(const char *, int));
|
||||
#endif /* __BSD_VISIBLE || (__POSIX_VISIBLE && __POSIX_VISIBLE < 200809) */
|
||||
|
||||
int _EXFUN(ffs,(int));
|
||||
int _EXFUN(strcasecmp,(const char *, const char *));
|
||||
int _EXFUN(strncasecmp,(const char *, const char *, size_t));
|
||||
__BEGIN_DECLS
|
||||
#if __BSD_VISIBLE || __POSIX_VISIBLE <= 200112
|
||||
int bcmp(const void *, const void *, size_t) __pure; /* LEGACY */
|
||||
void bcopy(const void *, void *, size_t); /* LEGACY */
|
||||
void bzero(void *, size_t); /* LEGACY */
|
||||
#endif
|
||||
#if __BSD_VISIBLE
|
||||
void explicit_bzero(void *, size_t);
|
||||
#endif
|
||||
#if __XSI_VISIBLE
|
||||
int ffs(int) __pure2;
|
||||
#endif
|
||||
#if __BSD_VISIBLE
|
||||
int ffsl(long) __pure2;
|
||||
int ffsll(long long) __pure2;
|
||||
int fls(int) __pure2;
|
||||
int flsl(long) __pure2;
|
||||
int flsll(long long) __pure2;
|
||||
#endif
|
||||
#if __BSD_VISIBLE || __POSIX_VISIBLE <= 200112
|
||||
char *index(const char *, int) __pure; /* LEGACY */
|
||||
char *rindex(const char *, int) __pure; /* LEGACY */
|
||||
#endif
|
||||
int strcasecmp(const char *, const char *) __pure;
|
||||
int strncasecmp(const char *, const char *, size_t) __pure;
|
||||
|
||||
#if __POSIX_VISIBLE >= 200809
|
||||
int strcasecmp_l (const char *, const char *, locale_t);
|
||||
int strncasecmp_l (const char *, const char *, size_t, locale_t);
|
||||
#endif /* __POSIX_VISIBLE >= 200809 */
|
||||
|
||||
_END_STD_C
|
||||
|
||||
#endif /* !(_STRING_H_ && __BSD_VISIBLE) */
|
||||
#endif
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _STRINGS_H_ */
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#ifndef _SYS__PTHREADTYPES_H_
|
||||
#define _SYS__PTHREADTYPES_H_
|
||||
|
||||
#if defined(_POSIX_THREADS)
|
||||
#if defined(_POSIX_THREADS) || __POSIX_VISIBLE >= 199506
|
||||
|
||||
#include <sys/sched.h>
|
||||
|
||||
|
@ -195,7 +195,7 @@ typedef struct {
|
|||
} pthread_once_t; /* dynamic package initialization */
|
||||
|
||||
#define _PTHREAD_ONCE_INIT { 1, 0 } /* is initialized and not run */
|
||||
#endif /* defined(_POSIX_THREADS) */
|
||||
#endif /* defined(_POSIX_THREADS) || __POSIX_VISIBLE >= 199506 */
|
||||
|
||||
/* POSIX Barrier Types */
|
||||
|
||||
|
|
|
@ -681,42 +681,42 @@
|
|||
#endif
|
||||
|
||||
/* Structure implements a lock. */
|
||||
#define __lockable __lock_annotate(lockable)
|
||||
#define __lockable __lock_annotate(__lockable__)
|
||||
|
||||
/* Function acquires an exclusive or shared lock. */
|
||||
#define __locks_exclusive(...) \
|
||||
__lock_annotate(exclusive_lock_function(__VA_ARGS__))
|
||||
__lock_annotate(__exclusive_lock_function__(__VA_ARGS__))
|
||||
#define __locks_shared(...) \
|
||||
__lock_annotate(shared_lock_function(__VA_ARGS__))
|
||||
__lock_annotate(__shared_lock_function__(__VA_ARGS__))
|
||||
|
||||
/* Function attempts to acquire an exclusive or shared lock. */
|
||||
#define __trylocks_exclusive(...) \
|
||||
__lock_annotate(exclusive_trylock_function(__VA_ARGS__))
|
||||
__lock_annotate(__exclusive_trylock_function__(__VA_ARGS__))
|
||||
#define __trylocks_shared(...) \
|
||||
__lock_annotate(shared_trylock_function(__VA_ARGS__))
|
||||
__lock_annotate(__shared_trylock_function__(__VA_ARGS__))
|
||||
|
||||
/* Function releases a lock. */
|
||||
#define __unlocks(...) __lock_annotate(unlock_function(__VA_ARGS__))
|
||||
#define __unlocks(...) __lock_annotate(__unlock_function__(__VA_ARGS__))
|
||||
|
||||
/* Function asserts that an exclusive or shared lock is held. */
|
||||
#define __asserts_exclusive(...) \
|
||||
__lock_annotate(assert_exclusive_lock(__VA_ARGS__))
|
||||
__lock_annotate(__assert_exclusive_lock__(__VA_ARGS__))
|
||||
#define __asserts_shared(...) \
|
||||
__lock_annotate(assert_shared_lock(__VA_ARGS__))
|
||||
__lock_annotate(__assert_shared_lock__(__VA_ARGS__))
|
||||
|
||||
/* Function requires that an exclusive or shared lock is or is not held. */
|
||||
#define __requires_exclusive(...) \
|
||||
__lock_annotate(exclusive_locks_required(__VA_ARGS__))
|
||||
__lock_annotate(__exclusive_locks_required__(__VA_ARGS__))
|
||||
#define __requires_shared(...) \
|
||||
__lock_annotate(shared_locks_required(__VA_ARGS__))
|
||||
__lock_annotate(__shared_locks_required__(__VA_ARGS__))
|
||||
#define __requires_unlocked(...) \
|
||||
__lock_annotate(locks_excluded(__VA_ARGS__))
|
||||
__lock_annotate(__locks_excluded__(__VA_ARGS__))
|
||||
|
||||
/* Function should not be analyzed. */
|
||||
#define __no_lock_analysis __lock_annotate(no_thread_safety_analysis)
|
||||
#define __no_lock_analysis __lock_annotate(__no_thread_safety_analysis__)
|
||||
|
||||
/* Guard variables and structure members by lock. */
|
||||
#define __guarded_by(x) __lock_annotate(guarded_by(x))
|
||||
#define __pt_guarded_by(x) __lock_annotate(pt_guarded_by(x))
|
||||
#define __guarded_by(x) __lock_annotate(__guarded_by__(x))
|
||||
#define __pt_guarded_by(x) __lock_annotate(__pt_guarded_by__(x))
|
||||
|
||||
#endif /* !_SYS_CDEFS_H_ */
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
#define _POINTER_INT short
|
||||
#endif
|
||||
|
||||
#if defined(__m68k__) || defined(__mc68000__)
|
||||
#if defined(__m68k__) || defined(__mc68000__) || defined(__riscv)
|
||||
#define _READ_WRITE_RETURN_TYPE _ssize_t
|
||||
#endif
|
||||
|
||||
|
@ -154,6 +154,7 @@
|
|||
#define _REENT_SMALL
|
||||
#endif
|
||||
|
||||
#define __BUFSIZ__ 256
|
||||
#define __SMALL_BITFIELDS
|
||||
|
||||
#ifdef __MSP430X_LARGE__
|
||||
|
@ -238,6 +239,7 @@
|
|||
#define _READ_WRITE_RETURN_TYPE _ssize_t
|
||||
#define __DYNAMIC_REENT__
|
||||
#define _REENT_GLOBAL_ATEXIT
|
||||
#define _REENT_GLOBAL_STDIO_STREAMS
|
||||
#endif
|
||||
|
||||
#ifndef __EXPORT
|
||||
|
@ -275,6 +277,12 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _WANT_REENT_GLOBAL_STDIO_STREAMS
|
||||
#ifndef _REENT_GLOBAL_STDIO_STREAMS
|
||||
#define _REENT_GLOBAL_STDIO_STREAMS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* If _MB_EXTENDED_CHARSETS_ALL is set, we want all of the extended
|
||||
charsets. The extended charsets add a few functions and a couple
|
||||
of tables of a few K each. */
|
||||
|
|
|
@ -505,10 +505,9 @@ extern "C" {
|
|||
/* #define _XOPEN_UNIX -1 */
|
||||
#endif /* __XSI_VISIBLE */
|
||||
|
||||
/* The value corresponds to UNICODE version 4.0, which is the version
|
||||
supported by XP. Newlib supports 5.2 (2011) but so far Cygwin needs
|
||||
the MS conversions for double-byte charsets. */
|
||||
#define __STDC_ISO_10646__ 200305L
|
||||
/* The value corresponds to UNICODE version 5.2, which is the current
|
||||
state of newlib's wide char conversion functions. */
|
||||
#define __STDC_ISO_10646__ 200910L
|
||||
|
||||
#endif /* __CYGWIN__ */
|
||||
|
||||
|
|
|
@ -644,14 +644,23 @@ struct _reent
|
|||
of the above members (on the off chance that future binary compatibility
|
||||
would be broken otherwise). */
|
||||
struct _glue __sglue; /* root of glue chain */
|
||||
# ifndef _REENT_GLOBAL_STDIO_STREAMS
|
||||
__FILE __sf[3]; /* first three file descriptors */
|
||||
# endif
|
||||
};
|
||||
|
||||
#ifdef _REENT_GLOBAL_STDIO_STREAMS
|
||||
extern __FILE __sf[3];
|
||||
#define _REENT_STDIO_STREAM(var, index) &__sf[index]
|
||||
#else
|
||||
#define _REENT_STDIO_STREAM(var, index) &(var)->__sf[index]
|
||||
#endif
|
||||
|
||||
#define _REENT_INIT(var) \
|
||||
{ 0, \
|
||||
&(var).__sf[0], \
|
||||
&(var).__sf[1], \
|
||||
&(var).__sf[2], \
|
||||
_REENT_STDIO_STREAM(&(var), 0), \
|
||||
_REENT_STDIO_STREAM(&(var), 1), \
|
||||
_REENT_STDIO_STREAM(&(var), 2), \
|
||||
0, \
|
||||
"", \
|
||||
0, \
|
||||
|
@ -696,9 +705,9 @@ struct _reent
|
|||
}
|
||||
|
||||
#define _REENT_INIT_PTR_ZEROED(var) \
|
||||
{ (var)->_stdin = &(var)->__sf[0]; \
|
||||
(var)->_stdout = &(var)->__sf[1]; \
|
||||
(var)->_stderr = &(var)->__sf[2]; \
|
||||
{ (var)->_stdin = _REENT_STDIO_STREAM(var, 0); \
|
||||
(var)->_stdout = _REENT_STDIO_STREAM(var, 1); \
|
||||
(var)->_stderr = _REENT_STDIO_STREAM(var, 2); \
|
||||
(var)->_new._reent._rand_next = 1; \
|
||||
(var)->_new._reent._r48._seed[0] = _RAND48_SEED_0; \
|
||||
(var)->_new._reent._r48._seed[1] = _RAND48_SEED_1; \
|
||||
|
|
|
@ -18,9 +18,11 @@ extern "C" {
|
|||
typedef __sigset_t sigset_t;
|
||||
#endif
|
||||
|
||||
#if defined(__rtems__)
|
||||
#if defined(__CYGWIN__)
|
||||
#include <cygwin/signal.h>
|
||||
#else
|
||||
|
||||
#if defined(_POSIX_REALTIME_SIGNALS)
|
||||
#if defined(_POSIX_REALTIME_SIGNALS) || __POSIX_VISIBLE >= 199309
|
||||
|
||||
/* sigev_notify values
|
||||
NOTE: P1003.1c/D10, p. 34 adds SIGEV_THREAD. */
|
||||
|
@ -68,7 +70,9 @@ typedef struct {
|
|||
int si_code; /* Cause of the signal */
|
||||
union sigval si_value; /* Signal value */
|
||||
} siginfo_t;
|
||||
#endif
|
||||
#endif /* defined(_POSIX_REALTIME_SIGNALS) || __POSIX_VISIBLE >= 199309 */
|
||||
|
||||
#if defined(__rtems__)
|
||||
|
||||
/* 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76 */
|
||||
|
||||
|
@ -108,9 +112,8 @@ struct sigaction {
|
|||
#define sa_sigaction _signal_handlers._sigaction
|
||||
#endif
|
||||
|
||||
#elif defined(__CYGWIN__)
|
||||
#include <cygwin/signal.h>
|
||||
#else
|
||||
#else /* defined(__rtems__) */
|
||||
|
||||
#define SA_NOCLDSTOP 1 /* only value supported now for sa_flags */
|
||||
|
||||
typedef void (*_sig_func_ptr)(int);
|
||||
|
@ -122,6 +125,7 @@ struct sigaction
|
|||
int sa_flags;
|
||||
};
|
||||
#endif /* defined(__rtems__) */
|
||||
#endif /* defined(__CYGWIN__) */
|
||||
|
||||
#if __BSD_VISIBLE || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809
|
||||
/*
|
||||
|
@ -152,13 +156,15 @@ typedef struct sigaltstack {
|
|||
size_t ss_size; /* Stack size. */
|
||||
} stack_t;
|
||||
|
||||
#if __POSIX_VISIBLE
|
||||
#define SIG_SETMASK 0 /* set mask with sigprocmask() */
|
||||
#define SIG_BLOCK 1 /* set of signals to block */
|
||||
#define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
|
||||
|
||||
int _EXFUN(sigprocmask, (int how, const sigset_t *set, sigset_t *oset));
|
||||
#endif
|
||||
|
||||
#if defined(_POSIX_THREADS)
|
||||
#if __POSIX_VISIBLE >= 199506
|
||||
int _EXFUN(pthread_sigmask, (int how, const sigset_t *set, sigset_t *oset));
|
||||
#endif
|
||||
|
||||
|
@ -168,10 +174,14 @@ int _EXFUN(_kill, (pid_t, int));
|
|||
#endif /* _COMPILING_NEWLIB */
|
||||
#endif /* __CYGWIN__ || __rtems__ */
|
||||
|
||||
#if __POSIX_VISIBLE
|
||||
int _EXFUN(kill, (pid_t, int));
|
||||
#endif
|
||||
|
||||
#if __BSD_VISIBLE || __XSI_VISIBLE >= 4
|
||||
int _EXFUN(killpg, (pid_t, int));
|
||||
#endif
|
||||
#if __POSIX_VISIBLE
|
||||
int _EXFUN(sigaction, (int, const struct sigaction *, struct sigaction *));
|
||||
int _EXFUN(sigaddset, (sigset_t *, const int));
|
||||
int _EXFUN(sigdelset, (sigset_t *, const int));
|
||||
|
@ -180,7 +190,7 @@ int _EXFUN(sigfillset, (sigset_t *));
|
|||
int _EXFUN(sigemptyset, (sigset_t *));
|
||||
int _EXFUN(sigpending, (sigset_t *));
|
||||
int _EXFUN(sigsuspend, (const sigset_t *));
|
||||
int _EXFUN(sigpause, (int));
|
||||
int _EXFUN(sigwait, (const sigset_t *set, int *sig));
|
||||
|
||||
#if !defined(__CYGWIN__) && !defined(__rtems__)
|
||||
/* These depend upon the type of sigset_t, which right now
|
||||
|
@ -192,17 +202,33 @@ int _EXFUN(sigpause, (int));
|
|||
#define sigfillset(what) (*(what) = ~(0), 0)
|
||||
#define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0)
|
||||
#endif /* !__CYGWIN__ && !__rtems__ */
|
||||
#endif /* __BSD_VISIBLE || __XSI_VISIBLE >= 4 */
|
||||
#endif /* __POSIX_VISIBLE */
|
||||
|
||||
/* There are two common sigpause variants, both of which take an int argument.
|
||||
If you request _XOPEN_SOURCE or _GNU_SOURCE, you get the System V version,
|
||||
which removes the given signal from the process's signal mask; otherwise
|
||||
you get the BSD version, which sets the process's signal mask to the given
|
||||
value. */
|
||||
#if __XSI_VISIBLE && !defined(__INSIDE_CYGWIN__)
|
||||
# ifdef __GNUC__
|
||||
int _EXFUN(sigpause, (int)) __asm__ (__ASMNAME ("__xpg_sigpause"));
|
||||
# else
|
||||
int _EXFUN(__xpg_sigpause, (int));
|
||||
# define sigpause __xpg_sigpause
|
||||
# endif
|
||||
#elif __BSD_VISIBLE
|
||||
int _EXFUN(sigpause, (int));
|
||||
#endif
|
||||
|
||||
#if __BSD_VISIBLE || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809
|
||||
int _EXFUN(sigaltstack, (const stack_t *__restrict, stack_t *__restrict));
|
||||
#endif
|
||||
|
||||
#if defined(_POSIX_THREADS)
|
||||
#if __POSIX_VISIBLE >= 199506
|
||||
int _EXFUN(pthread_kill, (pthread_t thread, int sig));
|
||||
#endif
|
||||
|
||||
#if defined(_POSIX_REALTIME_SIGNALS)
|
||||
#if __POSIX_VISIBLE >= 199309
|
||||
|
||||
/* 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76
|
||||
NOTE: P1003.1c/D10, p. 39 adds sigwait(). */
|
||||
|
@ -211,12 +237,10 @@ int _EXFUN(sigwaitinfo, (const sigset_t *set, siginfo_t *info));
|
|||
int _EXFUN(sigtimedwait,
|
||||
(const sigset_t *set, siginfo_t *info, const struct timespec *timeout)
|
||||
);
|
||||
int _EXFUN(sigwait, (const sigset_t *set, int *sig));
|
||||
|
||||
/* 3.3.9 Queue a Signal to a Process, P1003.1b-1993, p. 78 */
|
||||
int _EXFUN(sigqueue, (pid_t pid, int signo, const union sigval value));
|
||||
|
||||
#endif /* defined(_POSIX_REALTIME_SIGNALS) */
|
||||
#endif /* __POSIX_VISIBLE >= 199309 */
|
||||
|
||||
#if defined(___AM29K__)
|
||||
/* These all need to be defined for ANSI C, but I don't think they are
|
||||
|
|
|
@ -207,15 +207,21 @@ int _EXFUN(setuid, (uid_t __uid ));
|
|||
void _EXFUN(setusershell, (void));
|
||||
#endif
|
||||
unsigned _EXFUN(sleep, (unsigned int __seconds ));
|
||||
#if __XSI_VISIBLE
|
||||
void _EXFUN(swab, (const void *__restrict, void *__restrict, ssize_t));
|
||||
#endif
|
||||
long _EXFUN(sysconf, (int __name ));
|
||||
pid_t _EXFUN(tcgetpgrp, (int __fildes ));
|
||||
int _EXFUN(tcsetpgrp, (int __fildes, pid_t __pgrp_id ));
|
||||
char * _EXFUN(ttyname, (int __fildes ));
|
||||
int _EXFUN(ttyname_r, (int, char *, size_t));
|
||||
int _EXFUN(ttyname_r, (int, char *, size_t));
|
||||
int _EXFUN(unlink, (const char *__path ));
|
||||
#if __XSI_VISIBLE >= 500 && __POSIX_VISIBLE < 200809 || __BSD_VISIBLE
|
||||
int _EXFUN(usleep, (useconds_t __useconds));
|
||||
#endif
|
||||
#if __BSD_VISIBLE
|
||||
int _EXFUN(vhangup, (void ));
|
||||
#endif
|
||||
_READ_WRITE_RETURN_TYPE _EXFUN(write, (int __fd, const void *__buf, size_t __nbyte ));
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
|
@ -252,25 +258,34 @@ _READ_WRITE_RETURN_TYPE _EXFUN(_write, (int __fd, const void *__buf, size_t __nb
|
|||
int _EXFUN(_execve, (const char *__path, char * const __argv[], char * const __envp[] ));
|
||||
#endif
|
||||
|
||||
#if defined(__CYGWIN__) || defined(__rtems__) || defined(__aarch64__) || defined (__arm__) || defined(__sh__) || defined(__SPU__)
|
||||
#if !defined(__INSIDE_CYGWIN__)
|
||||
#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 500
|
||||
int _EXFUN(ftruncate, (int __fd, off_t __length));
|
||||
#endif
|
||||
#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 500
|
||||
int _EXFUN(truncate, (const char *, off_t __length));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__CYGWIN__) || defined(__rtems__)
|
||||
#if __BSD_VISIBLE || __POSIX_VISIBLE < 200112
|
||||
int _EXFUN(getdtablesize, (void));
|
||||
int _EXFUN(setdtablesize, (int));
|
||||
#endif
|
||||
#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 500
|
||||
useconds_t _EXFUN(ualarm, (useconds_t __useconds, useconds_t __interval));
|
||||
#endif
|
||||
|
||||
#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 500
|
||||
#if !(defined (_WINSOCK_H) || defined (_WINSOCKAPI_) || defined (__USE_W32_SOCKETS))
|
||||
/* winsock[2].h defines as __stdcall, and with int as 2nd arg */
|
||||
int _EXFUN(gethostname, (char *__name, size_t __len));
|
||||
#endif
|
||||
char * _EXFUN(mktemp, (char *));
|
||||
#endif
|
||||
|
||||
#if defined(__CYGWIN__) || defined(__SPU__) || defined(__rtems__)
|
||||
#if __MISC_VISIBLE
|
||||
int _EXFUN(setdtablesize, (int));
|
||||
#endif
|
||||
|
||||
#if __BSD_VISIBLE || __XSI_VISIBLE >= 500
|
||||
void _EXFUN(sync, (void));
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,167 +1,140 @@
|
|||
/* memcmp - compare memory
|
||||
|
||||
Copyright (c) 2013, Linaro Limited
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Linaro nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
/*
|
||||
* Copyright (c) 2017 ARM Ltd
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the company may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED))
|
||||
/* See memcmp-stub.c */
|
||||
#else
|
||||
|
||||
/* Assumptions:
|
||||
*
|
||||
* ARMv8-a, AArch64
|
||||
* ARMv8-a, AArch64, unaligned accesses.
|
||||
*/
|
||||
|
||||
.macro def_fn f p2align=0
|
||||
.text
|
||||
.p2align \p2align
|
||||
.global \f
|
||||
.type \f, %function
|
||||
\f:
|
||||
.endm
|
||||
|
||||
/* Parameters and result. */
|
||||
#define src1 x0
|
||||
#define src2 x1
|
||||
#define limit x2
|
||||
#define result x0
|
||||
#define result w0
|
||||
|
||||
/* Internal variables. */
|
||||
#define data1 x3
|
||||
#define data1w w3
|
||||
#define data2 x4
|
||||
#define data2w w4
|
||||
#define has_nul x5
|
||||
#define diff x6
|
||||
#define endloop x7
|
||||
#define tmp1 x8
|
||||
#define tmp2 x9
|
||||
#define tmp3 x10
|
||||
#define pos x11
|
||||
#define limit_wd x12
|
||||
#define mask x13
|
||||
#define tmp1 x5
|
||||
|
||||
.macro def_fn f p2align=0
|
||||
.text
|
||||
.p2align \p2align
|
||||
.global \f
|
||||
.type \f, %function
|
||||
\f:
|
||||
.endm
|
||||
|
||||
/* Small inputs of less than 8 bytes are handled separately. This allows the
|
||||
main code to be sped up using unaligned loads since there are now at least
|
||||
8 bytes to be compared. If the first 8 bytes are equal, align src1.
|
||||
This ensures each iteration does at most one unaligned access even if both
|
||||
src1 and src2 are unaligned, and mutually aligned inputs behave as if
|
||||
aligned. After the main loop, process the last 8 bytes using unaligned
|
||||
accesses. */
|
||||
|
||||
def_fn memcmp p2align=6
|
||||
cbz limit, .Lret0
|
||||
eor tmp1, src1, src2
|
||||
tst tmp1, #7
|
||||
b.ne .Lmisaligned8
|
||||
ands tmp1, src1, #7
|
||||
b.ne .Lmutual_align
|
||||
add limit_wd, limit, #7
|
||||
lsr limit_wd, limit_wd, #3
|
||||
/* Start of performance-critical section -- one 64B cache line. */
|
||||
.Lloop_aligned:
|
||||
ldr data1, [src1], #8
|
||||
ldr data2, [src2], #8
|
||||
.Lstart_realigned:
|
||||
subs limit_wd, limit_wd, #1
|
||||
eor diff, data1, data2 /* Non-zero if differences found. */
|
||||
csinv endloop, diff, xzr, ne /* Last Dword or differences. */
|
||||
cbz endloop, .Lloop_aligned
|
||||
/* End of performance-critical section -- one 64B cache line. */
|
||||
subs limit, limit, 8
|
||||
b.lo .Lless8
|
||||
|
||||
/* Not reached the limit, must have found a diff. */
|
||||
cbnz limit_wd, .Lnot_limit
|
||||
/* Limit >= 8, so check first 8 bytes using unaligned loads. */
|
||||
ldr data1, [src1], 8
|
||||
ldr data2, [src2], 8
|
||||
and tmp1, src1, 7
|
||||
add limit, limit, tmp1
|
||||
cmp data1, data2
|
||||
bne .Lreturn
|
||||
|
||||
/* Limit % 8 == 0 => all bytes significant. */
|
||||
ands limit, limit, #7
|
||||
b.eq .Lnot_limit
|
||||
/* Align src1 and adjust src2 with bytes not yet done. */
|
||||
sub src1, src1, tmp1
|
||||
sub src2, src2, tmp1
|
||||
|
||||
lsl limit, limit, #3 /* Bits -> bytes. */
|
||||
mov mask, #~0
|
||||
#ifdef __AARCH64EB__
|
||||
lsr mask, mask, limit
|
||||
#else
|
||||
lsl mask, mask, limit
|
||||
#endif
|
||||
bic data1, data1, mask
|
||||
bic data2, data2, mask
|
||||
subs limit, limit, 8
|
||||
b.ls .Llast_bytes
|
||||
|
||||
orr diff, diff, mask
|
||||
.Lnot_limit:
|
||||
/* Loop performing 8 bytes per iteration using aligned src1.
|
||||
Limit is pre-decremented by 8 and must be larger than zero.
|
||||
Exit if <= 8 bytes left to do or if the data is not equal. */
|
||||
.p2align 4
|
||||
.Lloop8:
|
||||
ldr data1, [src1], 8
|
||||
ldr data2, [src2], 8
|
||||
subs limit, limit, 8
|
||||
ccmp data1, data2, 0, hi /* NZCV = 0b0000. */
|
||||
b.eq .Lloop8
|
||||
|
||||
#ifndef __AARCH64EB__
|
||||
rev diff, diff
|
||||
cmp data1, data2
|
||||
bne .Lreturn
|
||||
|
||||
/* Compare last 1-8 bytes using unaligned access. */
|
||||
.Llast_bytes:
|
||||
ldr data1, [src1, limit]
|
||||
ldr data2, [src2, limit]
|
||||
|
||||
/* Compare data bytes and set return value to 0, -1 or 1. */
|
||||
.Lreturn:
|
||||
#ifndef __AARCH64EB__
|
||||
rev data1, data1
|
||||
rev data2, data2
|
||||
#endif
|
||||
/* The MS-non-zero bit of DIFF marks either the first bit
|
||||
that is different, or the end of the significant data.
|
||||
Shifting left now will bring the critical information into the
|
||||
top bits. */
|
||||
clz pos, diff
|
||||
lsl data1, data1, pos
|
||||
lsl data2, data2, pos
|
||||
/* But we need to zero-extend (char is unsigned) the value and then
|
||||
perform a signed 32-bit subtraction. */
|
||||
lsr data1, data1, #56
|
||||
sub result, data1, data2, lsr #56
|
||||
cmp data1, data2
|
||||
.Lret_eq:
|
||||
cset result, ne
|
||||
cneg result, result, lo
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
/* Compare up to 8 bytes. Limit is [-8..-1]. */
|
||||
.Lless8:
|
||||
adds limit, limit, 4
|
||||
b.lo .Lless4
|
||||
ldr data1w, [src1], 4
|
||||
ldr data2w, [src2], 4
|
||||
cmp data1w, data2w
|
||||
b.ne .Lreturn
|
||||
sub limit, limit, 4
|
||||
.Lless4:
|
||||
adds limit, limit, 4
|
||||
beq .Lret_eq
|
||||
.Lbyte_loop:
|
||||
ldrb data1w, [src1], 1
|
||||
ldrb data2w, [src2], 1
|
||||
subs limit, limit, 1
|
||||
ccmp data1w, data2w, 0, ne /* NZCV = 0b0000. */
|
||||
b.eq .Lbyte_loop
|
||||
sub result, data1w, data2w
|
||||
ret
|
||||
|
||||
.Lmutual_align:
|
||||
/* Sources are mutually aligned, but are not currently at an
|
||||
alignment boundary. Round down the addresses and then mask off
|
||||
the bytes that precede the start point. */
|
||||
bic src1, src1, #7
|
||||
bic src2, src2, #7
|
||||
add limit, limit, tmp1 /* Adjust the limit for the extra. */
|
||||
lsl tmp1, tmp1, #3 /* Bytes beyond alignment -> bits. */
|
||||
ldr data1, [src1], #8
|
||||
neg tmp1, tmp1 /* Bits to alignment -64. */
|
||||
ldr data2, [src2], #8
|
||||
mov tmp2, #~0
|
||||
#ifdef __AARCH64EB__
|
||||
/* Big-endian. Early bytes are at MSB. */
|
||||
lsl tmp2, tmp2, tmp1 /* Shift (tmp1 & 63). */
|
||||
#else
|
||||
/* Little-endian. Early bytes are at LSB. */
|
||||
lsr tmp2, tmp2, tmp1 /* Shift (tmp1 & 63). */
|
||||
.size memcmp, . - memcmp
|
||||
#endif
|
||||
add limit_wd, limit, #7
|
||||
orr data1, data1, tmp2
|
||||
orr data2, data2, tmp2
|
||||
lsr limit_wd, limit_wd, #3
|
||||
b .Lstart_realigned
|
||||
|
||||
.Lret0:
|
||||
mov result, #0
|
||||
ret
|
||||
|
||||
.p2align 6
|
||||
.Lmisaligned8:
|
||||
sub limit, limit, #1
|
||||
1:
|
||||
/* Perhaps we can do better than this. */
|
||||
ldrb data1w, [src1], #1
|
||||
ldrb data2w, [src2], #1
|
||||
subs limit, limit, #1
|
||||
ccmp data1w, data2w, #0, cs /* NZCV = 0b0000. */
|
||||
b.eq 1b
|
||||
sub result, data1, data2
|
||||
ret
|
||||
.size memcmp, . - memcmp
|
||||
|
||||
#endif
|
|
@ -8,7 +8,7 @@ AM_CCASFLAGS = $(INCLUDES)
|
|||
|
||||
noinst_LIBRARIES = lib.a
|
||||
|
||||
lib_a_SOURCES = setjmp.S access.c strcmp.S strcpy.c \
|
||||
lib_a_SOURCES = setjmp.S strcmp.S strcpy.c \
|
||||
aeabi_memcpy.c aeabi_memcpy-armv7a.S \
|
||||
aeabi_memmove.c aeabi_memmove-soft.S \
|
||||
aeabi_memset.c aeabi_memset-soft.S aeabi_memclr.c
|
||||
|
|
|
@ -69,9 +69,8 @@ LIBRARIES = $(noinst_LIBRARIES)
|
|||
ARFLAGS = cru
|
||||
lib_a_AR = $(AR) $(ARFLAGS)
|
||||
lib_a_LIBADD =
|
||||
am_lib_a_OBJECTS = lib_a-setjmp.$(OBJEXT) lib_a-access.$(OBJEXT) \
|
||||
lib_a-strcmp.$(OBJEXT) lib_a-strcpy.$(OBJEXT) \
|
||||
lib_a-aeabi_memcpy.$(OBJEXT) \
|
||||
am_lib_a_OBJECTS = lib_a-setjmp.$(OBJEXT) lib_a-strcmp.$(OBJEXT) \
|
||||
lib_a-strcpy.$(OBJEXT) lib_a-aeabi_memcpy.$(OBJEXT) \
|
||||
lib_a-aeabi_memcpy-armv7a.$(OBJEXT) \
|
||||
lib_a-aeabi_memmove.$(OBJEXT) \
|
||||
lib_a-aeabi_memmove-soft.$(OBJEXT) \
|
||||
|
@ -206,7 +205,7 @@ AUTOMAKE_OPTIONS = cygnus
|
|||
INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
|
||||
AM_CCASFLAGS = $(INCLUDES)
|
||||
noinst_LIBRARIES = lib.a
|
||||
lib_a_SOURCES = setjmp.S access.c strcmp.S strcpy.c aeabi_memcpy.c \
|
||||
lib_a_SOURCES = setjmp.S strcmp.S strcpy.c aeabi_memcpy.c \
|
||||
aeabi_memcpy-armv7a.S aeabi_memmove.c aeabi_memmove-soft.S \
|
||||
aeabi_memset.c aeabi_memset-soft.S aeabi_memclr.c \
|
||||
memchr-stub.c memchr.S memcpy-stub.c memcpy.S strlen-stub.c \
|
||||
|
@ -338,12 +337,6 @@ lib_a-strlen.obj: strlen.S
|
|||
.c.obj:
|
||||
$(COMPILE) -c `$(CYGPATH_W) '$<'`
|
||||
|
||||
lib_a-access.o: access.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-access.o `test -f 'access.c' || echo '$(srcdir)/'`access.c
|
||||
|
||||
lib_a-access.obj: access.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-access.obj `if test -f 'access.c'; then $(CYGPATH_W) 'access.c'; else $(CYGPATH_W) '$(srcdir)/access.c'; fi`
|
||||
|
||||
lib_a-strcpy.o: strcpy.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strcpy.o `test -f 'strcpy.c' || echo '$(srcdir)/'`strcpy.c
|
||||
|
||||
|
|
|
@ -135,10 +135,11 @@ memchr:
|
|||
/* Use a simple loop if there are less than 8 bytes to search. */
|
||||
cmp cntin, #7
|
||||
bhi .Llargestr
|
||||
and chrin, chrin, #0xff
|
||||
|
||||
.Lsmallstr:
|
||||
subs cntin, cntin, #1
|
||||
blt .Lnotfound /* Return not found if reached end. */
|
||||
blo .Lnotfound /* Return not found if reached end. */
|
||||
ldrb tmp, [srcin], #1
|
||||
cmp tmp, chrin
|
||||
bne .Lsmallstr /* Loop again if not found. */
|
||||
|
|
|
@ -42,6 +42,7 @@ char* __attribute__((naked))
|
|||
strcpy (char* dst, const char* src)
|
||||
{
|
||||
asm (
|
||||
".syntax unified\n\t"
|
||||
#if !(defined(__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED) || \
|
||||
(defined (__thumb__) && !defined (__thumb2__)))
|
||||
#ifdef _ISA_ARM_7
|
||||
|
@ -127,15 +128,15 @@ strcpy (char* dst, const char* src)
|
|||
#ifdef __ARMEB__
|
||||
"tst r2, #0xff00\n\t"
|
||||
"iteet ne\n\t"
|
||||
"strneh r2, [ip], #2\n\t"
|
||||
"strhne r2, [ip], #2\n\t"
|
||||
"lsreq r2, r2, #8\n\t"
|
||||
"streqb r2, [ip]\n\t"
|
||||
"strbeq r2, [ip]\n\t"
|
||||
"tstne r2, #0xff\n\t"
|
||||
#else
|
||||
"tst r2, #0xff\n\t"
|
||||
"itet ne\n\t"
|
||||
"strneh r2, [ip], #2\n\t"
|
||||
"streqb r2, [ip]\n\t"
|
||||
"strhne r2, [ip], #2\n\t"
|
||||
"strbeq r2, [ip]\n\t"
|
||||
"tstne r2, #0xff00\n\t"
|
||||
#endif
|
||||
"bne 5b\n\t"
|
||||
|
@ -159,12 +160,12 @@ strcpy (char* dst, const char* src)
|
|||
"bne 1b\n\t"
|
||||
"bx lr\n\t"
|
||||
#else
|
||||
"mov r3, r0\n\t"
|
||||
"movs r3, r0\n\t"
|
||||
"1:\n\t"
|
||||
"ldrb r2, [r1]\n\t"
|
||||
"add r1, r1, #1\n\t"
|
||||
"adds r1, #1\n\t"
|
||||
"strb r2, [r3]\n\t"
|
||||
"add r3, r3, #1\n\t"
|
||||
"adds r3, #1\n\t"
|
||||
"cmp r2, #0\n\t"
|
||||
"bne 1b\n\t"
|
||||
"bx lr\n\t"
|
||||
|
|
|
@ -813,6 +813,7 @@ m88k
|
|||
mep
|
||||
microblaze
|
||||
mips
|
||||
riscv
|
||||
mn10200
|
||||
mn10300
|
||||
moxie
|
||||
|
@ -11888,6 +11889,8 @@ subdirs="$subdirs a29k"
|
|||
microblaze ) subdirs="$subdirs microblaze"
|
||||
;;
|
||||
mips) subdirs="$subdirs mips"
|
||||
;;
|
||||
riscv) subdirs="$subdirs riscv"
|
||||
;;
|
||||
mn10200) subdirs="$subdirs mn10200"
|
||||
;;
|
||||
|
|
|
@ -52,6 +52,7 @@ if test -n "${machine_dir}"; then
|
|||
mep ) AC_CONFIG_SUBDIRS(mep) ;;
|
||||
microblaze ) AC_CONFIG_SUBDIRS(microblaze) ;;
|
||||
mips) AC_CONFIG_SUBDIRS(mips) ;;
|
||||
riscv) AC_CONFIG_SUBDIRS(riscv) ;;
|
||||
mn10200) AC_CONFIG_SUBDIRS(mn10200) ;;
|
||||
mn10300) AC_CONFIG_SUBDIRS(mn10300) ;;
|
||||
moxie) AC_CONFIG_SUBDIRS(moxie) ;;
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
## Process this file with automake to generate Makefile.in
|
||||
|
||||
AUTOMAKE_OPTIONS = cygnus
|
||||
|
||||
INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
|
||||
|
||||
AM_CCASFLAGS = $(INCLUDES)
|
||||
|
||||
noinst_LIBRARIES = lib.a
|
||||
|
||||
lib_a_SOURCES = memset.S memcpy.c strlen.c strcpy.c strcmp.S setjmp.S ieeefp.c ffs.c
|
||||
lib_a_CCASFLAGS=$(AM_CCASFLAGS)
|
||||
lib_a_CFLAGS=$(AM_CFLAGS)
|
||||
|
||||
ACLOCAL_AMFLAGS = -I ../../.. -I ../../../..
|
||||
CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
|
|
@ -0,0 +1,491 @@
|
|||
# Makefile.in generated by automake 1.11.6 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
|
||||
# Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
VPATH = @srcdir@
|
||||
am__make_dryrun = \
|
||||
{ \
|
||||
am__dry=no; \
|
||||
case $$MAKEFLAGS in \
|
||||
*\\[\ \ ]*) \
|
||||
echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
|
||||
| grep '^AM OK$$' >/dev/null || am__dry=yes;; \
|
||||
*) \
|
||||
for am__flg in $$MAKEFLAGS; do \
|
||||
case $$am__flg in \
|
||||
*=*|--*) ;; \
|
||||
*n*) am__dry=yes; break;; \
|
||||
esac; \
|
||||
done;; \
|
||||
esac; \
|
||||
test $$am__dry = yes; \
|
||||
}
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkglibexecdir = $(libexecdir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
subdir = .
|
||||
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
|
||||
$(top_srcdir)/configure $(am__configure_deps) \
|
||||
$(srcdir)/../../../../mkinstalldirs
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/../../../acinclude.m4 \
|
||||
$(top_srcdir)/configure.in
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
|
||||
configure.lineno config.status.lineno
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/../../../../mkinstalldirs
|
||||
CONFIG_CLEAN_FILES =
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
LIBRARIES = $(noinst_LIBRARIES)
|
||||
ARFLAGS = cru
|
||||
lib_a_AR = $(AR) $(ARFLAGS)
|
||||
lib_a_LIBADD =
|
||||
am_lib_a_OBJECTS = lib_a-memset.$(OBJEXT) lib_a-memcpy.$(OBJEXT) \
|
||||
lib_a-strlen.$(OBJEXT) lib_a-strcpy.$(OBJEXT) \
|
||||
lib_a-strcmp.$(OBJEXT) lib_a-setjmp.$(OBJEXT) \
|
||||
lib_a-ieeefp.$(OBJEXT) lib_a-ffs.$(OBJEXT)
|
||||
lib_a_OBJECTS = $(am_lib_a_OBJECTS)
|
||||
DEFAULT_INCLUDES = -I.@am__isrc@
|
||||
depcomp =
|
||||
am__depfiles_maybe =
|
||||
CPPASCOMPILE = $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
|
||||
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS)
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
CCLD = $(CC)
|
||||
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
SOURCES = $(lib_a_SOURCES)
|
||||
am__can_run_installinfo = \
|
||||
case $$AM_UPDATE_INFO_DIR in \
|
||||
n|no|NO) false;; \
|
||||
*) (install-info --version) >/dev/null 2>&1;; \
|
||||
esac
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AR = @AR@
|
||||
AS = @AS@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCAS = @CCAS@
|
||||
CCASFLAGS = @CCASFLAGS@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NEWLIB_CFLAGS = @NEWLIB_CFLAGS@
|
||||
NO_INCLUDE_LIST = @NO_INCLUDE_LIST@
|
||||
OBJEXT = @OBJEXT@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_URL = @PACKAGE_URL@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
RANLIB = @RANLIB@
|
||||
READELF = @READELF@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
STRIP = @STRIP@
|
||||
VERSION = @VERSION@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
aext = @aext@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
am__tar = @am__tar@
|
||||
am__untar = @am__untar@
|
||||
bindir = @bindir@
|
||||
build = @build@
|
||||
build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
builddir = @builddir@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
exec_prefix = @exec_prefix@
|
||||
host = @host@
|
||||
host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
htmldir = @htmldir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
libm_machine_dir = @libm_machine_dir@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
lpfx = @lpfx@
|
||||
machine_dir = @machine_dir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
newlib_basedir = @newlib_basedir@
|
||||
oext = @oext@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
sys_dir = @sys_dir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
AUTOMAKE_OPTIONS = cygnus
|
||||
INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
|
||||
AM_CCASFLAGS = $(INCLUDES)
|
||||
noinst_LIBRARIES = lib.a
|
||||
lib_a_SOURCES = memset.S memcpy.c strlen.c strcpy.c strcmp.S setjmp.S ieeefp.c ffs.c
|
||||
lib_a_CCASFLAGS = $(AM_CCASFLAGS)
|
||||
lib_a_CFLAGS = $(AM_CFLAGS)
|
||||
ACLOCAL_AMFLAGS = -I ../../.. -I ../../../..
|
||||
CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .S .c .o .obj
|
||||
am--refresh: Makefile
|
||||
@:
|
||||
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
echo ' cd $(srcdir) && $(AUTOMAKE) --cygnus'; \
|
||||
$(am__cd) $(srcdir) && $(AUTOMAKE) --cygnus \
|
||||
&& exit 0; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --cygnus Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --cygnus Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
echo ' $(SHELL) ./config.status'; \
|
||||
$(SHELL) ./config.status;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
$(SHELL) ./config.status --recheck
|
||||
|
||||
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
|
||||
$(am__cd) $(srcdir) && $(AUTOCONF)
|
||||
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
|
||||
$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
|
||||
$(am__aclocal_m4_deps):
|
||||
|
||||
clean-noinstLIBRARIES:
|
||||
-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
|
||||
lib.a: $(lib_a_OBJECTS) $(lib_a_DEPENDENCIES) $(EXTRA_lib_a_DEPENDENCIES)
|
||||
-rm -f lib.a
|
||||
$(lib_a_AR) lib.a $(lib_a_OBJECTS) $(lib_a_LIBADD)
|
||||
$(RANLIB) lib.a
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
.S.o:
|
||||
$(CPPASCOMPILE) -c -o $@ $<
|
||||
|
||||
.S.obj:
|
||||
$(CPPASCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
|
||||
|
||||
lib_a-memset.o: memset.S
|
||||
$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-memset.o `test -f 'memset.S' || echo '$(srcdir)/'`memset.S
|
||||
|
||||
lib_a-memset.obj: memset.S
|
||||
$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-memset.obj `if test -f 'memset.S'; then $(CYGPATH_W) 'memset.S'; else $(CYGPATH_W) '$(srcdir)/memset.S'; fi`
|
||||
|
||||
lib_a-strcmp.o: strcmp.S
|
||||
$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-strcmp.o `test -f 'strcmp.S' || echo '$(srcdir)/'`strcmp.S
|
||||
|
||||
lib_a-strcmp.obj: strcmp.S
|
||||
$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-strcmp.obj `if test -f 'strcmp.S'; then $(CYGPATH_W) 'strcmp.S'; else $(CYGPATH_W) '$(srcdir)/strcmp.S'; fi`
|
||||
|
||||
lib_a-setjmp.o: setjmp.S
|
||||
$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-setjmp.o `test -f 'setjmp.S' || echo '$(srcdir)/'`setjmp.S
|
||||
|
||||
lib_a-setjmp.obj: setjmp.S
|
||||
$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-setjmp.obj `if test -f 'setjmp.S'; then $(CYGPATH_W) 'setjmp.S'; else $(CYGPATH_W) '$(srcdir)/setjmp.S'; fi`
|
||||
|
||||
.c.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
.c.obj:
|
||||
$(COMPILE) -c `$(CYGPATH_W) '$<'`
|
||||
|
||||
lib_a-memcpy.o: memcpy.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-memcpy.o `test -f 'memcpy.c' || echo '$(srcdir)/'`memcpy.c
|
||||
|
||||
lib_a-memcpy.obj: memcpy.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-memcpy.obj `if test -f 'memcpy.c'; then $(CYGPATH_W) 'memcpy.c'; else $(CYGPATH_W) '$(srcdir)/memcpy.c'; fi`
|
||||
|
||||
lib_a-strlen.o: strlen.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strlen.o `test -f 'strlen.c' || echo '$(srcdir)/'`strlen.c
|
||||
|
||||
lib_a-strlen.obj: strlen.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strlen.obj `if test -f 'strlen.c'; then $(CYGPATH_W) 'strlen.c'; else $(CYGPATH_W) '$(srcdir)/strlen.c'; fi`
|
||||
|
||||
lib_a-strcpy.o: strcpy.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strcpy.o `test -f 'strcpy.c' || echo '$(srcdir)/'`strcpy.c
|
||||
|
||||
lib_a-strcpy.obj: strcpy.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strcpy.obj `if test -f 'strcpy.c'; then $(CYGPATH_W) 'strcpy.c'; else $(CYGPATH_W) '$(srcdir)/strcpy.c'; fi`
|
||||
|
||||
lib_a-ieeefp.o: ieeefp.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ieeefp.o `test -f 'ieeefp.c' || echo '$(srcdir)/'`ieeefp.c
|
||||
|
||||
lib_a-ieeefp.obj: ieeefp.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ieeefp.obj `if test -f 'ieeefp.c'; then $(CYGPATH_W) 'ieeefp.c'; else $(CYGPATH_W) '$(srcdir)/ieeefp.c'; fi`
|
||||
|
||||
lib_a-ffs.o: ffs.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ffs.o `test -f 'ffs.c' || echo '$(srcdir)/'`ffs.c
|
||||
|
||||
lib_a-ffs.obj: ffs.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ffs.obj `if test -f 'ffs.c'; then $(CYGPATH_W) 'ffs.c'; else $(CYGPATH_W) '$(srcdir)/ffs.c'; fi`
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
mkid -fID $$unique
|
||||
tags: TAGS
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
set x; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
shift; \
|
||||
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
if test $$# -gt 0; then \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
"$$@" $$unique; \
|
||||
else \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$unique; \
|
||||
fi; \
|
||||
fi
|
||||
ctags: CTAGS
|
||||
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
test -z "$(CTAGS_ARGS)$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& $(am__cd) $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) "$$here"
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
check-am:
|
||||
check: check-am
|
||||
all-am: Makefile $(LIBRARIES)
|
||||
installdirs:
|
||||
install: install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
|
||||
installcheck: installcheck-am
|
||||
install-strip:
|
||||
if test -z '$(STRIP)'; then \
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
install; \
|
||||
else \
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
|
||||
fi
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-tags
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-am
|
||||
|
||||
html-am:
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am:
|
||||
|
||||
install-dvi: install-dvi-am
|
||||
|
||||
install-dvi-am:
|
||||
|
||||
install-exec-am:
|
||||
|
||||
install-html: install-html-am
|
||||
|
||||
install-html-am:
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-info-am:
|
||||
|
||||
install-man:
|
||||
|
||||
install-pdf: install-pdf-am
|
||||
|
||||
install-pdf-am:
|
||||
|
||||
install-ps: install-ps-am
|
||||
|
||||
install-ps-am:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
|
||||
-rm -rf $(top_srcdir)/autom4te.cache
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
mostlyclean-am: mostlyclean-compile mostlyclean-generic
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am:
|
||||
|
||||
.MAKE: install-am install-strip
|
||||
|
||||
.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \
|
||||
clean-generic clean-noinstLIBRARIES ctags distclean \
|
||||
distclean-compile distclean-generic distclean-tags dvi dvi-am \
|
||||
html html-am info info-am install install-am install-data \
|
||||
install-data-am install-dvi install-dvi-am install-exec \
|
||||
install-exec-am install-html install-html-am install-info \
|
||||
install-info-am install-man install-pdf install-pdf-am \
|
||||
install-ps install-ps-am install-strip installcheck \
|
||||
installcheck-am installdirs maintainer-clean \
|
||||
maintainer-clean-generic mostlyclean mostlyclean-compile \
|
||||
mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
|
||||
uninstall-am
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,14 @@
|
|||
dnl This is the newlib/libc/machine/mips configure.in file.
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ(2.59)
|
||||
AC_INIT([newlib],[NEWLIB_VERSION])
|
||||
AC_CONFIG_SRCDIR([memset.S])
|
||||
|
||||
dnl Can't be done in NEWLIB_CONFIGURE because that confuses automake.
|
||||
AC_CONFIG_AUX_DIR(../../../..)
|
||||
|
||||
NEWLIB_CONFIGURE(../../..)
|
||||
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
AC_OUTPUT
|
|
@ -0,0 +1,32 @@
|
|||
/* Copyright (c) 2017 SiFive Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use,
|
||||
modify, copy, or redistribute it subject to the terms and conditions
|
||||
of the BSD License. This program is distributed in the hope that
|
||||
it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
|
||||
including the implied warranties of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. A copy of this license is available at
|
||||
http://www.opensource.org/licenses.
|
||||
*/
|
||||
#include <strings.h>
|
||||
|
||||
int
|
||||
ffs (int word)
|
||||
{
|
||||
#if __riscv_xlen == 32
|
||||
return (__builtin_ffs (word));
|
||||
#else
|
||||
int i;
|
||||
|
||||
if (!word)
|
||||
return 0;
|
||||
|
||||
i = 0;
|
||||
for (;;)
|
||||
{
|
||||
if (((1 << i++) & word) != 0)
|
||||
return i;
|
||||
}
|
||||
return 0;
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
/* Copyright (c) 2017 SiFive Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use,
|
||||
modify, copy, or redistribute it subject to the terms and conditions
|
||||
of the BSD License. This program is distributed in the hope that
|
||||
it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
|
||||
including the implied warranties of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. A copy of this license is available at
|
||||
http://www.opensource.org/licenses.
|
||||
*/
|
||||
|
||||
#include <ieeefp.h>
|
||||
|
||||
#ifdef __riscv_flen
|
||||
static void
|
||||
fssr(unsigned value)
|
||||
{
|
||||
asm volatile ("fssr %0" :: "r"(value));
|
||||
}
|
||||
|
||||
static unsigned
|
||||
frsr()
|
||||
{
|
||||
unsigned value;
|
||||
asm volatile ("frsr %0" : "=r" (value));
|
||||
return value;
|
||||
}
|
||||
|
||||
static fp_rnd
|
||||
frm_fp_rnd (unsigned frm)
|
||||
{
|
||||
switch (frm)
|
||||
{
|
||||
case 0: return FP_RN;
|
||||
case 1: return FP_RZ;
|
||||
case 2: return FP_RM;
|
||||
case 3: return FP_RP;
|
||||
/* 4 ~ 7 is invalid value, so just retun FP_RP. */
|
||||
default:return FP_RP;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* __riscv_flen */
|
||||
|
||||
fp_except
|
||||
fpgetmask(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
fp_rnd
|
||||
fpgetround(void)
|
||||
{
|
||||
#ifdef __riscv_flen
|
||||
unsigned rm = (frsr () >> 5) & 0x7;
|
||||
return frm_fp_rnd (rm);
|
||||
#else
|
||||
return FP_RZ;
|
||||
#endif /* __riscv_flen */
|
||||
}
|
||||
|
||||
fp_except
|
||||
fpgetsticky(void)
|
||||
{
|
||||
#ifdef __riscv_flen
|
||||
return frsr () & 0x1f;
|
||||
#else
|
||||
return 0;
|
||||
#endif /* __riscv_flen */
|
||||
}
|
||||
|
||||
fp_except
|
||||
fpsetmask(fp_except mask)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
fp_rnd
|
||||
fpsetround(fp_rnd rnd_dir)
|
||||
{
|
||||
#ifdef __riscv_flen
|
||||
unsigned fsr = frsr ();
|
||||
unsigned rm = (fsr >> 5) & 0x7;
|
||||
unsigned new_rm;
|
||||
switch (rnd_dir)
|
||||
{
|
||||
case FP_RN: new_rm = 0;
|
||||
case FP_RZ: new_rm = 1;
|
||||
case FP_RM: new_rm = 2;
|
||||
case FP_RP: new_rm = 3;
|
||||
default: return -1;
|
||||
}
|
||||
fssr (new_rm << 5 | fsr & 0x1f);
|
||||
return frm_fp_rnd (rm);
|
||||
#else
|
||||
return -1;
|
||||
#endif /* __riscv_flen */
|
||||
}
|
||||
|
||||
fp_except
|
||||
fpsetsticky(fp_except sticky)
|
||||
{
|
||||
#ifdef __riscv_flen
|
||||
unsigned fsr = frsr ();
|
||||
fssr (sticky & 0x1f | fsr & ~0x1f);
|
||||
return fsr & 0x1f;
|
||||
#else
|
||||
return -1;
|
||||
#endif /* __riscv_flen */
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/* Copyright (c) 2017 SiFive Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use,
|
||||
modify, copy, or redistribute it subject to the terms and conditions
|
||||
of the BSD License. This program is distributed in the hope that
|
||||
it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
|
||||
including the implied warranties of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. A copy of this license is available at
|
||||
http://www.opensource.org/licenses.
|
||||
*/
|
||||
|
||||
#ifndef _FENV_H
|
||||
#define _FENV_H
|
||||
|
||||
#include <sys/fenv.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exception */
|
||||
int feclearexcept(int excepts);
|
||||
int fegetexceptflag(fexcept_t *flagp, int excepts);
|
||||
int feraiseexcept(int excepts);
|
||||
int fesetexceptflag(const fexcept_t *flagp, int excepts);
|
||||
int fetestexcept(int excepts);
|
||||
|
||||
/* Rounding mode */
|
||||
int fegetround(void);
|
||||
int fesetround(int rounding_mode);
|
||||
|
||||
/* Float environment */
|
||||
int fegetenv(fenv_t *envp);
|
||||
int feholdexcept(fenv_t *envp);
|
||||
int fesetenv(const fenv_t *envp);
|
||||
int feupdateenv(const fenv_t *envp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,81 @@
|
|||
/* Copyright (c) 2017 SiFive Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use,
|
||||
modify, copy, or redistribute it subject to the terms and conditions
|
||||
of the BSD License. This program is distributed in the hope that
|
||||
it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
|
||||
including the implied warranties of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. A copy of this license is available at
|
||||
http://www.opensource.org/licenses.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define unlikely(X) __builtin_expect (!!(X), 0)
|
||||
|
||||
void *
|
||||
memcpy(void *__restrict aa, const void *__restrict bb, size_t n)
|
||||
{
|
||||
#define BODY(a, b, t) { \
|
||||
t tt = *b; \
|
||||
a++, b++; \
|
||||
*(a - 1) = tt; \
|
||||
}
|
||||
|
||||
char *a = (char *)aa;
|
||||
const char *b = (const char *)bb;
|
||||
char *end = a + n;
|
||||
uintptr_t msk = sizeof (long) - 1;
|
||||
if (unlikely ((((uintptr_t)a & msk) != ((uintptr_t)b & msk))
|
||||
|| n < sizeof (long)))
|
||||
{
|
||||
small:
|
||||
if (__builtin_expect (a < end, 1))
|
||||
while (a < end)
|
||||
BODY (a, b, char);
|
||||
return aa;
|
||||
}
|
||||
|
||||
if (unlikely (((uintptr_t)a & msk) != 0))
|
||||
while ((uintptr_t)a & msk)
|
||||
BODY (a, b, char);
|
||||
|
||||
long *la = (long *)a;
|
||||
const long *lb = (const long *)b;
|
||||
long *lend = (long *)((uintptr_t)end & ~msk);
|
||||
|
||||
if (unlikely (la < (lend - 8)))
|
||||
{
|
||||
while (la < (lend - 8))
|
||||
{
|
||||
long b0 = *lb++;
|
||||
long b1 = *lb++;
|
||||
long b2 = *lb++;
|
||||
long b3 = *lb++;
|
||||
long b4 = *lb++;
|
||||
long b5 = *lb++;
|
||||
long b6 = *lb++;
|
||||
long b7 = *lb++;
|
||||
long b8 = *lb++;
|
||||
*la++ = b0;
|
||||
*la++ = b1;
|
||||
*la++ = b2;
|
||||
*la++ = b3;
|
||||
*la++ = b4;
|
||||
*la++ = b5;
|
||||
*la++ = b6;
|
||||
*la++ = b7;
|
||||
*la++ = b8;
|
||||
}
|
||||
}
|
||||
|
||||
while (la < lend)
|
||||
BODY (la, lb, long);
|
||||
|
||||
a = (char *)la;
|
||||
b = (const char *)lb;
|
||||
if (unlikely (a < end))
|
||||
goto small;
|
||||
return aa;
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
/* Copyright (c) 2017 SiFive Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use,
|
||||
modify, copy, or redistribute it subject to the terms and conditions
|
||||
of the BSD License. This program is distributed in the hope that
|
||||
it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
|
||||
including the implied warranties of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. A copy of this license is available at
|
||||
http://www.opensource.org/licenses.
|
||||
*/
|
||||
|
||||
.text
|
||||
.global memset
|
||||
.type memset, @function
|
||||
memset:
|
||||
li t1, 15
|
||||
move a4, a0
|
||||
bleu a2, t1, .Ltiny
|
||||
and a5, a4, 15
|
||||
bnez a5, .Lmisaligned
|
||||
|
||||
.Laligned:
|
||||
bnez a1, .Lwordify
|
||||
|
||||
.Lwordified:
|
||||
and a3, a2, ~15
|
||||
and a2, a2, 15
|
||||
add a3, a3, a4
|
||||
|
||||
#if __riscv_xlen == 64
|
||||
1:sd a1, 0(a4)
|
||||
sd a1, 8(a4)
|
||||
#else
|
||||
1:sw a1, 0(a4)
|
||||
sw a1, 4(a4)
|
||||
sw a1, 8(a4)
|
||||
sw a1, 12(a4)
|
||||
#endif
|
||||
add a4, a4, 16
|
||||
bltu a4, a3, 1b
|
||||
|
||||
bnez a2, .Ltiny
|
||||
ret
|
||||
|
||||
.Ltiny:
|
||||
sub a3, t1, a2
|
||||
sll a3, a3, 2
|
||||
1:auipc t0, %pcrel_hi(.Ltable)
|
||||
add a3, a3, t0
|
||||
.option push
|
||||
.option norvc
|
||||
.Ltable_misaligned:
|
||||
jr a3, %pcrel_lo(1b)
|
||||
.Ltable:
|
||||
sb a1,14(a4)
|
||||
sb a1,13(a4)
|
||||
sb a1,12(a4)
|
||||
sb a1,11(a4)
|
||||
sb a1,10(a4)
|
||||
sb a1, 9(a4)
|
||||
sb a1, 8(a4)
|
||||
sb a1, 7(a4)
|
||||
sb a1, 6(a4)
|
||||
sb a1, 5(a4)
|
||||
sb a1, 4(a4)
|
||||
sb a1, 3(a4)
|
||||
sb a1, 2(a4)
|
||||
sb a1, 1(a4)
|
||||
sb a1, 0(a4)
|
||||
.option pop
|
||||
ret
|
||||
|
||||
.Lwordify:
|
||||
and a1, a1, 0xFF
|
||||
sll a3, a1, 8
|
||||
or a1, a1, a3
|
||||
sll a3, a1, 16
|
||||
or a1, a1, a3
|
||||
#if __riscv_xlen == 64
|
||||
sll a3, a1, 32
|
||||
or a1, a1, a3
|
||||
#endif
|
||||
j .Lwordified
|
||||
|
||||
.Lmisaligned:
|
||||
sll a3, a5, 2
|
||||
1:auipc t0, %pcrel_hi(.Ltable_misaligned)
|
||||
add a3, a3, t0
|
||||
mv t0, ra
|
||||
jalr a3, %pcrel_lo(1b)
|
||||
mv ra, t0
|
||||
|
||||
add a5, a5, -16
|
||||
sub a4, a4, a5
|
||||
add a2, a2, a5
|
||||
bleu a2, t1, .Ltiny
|
||||
j .Laligned
|
||||
.size memset, .-memset
|
|
@ -0,0 +1,98 @@
|
|||
/* Copyright (c) 2017 SiFive Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use,
|
||||
modify, copy, or redistribute it subject to the terms and conditions
|
||||
of the BSD License. This program is distributed in the hope that
|
||||
it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
|
||||
including the implied warranties of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. A copy of this license is available at
|
||||
http://www.opensource.org/licenses.
|
||||
*/
|
||||
|
||||
#include <sys/asm.h>
|
||||
|
||||
/* int setjmp (jmp_buf); */
|
||||
.globl setjmp
|
||||
.type setjmp, @function
|
||||
setjmp:
|
||||
REG_S ra, 0*SZREG(a0)
|
||||
REG_S s0, 1*SZREG(a0)
|
||||
REG_S s1, 2*SZREG(a0)
|
||||
|
||||
#ifndef __riscv_32e
|
||||
REG_S s2, 3*SZREG(a0)
|
||||
REG_S s3, 4*SZREG(a0)
|
||||
REG_S s4, 5*SZREG(a0)
|
||||
REG_S s5, 6*SZREG(a0)
|
||||
REG_S s6, 7*SZREG(a0)
|
||||
REG_S s7, 8*SZREG(a0)
|
||||
REG_S s8, 9*SZREG(a0)
|
||||
REG_S s9, 10*SZREG(a0)
|
||||
REG_S s10,11*SZREG(a0)
|
||||
REG_S s11,12*SZREG(a0)
|
||||
REG_S sp, 13*SZREG(a0)
|
||||
#else
|
||||
REG_S sp, 3*SZREG(a0)
|
||||
#endif
|
||||
|
||||
#ifndef __riscv_float_abi_soft
|
||||
FREG_S fs0, 14*SZREG+ 0*SZFREG(a0)
|
||||
FREG_S fs1, 14*SZREG+ 1*SZFREG(a0)
|
||||
FREG_S fs2, 14*SZREG+ 2*SZFREG(a0)
|
||||
FREG_S fs3, 14*SZREG+ 3*SZFREG(a0)
|
||||
FREG_S fs4, 14*SZREG+ 4*SZFREG(a0)
|
||||
FREG_S fs5, 14*SZREG+ 5*SZFREG(a0)
|
||||
FREG_S fs6, 14*SZREG+ 6*SZFREG(a0)
|
||||
FREG_S fs7, 14*SZREG+ 7*SZFREG(a0)
|
||||
FREG_S fs8, 14*SZREG+ 8*SZFREG(a0)
|
||||
FREG_S fs9, 14*SZREG+ 9*SZFREG(a0)
|
||||
FREG_S fs10,14*SZREG+10*SZFREG(a0)
|
||||
FREG_S fs11,14*SZREG+11*SZFREG(a0)
|
||||
#endif
|
||||
|
||||
li a0, 0
|
||||
ret
|
||||
.size setjmp, .-setjmp
|
||||
|
||||
/* volatile void longjmp (jmp_buf, int); */
|
||||
.globl longjmp
|
||||
.type longjmp, @function
|
||||
longjmp:
|
||||
REG_L ra, 0*SZREG(a0)
|
||||
REG_L s0, 1*SZREG(a0)
|
||||
REG_L s1, 2*SZREG(a0)
|
||||
#ifndef __riscv_32e
|
||||
REG_L s2, 3*SZREG(a0)
|
||||
REG_L s3, 4*SZREG(a0)
|
||||
REG_L s4, 5*SZREG(a0)
|
||||
REG_L s5, 6*SZREG(a0)
|
||||
REG_L s6, 7*SZREG(a0)
|
||||
REG_L s7, 8*SZREG(a0)
|
||||
REG_L s8, 9*SZREG(a0)
|
||||
REG_L s9, 10*SZREG(a0)
|
||||
REG_L s10,11*SZREG(a0)
|
||||
REG_L s11,12*SZREG(a0)
|
||||
REG_L sp, 13*SZREG(a0)
|
||||
#else
|
||||
REG_L sp, 3*SZREG(a0)
|
||||
#endif
|
||||
|
||||
#ifndef __riscv_float_abi_soft
|
||||
FREG_L fs0, 14*SZREG+ 0*SZFREG(a0)
|
||||
FREG_L fs1, 14*SZREG+ 1*SZFREG(a0)
|
||||
FREG_L fs2, 14*SZREG+ 2*SZFREG(a0)
|
||||
FREG_L fs3, 14*SZREG+ 3*SZFREG(a0)
|
||||
FREG_L fs4, 14*SZREG+ 4*SZFREG(a0)
|
||||
FREG_L fs5, 14*SZREG+ 5*SZFREG(a0)
|
||||
FREG_L fs6, 14*SZREG+ 6*SZFREG(a0)
|
||||
FREG_L fs7, 14*SZREG+ 7*SZFREG(a0)
|
||||
FREG_L fs8, 14*SZREG+ 8*SZFREG(a0)
|
||||
FREG_L fs9, 14*SZREG+ 9*SZFREG(a0)
|
||||
FREG_L fs10,14*SZREG+10*SZFREG(a0)
|
||||
FREG_L fs11,14*SZREG+11*SZFREG(a0)
|
||||
#endif
|
||||
|
||||
seqz a0, a1
|
||||
add a0, a0, a1 # a0 = (a1 == 0) ? 1 : a1
|
||||
ret
|
||||
.size longjmp, .-longjmp
|
|
@ -0,0 +1,148 @@
|
|||
/* Copyright (c) 2017 SiFive Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use,
|
||||
modify, copy, or redistribute it subject to the terms and conditions
|
||||
of the BSD License. This program is distributed in the hope that
|
||||
it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
|
||||
including the implied warranties of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. A copy of this license is available at
|
||||
http://www.opensource.org/licenses.
|
||||
*/
|
||||
|
||||
#include <sys/asm.h>
|
||||
|
||||
#if BYTE_ORDER != LITTLE_ENDIAN
|
||||
# error
|
||||
#endif
|
||||
|
||||
.text
|
||||
.globl strcmp
|
||||
.type strcmp, @function
|
||||
strcmp:
|
||||
or a4, a0, a1
|
||||
li t2, -1
|
||||
and a4, a4, SZREG-1
|
||||
bnez a4, .Lmisaligned
|
||||
|
||||
#if SZREG == 4
|
||||
li a5, 0x7f7f7f7f
|
||||
#else
|
||||
ld a5, mask
|
||||
#endif
|
||||
|
||||
.macro check_one_word i n
|
||||
REG_L a2, \i*SZREG(a0)
|
||||
REG_L a3, \i*SZREG(a1)
|
||||
|
||||
and t0, a2, a5
|
||||
or t1, a2, a5
|
||||
add t0, t0, a5
|
||||
or t0, t0, t1
|
||||
|
||||
bne t0, t2, .Lnull\i
|
||||
.if \i+1-\n
|
||||
bne a2, a3, .Lmismatch
|
||||
.else
|
||||
add a0, a0, \n*SZREG
|
||||
add a1, a1, \n*SZREG
|
||||
beq a2, a3, .Lloop
|
||||
# fall through to .Lmismatch
|
||||
.endif
|
||||
.endm
|
||||
|
||||
.macro foundnull i n
|
||||
.ifne \i
|
||||
.Lnull\i:
|
||||
add a0, a0, \i*SZREG
|
||||
add a1, a1, \i*SZREG
|
||||
.ifeq \i-1
|
||||
.Lnull0:
|
||||
.endif
|
||||
bne a2, a3, .Lmisaligned
|
||||
li a0, 0
|
||||
ret
|
||||
.endif
|
||||
.endm
|
||||
|
||||
.Lloop:
|
||||
# examine full words at a time, favoring strings of a couple dozen chars
|
||||
#if __riscv_xlen == 32
|
||||
check_one_word 0 5
|
||||
check_one_word 1 5
|
||||
check_one_word 2 5
|
||||
check_one_word 3 5
|
||||
check_one_word 4 5
|
||||
#else
|
||||
check_one_word 0 3
|
||||
check_one_word 1 3
|
||||
check_one_word 2 3
|
||||
#endif
|
||||
# backwards branch to .Lloop contained above
|
||||
|
||||
.Lmismatch:
|
||||
# words don't match, but a2 has no null byte.
|
||||
#if __riscv_xlen == 64
|
||||
sll a4, a2, 48
|
||||
sll a5, a3, 48
|
||||
bne a4, a5, .Lmismatch_upper
|
||||
sll a4, a2, 32
|
||||
sll a5, a3, 32
|
||||
bne a4, a5, .Lmismatch_upper
|
||||
#endif
|
||||
sll a4, a2, 16
|
||||
sll a5, a3, 16
|
||||
bne a4, a5, .Lmismatch_upper
|
||||
|
||||
srl a4, a2, 8*SZREG-16
|
||||
srl a5, a3, 8*SZREG-16
|
||||
sub a0, a4, a5
|
||||
and a1, a0, 0xff
|
||||
bnez a1, 1f
|
||||
ret
|
||||
|
||||
.Lmismatch_upper:
|
||||
srl a4, a4, 8*SZREG-16
|
||||
srl a5, a5, 8*SZREG-16
|
||||
sub a0, a4, a5
|
||||
and a1, a0, 0xff
|
||||
bnez a1, 1f
|
||||
ret
|
||||
|
||||
1:and a4, a4, 0xff
|
||||
and a5, a5, 0xff
|
||||
sub a0, a4, a5
|
||||
ret
|
||||
|
||||
.Lmisaligned:
|
||||
# misaligned
|
||||
lbu a2, 0(a0)
|
||||
lbu a3, 0(a1)
|
||||
add a0, a0, 1
|
||||
add a1, a1, 1
|
||||
bne a2, a3, 1f
|
||||
bnez a2, .Lmisaligned
|
||||
|
||||
1:
|
||||
sub a0, a2, a3
|
||||
ret
|
||||
|
||||
# cases in which a null byte was detected
|
||||
#if __riscv_xlen == 32
|
||||
foundnull 0 5
|
||||
foundnull 1 5
|
||||
foundnull 2 5
|
||||
foundnull 3 5
|
||||
foundnull 4 5
|
||||
#else
|
||||
foundnull 0 3
|
||||
foundnull 1 3
|
||||
foundnull 2 3
|
||||
#endif
|
||||
.size strcmp, .-strcmp
|
||||
|
||||
#if SZREG == 8
|
||||
.section .srodata.cst8,"aM",@progbits,8
|
||||
.align 3
|
||||
mask:
|
||||
.dword 0x7f7f7f7f7f7f7f7f
|
||||
#endif
|
|
@ -0,0 +1,64 @@
|
|||
/* Copyright (c) 2017 SiFive Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use,
|
||||
modify, copy, or redistribute it subject to the terms and conditions
|
||||
of the BSD License. This program is distributed in the hope that
|
||||
it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
|
||||
including the implied warranties of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. A copy of this license is available at
|
||||
http://www.opensource.org/licenses.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
char *strcpy(char *dst, const char *src)
|
||||
{
|
||||
char *dst0 = dst;
|
||||
|
||||
#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__)
|
||||
int misaligned = ((uintptr_t)dst | (uintptr_t)src) & (sizeof (long) - 1);
|
||||
if (__builtin_expect(!misaligned, 1))
|
||||
{
|
||||
long *ldst = (long *)dst;
|
||||
const long *lsrc = (const long *)src;
|
||||
|
||||
while (!__libc_detect_null(*lsrc))
|
||||
*ldst++ = *lsrc++;
|
||||
|
||||
dst = (char *)ldst;
|
||||
src = (const char *)lsrc;
|
||||
|
||||
char c0 = src[0];
|
||||
char c1 = src[1];
|
||||
char c2 = src[2];
|
||||
if (!(*dst++ = c0)) return dst0;
|
||||
if (!(*dst++ = c1)) return dst0;
|
||||
char c3 = src[3];
|
||||
if (!(*dst++ = c2)) return dst0;
|
||||
if (sizeof (long) == 4) goto out;
|
||||
char c4 = src[4];
|
||||
if (!(*dst++ = c3)) return dst0;
|
||||
char c5 = src[5];
|
||||
if (!(*dst++ = c4)) return dst0;
|
||||
char c6 = src[6];
|
||||
if (!(*dst++ = c5)) return dst0;
|
||||
if (!(*dst++ = c6)) return dst0;
|
||||
|
||||
out:
|
||||
*dst++ = 0;
|
||||
return dst0;
|
||||
}
|
||||
#endif /* not PREFER_SIZE_OVER_SPEED */
|
||||
|
||||
char ch;
|
||||
do
|
||||
{
|
||||
ch = *src;
|
||||
src++;
|
||||
dst++;
|
||||
*(dst - 1) = ch;
|
||||
} while (ch);
|
||||
|
||||
return dst0;
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/* Copyright (c) 2017 SiFive Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use,
|
||||
modify, copy, or redistribute it subject to the terms and conditions
|
||||
of the BSD License. This program is distributed in the hope that
|
||||
it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
|
||||
including the implied warranties of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. A copy of this license is available at
|
||||
http://www.opensource.org/licenses.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
size_t strlen(const char *str)
|
||||
{
|
||||
const char *start = str;
|
||||
|
||||
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__)
|
||||
while (*str++)
|
||||
;
|
||||
return str - start - 1;
|
||||
#else
|
||||
if (__builtin_expect ((uintptr_t)str & (sizeof (long) - 1), 0)) do
|
||||
{
|
||||
char ch = *str;
|
||||
str++;
|
||||
if (!ch)
|
||||
return str - start - 1;
|
||||
} while ((uintptr_t)str & (sizeof (long) - 1));
|
||||
|
||||
unsigned long *ls = (unsigned long *)str;
|
||||
while (!__libc_detect_null (*ls++))
|
||||
;
|
||||
asm volatile ("" : "+r"(ls)); /* prevent "optimization" */
|
||||
|
||||
str = (const char *)ls;
|
||||
size_t ret = str - start, sl = sizeof (long);
|
||||
|
||||
char c0 = str[0 - sl], c1 = str[1 - sl], c2 = str[2 - sl], c3 = str[3 - sl];
|
||||
if (c0 == 0) return ret + 0 - sl;
|
||||
if (c1 == 0) return ret + 1 - sl;
|
||||
if (c2 == 0) return ret + 2 - sl;
|
||||
if (sl == 4 || c3 == 0) return ret + 3 - sl;
|
||||
|
||||
c0 = str[4 - sl], c1 = str[5 - sl], c2 = str[6 - sl], c3 = str[7 - sl];
|
||||
if (c0 == 0) return ret + 4 - sl;
|
||||
if (c1 == 0) return ret + 5 - sl;
|
||||
if (c2 == 0) return ret + 6 - sl;
|
||||
|
||||
return ret + 7 - sl;
|
||||
#endif /* not PREFER_SIZE_OVER_SPEED */
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/* Copyright (c) 2017 SiFive Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use,
|
||||
modify, copy, or redistribute it subject to the terms and conditions
|
||||
of the BSD License. This program is distributed in the hope that
|
||||
it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
|
||||
including the implied warranties of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. A copy of this license is available at
|
||||
http://www.opensource.org/licenses.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_ASM_H
|
||||
#define _SYS_ASM_H
|
||||
|
||||
/*
|
||||
* Macros to handle different pointer/register sizes for 32/64-bit code
|
||||
*/
|
||||
#if __riscv_xlen == 64
|
||||
# define PTRLOG 3
|
||||
# define SZREG 8
|
||||
# define REG_S sd
|
||||
# define REG_L ld
|
||||
#elif __riscv_xlen == 32
|
||||
# define PTRLOG 2
|
||||
# define SZREG 4
|
||||
# define REG_S sw
|
||||
# define REG_L lw
|
||||
#else
|
||||
# error __riscv_xlen must equal 32 or 64
|
||||
#endif
|
||||
|
||||
#ifndef __riscv_float_abi_soft
|
||||
/* For ABI uniformity, reserve 8 bytes for floats, even if double-precision
|
||||
floating-point is not supported in hardware. */
|
||||
# define SZFREG 8
|
||||
# ifdef __riscv_float_abi_single
|
||||
# define FREG_L flw
|
||||
# define FREG_S fsw
|
||||
# elif defined(__riscv_float_abi_double)
|
||||
# define FREG_L fld
|
||||
# define FREG_S fsd
|
||||
# elif defined(__riscv_float_abi_quad)
|
||||
# define FREG_L flq
|
||||
# define FREG_S fsq
|
||||
# else
|
||||
# error unsupported FLEN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* sys/asm.h */
|
|
@ -0,0 +1,77 @@
|
|||
/* Copyright (c) 2017 SiFive Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use,
|
||||
modify, copy, or redistribute it subject to the terms and conditions
|
||||
of the BSD License. This program is distributed in the hope that
|
||||
it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
|
||||
including the implied warranties of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. A copy of this license is available at
|
||||
http://www.opensource.org/licenses.
|
||||
*/
|
||||
|
||||
#ifndef _FENV_H_
|
||||
#define _FENV_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/* Per "The RISC-V Instruction Set Manual: Volume I: User-Level ISA:
|
||||
* Version 2.1", Section 8.2, "Floating-Point Control and Status
|
||||
* Register":
|
||||
*
|
||||
* Flag Mnemonic Flag Meaning
|
||||
* ------------- -----------------
|
||||
* NV Invalid Operation
|
||||
* DZ Divide by Zero
|
||||
* OF Overflow
|
||||
* UF Underflow
|
||||
* NX Inexact
|
||||
*/
|
||||
|
||||
#define FE_INVALID 0x00000010
|
||||
#define FE_DIVBYZERO 0x00000008
|
||||
#define FE_OVERFLOW 0x00000004
|
||||
#define FE_UNDERFLOW 0x00000002
|
||||
#define FE_INEXACT 0x00000001
|
||||
|
||||
#define FE_ALL_EXCEPT (FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW|FE_UNDERFLOW|FE_INEXACT)
|
||||
|
||||
/* Per "The RISC-V Instruction Set Manual: Volume I: User-Level ISA:
|
||||
* Version 2.1", Section 8.2, "Floating-Point Control and Status
|
||||
* Register":
|
||||
*
|
||||
* Rounding Mode Mnemonic Meaning Meaning
|
||||
* ------------- ---------------- -------
|
||||
* 000 RNE Round to Nearest, ties to Even
|
||||
* 001 RTZ Round towards Zero
|
||||
* 010 RDN Round Down (towards −∞)
|
||||
* 011 RUP Round Up (towards +∞)
|
||||
* 100 RMM Round to Nearest, ties to Max Magnitude
|
||||
* 101 Invalid. Reserved for future use.
|
||||
* 110 Invalid. Reserved for future use.
|
||||
* 111 In instruction’s rm field, selects dynamic rounding mode;
|
||||
* In Rounding Mode register, Invalid
|
||||
*/
|
||||
|
||||
#define FE_TONEAREST_MM 0x00000004
|
||||
#define FE_UPWARD 0x00000003
|
||||
#define FE_DOWNWARD 0x00000002
|
||||
#define FE_TOWARDZERO 0x00000001
|
||||
#define FE_TONEAREST 0x00000000
|
||||
|
||||
#define FE_RMODE_MASK 0x7
|
||||
|
||||
/* Per "The RISC-V Instruction Set Manual: Volume I: User-Level ISA:
|
||||
* Version 2.1":
|
||||
*
|
||||
* "The F extension adds 32 floating-point registers, f0–f31, each 32
|
||||
* bits wide, and a floating-point control and status register fcsr,
|
||||
* which contains the operating mode and exception status of the
|
||||
* floating-point unit."
|
||||
*/
|
||||
|
||||
typedef size_t fenv_t;
|
||||
typedef size_t fexcept_t;
|
||||
extern const fenv_t fe_dfl_env;
|
||||
#define FE_DFL_ENV fe_dfl_env_p
|
||||
|
||||
#endif /* _FENV_H_ */
|
|
@ -0,0 +1,23 @@
|
|||
/* Copyright (c) 2017 SiFive Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use,
|
||||
modify, copy, or redistribute it subject to the terms and conditions
|
||||
of the BSD License. This program is distributed in the hope that
|
||||
it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
|
||||
including the implied warranties of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. A copy of this license is available at
|
||||
http://www.opensource.org/licenses.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_STRING_H
|
||||
#define _SYS_STRING_H
|
||||
|
||||
static __inline unsigned long __libc_detect_null(unsigned long w)
|
||||
{
|
||||
unsigned long mask = 0x7f7f7f7f;
|
||||
if (sizeof (long) == 8)
|
||||
mask = ((mask << 16) << 16) | mask;
|
||||
return ~(((w & mask) + mask) | w | mask);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -29,18 +29,8 @@ No supporting OS subroutines are required. */
|
|||
#include <strings.h>
|
||||
|
||||
int
|
||||
_DEFUN(ffs, (word),
|
||||
int word)
|
||||
ffs(int i)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!word)
|
||||
return 0;
|
||||
|
||||
i = 0;
|
||||
for (;;)
|
||||
{
|
||||
if (((1 << i++) & word) != 0)
|
||||
return i;
|
||||
}
|
||||
return (__builtin_ffs(i));
|
||||
}
|
||||
|
|
|
@ -182,7 +182,6 @@ ELIX_4_SOURCES = \
|
|||
swscanf.c \
|
||||
ungetwc.c \
|
||||
vasnprintf.c \
|
||||
vfwscanf.c \
|
||||
vswprintf.c \
|
||||
vswscanf.c \
|
||||
vwprintf.c \
|
||||
|
|
|
@ -179,7 +179,6 @@ am__objects_2 = $(am__objects_1) lib_a-clearerr.$(OBJEXT) \
|
|||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-swscanf.$(OBJEXT) \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-ungetwc.$(OBJEXT) \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-vasnprintf.$(OBJEXT) \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-vfwscanf.$(OBJEXT) \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-vswprintf.$(OBJEXT) \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-vswscanf.$(OBJEXT) \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-vwprintf.$(OBJEXT) \
|
||||
|
@ -263,7 +262,6 @@ am__objects_8 = $(am__objects_7) clearerr.lo fclose.lo fdopen.lo \
|
|||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ swscanf.lo \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ ungetwc.lo \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ vasnprintf.lo \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ vfwscanf.lo \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ vswprintf.lo \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ vswscanf.lo \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ vwprintf.lo \
|
||||
|
@ -593,7 +591,6 @@ GENERAL_SOURCES = \
|
|||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ swscanf.c \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ ungetwc.c \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ vasnprintf.c \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ vfwscanf.c \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ vswprintf.c \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ vswscanf.c \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ vwprintf.c \
|
||||
|
@ -1641,12 +1638,6 @@ lib_a-vasnprintf.o: vasnprintf.c
|
|||
lib_a-vasnprintf.obj: vasnprintf.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vasnprintf.obj `if test -f 'vasnprintf.c'; then $(CYGPATH_W) 'vasnprintf.c'; else $(CYGPATH_W) '$(srcdir)/vasnprintf.c'; fi`
|
||||
|
||||
lib_a-vfwscanf.o: vfwscanf.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vfwscanf.o `test -f 'vfwscanf.c' || echo '$(srcdir)/'`vfwscanf.c
|
||||
|
||||
lib_a-vfwscanf.obj: vfwscanf.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vfwscanf.obj `if test -f 'vfwscanf.c'; then $(CYGPATH_W) 'vfwscanf.c'; else $(CYGPATH_W) '$(srcdir)/vfwscanf.c'; fi`
|
||||
|
||||
lib_a-vswprintf.o: vswprintf.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vswprintf.o `test -f 'vswprintf.c' || echo '$(srcdir)/'`vswprintf.c
|
||||
|
||||
|
|
|
@ -35,16 +35,19 @@ const struct __sFILE_fake __sf_fake_stderr =
|
|||
{_NULL, 0, 0, 0, 0, {_NULL, 0}, 0, _NULL};
|
||||
#endif
|
||||
|
||||
#ifdef _REENT_GLOBAL_STDIO_STREAMS
|
||||
__FILE __sf[3];
|
||||
#endif
|
||||
|
||||
#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED))
|
||||
_NOINLINE_STATIC _VOID
|
||||
#else
|
||||
static _VOID
|
||||
#endif
|
||||
_DEFUN(std, (ptr, flags, file, data),
|
||||
_DEFUN(std, (ptr, flags, file),
|
||||
FILE *ptr _AND
|
||||
int flags _AND
|
||||
int file _AND
|
||||
struct _reent *data)
|
||||
int file)
|
||||
{
|
||||
ptr->_p = 0;
|
||||
ptr->_r = 0;
|
||||
|
@ -85,6 +88,36 @@ _DEFUN(std, (ptr, flags, file, data),
|
|||
#endif
|
||||
}
|
||||
|
||||
static inline void
|
||||
stdin_init(FILE *ptr)
|
||||
{
|
||||
std (ptr, __SRD, 0);
|
||||
}
|
||||
|
||||
static inline void
|
||||
stdout_init(FILE *ptr)
|
||||
{
|
||||
/* On platforms that have true file system I/O, we can verify
|
||||
whether stdout is an interactive terminal or not, as part of
|
||||
__smakebuf on first use of the stream. For all other platforms,
|
||||
we will default to line buffered mode here. Technically, POSIX
|
||||
requires both stdin and stdout to be line-buffered, but tradition
|
||||
leaves stdin alone on systems without fcntl. */
|
||||
#ifdef HAVE_FCNTL
|
||||
std (ptr, __SWR, 1);
|
||||
#else
|
||||
std (ptr, __SWR | __SLBF, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void
|
||||
stderr_init(FILE *ptr)
|
||||
{
|
||||
/* POSIX requires stderr to be opened for reading and writing, even
|
||||
when the underlying fd 2 is write-only. */
|
||||
std (ptr, __SRW | __SNBF, 2);
|
||||
}
|
||||
|
||||
struct glue_with_file {
|
||||
struct _glue glue;
|
||||
FILE file;
|
||||
|
@ -188,6 +221,14 @@ _DEFUN(_cleanup_r, (ptr),
|
|||
#else
|
||||
cleanup_func = _fclose_r;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef _REENT_GLOBAL_STDIO_STREAMS
|
||||
if (ptr->_stdin != &__sf[0])
|
||||
(*cleanup_func) (ptr, ptr->_stdin);
|
||||
if (ptr->_stdout != &__sf[1])
|
||||
(*cleanup_func) (ptr, ptr->_stdout);
|
||||
if (ptr->_stderr != &__sf[2])
|
||||
(*cleanup_func) (ptr, ptr->_stderr);
|
||||
#endif
|
||||
_CAST_VOID _fwalk_reent (ptr, cleanup_func);
|
||||
}
|
||||
|
@ -221,8 +262,10 @@ _DEFUN(__sinit, (s),
|
|||
|
||||
s->__sglue._next = NULL;
|
||||
#ifndef _REENT_SMALL
|
||||
# ifndef _REENT_GLOBAL_STDIO_STREAMS
|
||||
s->__sglue._niobs = 3;
|
||||
s->__sglue._iobs = &s->__sf[0];
|
||||
# endif
|
||||
#else
|
||||
s->__sglue._niobs = 0;
|
||||
s->__sglue._iobs = NULL;
|
||||
|
@ -236,24 +279,20 @@ _DEFUN(__sinit, (s),
|
|||
s->_stderr = __sfp(s);
|
||||
#endif
|
||||
|
||||
std (s->_stdin, __SRD, 0, s);
|
||||
|
||||
/* On platforms that have true file system I/O, we can verify
|
||||
whether stdout is an interactive terminal or not, as part of
|
||||
__smakebuf on first use of the stream. For all other platforms,
|
||||
we will default to line buffered mode here. Technically, POSIX
|
||||
requires both stdin and stdout to be line-buffered, but tradition
|
||||
leaves stdin alone on systems without fcntl. */
|
||||
#ifdef HAVE_FCNTL
|
||||
std (s->_stdout, __SWR, 1, s);
|
||||
#ifdef _REENT_GLOBAL_STDIO_STREAMS
|
||||
if (__sf[0]._cookie == NULL) {
|
||||
_GLOBAL_REENT->__sglue._niobs = 3;
|
||||
_GLOBAL_REENT->__sglue._iobs = &__sf[0];
|
||||
stdin_init (&__sf[0]);
|
||||
stdout_init (&__sf[1]);
|
||||
stderr_init (&__sf[2]);
|
||||
}
|
||||
#else
|
||||
std (s->_stdout, __SWR | __SLBF, 1, s);
|
||||
stdin_init (s->_stdin);
|
||||
stdout_init (s->_stdout);
|
||||
stderr_init (s->_stderr);
|
||||
#endif
|
||||
|
||||
/* POSIX requires stderr to be opened for reading and writing, even
|
||||
when the underlying fd 2 is write-only. */
|
||||
std (s->_stderr, __SRW | __SNBF, 2, s);
|
||||
|
||||
s->__sdidinit = 1;
|
||||
|
||||
__sinit_lock_release ();
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
case _STDIO_CLOSE_PER_REENT_STD_STREAMS is defined these file descriptors
|
||||
will be closed via close() provided the owner of the reent structure
|
||||
triggerd the on demand reent initilization, see CHECK_INIT(). */
|
||||
#if !defined(__rtems__) && !defined(__tirtos__)
|
||||
#if !defined(__tirtos__)
|
||||
#define _STDIO_CLOSE_PER_REENT_STD_STREAMS
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1245,6 +1245,8 @@ reswitch: switch (ch) {
|
|||
break;
|
||||
}
|
||||
if (isnan (_fpvalue)) {
|
||||
if (signbit (_fpvalue))
|
||||
sign = '-';
|
||||
if (ch <= 'G') /* 'A', 'E', 'F', or 'G' */
|
||||
cp = "NAN";
|
||||
else
|
||||
|
@ -1276,6 +1278,8 @@ reswitch: switch (ch) {
|
|||
break;
|
||||
}
|
||||
if (expt == 1) {
|
||||
if (signbit (_fpvalue))
|
||||
sign = '-';
|
||||
if (ch <= 'G') /* 'A', 'E', 'F', or 'G' */
|
||||
cp = "NAN";
|
||||
else
|
||||
|
|
|
@ -970,6 +970,8 @@ reswitch: switch (ch) {
|
|||
break;
|
||||
}
|
||||
if (isnan (_fpvalue)) {
|
||||
if (signbit (_fpvalue))
|
||||
sign = L'-';
|
||||
if (ch <= L'G') /* 'A', 'E', 'F', or 'G' */
|
||||
cp = L"NAN";
|
||||
else
|
||||
|
@ -1001,6 +1003,8 @@ reswitch: switch (ch) {
|
|||
break;
|
||||
}
|
||||
if (expt == 1) {
|
||||
if (signbit (_fpvalue))
|
||||
sign = L'-';
|
||||
if (ch <= L'G') /* 'A', 'E', 'F', or 'G' */
|
||||
cp = L"NAN";
|
||||
else
|
||||
|
|
|
@ -32,6 +32,8 @@ GENERAL_SOURCES = \
|
|||
gdtoa-hexnan.c \
|
||||
getenv.c \
|
||||
getenv_r.c \
|
||||
imaxabs.c \
|
||||
imaxdiv.c \
|
||||
itoa.c \
|
||||
labs.c \
|
||||
ldiv.c \
|
||||
|
@ -57,13 +59,17 @@ GENERAL_SOURCES = \
|
|||
sb_charsets.c \
|
||||
strtod.c \
|
||||
strtodg.c \
|
||||
strtoimax.c \
|
||||
strtol.c \
|
||||
strtorx.c \
|
||||
strtoul.c \
|
||||
strtoumax.c \
|
||||
utoa.c \
|
||||
wcstod.c \
|
||||
wcstoimax.c \
|
||||
wcstol.c \
|
||||
wcstoul.c \
|
||||
wcstoumax.c \
|
||||
wcstombs.c \
|
||||
wcstombs_r.c \
|
||||
wctomb.c \
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
# Makefile.in generated by automake 1.11.6 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.12.2 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
|
||||
# Foundation, Inc.
|
||||
# Copyright (C) 1994-2012 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
@ -58,15 +57,11 @@ host_triplet = @host@
|
|||
@HAVE_LONG_DOUBLE_TRUE@ wcstold.c
|
||||
|
||||
DIST_COMMON = $(srcdir)/../../Makefile.shared $(srcdir)/Makefile.in \
|
||||
$(srcdir)/Makefile.am
|
||||
$(srcdir)/Makefile.am $(top_srcdir)/../../mkinstalldirs
|
||||
subdir = stdlib
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/../../libtool.m4 \
|
||||
$(top_srcdir)/../../ltoptions.m4 \
|
||||
$(top_srcdir)/../../ltsugar.m4 \
|
||||
$(top_srcdir)/../../ltversion.m4 \
|
||||
$(top_srcdir)/../../lt~obsolete.m4 \
|
||||
$(top_srcdir)/../acinclude.m4 $(top_srcdir)/configure.in
|
||||
am__aclocal_m4_deps = $(top_srcdir)/../acinclude.m4 \
|
||||
$(top_srcdir)/configure.in
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/../../mkinstalldirs
|
||||
|
@ -94,7 +89,8 @@ am__objects_2 = lib_a-__adjust.$(OBJEXT) lib_a-__atexit.$(OBJEXT) \
|
|||
lib_a-envlock.$(OBJEXT) lib_a-eprintf.$(OBJEXT) \
|
||||
lib_a-exit.$(OBJEXT) lib_a-gdtoa-gethex.$(OBJEXT) \
|
||||
lib_a-gdtoa-hexnan.$(OBJEXT) lib_a-getenv.$(OBJEXT) \
|
||||
lib_a-getenv_r.$(OBJEXT) lib_a-itoa.$(OBJEXT) \
|
||||
lib_a-getenv_r.$(OBJEXT) lib_a-imaxabs.$(OBJEXT) \
|
||||
lib_a-imaxdiv.$(OBJEXT) lib_a-itoa.$(OBJEXT) \
|
||||
lib_a-labs.$(OBJEXT) lib_a-ldiv.$(OBJEXT) \
|
||||
lib_a-ldtoa.$(OBJEXT) lib_a-malloc.$(OBJEXT) \
|
||||
lib_a-mblen.$(OBJEXT) lib_a-mblen_r.$(OBJEXT) \
|
||||
|
@ -107,10 +103,12 @@ am__objects_2 = lib_a-__adjust.$(OBJEXT) lib_a-__atexit.$(OBJEXT) \
|
|||
lib_a-realloc.$(OBJEXT) lib_a-reallocarray.$(OBJEXT) \
|
||||
lib_a-reallocf.$(OBJEXT) lib_a-sb_charsets.$(OBJEXT) \
|
||||
lib_a-strtod.$(OBJEXT) lib_a-strtodg.$(OBJEXT) \
|
||||
lib_a-strtol.$(OBJEXT) lib_a-strtorx.$(OBJEXT) \
|
||||
lib_a-strtoul.$(OBJEXT) lib_a-utoa.$(OBJEXT) \
|
||||
lib_a-wcstod.$(OBJEXT) lib_a-wcstol.$(OBJEXT) \
|
||||
lib_a-wcstoul.$(OBJEXT) lib_a-wcstombs.$(OBJEXT) \
|
||||
lib_a-strtoimax.$(OBJEXT) lib_a-strtol.$(OBJEXT) \
|
||||
lib_a-strtorx.$(OBJEXT) lib_a-strtoul.$(OBJEXT) \
|
||||
lib_a-strtoumax.$(OBJEXT) lib_a-utoa.$(OBJEXT) \
|
||||
lib_a-wcstod.$(OBJEXT) lib_a-wcstoimax.$(OBJEXT) \
|
||||
lib_a-wcstol.$(OBJEXT) lib_a-wcstoul.$(OBJEXT) \
|
||||
lib_a-wcstoumax.$(OBJEXT) lib_a-wcstombs.$(OBJEXT) \
|
||||
lib_a-wcstombs_r.$(OBJEXT) lib_a-wctomb.$(OBJEXT) \
|
||||
lib_a-wctomb_r.$(OBJEXT) $(am__objects_1)
|
||||
am__objects_3 = lib_a-arc4random.$(OBJEXT) \
|
||||
|
@ -157,13 +155,15 @@ am__objects_9 = __adjust.lo __atexit.lo __call_atexit.lo __exp10.lo \
|
|||
assert.lo atexit.lo atof.lo atoff.lo atoi.lo atol.lo calloc.lo \
|
||||
div.lo dtoa.lo dtoastub.lo environ.lo envlock.lo eprintf.lo \
|
||||
exit.lo gdtoa-gethex.lo gdtoa-hexnan.lo getenv.lo getenv_r.lo \
|
||||
itoa.lo labs.lo ldiv.lo ldtoa.lo malloc.lo mblen.lo mblen_r.lo \
|
||||
mbstowcs.lo mbstowcs_r.lo mbtowc.lo mbtowc_r.lo mlock.lo \
|
||||
mprec.lo mstats.lo on_exit_args.lo quick_exit.lo rand.lo \
|
||||
rand_r.lo random.lo realloc.lo reallocarray.lo reallocf.lo \
|
||||
sb_charsets.lo strtod.lo strtodg.lo strtol.lo strtorx.lo \
|
||||
strtoul.lo utoa.lo wcstod.lo wcstol.lo wcstoul.lo wcstombs.lo \
|
||||
wcstombs_r.lo wctomb.lo wctomb_r.lo $(am__objects_8)
|
||||
imaxabs.lo imaxdiv.lo itoa.lo labs.lo ldiv.lo ldtoa.lo \
|
||||
malloc.lo mblen.lo mblen_r.lo mbstowcs.lo mbstowcs_r.lo \
|
||||
mbtowc.lo mbtowc_r.lo mlock.lo mprec.lo mstats.lo \
|
||||
on_exit_args.lo quick_exit.lo rand.lo rand_r.lo random.lo \
|
||||
realloc.lo reallocarray.lo reallocf.lo sb_charsets.lo \
|
||||
strtod.lo strtodg.lo strtoimax.lo strtol.lo strtorx.lo \
|
||||
strtoul.lo strtoumax.lo utoa.lo wcstod.lo wcstoimax.lo \
|
||||
wcstol.lo wcstoul.lo wcstoumax.lo wcstombs.lo wcstombs_r.lo \
|
||||
wctomb.lo wctomb_r.lo $(am__objects_8)
|
||||
am__objects_10 = arc4random.lo arc4random_uniform.lo cxa_atexit.lo \
|
||||
cxa_finalize.lo drand48.lo ecvtbuf.lo efgcvt.lo erand48.lo \
|
||||
jrand48.lo lcong48.lo lrand48.lo mrand48.lo msize.lo mtrim.lo \
|
||||
|
@ -269,8 +269,10 @@ LIBTOOL = @LIBTOOL@
|
|||
LIPO = @LIPO@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
|
||||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MANIFEST_TOOL = @MANIFEST_TOOL@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NEWLIB_CFLAGS = @NEWLIB_CFLAGS@
|
||||
NM = @NM@
|
||||
|
@ -299,6 +301,7 @@ abs_builddir = @abs_builddir@
|
|||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
aext = @aext@
|
||||
|
@ -361,12 +364,13 @@ GENERAL_SOURCES = __adjust.c __atexit.c __call_atexit.c __exp10.c \
|
|||
__ten_mu.c _Exit.c abort.c abs.c aligned_alloc.c assert.c \
|
||||
atexit.c atof.c atoff.c atoi.c atol.c calloc.c div.c dtoa.c \
|
||||
dtoastub.c environ.c envlock.c eprintf.c exit.c gdtoa-gethex.c \
|
||||
gdtoa-hexnan.c getenv.c getenv_r.c itoa.c labs.c ldiv.c \
|
||||
ldtoa.c malloc.c mblen.c mblen_r.c mbstowcs.c mbstowcs_r.c \
|
||||
mbtowc.c mbtowc_r.c mlock.c mprec.c mstats.c on_exit_args.c \
|
||||
quick_exit.c rand.c rand_r.c random.c realloc.c reallocarray.c \
|
||||
reallocf.c sb_charsets.c strtod.c strtodg.c strtol.c strtorx.c \
|
||||
strtoul.c utoa.c wcstod.c wcstol.c wcstoul.c wcstombs.c \
|
||||
gdtoa-hexnan.c getenv.c getenv_r.c imaxabs.c imaxdiv.c itoa.c \
|
||||
labs.c ldiv.c ldtoa.c malloc.c mblen.c mblen_r.c mbstowcs.c \
|
||||
mbstowcs_r.c mbtowc.c mbtowc_r.c mlock.c mprec.c mstats.c \
|
||||
on_exit_args.c quick_exit.c rand.c rand_r.c random.c realloc.c \
|
||||
reallocarray.c reallocf.c sb_charsets.c strtod.c strtodg.c \
|
||||
strtoimax.c strtol.c strtorx.c strtoul.c strtoumax.c utoa.c \
|
||||
wcstod.c wcstoimax.c wcstol.c wcstoul.c wcstoumax.c wcstombs.c \
|
||||
wcstombs_r.c wctomb.c wctomb_r.c $(am__append_1)
|
||||
@NEWLIB_NANO_MALLOC_FALSE@MALIGNR = malignr
|
||||
@NEWLIB_NANO_MALLOC_TRUE@MALIGNR = nano-malignr
|
||||
|
@ -594,12 +598,14 @@ lib.a: $(lib_a_OBJECTS) $(lib_a_DEPENDENCIES) $(EXTRA_lib_a_DEPENDENCIES)
|
|||
|
||||
clean-noinstLTLIBRARIES:
|
||||
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
|
||||
@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
|
||||
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
|
||||
test "$$dir" != "$$p" || dir=.; \
|
||||
echo "rm -f \"$${dir}/so_locations\""; \
|
||||
rm -f "$${dir}/so_locations"; \
|
||||
done
|
||||
@list='$(noinst_LTLIBRARIES)'; \
|
||||
locs=`for p in $$list; do echo $$p; done | \
|
||||
sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
|
||||
sort -u`; \
|
||||
test -z "$$locs" || { \
|
||||
echo rm -f $${locs}; \
|
||||
rm -f $${locs}; \
|
||||
}
|
||||
libstdlib.la: $(libstdlib_la_OBJECTS) $(libstdlib_la_DEPENDENCIES) $(EXTRA_libstdlib_la_DEPENDENCIES)
|
||||
$(libstdlib_la_LINK) $(am_libstdlib_la_rpath) $(libstdlib_la_OBJECTS) $(libstdlib_la_LIBADD) $(LIBS)
|
||||
|
||||
|
@ -780,6 +786,18 @@ lib_a-getenv_r.o: getenv_r.c
|
|||
lib_a-getenv_r.obj: getenv_r.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-getenv_r.obj `if test -f 'getenv_r.c'; then $(CYGPATH_W) 'getenv_r.c'; else $(CYGPATH_W) '$(srcdir)/getenv_r.c'; fi`
|
||||
|
||||
lib_a-imaxabs.o: imaxabs.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-imaxabs.o `test -f 'imaxabs.c' || echo '$(srcdir)/'`imaxabs.c
|
||||
|
||||
lib_a-imaxabs.obj: imaxabs.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-imaxabs.obj `if test -f 'imaxabs.c'; then $(CYGPATH_W) 'imaxabs.c'; else $(CYGPATH_W) '$(srcdir)/imaxabs.c'; fi`
|
||||
|
||||
lib_a-imaxdiv.o: imaxdiv.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-imaxdiv.o `test -f 'imaxdiv.c' || echo '$(srcdir)/'`imaxdiv.c
|
||||
|
||||
lib_a-imaxdiv.obj: imaxdiv.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-imaxdiv.obj `if test -f 'imaxdiv.c'; then $(CYGPATH_W) 'imaxdiv.c'; else $(CYGPATH_W) '$(srcdir)/imaxdiv.c'; fi`
|
||||
|
||||
lib_a-itoa.o: itoa.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-itoa.o `test -f 'itoa.c' || echo '$(srcdir)/'`itoa.c
|
||||
|
||||
|
@ -930,6 +948,12 @@ lib_a-strtodg.o: strtodg.c
|
|||
lib_a-strtodg.obj: strtodg.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strtodg.obj `if test -f 'strtodg.c'; then $(CYGPATH_W) 'strtodg.c'; else $(CYGPATH_W) '$(srcdir)/strtodg.c'; fi`
|
||||
|
||||
lib_a-strtoimax.o: strtoimax.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strtoimax.o `test -f 'strtoimax.c' || echo '$(srcdir)/'`strtoimax.c
|
||||
|
||||
lib_a-strtoimax.obj: strtoimax.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strtoimax.obj `if test -f 'strtoimax.c'; then $(CYGPATH_W) 'strtoimax.c'; else $(CYGPATH_W) '$(srcdir)/strtoimax.c'; fi`
|
||||
|
||||
lib_a-strtol.o: strtol.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strtol.o `test -f 'strtol.c' || echo '$(srcdir)/'`strtol.c
|
||||
|
||||
|
@ -948,6 +972,12 @@ lib_a-strtoul.o: strtoul.c
|
|||
lib_a-strtoul.obj: strtoul.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strtoul.obj `if test -f 'strtoul.c'; then $(CYGPATH_W) 'strtoul.c'; else $(CYGPATH_W) '$(srcdir)/strtoul.c'; fi`
|
||||
|
||||
lib_a-strtoumax.o: strtoumax.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strtoumax.o `test -f 'strtoumax.c' || echo '$(srcdir)/'`strtoumax.c
|
||||
|
||||
lib_a-strtoumax.obj: strtoumax.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strtoumax.obj `if test -f 'strtoumax.c'; then $(CYGPATH_W) 'strtoumax.c'; else $(CYGPATH_W) '$(srcdir)/strtoumax.c'; fi`
|
||||
|
||||
lib_a-utoa.o: utoa.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-utoa.o `test -f 'utoa.c' || echo '$(srcdir)/'`utoa.c
|
||||
|
||||
|
@ -960,6 +990,12 @@ lib_a-wcstod.o: wcstod.c
|
|||
lib_a-wcstod.obj: wcstod.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcstod.obj `if test -f 'wcstod.c'; then $(CYGPATH_W) 'wcstod.c'; else $(CYGPATH_W) '$(srcdir)/wcstod.c'; fi`
|
||||
|
||||
lib_a-wcstoimax.o: wcstoimax.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcstoimax.o `test -f 'wcstoimax.c' || echo '$(srcdir)/'`wcstoimax.c
|
||||
|
||||
lib_a-wcstoimax.obj: wcstoimax.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcstoimax.obj `if test -f 'wcstoimax.c'; then $(CYGPATH_W) 'wcstoimax.c'; else $(CYGPATH_W) '$(srcdir)/wcstoimax.c'; fi`
|
||||
|
||||
lib_a-wcstol.o: wcstol.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcstol.o `test -f 'wcstol.c' || echo '$(srcdir)/'`wcstol.c
|
||||
|
||||
|
@ -972,6 +1008,12 @@ lib_a-wcstoul.o: wcstoul.c
|
|||
lib_a-wcstoul.obj: wcstoul.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcstoul.obj `if test -f 'wcstoul.c'; then $(CYGPATH_W) 'wcstoul.c'; else $(CYGPATH_W) '$(srcdir)/wcstoul.c'; fi`
|
||||
|
||||
lib_a-wcstoumax.o: wcstoumax.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcstoumax.o `test -f 'wcstoumax.c' || echo '$(srcdir)/'`wcstoumax.c
|
||||
|
||||
lib_a-wcstoumax.obj: wcstoumax.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcstoumax.obj `if test -f 'wcstoumax.c'; then $(CYGPATH_W) 'wcstoumax.c'; else $(CYGPATH_W) '$(srcdir)/wcstoumax.c'; fi`
|
||||
|
||||
lib_a-wcstombs.o: wcstombs.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcstombs.o `test -f 'wcstombs.c' || echo '$(srcdir)/'`wcstombs.c
|
||||
|
||||
|
@ -1375,6 +1417,20 @@ GTAGS:
|
|||
&& $(am__cd) $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) "$$here"
|
||||
|
||||
cscopelist: $(HEADERS) $(SOURCES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP)'; \
|
||||
case "$(srcdir)" in \
|
||||
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
|
||||
*) sdir=$(subdir)/$(srcdir) ;; \
|
||||
esac; \
|
||||
for i in $$list; do \
|
||||
if test -f "$$i"; then \
|
||||
echo "$(subdir)/$$i"; \
|
||||
else \
|
||||
echo "$$sdir/$$i"; \
|
||||
fi; \
|
||||
done >> $(top_builddir)/cscope.files
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
check-am:
|
||||
|
@ -1485,7 +1541,7 @@ uninstall-am:
|
|||
|
||||
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
|
||||
clean-libtool clean-noinstLIBRARIES clean-noinstLTLIBRARIES \
|
||||
ctags distclean distclean-compile distclean-generic \
|
||||
cscopelist ctags distclean distclean-compile distclean-generic \
|
||||
distclean-libtool distclean-tags dvi dvi-am html html-am info \
|
||||
info-am install install-am install-data install-data-am \
|
||||
install-dvi install-dvi-am install-exec install-exec-am \
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/*-
|
||||
* Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/lib/libc/stdlib/imaxabs.c 86368 2001-11-15 02:05:03Z mike $");
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
intmax_t
|
||||
imaxabs(intmax_t j)
|
||||
{
|
||||
return (j < 0 ? -j : j);
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/*-
|
||||
* Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/lib/libc/stdlib/imaxdiv.c 301115 2016-06-01 10:14:25Z ache $");
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* See comments in div.c for implementation details. */
|
||||
imaxdiv_t
|
||||
imaxdiv(intmax_t numer, intmax_t denom)
|
||||
{
|
||||
imaxdiv_t retval;
|
||||
|
||||
retval.quot = numer / denom;
|
||||
retval.rem = numer % denom;
|
||||
#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
|
||||
if (numer >= 0 && retval.rem < 0) {
|
||||
retval.quot++;
|
||||
retval.rem -= denom;
|
||||
}
|
||||
#endif
|
||||
return (retval);
|
||||
}
|
|
@ -0,0 +1,169 @@
|
|||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2011 The FreeBSD Foundation
|
||||
* All rights reserved.
|
||||
* Portions of this software were developed by David Chisnall
|
||||
* under sponsorship from the FreeBSD Foundation.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "from @(#)strtol.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/lib/libc/stdlib/strtoimax.c 251672 2013-06-13 00:19:30Z emaste $");
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
#include <reent.h>
|
||||
#include "../locale/setlocale.h"
|
||||
|
||||
/*
|
||||
* Convert a string to an intmax_t integer.
|
||||
*
|
||||
* Assumes that the upper and lower case
|
||||
* alphabets and digits are each contiguous.
|
||||
*/
|
||||
|
||||
/*
|
||||
*Reentrant version of strtoimax.
|
||||
*/
|
||||
static intmax_t
|
||||
_strtoimax_l(struct _reent *rptr, const char * __restrict nptr,
|
||||
char ** __restrict endptr, int base, locale_t loc)
|
||||
{
|
||||
const char *s = (const unsigned char *)nptr;
|
||||
uintmax_t acc;
|
||||
char c;
|
||||
uintmax_t cutoff;
|
||||
int neg = 0, any, cutlim;
|
||||
|
||||
/*
|
||||
* Skip white space and pick up leading +/- sign if any.
|
||||
* If base is 0, allow 0x for hex and 0 for octal, else
|
||||
* assume decimal; if base is already 16, allow 0x.
|
||||
*/
|
||||
do {
|
||||
c = *s++;
|
||||
} while (isspace_l(c, loc));
|
||||
if (c == '-') {
|
||||
neg = 1;
|
||||
c = *s++;
|
||||
} else {
|
||||
neg = 0;
|
||||
if (c == '+')
|
||||
c = *s++;
|
||||
}
|
||||
if ((base == 0 || base == 16) &&
|
||||
c == '0' && (*s == 'x' || *s == 'X')) {
|
||||
c = s[1];
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
if (base == 0)
|
||||
base = c == '0' ? 8 : 10;
|
||||
|
||||
/*
|
||||
* Compute the cutoff value between legal numbers and illegal
|
||||
* numbers. That is the largest legal value, divided by the
|
||||
* base. An input number that is greater than this value, if
|
||||
* followed by a legal input character, is too big. One that
|
||||
* is equal to this value may be valid or not; the limit
|
||||
* between valid and invalid numbers is then based on the last
|
||||
* digit. For instance, if the range for intmax_t is
|
||||
* [-9223372036854775808..9223372036854775807] and the input base
|
||||
* is 10, cutoff will be set to 922337203685477580 and cutlim to
|
||||
* either 7 (neg==0) or 8 (neg==1), meaning that if we have
|
||||
* accumulated a value > 922337203685477580, or equal but the
|
||||
* next digit is > 7 (or 8), the number is too big, and we will
|
||||
* return a range error.
|
||||
*
|
||||
* Set 'any' if any `digits' consumed; make it negative to indicate
|
||||
* overflow.
|
||||
*/
|
||||
cutoff = neg ? -(uintmax_t)INTMAX_MIN : INTMAX_MAX;
|
||||
cutlim = cutoff % base;
|
||||
cutoff /= base;
|
||||
for ( ; ; c = *s++) {
|
||||
if (c >= '0' && c <= '9')
|
||||
c -= '0';
|
||||
else if (c >= 'A' && c <= 'Z')
|
||||
c -= 'A' - 10;
|
||||
else if (c >= 'a' && c <= 'z')
|
||||
c -= 'a' - 10;
|
||||
else
|
||||
break;
|
||||
if (c >= base)
|
||||
break;
|
||||
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
|
||||
any = -1;
|
||||
else {
|
||||
any = 1;
|
||||
acc *= base;
|
||||
acc += c;
|
||||
}
|
||||
}
|
||||
if (any < 0) {
|
||||
acc = neg ? INTMAX_MIN : INTMAX_MAX;
|
||||
rptr->_errno = ERANGE;
|
||||
} else if (!any) {
|
||||
noconv:
|
||||
rptr->_errno = EINVAL;
|
||||
} else if (neg)
|
||||
acc = -acc;
|
||||
if (endptr != NULL)
|
||||
*endptr = (char *)(any ? s - 1 : nptr);
|
||||
return (acc);
|
||||
}
|
||||
|
||||
intmax_t
|
||||
_strtoimax_r(struct _reent *rptr, const char *__restrict nptr,
|
||||
char **__restrict endptr, int base)
|
||||
{
|
||||
return _strtoimax_l(rptr, nptr, endptr, base, __get_current_locale());
|
||||
}
|
||||
|
||||
#ifndef _REENT_ONLY
|
||||
|
||||
intmax_t
|
||||
strtoimax_l(const char * __restrict nptr, char ** __restrict endptr, int base,
|
||||
locale_t loc)
|
||||
{
|
||||
return _strtoimax_l(_REENT, nptr, endptr, base, loc);
|
||||
}
|
||||
|
||||
intmax_t
|
||||
strtoimax(const char* __restrict nptr, char** __restrict endptr, int base)
|
||||
{
|
||||
return _strtoimax_l(_REENT, nptr, endptr, base, __get_current_locale());
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,151 @@
|
|||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2011 The FreeBSD Foundation
|
||||
* All rights reserved.
|
||||
* Portions of this software were developed by David Chisnall
|
||||
* under sponsorship from the FreeBSD Foundation.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "from @(#)strtoul.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/lib/libc/stdlib/strtoumax.c 251672 2013-06-13 00:19:30Z emaste $");
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
#include <reent.h>
|
||||
#include "../locale/setlocale.h"
|
||||
|
||||
/*
|
||||
* Convert a string to a uintmax_t integer.
|
||||
*
|
||||
* Assumes that the upper and lower case
|
||||
* alphabets and digits are each contiguous.
|
||||
*/
|
||||
|
||||
/*
|
||||
*Reentrant version of strtoumax.
|
||||
*/
|
||||
static uintmax_t
|
||||
_strtoumax_l(struct _reent *rptr, const char * __restrict nptr,
|
||||
char ** __restrict endptr, int base, locale_t loc)
|
||||
{
|
||||
const char *s = (const unsigned char *)nptr;
|
||||
uintmax_t acc;
|
||||
char c;
|
||||
uintmax_t cutoff;
|
||||
int neg = 0, any, cutlim;
|
||||
|
||||
/*
|
||||
* See strtoimax for comments as to the logic used.
|
||||
*/
|
||||
do {
|
||||
c = *s++;
|
||||
} while (isspace_l(c, loc));
|
||||
if (c == '-') {
|
||||
neg = 1;
|
||||
c = *s++;
|
||||
} else {
|
||||
neg = 0;
|
||||
if (c == '+')
|
||||
c = *s++;
|
||||
}
|
||||
if ((base == 0 || base == 16) &&
|
||||
c == '0' && (*s == 'x' || *s == 'X')) {
|
||||
c = s[1];
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
if (base == 0)
|
||||
base = c == '0' ? 8 : 10;
|
||||
acc = any = 0;
|
||||
if (base < 2 || base > 36)
|
||||
goto noconv;
|
||||
|
||||
cutoff = UINTMAX_MAX / base;
|
||||
cutlim = UINTMAX_MAX % base;
|
||||
for ( ; ; c = *s++) {
|
||||
if (c >= '0' && c <= '9')
|
||||
c -= '0';
|
||||
else if (c >= 'A' && c <= 'Z')
|
||||
c -= 'A' - 10;
|
||||
else if (c >= 'a' && c <= 'z')
|
||||
c -= 'a' - 10;
|
||||
else
|
||||
break;
|
||||
if (c >= base)
|
||||
break;
|
||||
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
|
||||
any = -1;
|
||||
else {
|
||||
any = 1;
|
||||
acc *= base;
|
||||
acc += c;
|
||||
}
|
||||
}
|
||||
if (any < 0) {
|
||||
acc = UINTMAX_MAX;
|
||||
rptr->_errno = ERANGE;
|
||||
} else if (!any) {
|
||||
noconv:
|
||||
rptr->_errno = EINVAL;
|
||||
} else if (neg)
|
||||
acc = -acc;
|
||||
if (endptr != NULL)
|
||||
*endptr = (char *)(any ? s - 1 : nptr);
|
||||
return (acc);
|
||||
}
|
||||
|
||||
uintmax_t
|
||||
_strtoumax_r(struct _reent *rptr, const char *__restrict nptr,
|
||||
char **__restrict endptr, int base)
|
||||
{
|
||||
return _strtoumax_l(rptr, nptr, endptr, base, __get_current_locale());
|
||||
}
|
||||
|
||||
#ifndef _REENT_ONLY
|
||||
|
||||
uintmax_t
|
||||
strtoumax_l(const char * __restrict nptr, char ** __restrict endptr, int base,
|
||||
locale_t loc)
|
||||
{
|
||||
return _strtoumax_l(_REENT, nptr, endptr, base, loc);
|
||||
}
|
||||
|
||||
uintmax_t
|
||||
strtoumax(const char* __restrict nptr, char** __restrict endptr, int base)
|
||||
{
|
||||
return _strtoumax_l(_REENT, nptr, endptr, base, __get_current_locale());
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,158 @@
|
|||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2011 The FreeBSD Foundation
|
||||
* All rights reserved.
|
||||
* Portions of this software were developed by David Chisnall
|
||||
* under sponsorship from the FreeBSD Foundation.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if 0
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "from @(#)strtol.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
__FBSDID("FreeBSD: src/lib/libc/stdlib/strtoimax.c,v 1.8 2002/09/06 11:23:59 tjr Exp ");
|
||||
#endif
|
||||
__FBSDID("$FreeBSD: head/lib/libc/locale/wcstoimax.c 314436 2017-02-28 23:42:47Z imp $");
|
||||
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#include <wctype.h>
|
||||
#include <reent.h>
|
||||
#include <stdint.h>
|
||||
#include "../locale/setlocale.h"
|
||||
|
||||
/*
|
||||
* Convert a wide character string to an intmax_t integer.
|
||||
*/
|
||||
|
||||
/*
|
||||
*Reentrant version of wcstoimax.
|
||||
*/
|
||||
static intmax_t
|
||||
_wcstoimax_l(struct _reent *rptr, const wchar_t * __restrict nptr,
|
||||
wchar_t ** __restrict endptr, int base, locale_t loc)
|
||||
{
|
||||
const wchar_t *s = nptr;
|
||||
uintmax_t acc;
|
||||
wchar_t c;
|
||||
uintmax_t cutoff;
|
||||
int neg = 0, any, cutlim;
|
||||
|
||||
/*
|
||||
* See strtoimax for comments as to the logic used.
|
||||
*/
|
||||
do {
|
||||
c = *s++;
|
||||
} while (iswspace_l(c, loc));
|
||||
if (c == L'-') {
|
||||
neg = 1;
|
||||
c = *s++;
|
||||
} else {
|
||||
neg = 0;
|
||||
if (c == L'+')
|
||||
c = *s++;
|
||||
}
|
||||
if ((base == 0 || base == 16) &&
|
||||
c == L'0' && (*s == L'x' || *s == L'X')) {
|
||||
c = s[1];
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
if (base == 0)
|
||||
base = c == L'0' ? 8 : 10;
|
||||
acc = any = 0;
|
||||
if (base < 2 || base > 36)
|
||||
goto noconv;
|
||||
|
||||
cutoff = neg ? -(uintmax_t)INTMAX_MIN : INTMAX_MAX;
|
||||
cutlim = cutoff % base;
|
||||
cutoff /= base;
|
||||
for ( ; ; c = *s++) {
|
||||
#ifdef notyet
|
||||
if (iswdigit_l(c, loc))
|
||||
c = digittoint_l(c, loc);
|
||||
else
|
||||
#endif
|
||||
if (c >= L'0' && c <= L'9')
|
||||
c -= L'0';
|
||||
else if (c >= L'A' && c <= L'Z')
|
||||
c -= L'A' - 10;
|
||||
else if (c >= 'a' && c <= 'z')
|
||||
c -= L'a' - 10;
|
||||
else
|
||||
break;
|
||||
if (c >= base)
|
||||
break;
|
||||
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
|
||||
any = -1;
|
||||
else {
|
||||
any = 1;
|
||||
acc *= base;
|
||||
acc += c;
|
||||
}
|
||||
}
|
||||
if (any < 0) {
|
||||
acc = neg ? INTMAX_MIN : INTMAX_MAX;
|
||||
rptr->_errno = ERANGE;
|
||||
} else if (!any) {
|
||||
noconv:
|
||||
rptr->_errno = EINVAL;
|
||||
} else if (neg)
|
||||
acc = -acc;
|
||||
if (endptr != NULL)
|
||||
*endptr = (wchar_t *)(any ? s - 1 : nptr);
|
||||
return (acc);
|
||||
}
|
||||
|
||||
intmax_t
|
||||
_wcstoimax_r(struct _reent *rptr, const wchar_t *__restrict nptr,
|
||||
wchar_t **__restrict endptr, int base)
|
||||
{
|
||||
return _wcstoimax_l(rptr, nptr, endptr, base, __get_current_locale());
|
||||
}
|
||||
|
||||
#ifndef _REENT_ONLY
|
||||
|
||||
intmax_t
|
||||
wcstoimax_l(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr,
|
||||
int base, locale_t loc)
|
||||
{
|
||||
return _wcstoimax_l(_REENT, nptr, endptr, base, loc);
|
||||
}
|
||||
|
||||
intmax_t
|
||||
wcstoimax(const wchar_t* __restrict nptr, wchar_t** __restrict endptr, int base)
|
||||
{
|
||||
return _wcstoimax_l(_REENT, nptr, endptr, base, __get_current_locale());
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,157 @@
|
|||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2011 The FreeBSD Foundation
|
||||
* All rights reserved.
|
||||
* Portions of this software were developed by David Chisnall
|
||||
* under sponsorship from the FreeBSD Foundation.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if 0
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "from @(#)strtoul.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
__FBSDID("FreeBSD: src/lib/libc/stdlib/strtoumax.c,v 1.8 2002/09/06 11:23:59 tjr Exp ");
|
||||
#endif
|
||||
__FBSDID("$FreeBSD: head/lib/libc/locale/wcstoumax.c 314436 2017-02-28 23:42:47Z imp $");
|
||||
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#include <wctype.h>
|
||||
#include <stdint.h>
|
||||
#include <reent.h>
|
||||
#include "../locale/setlocale.h"
|
||||
|
||||
/*
|
||||
* Convert a wide character string to a uintmax_t integer.
|
||||
*/
|
||||
|
||||
/*
|
||||
*Reentrant version of wcstoumax.
|
||||
*/
|
||||
static uintmax_t
|
||||
_wcstoumax_l(struct _reent *rptr,const wchar_t * __restrict nptr,
|
||||
wchar_t ** __restrict endptr, int base, locale_t loc)
|
||||
{
|
||||
const wchar_t *s = nptr;
|
||||
uintmax_t acc;
|
||||
wchar_t c;
|
||||
uintmax_t cutoff;
|
||||
int neg = 0, any, cutlim;
|
||||
|
||||
/*
|
||||
* See strtoimax for comments as to the logic used.
|
||||
*/
|
||||
do {
|
||||
c = *s++;
|
||||
} while (iswspace_l(c, loc));
|
||||
if (c == L'-') {
|
||||
neg = 1;
|
||||
c = *s++;
|
||||
} else {
|
||||
neg = 0;
|
||||
if (c == L'+')
|
||||
c = *s++;
|
||||
}
|
||||
if ((base == 0 || base == 16) &&
|
||||
c == L'0' && (*s == L'x' || *s == L'X')) {
|
||||
c = s[1];
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
if (base == 0)
|
||||
base = c == L'0' ? 8 : 10;
|
||||
acc = any = 0;
|
||||
if (base < 2 || base > 36)
|
||||
goto noconv;
|
||||
|
||||
cutoff = UINTMAX_MAX / base;
|
||||
cutlim = UINTMAX_MAX % base;
|
||||
for ( ; ; c = *s++) {
|
||||
#ifdef notyet
|
||||
if (iswdigit_l(c, loc))
|
||||
c = digittoint_l(c, loc);
|
||||
else
|
||||
#endif
|
||||
if (c >= L'0' && c <= L'9')
|
||||
c -= L'0';
|
||||
else if (c >= L'A' && c <= L'Z')
|
||||
c -= L'A' - 10;
|
||||
else if (c >= L'a' && c <= L'z')
|
||||
c -= L'a' - 10;
|
||||
else
|
||||
break;
|
||||
if (c >= base)
|
||||
break;
|
||||
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
|
||||
any = -1;
|
||||
else {
|
||||
any = 1;
|
||||
acc *= base;
|
||||
acc += c;
|
||||
}
|
||||
}
|
||||
if (any < 0) {
|
||||
acc = UINTMAX_MAX;
|
||||
rptr->_errno = ERANGE;
|
||||
} else if (!any) {
|
||||
noconv:
|
||||
rptr->_errno = EINVAL;
|
||||
} else if (neg)
|
||||
acc = -acc;
|
||||
if (endptr != NULL)
|
||||
*endptr = (wchar_t *)(any ? s - 1 : nptr);
|
||||
return (acc);
|
||||
}
|
||||
|
||||
uintmax_t
|
||||
_wcstoumax_r(struct _reent *rptr, const wchar_t *__restrict nptr,
|
||||
wchar_t **__restrict endptr, int base)
|
||||
{
|
||||
return _wcstoumax_l(rptr, nptr, endptr, base, __get_current_locale());
|
||||
}
|
||||
|
||||
#ifndef _REENT_ONLY
|
||||
|
||||
uintmax_t
|
||||
wcstoumax_l(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr,
|
||||
int base, locale_t loc)
|
||||
{
|
||||
return _wcstoumax_l(_REENT, nptr, endptr, base, loc);
|
||||
}
|
||||
|
||||
uintmax_t
|
||||
wcstoumax(const wchar_t* __restrict nptr, wchar_t** __restrict endptr, int base)
|
||||
{
|
||||
return _wcstoumax_l(_REENT, nptr, endptr, base, __get_current_locale());
|
||||
}
|
||||
|
||||
#endif
|
|
@ -8,6 +8,11 @@ GENERAL_SOURCES = \
|
|||
bcopy.c \
|
||||
bzero.c \
|
||||
explicit_bzero.c \
|
||||
ffsl.c \
|
||||
ffsll.c \
|
||||
fls.c \
|
||||
flsl.c \
|
||||
flsll.c \
|
||||
index.c \
|
||||
memchr.c \
|
||||
memcmp.c \
|
||||
|
@ -112,6 +117,7 @@ ELIX_4_SOURCES = \
|
|||
strcasecmp_l.c \
|
||||
strcoll_l.c \
|
||||
strncasecmp_l.c \
|
||||
strverscmp.c \
|
||||
strxfrm_l.c \
|
||||
wcscasecmp.c \
|
||||
wcscasecmp_l.c \
|
||||
|
@ -156,6 +162,7 @@ wcswidth.def wcsxfrm.def wcwidth.def wmemchr.def \
|
|||
wmemcmp.def wmemcpy.def wmemmove.def wmemset.def \
|
||||
memmem.def memrchr.def rawmemchr.def strchrnul.def \
|
||||
strcasecmp_l.def strcoll_l.def strncasecmp_l.def strxfrm_l.def \
|
||||
wcscasecmp_l.def wcscoll_l.def wcsncasecmp_l.def wcsxfrm_l.def
|
||||
wcscasecmp_l.def wcscoll_l.def wcsncasecmp_l.def wcsxfrm_l.def \
|
||||
strverscmp.def
|
||||
|
||||
CHAPTERS = strings.tex wcstrings.tex
|
||||
|
|
|
@ -73,7 +73,9 @@ ARFLAGS = cru
|
|||
lib_a_AR = $(AR) $(ARFLAGS)
|
||||
lib_a_LIBADD =
|
||||
am__objects_1 = lib_a-bcopy.$(OBJEXT) lib_a-bzero.$(OBJEXT) \
|
||||
lib_a-explicit_bzero.$(OBJEXT) lib_a-index.$(OBJEXT) \
|
||||
lib_a-explicit_bzero.$(OBJEXT) lib_a-ffsl.$(OBJEXT) \
|
||||
lib_a-ffsll.$(OBJEXT) lib_a-fls.$(OBJEXT) lib_a-flsl.$(OBJEXT) \
|
||||
lib_a-flsll.$(OBJEXT) lib_a-index.$(OBJEXT) \
|
||||
lib_a-memchr.$(OBJEXT) lib_a-memcmp.$(OBJEXT) \
|
||||
lib_a-memcpy.$(OBJEXT) lib_a-memmove.$(OBJEXT) \
|
||||
lib_a-memset.$(OBJEXT) lib_a-rindex.$(OBJEXT) \
|
||||
|
@ -127,6 +129,7 @@ am__objects_1 = lib_a-bcopy.$(OBJEXT) lib_a-bzero.$(OBJEXT) \
|
|||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-strcasecmp_l.$(OBJEXT) \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-strcoll_l.$(OBJEXT) \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-strncasecmp_l.$(OBJEXT) \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-strverscmp.$(OBJEXT) \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-strxfrm_l.$(OBJEXT) \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-wcscasecmp.$(OBJEXT) \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-wcscasecmp_l.$(OBJEXT) \
|
||||
|
@ -139,18 +142,19 @@ am__objects_1 = lib_a-bcopy.$(OBJEXT) lib_a-bzero.$(OBJEXT) \
|
|||
lib_a_OBJECTS = $(am_lib_a_OBJECTS)
|
||||
LTLIBRARIES = $(noinst_LTLIBRARIES)
|
||||
libstring_la_LIBADD =
|
||||
am__objects_4 = bcopy.lo bzero.lo explicit_bzero.lo index.lo memchr.lo \
|
||||
memcmp.lo memcpy.lo memmove.lo memset.lo rindex.lo \
|
||||
strcasecmp.lo strcat.lo strchr.lo strcmp.lo strcoll.lo \
|
||||
strcpy.lo strcspn.lo strdup.lo strdup_r.lo strerror.lo \
|
||||
strerror_r.lo strlcat.lo strlcpy.lo strlen.lo strlwr.lo \
|
||||
strncasecmp.lo strncat.lo strncmp.lo strncpy.lo strnlen.lo \
|
||||
strpbrk.lo strrchr.lo strsep.lo strsignal.lo strspn.lo \
|
||||
strtok.lo strtok_r.lo strupr.lo strxfrm.lo strstr.lo swab.lo \
|
||||
timingsafe_bcmp.lo timingsafe_memcmp.lo u_strerr.lo wcscat.lo \
|
||||
wcschr.lo wcscmp.lo wcscoll.lo wcscpy.lo wcscspn.lo wcslcat.lo \
|
||||
wcslcpy.lo wcslen.lo wcsncat.lo wcsncmp.lo wcsncpy.lo \
|
||||
wcsnlen.lo wcspbrk.lo wcsrchr.lo wcsspn.lo wcsstr.lo wcstok.lo \
|
||||
am__objects_4 = bcopy.lo bzero.lo explicit_bzero.lo ffsl.lo ffsll.lo \
|
||||
fls.lo flsl.lo flsll.lo index.lo memchr.lo memcmp.lo memcpy.lo \
|
||||
memmove.lo memset.lo rindex.lo strcasecmp.lo strcat.lo \
|
||||
strchr.lo strcmp.lo strcoll.lo strcpy.lo strcspn.lo strdup.lo \
|
||||
strdup_r.lo strerror.lo strerror_r.lo strlcat.lo strlcpy.lo \
|
||||
strlen.lo strlwr.lo strncasecmp.lo strncat.lo strncmp.lo \
|
||||
strncpy.lo strnlen.lo strpbrk.lo strrchr.lo strsep.lo \
|
||||
strsignal.lo strspn.lo strtok.lo strtok_r.lo strupr.lo \
|
||||
strxfrm.lo strstr.lo swab.lo timingsafe_bcmp.lo \
|
||||
timingsafe_memcmp.lo u_strerr.lo wcscat.lo wcschr.lo wcscmp.lo \
|
||||
wcscoll.lo wcscpy.lo wcscspn.lo wcslcat.lo wcslcpy.lo \
|
||||
wcslen.lo wcsncat.lo wcsncmp.lo wcsncpy.lo wcsnlen.lo \
|
||||
wcspbrk.lo wcsrchr.lo wcsspn.lo wcsstr.lo wcstok.lo \
|
||||
wcswidth.lo wcsxfrm.lo wcwidth.lo wmemchr.lo wmemcmp.lo \
|
||||
wmemcpy.lo wmemmove.lo wmemset.lo xpg_strerror_r.lo
|
||||
@ELIX_LEVEL_1_FALSE@am__objects_5 = bcmp.lo memccpy.lo mempcpy.lo \
|
||||
|
@ -164,6 +168,7 @@ am__objects_4 = bcopy.lo bzero.lo explicit_bzero.lo index.lo memchr.lo \
|
|||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ strcasecmp_l.lo \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ strcoll_l.lo \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ strncasecmp_l.lo \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ strverscmp.lo \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ strxfrm_l.lo \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ wcscasecmp.lo \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ wcscasecmp_l.lo \
|
||||
|
@ -349,6 +354,11 @@ GENERAL_SOURCES = \
|
|||
bcopy.c \
|
||||
bzero.c \
|
||||
explicit_bzero.c \
|
||||
ffsl.c \
|
||||
ffsll.c \
|
||||
fls.c \
|
||||
flsl.c \
|
||||
flsll.c \
|
||||
index.c \
|
||||
memchr.c \
|
||||
memcmp.c \
|
||||
|
@ -441,6 +451,7 @@ GENERAL_SOURCES = \
|
|||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ strcasecmp_l.c \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ strcoll_l.c \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ strncasecmp_l.c \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ strverscmp.c \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ strxfrm_l.c \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ wcscasecmp.c \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ wcscasecmp_l.c \
|
||||
|
@ -488,7 +499,8 @@ wcswidth.def wcsxfrm.def wcwidth.def wmemchr.def \
|
|||
wmemcmp.def wmemcpy.def wmemmove.def wmemset.def \
|
||||
memmem.def memrchr.def rawmemchr.def strchrnul.def \
|
||||
strcasecmp_l.def strcoll_l.def strncasecmp_l.def strxfrm_l.def \
|
||||
wcscasecmp_l.def wcscoll_l.def wcsncasecmp_l.def wcsxfrm_l.def
|
||||
wcscasecmp_l.def wcscoll_l.def wcsncasecmp_l.def wcsxfrm_l.def \
|
||||
strverscmp.def
|
||||
|
||||
CHAPTERS = strings.tex wcstrings.tex
|
||||
all: all-am
|
||||
|
@ -578,6 +590,36 @@ lib_a-explicit_bzero.o: explicit_bzero.c
|
|||
lib_a-explicit_bzero.obj: explicit_bzero.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-explicit_bzero.obj `if test -f 'explicit_bzero.c'; then $(CYGPATH_W) 'explicit_bzero.c'; else $(CYGPATH_W) '$(srcdir)/explicit_bzero.c'; fi`
|
||||
|
||||
lib_a-ffsl.o: ffsl.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ffsl.o `test -f 'ffsl.c' || echo '$(srcdir)/'`ffsl.c
|
||||
|
||||
lib_a-ffsl.obj: ffsl.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ffsl.obj `if test -f 'ffsl.c'; then $(CYGPATH_W) 'ffsl.c'; else $(CYGPATH_W) '$(srcdir)/ffsl.c'; fi`
|
||||
|
||||
lib_a-ffsll.o: ffsll.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ffsll.o `test -f 'ffsll.c' || echo '$(srcdir)/'`ffsll.c
|
||||
|
||||
lib_a-ffsll.obj: ffsll.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ffsll.obj `if test -f 'ffsll.c'; then $(CYGPATH_W) 'ffsll.c'; else $(CYGPATH_W) '$(srcdir)/ffsll.c'; fi`
|
||||
|
||||
lib_a-fls.o: fls.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fls.o `test -f 'fls.c' || echo '$(srcdir)/'`fls.c
|
||||
|
||||
lib_a-fls.obj: fls.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fls.obj `if test -f 'fls.c'; then $(CYGPATH_W) 'fls.c'; else $(CYGPATH_W) '$(srcdir)/fls.c'; fi`
|
||||
|
||||
lib_a-flsl.o: flsl.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-flsl.o `test -f 'flsl.c' || echo '$(srcdir)/'`flsl.c
|
||||
|
||||
lib_a-flsl.obj: flsl.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-flsl.obj `if test -f 'flsl.c'; then $(CYGPATH_W) 'flsl.c'; else $(CYGPATH_W) '$(srcdir)/flsl.c'; fi`
|
||||
|
||||
lib_a-flsll.o: flsll.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-flsll.o `test -f 'flsll.c' || echo '$(srcdir)/'`flsll.c
|
||||
|
||||
lib_a-flsll.obj: flsll.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-flsll.obj `if test -f 'flsll.c'; then $(CYGPATH_W) 'flsll.c'; else $(CYGPATH_W) '$(srcdir)/flsll.c'; fi`
|
||||
|
||||
lib_a-index.o: index.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-index.o `test -f 'index.c' || echo '$(srcdir)/'`index.c
|
||||
|
||||
|
@ -1100,6 +1142,12 @@ lib_a-strncasecmp_l.o: strncasecmp_l.c
|
|||
lib_a-strncasecmp_l.obj: strncasecmp_l.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strncasecmp_l.obj `if test -f 'strncasecmp_l.c'; then $(CYGPATH_W) 'strncasecmp_l.c'; else $(CYGPATH_W) '$(srcdir)/strncasecmp_l.c'; fi`
|
||||
|
||||
lib_a-strverscmp.o: strverscmp.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strverscmp.o `test -f 'strverscmp.c' || echo '$(srcdir)/'`strverscmp.c
|
||||
|
||||
lib_a-strverscmp.obj: strverscmp.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strverscmp.obj `if test -f 'strverscmp.c'; then $(CYGPATH_W) 'strverscmp.c'; else $(CYGPATH_W) '$(srcdir)/strverscmp.c'; fi`
|
||||
|
||||
lib_a-strxfrm_l.o: strxfrm_l.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strxfrm_l.o `test -f 'strxfrm_l.c' || echo '$(srcdir)/'`strxfrm_l.c
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue