llvm.org GIT mirror llvm / ac90d5e
In LLVM 2.0 we won't use the runtime libraries as llvm-gcc3 support will be dropped. This patch pertains to removing the runtime directory from LLVM. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31793 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Spencer 12 years ago
53 changed file(s) with 38 addition(s) and 3284 deletion(s). Raw diff Collapse all Expand all
1414 # 3. Build VMCore, which builds the Intrinsics.inc file used by libs.
1515 # 4. Build libs, which are needed by llvm-config.
1616 # 5. Build llvm-config, which determines inter-lib dependencies for tools.
17 # 6. Build tools, runtime, docs.
17 # 6. Build tools, docs.
1818 #
1919 DIRS := lib/System lib/Support utils lib/VMCore lib tools/llvm-config \
20 tools runtime docs
20 tools docs
2121
2222 OPTIONAL_DIRS := examples projects
2323 EXTRA_DIST := test llvm.spec include win32 Xcode
2424
2525 include $(LEVEL)/Makefile.config
2626
27 # llvm-gcc4 doesn't need runtime libs.
28 ifeq ($(LLVMGCC_MAJVERS),4)
29 DIRS := $(filter-out runtime, $(DIRS))
30 endif
31
3227 ifeq ($(MAKECMDGOALS),libs-only)
33 DIRS := $(filter-out tools runtime docs, $(DIRS))
28 DIRS := $(filter-out tools docs, $(DIRS))
3429 OPTIONAL_DIRS :=
3530 endif
3631
3732 ifeq ($(MAKECMDGOALS),tools-only)
38 DIRS := $(filter-out runtime docs, $(DIRS))
33 DIRS := $(filter-out docs, $(DIRS))
3934 OPTIONAL_DIRS :=
4035 endif
4136
206206 #DISABLE_ASSERTIONS = 1
207207 @DISABLE_ASSERTIONS@
208208
209 # When DEBUG_RUNTIME is enabled, the runtime libraries will retain debug
210 # symbols.
211 #DEBUG_RUNTIME = 1
212 @DEBUG_RUNTIME@
213
214209 # When ENABLE_PROFILING is enabled, the llvm source base is built with profile
215210 # information to allow gprof to be used to get execution frequencies.
216211 #ENABLE_PROFILING = 1
10981098 $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG)
10991099 $(MAYBE_PIC_Compile.C) $< -o $@ -S
11001100
1101
11021101 # make the C and C++ compilers strip debug info out of bytecode libraries.
1103 ifdef DEBUG_RUNTIME
1104 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(GCCAS)
1105 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
1106 $(Verb) $(GCCAS) $< -o $@
1107 else
11081102 $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(GCCAS)
11091103 $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)"
11101104 $(Verb) $(GCCAS) -strip-debug $< -o $@
1111 endif
1112
11131105
11141106 #---------------------------------------------------------
11151107 # Provide rule to build .bc files from .ll sources,
265265 AC_SUBST(DISABLE_ASSERTIONS,[[]])
266266 else
267267 AC_SUBST(DISABLE_ASSERTIONS,[[DISABLE_ASSERTIONS=1]])
268 fi
269
270 dnl --enable-debug-runtime : should runtime libraries have debug symbols?
271 AC_ARG_ENABLE(debug-runtime,
272 AS_HELP_STRING([--enable-debug-runtime,Build runtime libs with debug symbols (default is NO)]),,enableval=no)
273 if test ${enableval} = "no" ; then
274 AC_SUBST(DEBUG_RUNTIME,[[]])
275 else
276 AC_SUBST(DEBUG_RUNTIME,[[DEBUG_RUNTIME=1]])
277268 fi
278269
279270 dnl --enable-jit: check whether they want to enable the jit
819810 AC_CONFIG_MAKEFILE(Makefile.common)
820811 AC_CONFIG_MAKEFILE(examples/Makefile)
821812 AC_CONFIG_MAKEFILE(lib/Makefile)
822 AC_CONFIG_MAKEFILE(runtime/Makefile)
823813 AC_CONFIG_MAKEFILE(test/Makefile)
824814 AC_CONFIG_MAKEFILE(test/Makefile.tests)
825815 AC_CONFIG_MAKEFILE(tools/Makefile)
832822 dnl Warn loudly if llvm-gcc was not obviously working
833823 if test "$llvm_cv_llvmgcc_sanity" = "no" ; then
834824 AC_MSG_WARN([***** llvm-gcc/llvm-g++ was not found, or does not appear to be ])
835 AC_MSG_WARN([***** working. Please make sure you have llvm-gcc and llvm-g++ in])
836 AC_MSG_WARN([***** your path before configuring LLVM. The runtime libraries])
837 AC_MSG_WARN([***** (llvm/runtime) will not be built but you should be able to])
838 AC_MSG_WARN([***** build the llvm tools.])
839 fi
825 AC_MSG_WARN([***** working. Please make sure you have llvm-gcc and llvm-g++ ])
826 AC_MSG_WARN([***** in your path before configuring LLVM.])
827 fi
829829 CVSBUILD
830830 ENABLE_OPTIMIZED
831831 DISABLE_ASSERTIONS
832 DEBUG_RUNTIME
833832 JIT
834833 TARGET_HAS_JIT
835834 ENABLE_DOXYGEN
15191518 --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
15201519 --enable-optimized
15211520 --enable-assertions
1522 --enable-debug-runtime
15231521 --enable-jit Enable Just In Time Compiling (default is YES)
15241522 --enable-doxygen Build doxygen documentation (default is NO)
15251523 --enable-threads Use threads if available (default is YES)
45624560
45634561 fi
45644562
4565 # Check whether --enable-debug-runtime was given.
4566 if test "${enable_debug_runtime+set}" = set; then
4567 enableval=$enable_debug_runtime;
4568 else
4569 enableval=no
4570 fi
4571
4572 if test ${enableval} = "no" ; then
4573 DEBUG_RUNTIME=
4574
4575 else
4576 DEBUG_RUNTIME=DEBUG_RUNTIME=1
4577
4578 fi
4579
45804563 # Check whether --enable-jit was given.
45814564 if test "${enable_jit+set}" = set; then
45824565 enableval=$enable_jit;
1029710280 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1029810281 lt_status=$lt_dlunknown
1029910282 cat > conftest.$ac_ext <
10300 #line 10301 "configure"
10283 #line 10284 "configure"
1030110284 #include "confdefs.h"
1030210285
1030310286 #if HAVE_DLFCN_H
1244112424 ;;
1244212425 *-*-irix6*)
1244312426 # Find out which ABI we are using.
12444 echo '#line 12445 "configure"' > conftest.$ac_ext
12427 echo '#line 12428 "configure"' > conftest.$ac_ext
1244512428 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
1244612429 (eval $ac_compile) 2>&5
1244712430 ac_status=$?
1415914142 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
1416014143 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
1416114144 -e 's:$: $lt_compiler_flag:'`
14162 (eval echo "\"\$as_me:14163: $lt_compile\"" >&5)
14145 (eval echo "\"\$as_me:14146: $lt_compile\"" >&5)
1416314146 (eval "$lt_compile" 2>conftest.err)
1416414147 ac_status=$?
1416514148 cat conftest.err >&5
14166 echo "$as_me:14167: \$? = $ac_status" >&5
14149 echo "$as_me:14150: \$? = $ac_status" >&5
1416714150 if (exit $ac_status) && test -s "$ac_outfile"; then
1416814151 # The compiler can only warn and ignore the option if not recognized
1416914152 # So say no if there are warnings other than the usual output.
1442714410 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
1442814411 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
1442914412 -e 's:$: $lt_compiler_flag:'`
14430 (eval echo "\"\$as_me:14431: $lt_compile\"" >&5)
14413 (eval echo "\"\$as_me:14414: $lt_compile\"" >&5)
1443114414 (eval "$lt_compile" 2>conftest.err)
1443214415 ac_status=$?
1443314416 cat conftest.err >&5
14434 echo "$as_me:14435: \$? = $ac_status" >&5
14417 echo "$as_me:14418: \$? = $ac_status" >&5
1443514418 if (exit $ac_status) && test -s "$ac_outfile"; then
1443614419 # The compiler can only warn and ignore the option if not recognized
1443714420 # So say no if there are warnings other than the usual output.
1453114514 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
1453214515 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
1453314516 -e 's:$: $lt_compiler_flag:'`
14534 (eval echo "\"\$as_me:14535: $lt_compile\"" >&5)
14517 (eval echo "\"\$as_me:14518: $lt_compile\"" >&5)
1453514518 (eval "$lt_compile" 2>out/conftest.err)
1453614519 ac_status=$?
1453714520 cat out/conftest.err >&5
14538 echo "$as_me:14539: \$? = $ac_status" >&5
14521 echo "$as_me:14522: \$? = $ac_status" >&5
1453914522 if (exit $ac_status) && test -s out/conftest2.$ac_objext
1454014523 then
1454114524 # The compiler can only warn and ignore the option if not recognized
1698316966 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1698416967 lt_status=$lt_dlunknown
1698516968 cat > conftest.$ac_ext <
16986 #line 16987 "configure"
16969 #line 16970 "configure"
1698716970 #include "confdefs.h"
1698816971
1698916972 #if HAVE_DLFCN_H
1708317066 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1708417067 lt_status=$lt_dlunknown
1708517068 cat > conftest.$ac_ext <
17086 #line 17087 "configure"
17069 #line 17070 "configure"
1708717070 #include "confdefs.h"
1708817071
1708917072 #if HAVE_DLFCN_H
1945119434 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
1945219435 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
1945319436 -e 's:$: $lt_compiler_flag:'`
19454 (eval echo "\"\$as_me:19455: $lt_compile\"" >&5)
19437 (eval echo "\"\$as_me:19438: $lt_compile\"" >&5)
1945519438 (eval "$lt_compile" 2>conftest.err)
1945619439 ac_status=$?
1945719440 cat conftest.err >&5
19458 echo "$as_me:19459: \$? = $ac_status" >&5
19441 echo "$as_me:19442: \$? = $ac_status" >&5
1945919442 if (exit $ac_status) && test -s "$ac_outfile"; then
1946019443 # The compiler can only warn and ignore the option if not recognized
1946119444 # So say no if there are warnings other than the usual output.
1955519538 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
1955619539 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
1955719540 -e 's:$: $lt_compiler_flag:'`
19558 (eval echo "\"\$as_me:19559: $lt_compile\"" >&5)
19541 (eval echo "\"\$as_me:19542: $lt_compile\"" >&5)
1955919542 (eval "$lt_compile" 2>out/conftest.err)
1956019543 ac_status=$?
1956119544 cat out/conftest.err >&5
19562 echo "$as_me:19563: \$? = $ac_status" >&5
19545 echo "$as_me:19546: \$? = $ac_status" >&5
1956319546 if (exit $ac_status) && test -s out/conftest2.$ac_objext
1956419547 then
1956519548 # The compiler can only warn and ignore the option if not recognized
2112521108 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
2112621109 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
2112721110 -e 's:$: $lt_compiler_flag:'`
21128 (eval echo "\"\$as_me:21129: $lt_compile\"" >&5)
21111 (eval echo "\"\$as_me:21112: $lt_compile\"" >&5)
2112921112 (eval "$lt_compile" 2>conftest.err)
2113021113 ac_status=$?
2113121114 cat conftest.err >&5
21132 echo "$as_me:21133: \$? = $ac_status" >&5
21115 echo "$as_me:21116: \$? = $ac_status" >&5
2113321116 if (exit $ac_status) && test -s "$ac_outfile"; then
2113421117 # The compiler can only warn and ignore the option if not recognized
2113521118 # So say no if there are warnings other than the usual output.
2122921212 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
2123021213 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
2123121214 -e 's:$: $lt_compiler_flag:'`
21232 (eval echo "\"\$as_me:21233: $lt_compile\"" >&5)
21215 (eval echo "\"\$as_me:21216: $lt_compile\"" >&5)
2123321216 (eval "$lt_compile" 2>out/conftest.err)
2123421217 ac_status=$?
2123521218 cat out/conftest.err >&5
21236 echo "$as_me:21237: \$? = $ac_status" >&5
21219 echo "$as_me:21220: \$? = $ac_status" >&5
2123721220 if (exit $ac_status) && test -s out/conftest2.$ac_objext
2123821221 then
2123921222 # The compiler can only warn and ignore the option if not recognized
2346423447 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
2346523448 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
2346623449 -e 's:$: $lt_compiler_flag:'`
23467 (eval echo "\"\$as_me:23468: $lt_compile\"" >&5)
23450 (eval echo "\"\$as_me:23451: $lt_compile\"" >&5)
2346823451 (eval "$lt_compile" 2>conftest.err)
2346923452 ac_status=$?
2347023453 cat conftest.err >&5
23471 echo "$as_me:23472: \$? = $ac_status" >&5
23454 echo "$as_me:23455: \$? = $ac_status" >&5
2347223455 if (exit $ac_status) && test -s "$ac_outfile"; then
2347323456 # The compiler can only warn and ignore the option if not recognized
2347423457 # So say no if there are warnings other than the usual output.
2373223715 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
2373323716 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
2373423717 -e 's:$: $lt_compiler_flag:'`
23735 (eval echo "\"\$as_me:23736: $lt_compile\"" >&5)
23718 (eval echo "\"\$as_me:23719: $lt_compile\"" >&5)
2373623719 (eval "$lt_compile" 2>conftest.err)
2373723720 ac_status=$?
2373823721 cat conftest.err >&5
23739 echo "$as_me:23740: \$? = $ac_status" >&5
23722 echo "$as_me:23723: \$? = $ac_status" >&5
2374023723 if (exit $ac_status) && test -s "$ac_outfile"; then
2374123724 # The compiler can only warn and ignore the option if not recognized
2374223725 # So say no if there are warnings other than the usual output.
2383623819 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
2383723820 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
2383823821 -e 's:$: $lt_compiler_flag:'`
23839 (eval echo "\"\$as_me:23840: $lt_compile\"" >&5)
23822 (eval echo "\"\$as_me:23823: $lt_compile\"" >&5)
2384023823 (eval "$lt_compile" 2>out/conftest.err)
2384123824 ac_status=$?
2384223825 cat out/conftest.err >&5
23843 echo "$as_me:23844: \$? = $ac_status" >&5
23826 echo "$as_me:23827: \$? = $ac_status" >&5
2384423827 if (exit $ac_status) && test -s out/conftest2.$ac_objext
2384523828 then
2384623829 # The compiler can only warn and ignore the option if not recognized
3343033413 ac_config_commands="$ac_config_commands lib/Makefile"
3343133414
3343233415
33433 ac_config_commands="$ac_config_commands runtime/Makefile"
33434
33435
3343633416 ac_config_commands="$ac_config_commands test/Makefile"
3343733417
3343833418
3402634006 "Makefile.common") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile.common" ;;
3402734007 "examples/Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS examples/Makefile" ;;
3402834008 "lib/Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS lib/Makefile" ;;
34029 "runtime/Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS runtime/Makefile" ;;
3403034009 "test/Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS test/Makefile" ;;
3403134010 "test/Makefile.tests") CONFIG_COMMANDS="$CONFIG_COMMANDS test/Makefile.tests" ;;
3403234011 "tools/Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS tools/Makefile" ;;
3416834147 CVSBUILD!$CVSBUILD$ac_delim
3416934148 ENABLE_OPTIMIZED!$ENABLE_OPTIMIZED$ac_delim
3417034149 DISABLE_ASSERTIONS!$DISABLE_ASSERTIONS$ac_delim
34171 DEBUG_RUNTIME!$DEBUG_RUNTIME$ac_delim
3417234150 JIT!$JIT$ac_delim
3417334151 TARGET_HAS_JIT!$TARGET_HAS_JIT$ac_delim
3417434152 ENABLE_DOXYGEN!$ENABLE_DOXYGEN$ac_delim
3419134169 LN_S!$LN_S$ac_delim
3419234170 CMP!$CMP$ac_delim
3419334171 CP!$CP$ac_delim
34172 DATE!$DATE$ac_delim
3419434173 _ACEOF
3419534174
3419634175 if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
3423234211 ac_delim='%!_!# '
3423334212 for ac_last_try in false false false false false :; do
3423434213 cat >conf$$subs.sed <<_ACEOF
34235 DATE!$DATE$ac_delim
3423634214 FIND!$FIND$ac_delim
3423734215 MKDIR!$MKDIR$ac_delim
3423834216 MV!$MV$ac_delim
3429834276 LTLIBOBJS!$LTLIBOBJS$ac_delim
3429934277 _ACEOF
3430034278
34301 if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 64; then
34279 if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 63; then
3430234280 break
3430334281 elif $ac_last_try; then
3430434282 { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
3470934687 ${SHELL} ${llvm_src}/autoconf/install-sh -c ${srcdir}/examples/Makefile examples/Makefile ;;
3471034688 "lib/Makefile":C) ${llvm_src}/autoconf/mkinstalldirs `dirname lib/Makefile`
3471134689 ${SHELL} ${llvm_src}/autoconf/install-sh -c ${srcdir}/lib/Makefile lib/Makefile ;;
34712 "runtime/Makefile":C) ${llvm_src}/autoconf/mkinstalldirs `dirname runtime/Makefile`
34713 ${SHELL} ${llvm_src}/autoconf/install-sh -c ${srcdir}/runtime/Makefile runtime/Makefile ;;
3471434690 "test/Makefile":C) ${llvm_src}/autoconf/mkinstalldirs `dirname test/Makefile`
3471534691 ${SHELL} ${llvm_src}/autoconf/install-sh -c ${srcdir}/test/Makefile test/Makefile ;;
3471634692 "test/Makefile.tests":C) ${llvm_src}/autoconf/mkinstalldirs `dirname test/Makefile.tests`
3493234908 if test "$llvm_cv_llvmgcc_sanity" = "no" ; then
3493334909 { echo "$as_me:$LINENO: WARNING: ***** llvm-gcc/llvm-g++ was not found, or does not appear to be " >&5
3493434910 echo "$as_me: WARNING: ***** llvm-gcc/llvm-g++ was not found, or does not appear to be " >&2;}
34935 { echo "$as_me:$LINENO: WARNING: ***** working. Please make sure you have llvm-gcc and llvm-g++ in" >&5
34936 echo "$as_me: WARNING: ***** working. Please make sure you have llvm-gcc and llvm-g++ in" >&2;}
34937 { echo "$as_me:$LINENO: WARNING: ***** your path before configuring LLVM. The runtime libraries" >&5
34938 echo "$as_me: WARNING: ***** your path before configuring LLVM. The runtime libraries" >&2;}
34939 { echo "$as_me:$LINENO: WARNING: ***** (llvm/runtime) will not be built but you should be able to" >&5
34940 echo "$as_me: WARNING: ***** (llvm/runtime) will not be built but you should be able to" >&2;}
34941 { echo "$as_me:$LINENO: WARNING: ***** build the llvm tools." >&5
34942 echo "$as_me: WARNING: ***** build the llvm tools." >&2;}
34943 fi
34911 { echo "$as_me:$LINENO: WARNING: ***** working. Please make sure you have llvm-gcc and llvm-g++ " >&5
34912 echo "$as_me: WARNING: ***** working. Please make sure you have llvm-gcc and llvm-g++ " >&2;}
34913 { echo "$as_me:$LINENO: WARNING: ***** in your path before configuring LLVM." >&5
34914 echo "$as_me: WARNING: ***** in your path before configuring LLVM." >&2;}
34915 fi
+0
-48
runtime/GC/GCInterface.h less more
None /*===-- GCInterface.h - Public interface exposed by garbage collectors ----===*\
1 |*
2 |* The LLVM Compiler Infrastructure
3 |*
4 |* This file was developed by the LLVM research group and is distributed under
5 |* the University of Illinois Open Source License. See LICENSE.TXT for details.
6 |*
7 |*===----------------------------------------------------------------------===*|
8 |*
9 |* This file defines the common public interface that must be exposed by all
10 |* LLVM garbage collectors.
11 |*
12 \*===----------------------------------------------------------------------===*/
13
14 #ifndef GCINTERFACE_H
15 #define GCINTERFACE_H
16
17 /* llvm_cg_walk_gcroots - This function is exposed by the LLVM code generator,
18 * and allows us to traverse the roots on the stack.
19 */
20 void llvm_cg_walk_gcroots(void (*FP)(void **Root, void *Meta));
21
22
23 /* llvm_gc_initialize - This function is called to initalize the garbage
24 * collector.
25 */
26 void llvm_gc_initialize(unsigned InitialHeapSize);
27
28 /* llvm_gc_allocate - This function allocates Size bytes from the heap and
29 * returns a pointer to it.
30 */
31 void *llvm_gc_allocate(unsigned Size);
32
33 /* llvm_gc_collect - This function forces a garbage collection cycle.
34 */
35 void llvm_gc_collect();
36
37 /* llvm_gc_read - This function should be implemented to include any read
38 * barrier code that is needed by the garbage collector.
39 */
40 void *llvm_gc_read(void *ObjPtr, void **FieldPtr);
41
42 /* llvm_gc_write - This function should be implemented to include any write
43 * barrier code that is needed by the garbage collector.
44 */
45 void llvm_gc_write(void *V, void *ObjPtr, void **FieldPtr);
46
47 #endif
+0
-19
runtime/GC/Makefile less more
None ##===- runtime/GC/Makefile ---------------------------------*- Makefile -*-===##
1 #
2 # The LLVM Compiler Infrastructure
3 #
4 # This file was developed by the LLVM research group and is distributed under
5 # the University of Illinois Open Source License. See LICENSE.TXT for details.
6 #
7 ##===----------------------------------------------------------------------===##
8
9 LEVEL = ../..
10 PARALLEL_DIRS := SemiSpace
11 EXTRA_DIST := gc_exported_symbols.lst
12 include $(LEVEL)/Makefile.common
13
14 # Install target for libraries: Copy into $LLVMGCCDIR/bytecode-libs
15 #
16 install::
17
18 clean::
+0
-19
runtime/GC/SemiSpace/Makefile less more
None ##===- runtime/GC/SemiSpace/Makefile -----------------------*- Makefile -*-===##
1 #
2 # The LLVM Compiler Infrastructure
3 #
4 # This file was developed by the LLVM research group and is distributed under
5 # the University of Illinois Open Source License. See LICENSE.TXT for details.
6 #
7 ##===----------------------------------------------------------------------===##
8
9 LEVEL = ../../..
10 BYTECODE_LIBRARY = 1
11 LIBRARYNAME = gcsemispace
12 BYTECODE_DESTINATION = $(CFERuntimeLibDir)
13 EXPORTED_SYMBOL_FILE = $(PROJ_SRC_DIR)/../gc_exported_symbols.lst
14
15 include $(LEVEL)/Makefile.common
16
17 CompileCommonOpts := $(filter-out -pedantic,$(CompileCommonOpts))
18 CompileCommonOpts := $(filter-out -Wno-long-long,$(CompileCommonOpts))
+0
-122
runtime/GC/SemiSpace/semispace.c less more
None /*===-- semispace.c - Simple semi-space copying garbage collector ---------===*\
1 |*
2 |* The LLVM Compiler Infrastructure
3 |*
4 |* This file was developed by the LLVM research group and is distributed under
5 |* the University of Illinois Open Source License. See LICENSE.TXT for details.
6 |*
7 |*===----------------------------------------------------------------------===*|
8 |*
9 |* This garbage collector is an extremely simple copying collector. It splits
10 |* the managed region of memory into two pieces: the current space to allocate
11 |* from, and the copying space. When the portion being allocated from fills up,
12 |* a garbage collection cycle happens, which copies all live blocks to the other
13 |* half of the managed space.
14 |*
15 \*===----------------------------------------------------------------------===*/
16
17 #include "../GCInterface.h"
18 #include
19 #include
20 #include
21
22 /* AllocPtr - This points to the next byte that is available for allocation.
23 */
24 static char *AllocPtr;
25
26 /* AllocEnd - This points to the first byte not available for allocation. When
27 * AllocPtr passes this, we have run out of space.
28 */
29 static char *AllocEnd;
30
31 /* CurSpace/OtherSpace - These pointers point to the two regions of memory that
32 * we switch between. The unallocated portion of the CurSpace is known to be
33 * zero'd out, but the OtherSpace contains junk.
34 */
35 static void *CurSpace, *OtherSpace;
36
37 /* SpaceSize - The size of each space. */
38 static unsigned SpaceSize;
39
40 /* llvm_gc_initialize - Allocate the two spaces that we plan to switch between.
41 */
42 void llvm_gc_initialize(unsigned InitialHeapSize) {
43 SpaceSize = InitialHeapSize/2;
44 CurSpace = AllocPtr = calloc(1, SpaceSize);
45 OtherSpace = malloc(SpaceSize);
46 AllocEnd = AllocPtr + SpaceSize;
47 }
48
49 /* We always want to inline the fast path, but never want to inline the slow
50 * path.
51 */
52 void *llvm_gc_allocate(unsigned Size) __attribute__((always_inline));
53 static void* llvm_gc_alloc_slow(unsigned Size) __attribute__((noinline));
54
55 void *llvm_gc_allocate(unsigned Size) {
56 char *OldAP = AllocPtr;
57 char *NewEnd = OldAP+Size;
58 if (NewEnd > AllocEnd)
59 return llvm_gc_alloc_slow(Size);
60 AllocPtr = NewEnd;
61 return OldAP;
62 }
63
64 static void* llvm_gc_alloc_slow(unsigned Size) {
65 llvm_gc_collect();
66 if (AllocPtr+Size > AllocEnd) {
67 fprintf(stderr, "Garbage collector ran out of memory "
68 "allocating object of size: %d\n", Size);
69 exit(1);
70 }
71
72 return llvm_gc_allocate(Size);
73 }
74
75
76 static void process_pointer(void **Root, void *Meta) {
77 printf("process_root[0x%p] = 0x%p\n", (void*) Root, (void*) *Root);
78 }
79
80 void llvm_gc_collect() {
81 // Clear out the space we will be copying into.
82 // FIXME: This should do the copy, then clear out whatever space is left.
83 memset(OtherSpace, 0, SpaceSize);
84
85 printf("Garbage collecting!!\n");
86 llvm_cg_walk_gcroots(process_pointer);
87 abort();
88 }
89
90 /* We use no read/write barriers */
91 void *llvm_gc_read(void *ObjPtr, void **FieldPtr) { return *FieldPtr; }
92 void llvm_gc_write(void *V, void *ObjPtr, void **FieldPtr) { *FieldPtr = V; }
93
94
95 /*===----------------------------------------------------------------------===**
96 * FIXME: This should be in a code-generator specific library, but for now this
97 * will work for all code generators.
98 */
99 typedef struct GCRoot {
100 void **RootPtr;
101 void *Meta;
102 } GCRoot;
103
104 typedef struct GCRoots {
105 struct GCRoots *Next;
106 unsigned NumRoots;
107 GCRoot RootRecords[];
108 } GCRoots;
109 GCRoots *llvm_gc_root_chain;
110
111 void llvm_cg_walk_gcroots(void (*FP)(void **Root, void *Meta)) {
112 GCRoots *R = llvm_gc_root_chain;
113 for (; R; R = R->Next) {
114 unsigned i, e;
115 for (i = 0, e = R->NumRoots; i != e; ++i)
116 FP(R->RootRecords[i].RootPtr, R->RootRecords[i].Meta);
117 }
118 }
119 /* END FIXME! */
120
121
+0
-7
runtime/GC/gc_exported_symbols.lst less more
None llvm_gc_initialize
1 llvm_gc_allocate
2 llvm_gc_collect
3 llvm_gc_write
4 llvm_gc_read
5
6 llvm_gc_root_chain
+0
-12
runtime/GCCLibraries/Makefile less more
None ##===- runtime/GCCLibraries/Makefile -----------------------*- Makefile -*-===##
1 #
2 # The LLVM Compiler Infrastructure
3 #
4 # This file was developed by the LLVM research group and is distributed under
5 # the University of Illinois Open Source License. See LICENSE.TXT for details.
6 #
7 ##===----------------------------------------------------------------------===##
8
9 LEVEL := ../..
10 PARALLEL_DIRS := crtend libc libgcc libm
11 include $(LEVEL)/Makefile.common
+0
-7
runtime/GCCLibraries/README.txt less more
None This directory contains libraries which are used when building the GCC
1 front-end. For the most part, these are just stub libraries, but some
2 of them contain actual code.
3
4 In particular, the crtend library contains the runtime code to handle
5 static constructors and destructors for C and C++ programs.
6
+0
-54
runtime/GCCLibraries/crtend/Exception.cpp less more
None //===- Exception.cpp - Generic language-independent exceptions ------------===//
1 //
2 // This file defines the the shared data structures used by all language
3 // specific exception handling runtime libraries.
4 //
5 //===----------------------------------------------------------------------===//
6
7 #include "Exception.h"
8
9 // Thread local state for exception handling. FIXME: This should really be made
10 // thread-local!
11
12 // UncaughtExceptionStack - The stack of exceptions currently being thrown.
13 static llvm_exception *UncaughtExceptionStack = 0;
14
15 // __llvm_eh_has_uncaught_exception - This is used to implement
16 // std::uncaught_exception.
17 //
18 bool __llvm_eh_has_uncaught_exception() throw() {
19 return UncaughtExceptionStack != 0;
20 }
21
22 // __llvm_eh_current_uncaught_exception - This function checks to see if the
23 // current uncaught exception is of the specified language type. If so, it
24 // returns a pointer to the exception area data.
25 //
26 void *__llvm_eh_current_uncaught_exception_type(unsigned HandlerType) throw() {
27 if (UncaughtExceptionStack->ExceptionType == HandlerType)
28 return UncaughtExceptionStack+1;
29 return 0;
30 }
31
32 // __llvm_eh_add_uncaught_exception - This adds the specified exception to the
33 // top of the uncaught exception stack. The exception should not already be on
34 // the stack!
35 void __llvm_eh_add_uncaught_exception(llvm_exception *E) throw() {
36 E->Next = UncaughtExceptionStack;
37 UncaughtExceptionStack = E;
38 }
39
40
41 // __llvm_eh_get_uncaught_exception - Returns the current uncaught exception.
42 // There must be an uncaught exception for this to work!
43 llvm_exception *__llvm_eh_get_uncaught_exception() throw() {
44 return UncaughtExceptionStack;
45 }
46
47 // __llvm_eh_pop_from_uncaught_stack - Remove the current uncaught exception
48 // from the top of the stack.
49 llvm_exception *__llvm_eh_pop_from_uncaught_stack() throw() {
50 llvm_exception *E = __llvm_eh_get_uncaught_exception();
51 UncaughtExceptionStack = E->Next;
52 return E;
53 }
+0
-71
runtime/GCCLibraries/crtend/Exception.h less more
None //===- Exception.h - Generic language-independent exceptions ----*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file was developed by the LLVM research group and is distributed under
5 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the the shared data structures used by all language
10 // specific exception handling runtime libraries.
11 //
12 // NOTE NOTE NOTE: A copy of this file lives in llvmgcc/libstdc++-v3/libsupc++/
13 // Any modifications to this file must keep it in sync!
14 //
15 //===----------------------------------------------------------------------===//
16
17 #ifndef EXCEPTION_H
18 #define EXCEPTION_H
19
20 struct llvm_exception {
21 // ExceptionDestructor - This call-back function is used to destroy the
22 // current exception, without requiring the caller to know what the concrete
23 // exception type is.
24 //
25 void (*ExceptionDestructor)(llvm_exception *);
26
27 // ExceptionType - This field identifies what runtime library this exception
28 // came from. Currently defined values are:
29 // 0 - Error
30 // 1 - longjmp exception (see longjmp-exception.c)
31 // 2 - C++ exception (see c++-exception.c)
32 //
33 unsigned ExceptionType;
34
35 // Next - This points to the next exception in the current stack.
36 llvm_exception *Next;
37
38 // HandlerCount - This is a count of the number of handlers which have
39 // currently caught this exception. If the handler is caught and this number
40 // falls to zero, the exception is destroyed.
41 //
42 unsigned HandlerCount;
43
44 // isRethrown - This field is set on an exception if it has been 'throw;'n.
45 // This is needed because the exception might exit through a number of the
46 // end_catch statements matching the number of begin_catch statements that
47 // have been processed. When this happens, the exception should become
48 // uncaught, not dead.
49 //
50 int isRethrown;
51 };
52
53 enum {
54 ErrorException = 0,
55 SJLJException = 1,
56 CXXException = 2
57 };
58
59 // Language independent exception handling API...
60 //
61 extern "C" {
62 bool __llvm_eh_has_uncaught_exception() throw();
63 void *__llvm_eh_current_uncaught_exception_type(unsigned HandlerType) throw();
64 void __llvm_eh_add_uncaught_exception(llvm_exception *E) throw();
65
66 llvm_exception *__llvm_eh_get_uncaught_exception() throw();
67 llvm_exception *__llvm_eh_pop_from_uncaught_stack() throw();
68 }
69
70 #endif
+0
-83
runtime/GCCLibraries/crtend/Makefile less more
None ##===- runtime/GCCLibraries/crtend/Makefile ----------------*- Makefile -*-===##
1 #
2 # The LLVM Compiler Infrastructure
3 #
4 # This file was developed by the LLVM research group and is distributed under
5 # the University of Illinois Open Source License. See LICENSE.TXT for details.
6 #
7 ##===----------------------------------------------------------------------===##
8 #
9 # This directory contains the C and C++ runtime libraries for the LLVM GCC
10 # front-ends. See the README.txt file for more details.
11 #
12 # Since this archive has strange requirements, we use some custom rules for
13 # building it.
14 #
15 ##===----------------------------------------------------------------------===##
16
17 LEVEL = ../../..
18 DONT_BUILD_RELINKED = 1
19 LIBRARYNAME = crtend
20 BYTECODE_DESTINATION = $(CFERuntimeLibDir)
21
22 MainSrc := crtend.c
23 GenericEHSrc := Exception.cpp
24 SJLJEHSrc := SJLJ-Exception.cpp
25
26 EXTRA_DIST := $(MainSrc) $(GenericEHSrc) $(SJLJEHSrc) \
27 comp_main.lst comp_genericeh.lst comp_sjljeh.lst
28
29 include $(LEVEL)/Makefile.common
30
31 MainObj := $(ObjDir)/crtend.bc
32 GenericEHObj := $(ObjDir)/Exception.bc
33 SJLJEHObj := $(ObjDir)/SJLJ-Exception.bc
34
35 # __main and ctor/dtor support component
36 $(ObjDir)/comp_main.bc: $(MainObj)
37 $(Echo) Linking $(notdir $@) component...
38 $(Verb) $(GCCLD) -link-as-library \
39 -internalize-public-api-file=$(PROJ_SRC_DIR)/comp_main.lst \
40 $(MainObj) -o $@
41
42 # Generic exception handling support runtime.
43 $(ObjDir)/comp_genericeh.bc: $(GenericEHObj)
44 $(Echo) Linking $(notdir $@) component...
45 $(Verb) $(GCCLD) -link-as-library \
46 -internalize-public-api-file=$(PROJ_SRC_DIR)/comp_genericeh.lst \
47 $(GenericEHObj) -o $@
48
49 # setjmp/longjmp exception handling support runtime.
50 $(ObjDir)/comp_sjljeh.bc: $(SJLJEHObj)
51 $(Echo) Linking $(notdir $@) component...
52 $(Verb) $(GCCLD) -link-as-library \
53 -internalize-public-api-file=$(PROJ_SRC_DIR)/comp_sjljeh.lst \
54 $(SJLJEHObj) -o $@
55
56 SYMBOLHACKEDOBJS := $(ObjDir)/comp_main.bc $(ObjDir)/comp_genericeh.bc \
57 $(ObjDir)/comp_sjljeh.bc
58
59 all-local:: $(LibName.BCA)
60
61 ifdef BYTECODE_DESTINATION
62 BytecodeDestDir := $(BYTECODE_DESTINATION)
63 else
64 BytecodeDestDir := $(PROJ_libdir)
65 endif
66
67 DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
68 install-bytecode-local:: $(DestBytecodeLib)
69 install-local:: $(DestBytecodeLib)
70
71 $(LibName.BCA): $(SYMBOLHACKEDOBJS) $(LibDir)/.dir $(LLVMToolDir)/llvm-ar
72 $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
73 $(Verb) $(RM) -f $@
74 $(Verb) $(LArchive) $@ $(SYMBOLHACKEDOBJS)
75
76 $(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
77 $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
78 $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
79
80 uninstall-local::
81 $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
82 -$(Verb) $(RM) -f $(DestBytecodeLib)
+0
-15
runtime/GCCLibraries/crtend/README.txt less more
None This directory contains the C and C++ runtime libraries for the LLVM GCC
1 front-ends. It is composed of four distinct pieces:
2
3 1. __main: now dead, but provided for compatibility.
4
5 2. Generic EH support routines. This is used by C/C++ programs that use
6 setjmp/longjmp, and by C++ programs that make use of exceptions.
7
8 3. setjmp/longjmp EH support. This is used by C/C++ programs that call SJLJ.
9
10 4. C++ exception handling runtime support.
11
12 These four components are compiled together into an archive file, so that
13 applications using a subset of the four do not pull in unnecessary code and
14 dependencies.
+0
-146
runtime/GCCLibraries/crtend/SJLJ-Exception.cpp less more
None //===- SJLJ-Exception.cpp - SetJmp/LongJmp Exception Handling -------------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file was developed by the LLVM research group and is distributed under
5 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the API used by the Setjmp/Longjmp exception handling
10 // runtime library.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "SJLJ-Exception.h"
15 #include
16 #include
17
18 // Assert should only be used for debugging the runtime library. Enabling it in
19 // CVS will break some platforms!
20 #undef assert
21 #define assert(X)
22
23 // get_sjlj_exception - Adjust the llvm_exception pointer to be an appropriate
24 // llvm_sjlj_exception pointer.
25 inline llvm_sjlj_exception *get_sjlj_exception(llvm_exception *E) {
26 assert(E->ExceptionType == SJLJException);
27 return (llvm_sjlj_exception*)(E+1) - 1;
28 }
29
30 // SetJmpMapEntry - One entry in a linked list of setjmps for the current
31 // function.
32 struct SetJmpMapEntry {
33 void *JmpBuf;
34 unsigned SetJmpID;
35 SetJmpMapEntry *Next;
36 };
37
38 // SJLJDestructor - This function is used to free the exception when
39 // language-indent code needs to destroy the exception without knowing exactly
40 // what type it is.
41 static void SJLJDestructor(llvm_exception *E) {
42 free(get_sjlj_exception(E));
43 }
44
45
46 // __llvm_sjljeh_throw_longjmp - This function creates the longjmp exception and
47 // returns. It takes care of mapping the longjmp value from 0 -> 1 as
48 // appropriate. The caller should immediately call llvm.unwind after this
49 // function call.
50 void __llvm_sjljeh_throw_longjmp(void *JmpBuffer, int Val) throw() {
51 llvm_sjlj_exception *E =
52 (llvm_sjlj_exception *)malloc(sizeof(llvm_sjlj_exception));
53 E->BaseException.ExceptionDestructor = SJLJDestructor;
54 E->BaseException.ExceptionType = SJLJException;
55 E->BaseException.HandlerCount = 0;
56 E->BaseException.isRethrown = 0;
57 E->JmpBuffer = JmpBuffer;
58 E->LongJmpValue = Val ? Val : 1;
59
60 __llvm_eh_add_uncaught_exception(&E->BaseException);
61 }
62
63 // __llvm_sjljeh_init_setjmpmap - This funciton initializes the pointer provided
64 // to an empty setjmp map, and should be called on entry to a function which
65 // calls setjmp.
66 void __llvm_sjljeh_init_setjmpmap(void **SetJmpMap) throw() {
67 *SetJmpMap = 0;
68 }
69
70 // __llvm_sjljeh_destroy_setjmpmap - This function frees all memory associated
71 // with the specified setjmpmap structure. It should be called on all exits
72 // (returns or unwinds) from the function which calls ...init_setjmpmap.
73 void __llvm_sjljeh_destroy_setjmpmap(void **SetJmpMap) throw() {
74 SetJmpMapEntry *Next;
75 for (SetJmpMapEntry *SJE = *(SetJmpMapEntry**)SetJmpMap; SJE; SJE = Next) {
76 Next = SJE->Next;
77 free(SJE);
78 }
79 }
80
81 // __llvm_sjljeh_add_setjmp_to_map - This function adds or updates an entry to
82 // the map, to indicate which setjmp should be returned to if a longjmp happens.
83 void __llvm_sjljeh_add_setjmp_to_map(void **SetJmpMap, void *JmpBuf,
84 unsigned SetJmpID) throw() {
85 SetJmpMapEntry **SJE = (SetJmpMapEntry**)SetJmpMap;
86
87 // Scan for a pre-existing entry...
88 for (; *SJE; SJE = &(*SJE)->Next)
89 if ((*SJE)->JmpBuf == JmpBuf) {
90 (*SJE)->SetJmpID = SetJmpID;
91 return;
92 }
93
94 // No prexisting entry found, append to the end of the list...
95 SetJmpMapEntry *New = (SetJmpMapEntry *)malloc(sizeof(SetJmpMapEntry));
96 *SJE = New;
97 New->JmpBuf = JmpBuf;
98 New->SetJmpID = SetJmpID;
99 New->Next = 0;
100 }
101
102 // __llvm_sjljeh_is_longjmp_exception - This function returns true if the
103 // current uncaught exception is a longjmp exception. This is the first step of
104 // catching a sjlj exception.
105 bool __llvm_sjljeh_is_longjmp_exception() throw() {
106 return __llvm_eh_current_uncaught_exception_type(SJLJException) != 0;
107 }
108
109 // __llvm_sjljeh_get_longjmp_value - This function returns the value that the
110 // setjmp call should "return". This requires that the current uncaught
111 // exception be a sjlj exception, though it does not require the exception to be
112 // caught by this function.
113 int __llvm_sjljeh_get_longjmp_value() throw() {
114 llvm_sjlj_exception *E =
115 get_sjlj_exception(__llvm_eh_get_uncaught_exception());
116 return E->LongJmpValue;
117 }
118
119 // __llvm_sjljeh_try_catching_longjmp_exception - This function checks to see if
120 // the current uncaught longjmp exception matches any of the setjmps collected
121 // in the setjmpmap structure. If so, it catches and destroys the exception,
122 // returning the index of the setjmp which caught the exception. If not, it
123 // leaves the exception uncaught and returns a value of ~0.
124 unsigned __llvm_sjljeh_try_catching_longjmp_exception(void **SetJmpMap) throw(){
125 llvm_sjlj_exception *E =
126 get_sjlj_exception(__llvm_eh_get_uncaught_exception());
127
128 // Scan for a matching entry in the SetJmpMap...
129 SetJmpMapEntry *SJE = *(SetJmpMapEntry**)SetJmpMap;
130 for (; SJE; SJE = SJE->Next)
131 if (SJE->JmpBuf == E->JmpBuffer) {
132 // "Catch" and destroy the exception...
133 __llvm_eh_pop_from_uncaught_stack();
134
135 // We know it's a longjmp exception, so we can just free it instead of
136 // calling the destructor.
137 free(E);
138
139 // Return the setjmp ID which we should branch to...
140 return SJE->SetJmpID;
141 }
142
143 // No setjmp in this function catches the exception!
144 return ~0;
145 }
+0
-80
runtime/GCCLibraries/crtend/SJLJ-Exception.h less more
None //===- SJLJ-Exception.h - SetJmp/LongJmp Exception Handling -----*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file was developed by the LLVM research group and is distributed under
5 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the data structures and API used by the Setjmp/Longjmp
10 // exception handling runtime library.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef SJLJ_EXCEPTION_H
15 #define SJLJ_EXCEPTION_H
16
17 #include "Exception.h"
18
19 struct llvm_sjlj_exception {
20 // JmpBuffer - This is the buffer which was longjmp'd with.
21 //
22 void *JmpBuffer;
23
24 // LongJmpValue - The value passed into longjmp, which the corresponding
25 // setjmp should return. Note that this value will never be equal to 0.
26 //
27 int LongJmpValue;
28
29 // BaseException - The language independent portion of the exception state.
30 // This is at the end of the record so that we can add additional members to
31 // this structure without breaking binary compatibility.
32 //
33 llvm_exception BaseException;
34 };
35
36 extern "C" {
37 // __llvm_sjljeh_throw_longjmp - This function creates the longjmp exception
38 // and returns. It takes care of mapping the longjmp value from 0 -> 1 as
39 // appropriate. The caller should immediately call llvm.unwind after this
40 // function call.
41 void __llvm_sjljeh_throw_longjmp(void *JmpBuffer, int Val) throw();
42
43 // __llvm_sjljeh_init_setjmpmap - This funciton initializes the pointer
44 // provided to an empty setjmp map, and should be called on entry to a
45 // function which calls setjmp.
46 void __llvm_sjljeh_init_setjmpmap(void **SetJmpMap) throw();
47
48 // __llvm_sjljeh_destroy_setjmpmap - This function frees all memory associated
49 // with the specified setjmpmap structure. It should be called on all exits
50 // (returns or unwinds) from the function which calls ...init_setjmpmap.
51 void __llvm_sjljeh_destroy_setjmpmap(void **SetJmpMap) throw();
52
53 // __llvm_sjljeh_add_setjmp_to_map - This function adds or updates an entry to
54 // the map, to indicate which setjmp should be returned to if a longjmp
55 // happens.
56 void __llvm_sjljeh_add_setjmp_to_map(void **SetJmpMap, void *JmpBuf,
57 unsigned SetJmpID) throw();
58
59 // __llvm_sjljeh_is_longjmp_exception - This function returns true if the
60 // current uncaught exception is a longjmp exception. This is the first step
61 // of catching a sjlj exception.
62 bool __llvm_sjljeh_is_longjmp_exception() throw();
63
64 // __llvm_sjljeh_get_longjmp_value - This function returns the value that the
65 // setjmp call should "return". This requires that the current uncaught
66 // exception be a sjlj exception, though it does not require the exception to
67 // be caught by this function.
68 int __llvm_sjljeh_get_longjmp_value() throw();
69
70 // __llvm_sjljeh_try_catching_longjmp_exception - This function checks to see
71 // if the current uncaught longjmp exception matches any of the setjmps
72 // collected in the setjmpmap structure. If so, it catches and destroys the
73 // exception, returning the index of the setjmp which caught the exception.
74 // If not, it leaves the exception uncaught and returns a value of ~0.
75 unsigned __llvm_sjljeh_try_catching_longjmp_exception(void **SetJmpMap)
76 throw();
77 }
78
79 #endif
+0
-9
runtime/GCCLibraries/crtend/comp_genericeh.lst less more
None __main
1 llvm.global_ctors
2 llvm.global_dtors
3
4 __llvm_eh_has_uncaught_exception
5 __llvm_eh_current_uncaught_exception_type
6 __llvm_eh_add_uncaught_exception
7 __llvm_eh_get_uncaught_exception
8 __llvm_eh_pop_from_uncaught_stack
+0
-3
runtime/GCCLibraries/crtend/comp_main.lst less more
None __main
1 llvm.global_ctors
2 llvm.global_dtors
+0
-7
runtime/GCCLibraries/crtend/comp_sjljeh.lst less more
None __llvm_sjljeh_throw_longjmp
1 __llvm_sjljeh_init_setjmpmap
2 __llvm_sjljeh_destroy_setjmpmap
3 __llvm_sjljeh_add_setjmp_to_map
4 __llvm_sjljeh_is_longjmp_exception
5 __llvm_sjljeh_get_longjmp_value
6 __llvm_sjljeh_try_catching_longjmp_exception
+0
-16
runtime/GCCLibraries/crtend/crtend.c less more
None /*===- crtend.c - Initialization code for programs ------------------------===*\
1 *
2 * The LLVM Compiler Infrastructure
3 *
4 * This file was developed by the LLVM research group and is distributed under
5 * the University of Illinois Open Source License. See LICENSE.TXT for details.
6 *
7 *===----------------------------------------------------------------------===*
8 *
9 * This file defines the __main function, which we preserve for backwards
10 * compatibility.
11 *
12 \*===----------------------------------------------------------------------===*/
13
14 void __main(void) {
15 }
+0
-510
runtime/GCCLibraries/libc/COPYING.LIB less more
None
1 GNU LESSER GENERAL PUBLIC LICENSE
2 Version 2.1, February 1999
3
4 Copyright (C) 1991, 1999 Free Software Foundation, Inc.
5 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6 Everyone is permitted to copy and distribute verbatim copies
7 of this license document, but changing it is not allowed.
8
9 [This is the first released version of the Lesser GPL. It also counts
10 as the successor of the GNU Library Public License, version 2, hence
11 the version number 2.1.]
12
13 Preamble
14
15 The licenses for most software are designed to take away your
16 freedom to share and change it. By contrast, the GNU General Public
17 Licenses are intended to guarantee your freedom to share and change
18 free software--to make sure the software is free for all its users.
19
20 This license, the Lesser General Public License, applies to some
21 specially designated software packages--typically libraries--of the
22 Free Software Foundation and other authors who decide to use it. You
23 can use it too, but we suggest you first think carefully about whether
24 this license or the ordinary General Public License is the better
25 strategy to use in any particular case, based on the explanations
26 below.
27
28 When we speak of free software, we are referring to freedom of use,
29 not price. Our General Public Licenses are designed to make sure that
30 you have the freedom to distribute copies of free software (and charge
31 for this service if you wish); that you receive source code or can get
32 it if you want it; that you can change the software and use pieces of
33 it in new free programs; and that you are informed that you can do
34 these things.
35
36 To protect your rights, we need to make restrictions that forbid
37 distributors to deny you these rights or to ask you to surrender these
38 rights. These restrictions translate to certain responsibilities for
39 you if you distribute copies of the library or if you modify it.
40
41 For example, if you distribute copies of the library, whether gratis
42 or for a fee, you must give the recipients all the rights that we gave
43 you. You must make sure that they, too, receive or can get the source
44 code. If you link other code with the library, you must provide
45 complete object files to the recipients, so that they can relink them
46 with the library after making changes to the library and recompiling
47 it. And you must show them these terms so they know their rights.
48
49 We protect your rights with a two-step method: (1) we copyright the
50 library, and (2) we offer you this license, which gives you legal
51 permission to copy, distribute and/or modify the library.
52
53 To protect each distributor, we want to make it very clear that
54 there is no warranty for the free library. Also, if the library is
55 modified by someone else and passed on, the recipients should know
56 that what they have is not the original version, so that the original
57 author's reputation will not be affected by problems that might be
58 introduced by others.
59 ^L
60 Finally, software patents pose a constant threat to the existence of
61 any free program. We wish to make sure that a company cannot
62 effectively restrict the users of a free program by obtaining a
63 restrictive license from a patent holder. Therefore, we insist that
64 any patent license obtained for a version of the library must be
65 consistent with the full freedom of use specified in this license.
66
67 Most GNU software, including some libraries, is covered by the
68 ordinary GNU General Public License. This license, the GNU Lesser
69 General Public License, applies to certain designated libraries, and
70 is quite different from the ordinary General Public License. We use
71 this license for certain libraries in order to permit linking those
72 libraries into non-free programs.
73
74 When a program is linked with a library, whether statically or using
75 a shared library, the combination of the two is legally speaking a
76 combined work, a derivative of the original library. The ordinary
77 General Public License therefore permits such linking only if the
78 entire combination fits its criteria of freedom. The Lesser General
79 Public License permits more lax criteria for linking other code with
80 the library.
81
82 We call this license the "Lesser" General Public License because it
83 does Less to protect the user's freedom than the ordinary General
84 Public License. It also provides other free software developers Less
85 of an advantage over competing non-free programs. These disadvantages
86 are the reason we use the ordinary General Public License for many
87 libraries. However, the Lesser license provides advantages in certain
88 special circumstances.
89
90 For example, on rare occasions, there may be a special need to
91 encourage the widest possible use of a certain library, so that it
92 becomes a de-facto standard. To achieve this, non-free programs must
93 be allowed to use the library. A more frequent case is that a free
94 library does the same job as widely used non-free libraries. In this
95 case, there is little to gain by limiting the free library to free
96 software only, so we use the Lesser General Public License.
97
98 In other cases, permission to use a particular library in non-free
99 programs enables a greater number of people to use a large body of
100 free software. For example, permission to use the GNU C Library in
101 non-free programs enables many more people to use the whole GNU
102 operating system, as well as its variant, the GNU/Linux operating
103 system.
104
105 Although the Lesser General Public License is Less protective of the
106 users' freedom, it does ensure that the user of a program that is
107 linked with the Library has the freedom and the wherewithal to run
108 that program using a modified version of the Library.
109
110 The precise terms and conditions for copying, distribution and
111 modification follow. Pay close attention to the difference between a
112 "work based on the library" and a "work that uses the library". The
113 former contains code derived from the library, whereas the latter must
114 be combined with the library in order to run.
115 ^L
116 GNU LESSER GENERAL PUBLIC LICENSE
117 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
118
119 0. This License Agreement applies to any software library or other
120 program which contains a notice placed by the copyright holder or
121 other authorized party saying it may be distributed under the terms of
122 this Lesser General Public License (also called "this License").
123 Each licensee is addressed as "you".
124
125 A "library" means a collection of software functions and/or data
126 prepared so as to be conveniently linked with application programs
127 (which use some of those functions and data) to form executables.
128
129 The "Library", below, refers to any such software library or work
130 which has been distributed under these terms. A "work based on the
131 Library" means either the Library or any derivative work under
132 copyright law: that is to say, a work containing the Library or a
133 portion of it, either verbatim or with modifications and/or translated
134 straightforwardly into another language. (Hereinafter, translation is
135 included without limitation in the term "modification".)
136
137 "Source code" for a work means the preferred form of the work for
138 making modifications to it. For a library, complete source code means
139 all the source code for all modules it contains, plus any associated
140 interface definition files, plus the scripts used to control
141 compilation and installation of the library.
142
143 Activities other than copying, distribution and modification are not
144 covered by this License; they are outside its scope. The act of
145 running a program using the Library is not restricted, and output from
146 such a program is covered only if its contents constitute a work based
147 on the Library (independent of the use of the Library in a tool for
148 writing it). Whether that is true depends on what the Library does
149 and what the program that uses the Library does.
150
151 1. You may copy and distribute verbatim copies of the Library's
152 complete source code as you receive it, in any medium, provided that
153 you conspicuously and appropriately publish on each copy an
154 appropriate copyright notice and disclaimer of warranty; keep intact
155 all the notices that refer to this License and to the absence of any
156 warranty; and distribute a copy of this License along with the
157 Library.
158
159 You may charge a fee for the physical act of transferring a copy,
160 and you may at your option offer warranty protection in exchange for a
161 fee.
162
163 2. You may modify your copy or copies of the Library or any portion
164 of it, thus forming a work based on the Library, and copy and
165 distribute such modifications or work under the terms of Section 1
166 above, provided that you also meet all of these conditions:
167
168 a) The modified work must itself be a software library.
169
170 b) You must cause the files modified to carry prominent notices
171 stating that you changed the files and the date of any change.
172
173 c) You must cause the whole of the work to be licensed at no
174 charge to all third parties under the terms of this License.
175
176 d) If a facility in the modified Library refers to a function or a
177 table of data to be supplied by an application program that uses
178 the facility, other than as an argument passed when the facility
179 is invoked, then you must make a good faith effort to ensure that,
180 in the event an application does not supply such function or
181 table, the facility still operates, and performs whatever part of
182 its purpose remains meaningful.
183
184 (For example, a function in a library to compute square roots has
185 a purpose that is entirely well-defined independent of the
186 application. Therefore, Subsection 2d requires that any
187 application-supplied function or table used by this function must
188 be optional: if the application does not supply it, the square
189 root function must still compute square roots.)
190
191 These requirements apply to the modified work as a whole. If
192 identifiable sections of that work are not derived from the Library,
193 and can be reasonably considered independent and separate works in
194 themselves, then this License, and its terms, do not apply to those
195 sections when you distribute them as separate works. But when you
196 distribute the same sections as part of a whole which is a work based
197 on the Library, the distribution of the whole must be on the terms of
198 this License, whose permissions for other licensees extend to the
199 entire whole, and thus to each and every part regardless of who wrote
200 it.
201
202 Thus, it is not the intent of this section to claim rights or contest
203 your rights to work written entirely by you; rather, the intent is to
204 exercise the right to control the distribution of derivative or
205 collective works based on the Library.
206
207 In addition, mere aggregation of another work not based on the Library
208 with the Library (or with a work based on the Library) on a volume of
209 a storage or distribution medium does not bring the other work under
210 the scope of this License.
211
212 3. You may opt to apply the terms of the ordinary GNU General Public
213 License instead of this License to a given copy of the Library. To do
214 this, you must alter all the notices that refer to this License, so
215 that they refer to the ordinary GNU General Public License, version 2,
216 instead of to this License. (If a newer version than version 2 of the
217 ordinary GNU General Public License has appeared, then you can specify
218 that version instead if you wish.) Do not make any other change in
219 these notices.
220 ^L
221 Once this change is made in a given copy, it is irreversible for
222 that copy, so the ordinary GNU General Public License applies to all
223 subsequent copies and derivative works made from that copy.
224
225 This option is useful when you wish to copy part of the code of
226 the Library into a program that is not a library.
227
228 4. You may copy and distribute the Library (or a portion or
229 derivative of it, under Section 2) in object code or executable form
230 under the terms of Sections 1 and 2 above provided that you accompany
231 it with the complete corresponding machine-readable source code, which
232 must be distributed under the terms of Sections 1 and 2 above on a
233 medium customarily used for software interchange.
234
235 If distribution of object code is made by offering access to copy
236 from a designated place, then offering equivalent access to copy the
237 source code from the same place satisfies the requirement to
238 distribute the source code, even though third parties are not
239 compelled to copy the source along with the object code.
240
241 5. A program that contains no derivative of any portion of the
242 Library, but is designed to work with the Library by being compiled or
243 linked with it, is called a "work that uses the Library". Such a
244 work, in isolation, is not a derivative work of the Library, and
245 therefore falls outside the scope of this License.
246
247 However, linking a "work that uses the Library" with the Library
248 creates an executable that is a derivative of the Library (because it
249 contains portions of the Library), rather than a "work that uses the
250 library". The executable is therefore covered by this License.
251 Section 6 states terms for distribution of such executables.
252
253 When a "work that uses the Library" uses material from a header file
254 that is part of the Library, the object code for the work may be a
255 derivative work of the Library even though the source code is not.
256 Whether this is true is especially significant if the work can be
257 linked without the Library, or if the work is itself a library. The
258 threshold for this to be true is not precisely defined by law.
259
260 If such an object file uses only numerical parameters, data
261 structure layouts and accessors, and small macros and small inline
262 functions (ten lines or less in length), then the use of the object
263 file is unrestricted, regardless of whether it is legally a derivative
264 work. (Executables containing this object code plus portions of the
265 Library will still fall under Section 6.)
266
267 Otherwise, if the work is a derivative of the Library, you may
268 distribute the object code for the work under the terms of Section 6.
269 Any executables containing that work also fall under Section 6,
270 whether or not they are linked directly with the Library itself.
271 ^L
272 6. As an exception to the Sections above, you may also combine or
273 link a "work that uses the Library" with the Library to produce a
274 work containing portions of the Library, and distribute that work
275 under terms of your choice, provided that the terms permit
276 modification of the work for the customer's own use and reverse
277 engineering for debugging such modifications.
278
279 You must give prominent notice with each copy of the work that the
280 Library is used in it and that the Library and its use are covered by
281 this License. You must supply a copy of this License. If the work
282 during execution displays copyright notices, you must include the
283 copyright notice for the Library among them, as well as a reference
284 directing the user to the copy of this License. Also, you must do one
285 of these things:
286
287 a) Accompany the work with the complete corresponding
288 machine-readable source code for the Library including whatever
289 changes were used in the work (which must be distributed under
290 Sections 1 and 2 above); and, if the work is an executable linked
291 with the Library, with the complete machine-readable "work that
292 uses the Library", as object code and/or source code, so that the
293 user can modify the Library and then relink to produce a modified
294 executable containing the modified Library. (It is understood
295 that the user who changes the contents of definitions files in the
296 Library will not necessarily be able to recompile the application
297 to use the modified definitions.)
298
299 b) Use a suitable shared library mechanism for linking with the
300 Library. A suitable mechanism is one that (1) uses at run time a
301 copy of the library already present on the user's computer system,
302 rather than copying library functions into the executable, and (2)
303 will operate properly with a modified version of the library, if
304 the user installs one, as long as the modified version is
305 interface-compatible with the version that the work was made with.
306
307 c) Accompany the work with a written offer, valid for at least
308 three years, to give the same user the materials specified in
309 Subsection 6a, above, for a charge no more than the cost of
310 performing this distribution.
311
312 d) If distribution of the work is made by offering access to copy
313 from a designated place, offer equivalent access to copy the above
314 specified materials from the same place.
315
316 e) Verify that the user has already received a copy of these
317 materials or that you have already sent this user a copy.
318
319 For an executable, the required form of the "work that uses the
320 Library" must include any data and utility programs needed for
321 reproducing the executable from it. However, as a special exception,
322 the materials to be distributed need not include anything that is
323 normally distributed (in either source or binary form) with the major
324 components (compiler, kernel, and so on) of the operating system on
325 which the executable runs, unless that component itself accompanies
326 the executable.
327
328 It may happen that this requirement contradicts the license
329 restrictions of other proprietary libraries that do not normally
330 accompany the operating system. Such a contradiction means you cannot
331 use both them and the Library together in an executable that you
332 distribute.
333 ^L
334 7. You may place library facilities that are a work based on the
335 Library side-by-side in a single library together with other library
336 facilities not covered by this License, and distribute such a combined
337 library, provided that the separate distribution of the work based on
338 the Library and of the other library facilities is otherwise
339 permitted, and provided that you do these two things:
340
341 a) Accompany the combined library with a copy of the same work
342 based on the Library, uncombined with any other library
343 facilities. This must be distributed under the terms of the
344 Sections above.
345
346 b) Give prominent notice with the combined library of the fact
347 that part of it is a work based on the Library, and explaining
348 where to find the accompanying uncombined form of the same work.
349
350 8. You may not copy, modify, sublicense, link with, or distribute
351 the Library except as expressly provided under this License. Any
352 attempt otherwise to copy, modify, sublicense, link with, or
353 distribute the Library is void, and will automatically terminate your
354 rights under this License. However, parties who have received copies,
355 or rights, from you under this License will not have their licenses
356 terminated so long as such parties remain in full compliance.
357
358 9. You are not required to accept this License, since you have not
359 signed it. However, nothing else grants you permission to modify or
360 distribute the Library or its derivative works. These actions are
361 prohibited by law if you do not accept this License. Therefore, by
362 modifying or distributing the Library (or any work based on the
363 Library), you indicate your acceptance of this License to do so, and
364 all its terms and conditions for copying, distributing or modifying
365 the Library or works based on it.
366
367 10. Each time you redistribute the Library (or any work based on the
368 Library), the recipient automatically receives a license from the
369 original licensor to copy, distribute, link with or modify the Library
370 subject to these terms and conditions. You may not impose any further
371 restrictions on the recipients' exercise of the rights granted herein.
372 You are not responsible for enforcing compliance by third parties with
373 this License.
374 ^L
375 11. If, as a consequence of a court judgment or allegation of patent
376 infringement or for any other reason (not limited to patent issues),
377 conditions are imposed on you (whether by court order, agreement or
378 otherwise) that contradict the conditions of this License, they do not
379 excuse you from the conditions of this License. If you cannot
380 distribute so as to satisfy simultaneously your obligations under this
381 License and any other pertinent obligations, then as a consequence you
382 may not distribute the Library at all. For example, if a patent
383 license would not permit royalty-free redistribution of the Library by
384 all those who receive copies directly or indirectly through you, then
385 the only way you could satisfy both it and this License would be to
386 refrain entirely from distribution of the Library.
387
388 If any portion of this section is held invalid or unenforceable under
389 any particular circumstance, the balance of the section is intended to
390 apply, and the section as a whole is intended to apply in other
391 circumstances.
392
393 It is not the purpose of this section to induce you to infringe any
394 patents or other property right claims or to contest validity of any
395 such claims; this section has the sole purpose of protecting the
396 integrity of the free software distribution system which is
397 implemented by public license practices. Many people have made
398 generous contributions to the wide range of software distributed
399 through that system in reliance on consistent application of that
400 system; it is up to the author/donor to decide if he or she is willing
401 to distribute software through any other system and a licensee cannot
402 impose that choice.
403
404 This section is intended to make thoroughly clear what is believed to
405 be a consequence of the rest of this License.
406
407 12. If the distribution and/or use of the Library is restricted in
408 certain countries either by patents or by copyrighted interfaces, the
409 original copyright holder who places the Library under this License
410 may add an explicit geographical distribution limitation excluding those
411 countries, so that distribution is permitted only in or among
412 countries not thus excluded. In such case, this License incorporates
413 the limitation as if written in the body of this License.
414
415 13. The Free Software Foundation may publish revised and/or new
416 versions of the Lesser General Public License from time to time.
417 Such new versions will be similar in spirit to the present version,
418 but may differ in detail to address new problems or concerns.
419
420 Each version is given a distinguishing version number. If the Library
421 specifies a version number of this License which applies to it and
422 "any later version", you have the option of following the terms and
423 conditions either of that version or of any later version published by
424 the Free Software Foundation. If the Library does not specify a
425 license version number, you may choose any version ever published by
426 the Free Software Foundation.
427 ^L
428 14. If you wish to incorporate parts of the Library into other free
429 programs whose distribution conditions are incompatible with these,
430 write to the author to ask for permission. For software which is
431 copyrighted by the Free Software Foundation, write to the Free
432 Software Foundation; we sometimes make exceptions for this. Our
433 decision will be guided by the two goals of preserving the free status
434 of all derivatives of our free software and of promoting the sharing
435 and reuse of software generally.
436
437 NO WARRANTY
438
439 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
440 WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
441 EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
442 OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
443 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
444 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
445 PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
446 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
447 THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
448
449 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
450 WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
451 AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
452 FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
453 CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
454 LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
455 RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
456 FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
457 SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
458 DAMAGES.
459
460 END OF TERMS AND CONDITIONS
461 ^L
462 How to Apply These Terms to Your New Libraries
463
464 If you develop a new library, and you want it to be of the greatest
465 possible use to the public, we recommend making it free software that
466 everyone can redistribute and change. You can do so by permitting
467 redistribution under these terms (or, alternatively, under the terms
468 of the ordinary General Public License).
469
470 To apply these terms, attach the following notices to the library.
471 It is safest to attach them to the start of each source file to most
472 effectively convey the exclusion of warranty; and each file should
473 have at least the "copyright" line and a pointer to where the full
474 notice is found.
475
476
477
478 Copyright (C)
479
480 This library is free software; you can redistribute it and/or
481 modify it under the terms of the GNU Lesser General Public
482 License as published by the Free Software Foundation; either
483 version 2.1 of the License, or (at your option) any later version.
484
485 This library is distributed in the hope that it will be useful,
486 but WITHOUT ANY WARRANTY; without even the implied warranty of
487 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
488 Lesser General Public License for more details.
489
490 You should have received a copy of the GNU Lesser General Public
491 License along with this library; if not, write to the Free Software
492 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
493
494 Also add information on how to contact you by electronic and paper mail.
495
496 You should also get your employer (if you work as a programmer) or
497 your school, if any, to sign a "copyright disclaimer" for the library,
498 if necessary. Here is a sample; alter the names:
499
500 Yoyodyne, Inc., hereby disclaims all copyright interest in the
501 library `Frob' (a library for tweaking knobs) written by James
502 Random Hacker.
503
504 , 1 April 1990
505 Ty Coon, President of Vice
506
507 That's all there is to it!
508
509
+0
-17
runtime/GCCLibraries/libc/LICENSE.TXT less more
None libc
1 ------------------------------------------------------------------------------
2 The stripped down C library found in llvm/runtime/GCCLibraries/libc is licensed
3 to you under the GNU Lesser General Public License (LGPL). The license, along
4 with copyright information, is in COPYING.LIB.
5
6 Portions of glibc also contain copyrights and licenses from third parties.
7 Those are listed in LICENSES.
8
9 FSF copyright and warranty disclaimer:
10 Copyright (C) 1991, 1992, 1996, 1997, 1999 Free Software Foundation, Inc.
11 Copyright (C) 1995,96,97,2002 Free Software Foundation, Inc.
12
13 The GNU C Library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
+0
-219
runtime/GCCLibraries/libc/LICENSES less more
None This file contains the copying permission notices for various files in the
1 GNU C Library distribution that have copyright owners other than the Free
2 Software Foundation. These notices all require that a copy of the notice
3 be included in the accompanying documentation and be distributed with
4 binary distributions of the code, so be sure to include this file along
5 with any binary distributions derived from the GNU C Library.
6
7
8 All code incorporated from 4.4 BSD is distributed under the following
9 license:
10
11 Copyright (C) 1991 Regents of the University of California.
12 All rights reserved.
13
14 Redistribution and use in source and binary forms, with or without
15 modification, are permitted provided that the following conditions
16 are met:
17
18 1. Redistributions of source code must retain the above copyright
19 notice, this list of conditions and the following disclaimer.
20 2. Redistributions in binary form must reproduce the above copyright
21 notice, this list of conditions and the following disclaimer in the
22 documentation and/or other materials provided with the distribution.
23 3. [This condition was removed.]
24 4. Neither the name of the University nor the names of its contributors
25 may be used to endorse or promote products derived from this software
26 without specific prior written permission.
27
28 THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 SUCH DAMAGE.
39
40 The DNS resolver code, taken from BIND 4.9.5, is copyrighted both by
41 UC Berkeley and by Digital Equipment Corporation. The DEC portions
42 are under the following license:
43
44 Portions Copyright (C) 1993 by Digital Equipment Corporation.
45
46 Permission to use, copy, modify, and distribute this software for any
47 purpose with or without fee is hereby granted, provided that the above
48 copyright notice and this permission notice appear in all copies, and
49 that the name of Digital Equipment Corporation not be used in
50 advertising or publicity pertaining to distribution of the document or
51 software without specific, written prior permission.
52
53 THE SOFTWARE IS PROVIDED ``AS IS'' AND DIGITAL EQUIPMENT CORP.
54 DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
55 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
56 DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT,
57 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
58 FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
59 NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
60 WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
61
62 The Sun RPC support (from rpcsrc-4.0) is covered by the following
63 license:
64
65 Copyright (C) 1984, Sun Microsystems, Inc.
66
67 Sun RPC is a product of Sun Microsystems, Inc. and is provided for
68 unrestricted use provided that this legend is included on all tape media
69 and as a part of the software program in whole or part. Users may copy
70 or modify Sun RPC without charge, but are not authorized to license or
71 distribute it to anyone else except as part of a product or program
72 developed by the user.
73
74 SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
75 WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
76 PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
77
78 Sun RPC is provided with no support and without any obligation on the
79 part of Sun Microsystems, Inc. to assist in its use, correction,
80 modification or enhancement.
81
82 SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
83 INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
84 OR ANY PART THEREOF.
85
86 In no event will Sun Microsystems, Inc. be liable for any lost revenue
87 or profits or other special, indirect and consequential damages, even if
88 Sun has been advised of the possibility of such damages.
89
90
91 The following CMU license covers some of the support code for Mach,
92 derived from Mach 3.0:
93
94 Mach Operating System
95 Copyright (C) 1991,1990,1989 Carnegie Mellon University
96 All Rights Reserved.
97
98 Permission to use, copy, modify and distribute this software and its
99 documentation is hereby granted, provided that both the copyright
100 notice and this permission notice appear in all copies of the
101 software, derivative works or modified versions, and any portions
102 thereof, and that both notices appear in supporting documentation.
103
104 CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS ``AS IS''
105 CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
106 ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
107
108 Carnegie Mellon requests users of this software to return to
109
110 Software Distribution Coordinator
111 School of Computer Science
112 Carnegie Mellon University
113 Pittsburgh PA 15213-3890
114
115 or Software.Distribution@CS.CMU.EDU any improvements or
116 extensions that they make and grant Carnegie Mellon the rights to
117 redistribute these changes.
118
119 The file if_ppp.h is under the following CMU license:
120
121 Redistribution and use in source and binary forms, with or without
122 modification, are permitted provided that the following conditions
123 are met:
124 1. Redistributions of source code must retain the above copyright
125 notice, this list of conditions and the following disclaimer.
126 2. Redistributions in binary form must reproduce the above copyright
127 notice, this list of conditions and the following disclaimer in the
128 documentation and/or other materials provided with the distribution.
129 3. Neither the name of the University nor the names of its contributors
130 may be used to endorse or promote products derived from this software
131 without specific prior written permission.
132
133 THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY AND
134 CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
135 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
136 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
137 IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE FOR ANY
138 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
139 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
140 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
141 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
142 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
143 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
144 IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145
146 The following license covers the files from Intel's "Highly Optimized
147 Mathematical Functions for Itanium" collection:
148
149 Intel License Agreement
150
151 Copyright (c) 2000, Intel Corporation
152
153 All rights reserved.
154
155 Redistribution and use in source and binary forms, with or without
156 modification, are permitted provided that the following conditions are
157 met:
158
159 * Redistributions of source code must retain the above copyright
160 notice, this list of conditions and the following disclaimer.
161
162 * Redistributions in binary form must reproduce the above copyright
163 notice, this list of conditions and the following disclaimer in the
164 documentation and/or other materials provided with the distribution.
165
166 * The name of Intel Corporation may not be used to endorse or promote
167 products derived from this software without specific prior written
168 permission.
169
170 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
171 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
172 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
173 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
174 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
175 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
176 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
177 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
178 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
179 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
180 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
181
182 The files inet/getnameinfo.c and sysdeps/posix/getaddrinfo.c are copyright
183 (C) by Craig Metz and are distributed under the following license:
184
185 /* The Inner Net License, Version 2.00
186
187 The author(s) grant permission for redistribution and use in source and
188 binary forms, with or without modification, of the software and documentation
189 provided that the following conditions are met:
190
191 0. If you receive a version of the software that is specifically labelled
192 as not being for redistribution (check the version message and/or README),
193 you are not permitted to redistribute that version of the software in any
194 way or form.
195 1. All terms of the all other applicable copyrights and licenses must be
196 followed.
197 2. Redistributions of source code must retain the authors' copyright
198 notice(s), this list of conditions, and the following disclaimer.
199 3. Redistributions in binary form must reproduce the authors' copyright
200 notice(s), this list of conditions, and the following disclaimer in the
201 documentation and/or other materials provided with the distribution.
202 4. [The copyright holder has authorized the removal of this clause.]
203 5. Neither the name(s) of the author(s) nor the names of its contributors
204 may be used to endorse or promote products derived from this software
205 without specific prior written permission.
206
207 THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS ``AS IS'' AND ANY
208 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
209 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
210 DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
211 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
212 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
213 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
214 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
215 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
216 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
217
218 If these license terms cause you a real problem, contact the author. */
+0
-19
runtime/GCCLibraries/libc/Makefile less more
None ##===- runtime/GCCLibraries/libc/Makefile ------------------*- Makefile -*-===##
1 #
2 # The LLVM Compiler Infrastructure
3 #
4 # This file was developed by the LLVM research group and is distributed under
5 # the University of Illinois Open Source License. See LICENSE.TXT for details.
6 #
7 ##===----------------------------------------------------------------------===##
8
9 LEVEL = ../../..
10 BYTECODE_LIBRARY = 1
11 DONT_BUILD_RELINKED = 1
12 LIBRARYNAME = c
13 BYTECODE_DESTINATION = $(CFERuntimeLibDir)
14
15 include $(LEVEL)/Makefile.common
16
17 CompileCommonOpts := $(filter-out -pedantic,$(CompileCommonOpts))
18 CompileCommonOpts := $(filter-out -Wno-long-long,$(CompileCommonOpts))
+0
-4
runtime/GCCLibraries/libc/README.txt less more
None This directory contains source files to build the LLVM version of libc.
1
2 Currently it is hacked together on a by-demand basis, but someday a proper
3 port of libc would be very nice.
+0
-118
runtime/GCCLibraries/libc/atox.c less more
None //===-- atox.c - Ascii string parsers for LLVM libc Library -------*- C -*-===//
1 //
2 // A lot of this code is ripped gratuitously from glibc and libiberty.
3 //
4 //===----------------------------------------------------------------------===//
5
6
7 #define isspace(x) ((x) == ' ' || (x) == '\t' || (x) == '\n')
8 #define isdigit(x) ((x) >= '0' && (x) <= '9')
9 #define isupper(x) ((x) >= 'A' && (x) <= 'Z')
10 #define islower(x) ((x) >= 'a' && (x) <= 'z')
11 #define isalpha(x) (isupper(x) || islower(x))
12
13 #ifndef ULONG_MAX
14 #define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF */
15 #endif
16
17 #ifndef LONG_MAX
18 #define LONG_MAX ((long)(ULONG_MAX >> 1)) /* 0x7FFFFFFF */
19 #endif
20
21 #ifndef LONG_MIN
22 #define LONG_MIN ((long)(~LONG_MAX)) /* 0x80000000 */
23 #endif
24
25 #if 0
26 /*
27 * Convert a string to a long integer.
28 *
29 * Ignores `locale' stuff. Assumes that the upper and lower case
30 * alphabets and digits are each contiguous.
31 */
32 long strtol(const char *nptr, char **endptr, int base) {
33 register const char *s = nptr;
34 register unsigned long acc;
35 register int c;
36 register unsigned long cutoff;
37 register int neg = 0, any, cutlim;
38
39 /*
40 * Skip white space and pick up leading +/- sign if any.
41 * If base is 0, allow 0x for hex and 0 for octal, else
42 * assume decimal; if base is already 16, allow 0x.
43 */
44 do {
45 c = *s++;
46 } while (isspace(c));
47 if (c == '-') {
48 neg = 1;
49 c = *s++;
50 } else if (c == '+')
51 c = *s++;
52 if ((base == 0 || base == 16) &&
53 c == '0' && (*s == 'x' || *s == 'X')) {
54 c = s[1];
55 s += 2;
56 base = 16;
57 }
58 if (base == 0)
59 base = c == '0' ? 8 : 10;
60
61 /*
62 * Compute the cutoff value between legal numbers and illegal
63 * numbers. That is the largest legal value, divided by the
64 * base. An input number that is greater than this value, if
65 * followed by a legal input character, is too big. One that
66 * is equal to this value may be valid or not; the limit
67 * between valid and invalid numbers is then based on the last
68 * digit. For instance, if the range for longs is
69 * [-2147483648..2147483647] and the input base is 10,
70 * cutoff will be set to 214748364 and cutlim to either
71 * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated
72 * a value > 214748364, or equal but the next digit is > 7 (or 8),
73 * the number is too big, and we will return a range error.
74 *
75 * Set any if any `digits' consumed; make it negative to indicate
76 * overflow.
77 */
78 cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX;
79 cutlim = cutoff % (unsigned long)base;
80 cutoff /= (unsigned long)base;
81 for (acc = 0, any = 0;; c = *s++) {
82 if (isdigit(c))
83 c -= '0';
84 else if (isalpha(c))
85 c -= isupper(c) ? 'A' - 10 : 'a' - 10;
86 else
87 break;
88 if (c >= base)
89 break;
90 if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
91 any = -1;
92 else {
93 any = 1;
94 acc *= base;
95 acc += c;
96 }
97 }
98 if (any < 0) {
99 acc = neg ? LONG_MIN : LONG_MAX;
100 } else if (neg)
101 acc = -acc;
102 if (endptr != 0)
103 *endptr = (char *) (any ? s - 1 : nptr);
104 return (acc);
105 }
106
107
108 /* Convert a string to an int. */
109 int atoi(const char *nptr) {
110 return (int)strtol(nptr, 0, 10);
111 }
112
113 /* Convert a string to a long int. */
114 long int atol(const char *nptr) {
115 return strtol(nptr, 0, 10);
116 }
117 #endif
+0
-18
runtime/GCCLibraries/libc/io.c less more
None //===-- io.c - IO routines for LLVM libc Library ------------------*- C -*-===//
1 //
2 // A lot of this code is ripped gratuitously from glibc and libiberty.
3 //
4 //===----------------------------------------------------------------------===//
5
6 int putchar(int);
7
8 // The puts() function writes the string pointed to by s, followed by a
9 // NEWLINE character, to the standard output stream stdout. On success the
10 // number of characters written is returned; otherwise they return EOF.
11 //
12 int puts(const char *S) {
13 const char *Str = S;
14 while (*Str) putchar(*Str++);
15 putchar('\n');
16 return Str+1-S;
17 }
+0
-261
runtime/GCCLibraries/libc/qsort.c less more
None //===-- qsort.c - The qsort function for the LLVM libc Library ----*- C -*-===//
1 //
2 // This code is a modified form of the qsort() function from the GNU C
3 // library.
4 //
5 // Modifications:
6 // 2003/05/29 - Code disabled for compilation. Line wrapping changed.
7 //
8 //===----------------------------------------------------------------------===//
9
10 /* Copyright (C) 1991, 1992, 1996, 1997, 1999 Free Software Foundation, Inc.
11 This file is part of the GNU C Library.
12 Written by Douglas C. Schmidt (schmidt@ics.uci.edu).
13
14 The GNU C Library is free software; you can redistribute it and/or
15 modify it under the terms of the GNU Lesser General Public
16 License as published by the Free Software Foundation; either
17 version 2.1 of the License, or (at your option) any later version.
18
19 The GNU C Library is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 Lesser General Public License for more details.
23
24 You should have received a copy of the GNU Lesser General Public
25 License along with the GNU C Library; if not, write to the Free
26 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
27 02111-1307 USA. */
28
29 /* If you consider tuning this algorithm, you should consult first:
30 Engineering a sort function; Jon Bentley and M. Douglas McIlroy;
31 Software - Practice and Experience; Vol. 23 (11), 1249-1265, 1993. */
32
33 #if 0
34
35 #include
36 #include
37 #include
38
39 /* Byte-wise swap two items of size SIZE. */
40 #define SWAP(a, b, size) \
41 do \
42 { \
43 register size_t __size = (size); \
44 register char *__a = (a), *__b = (b); \
45 do \
46 { \
47 char __tmp = *__a; \
48 *__a++ = *__b; \
49 *__b++ = __tmp; \
50 } while (--__size > 0); \
51 } while (0)
52
53 /* Discontinue quicksort algorithm when partition gets below this size.
54 This particular magic number was chosen to work best on a Sun 4/260. */
55 #define MAX_THRESH 4
56
57 /* Stack node declarations used to store unfulfilled partition obligations. */
58 typedef struct
59 {
60 char *lo;
61 char *hi;
62 } stack_node;
63
64 /* The next 4 #defines implement a very fast in-line stack abstraction. */
65 /* The stack needs log (total_elements) entries (we could even subtract
66 log(MAX_THRESH)). Since total_elements has type size_t, we get as
67 upper bound for log (total_elements):
68 bits per byte (CHAR_BIT) * sizeof(size_t). */
69 #define STACK_SIZE (CHAR_BIT * sizeof(size_t))
70 #define PUSH(low, high) ((void) ((top->lo = (low)), (top->hi = (high)), ++top))
71 #define POP(low, high) ((void) (--top, (low = top->lo), (high = top->hi)))
72 #define STACK_NOT_EMPTY (stack < top)
73
74
75 /* Order size using quicksort. This implementation incorporates
76 four optimizations discussed in Sedgewick:
77
78 1. Non-recursive, using an explicit stack of pointer that store the
79 next array partition to sort. To save time, this maximum amount
80 of space required to store an array of SIZE_MAX is allocated on the
81 stack. Assuming a 32-bit (64 bit) integer for size_t, this needs
82 only 32 * sizeof(stack_node) == 256 bytes (for 64 bit: 1024 bytes).
83 Pretty cheap, actually.
84
85 2. Chose the pivot element using a median-of-three decision tree.
86 This reduces the probability of selecting a bad pivot value and
87 eliminates certain extraneous comparisons.
88
89 3. Only quicksorts TOTAL_ELEMS / MAX_THRESH partitions, leaving
90 insertion sort to order the MAX_THRESH items within each partition.
91 This is a big win, since insertion sort is faster for small, mostly
92 sorted array segments.
93
94 4. The larger of the two sub-partitions is always pushed onto the
95 stack first, with the algorithm then concentrating on the
96 smaller partition. This *guarantees* no more than log (total_elems)
97 stack size is needed (actually O(1) in this case)! */
98
99 typedef int(*__compar_fn_t)(const void *, const void *);
100 void
101 qsort (void *const pbase, size_t total_elems, size_t size,
102 __compar_fn_t cmp)
103 {
104 register char *base_ptr = (char *) pbase;
105
106 const size_t max_thresh = MAX_THRESH * size;
107
108 if (total_elems == 0)
109 /* Avoid lossage with unsigned arithmetic below. */
110 return;
111
112 if (total_elems > MAX_THRESH)
113 {
114 char *lo = base_ptr;
115 char *hi = &lo[size * (total_elems - 1)];
116 stack_node stack[STACK_SIZE];
117 stack_node *top = stack + 1;
118
119 while (STACK_NOT_EMPTY)
120 {
121 char *left_ptr;
122 char *right_ptr;
123
124 /* Select median value from among LO, MID, and HI. Rearrange
125 LO and HI so the three values are sorted. This lowers the
126 probability of picking a pathological pivot value and
127 skips a comparison for both the LEFT_PTR and RIGHT_PTR in
128 the while loops. */
129
130 char *mid = lo + size * ((hi - lo) / size >> 1);
131
132 if ((*cmp) ((void *) mid, (void *) lo) < 0)
133 SWAP (mid, lo, size);
134 if ((*cmp) ((void *) hi, (void *) mid) < 0)
135 SWAP (mid, hi, size);
136 else
137 goto jump_over;
138 if ((*cmp) ((void *) mid, (void *) lo) < 0)
139 SWAP (mid, lo, size);
140 jump_over:;
141
142 left_ptr = lo + size;
143 right_ptr = hi - size;
144
145 /* Here's the famous ``collapse the walls'' section of quicksort.
146 Gotta like those tight inner loops! They are the main reason
147 that this algorithm runs much faster than others. */
148 do
149 {
150 while ((*cmp) ((void *) left_ptr, (void *) mid) < 0)
151 left_ptr += size;
152
153 while ((*cmp) ((void *) mid, (void *) right_ptr) < 0)
154 right_ptr -= size;
155
156 if (left_ptr < right_ptr)
157 {
158 SWAP (left_ptr, right_ptr, size);
159 if (mid == left_ptr)
160 mid = right_ptr;
161 else if (mid == right_ptr)
162 mid = left_ptr;
163 left_ptr += size;
164 right_ptr -= size;
165 }
166 else if (left_ptr == right_ptr)
167 {
168 left_ptr += size;
169 right_ptr -= size;
170 break;
171 }
172 }
173 while (left_ptr <= right_ptr);
174
175 /* Set up pointers for next iteration. First determine whether
176 left and right partitions are below the threshold size. If so,
177 ignore one or both. Otherwise, push the larger partition's
178 bounds on the stack and continue sorting the smaller one. */
179
180 if ((size_t) (right_ptr - lo) <= max_thresh)
181 {
182 if ((size_t) (hi - left_ptr) <= max_thresh)
183 /* Ignore both small partitions. */
184 POP (lo, hi);
185 else
186 /* Ignore small left partition. */
187 lo = left_ptr;
188 }
189 else if ((size_t) (hi - left_ptr) <= max_thresh)
190 /* Ignore small right partition. */
191 hi = right_ptr;
192 else if ((right_ptr - lo) > (hi - left_ptr))
193 {
194 /* Push larger left partition indices. */
195 PUSH (lo, right_ptr);
196 lo = left_ptr;
197 }
198 else
199 {
200 /* Push larger right partition indices. */
201 PUSH (left_ptr, hi);
202 hi = right_ptr;
203 }
204 }
205 }
206
207 /* Once the BASE_PTR array is partially sorted by quicksort the rest
208 is completely sorted using insertion sort, since this is efficient
209 for partitions below MAX_THRESH size. BASE_PTR points to the beginning
210 of the array to sort, and END_PTR points at the very last element in
211 the array (*not* one beyond it!). */
212
213 #define min(x, y) ((x) < (y) ? (x) : (y))
214
215 {
216 char *const end_ptr = &base_ptr[size * (total_elems - 1)];
217 char *tmp_ptr = base_ptr;
218 char *thresh = min(end_ptr, base_ptr + max_thresh);
219 register char *run_ptr;
220
221 /* Find smallest element in first threshold and place it at the
222 array's beginning. This is the smallest array element,
223 and the operation speeds up insertion sort's inner loop. */
224
225 for (run_ptr = tmp_ptr + size; run_ptr <= thresh; run_ptr += size)
226 if ((*cmp) ((void *) run_ptr, (void *) tmp_ptr) < 0)
227 tmp_ptr = run_ptr;
228
229 if (tmp_ptr != base_ptr)
230 SWAP (tmp_ptr, base_ptr, size);
231
232 /* Insertion sort, running from left-hand-side up to right-hand-side. */
233
234 run_ptr = base_ptr + size;
235 while ((run_ptr += size) <= end_ptr)
236 {
237 tmp_ptr = run_ptr - size;
238 while ((*cmp) ((void *) run_ptr, (void *) tmp_ptr) < 0)
239 tmp_ptr -= size;
240
241 tmp_ptr += size;
242 if (tmp_ptr != run_ptr)
243 {
244 char *trav;
245
246 trav = run_ptr + size;
247 while (--trav >= run_ptr)
248 {
249 char c = *trav;
250 char *hi, *lo;
251
252 for (hi = lo = trav; (lo -= size) >= tmp_ptr; hi = lo)
253 *hi = *lo;
254 *hi = c;
255 }
256 }
257 }
258 }
259 }
260 #endif
+0
-51
runtime/GCCLibraries/libc/remove.c less more
None //===-- remove.c - The remove function for the LLVM libc Library --*- C -*-===//
1 //
2 // This code is a modified form of the remove() function from the GNU C
3 // library.
4 //
5 // Modifications:
6 // 2005/11/28 - Added to LLVM tree. Functions renamed to allow compilation.
7 // Code to control symbol linkage types removed.
8 //
9 //===----------------------------------------------------------------------===//
10
11 /* ANSI C `remove' function to delete a file or directory. POSIX.1 version.
12 Copyright (C) 1995,96,97,2002 Free Software Foundation, Inc.
13 This file is part of the GNU C Library.
14
15 The GNU C Library is free software; you can redistribute it and/or
16 modify it under the terms of the GNU Lesser General Public
17 License as published by the Free Software Foundation; either
18 version 2.1 of the License, or (at your option) any later version.
19
20 The GNU C Library is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 Lesser General Public License for more details.
24
25 You should have received a copy of the GNU Lesser General Public
26 License along with the GNU C Library; if not, write to the Free
27 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
28 02111-1307 USA. */
29
30 #include
31 #include
32 #include
33
34 int
35 remove (const char * file)
36 {
37 int save;
38
39 save = errno;
40 if (rmdir (file) == 0)
41 return 0;
42 else if (errno == ENOTDIR && unlink (file) == 0)
43 {
44 errno = (save);
45 return 0;
46 }
47
48 return -1;
49 }
50
+0
-172
runtime/GCCLibraries/libc/string.c less more
None //===-- string.c - String functions for the LLVM libc Library -----*- C -*-===//
1 //
2 // A lot of this code is ripped gratuitously from glibc and libiberty.
3 //
4 //===----------------------------------------------------------------------===//
5
6 #include
7 #include
8
9 #ifdef strlen
10 #undef strlen
11 #endif
12 size_t strlen(const char *Str) {
13 size_t Count = 0;
14 while (*Str) { ++Count; ++Str; }
15 return Count;
16 }
17
18 #ifdef strdup
19 #undef strdup
20 #endif
21 char *strdup(const char *str) {
22 size_t Len = strlen(str);
23 char *Result = (char*)malloc((Len+1)*sizeof(char));
24 memcpy(Result, str, Len+1);
25 return Result;
26 }
27
28 #ifdef strndup
29 #undef strndup
30 #endif
31 char *strndup(const char *str, size_t n) {
32 size_t Len = strlen(str);
33 if (Len > n) Len = n;
34 char *Result = (char*)malloc((Len+1)*sizeof(char));
35 memcpy(Result, str, Len);
36 Result[Len] = 0;
37 return Result;
38 }
39
40 #ifdef strcpy
41 #undef strcpy
42 #endif
43 char *strcpy(char *s1, const char *s2) {
44 char *dest = s1;
45 while ((*s1++ = *s2++));
46 return dest;
47 }
48
49 #ifdef strncpy
50 #undef strncpy
51 #endif
52 char *strncpy(char *s1, const char *s2, size_t n) {
53 char *dest = s1;
54 while (n-- && (*s1++ = *s2++));
55 return dest;
56 }
57
58 #ifdef strcat
59 #undef strcat
60 #endif
61 char *strcat(char *s1, const char *s2) {
62 strcpy(s1+strlen(s1), s2);
63 return s1;
64 }
65
66
67 #ifdef strcmp
68 #undef strcmp
69 #endif
70 /* Compare S1 and S2, returning less than, equal to or
71 greater than zero if S1 is lexicographically less than,
72 equal to or greater than S2. */
73 int strcmp (const char *p1, const char *p2) {
74 register const unsigned char *s1 = (const unsigned char *) p1;
75 register const unsigned char *s2 = (const unsigned char *) p2;
76 unsigned char c1, c2;
77
78 do
79 {
80 c1 = (unsigned char) *s1++;
81 c2 = (unsigned char) *s2++;
82 if (c1 == '\0')
83 return c1 - c2;
84 }
85 while (c1 == c2);
86
87 return c1 - c2;
88 }
89
90 // http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/generic/?cvsroot=glibc
91 #if 0
92 typedef unsigned int op_t;
93 #define OPSIZ 4
94
95 void *memset (void *dstpp, int c, size_t len) {
96 long long int dstp = (long long int) dstpp;
97
98 if (len >= 8)
99 {
100 size_t xlen;
101 op_t cccc;
102
103 cccc = (unsigned char) c;
104 cccc |= cccc << 8;
105 cccc |= cccc << 16;
106 if (OPSIZ > 4)
107 /* Do the shift in two steps to avoid warning if long has 32 bits. */
108 cccc |= (cccc << 16) << 16;
109
110 /* There are at least some bytes to set.
111 No need to test for LEN == 0 in this alignment loop. */
112 while (dstp % OPSIZ != 0)
113 {
114 ((unsigned char *) dstp)[0] = c;
115 dstp += 1;
116 len -= 1;
117 }
118
119 /* Write 8 `op_t' per iteration until less than 8 `op_t' remain. */
120 xlen = len / (OPSIZ * 8);
121 while (xlen > 0)
122 {
123 ((op_t *) dstp)[0] = cccc;
124 ((op_t *) dstp)[1] = cccc;
125 ((op_t *) dstp)[2] = cccc;
126 ((op_t *) dstp)[3] = cccc;
127 ((op_t *) dstp)[4] = cccc;
128 ((op_t *) dstp)[5] = cccc;
129 ((op_t *) dstp)[6] = cccc;
130 ((op_t *) dstp)[7] = cccc;
131 dstp += 8 * OPSIZ;
132 xlen -= 1;
133 }
134 len %= OPSIZ * 8;
135
136 /* Write 1 `op_t' per iteration until less than OPSIZ bytes remain. */
137 xlen = len / OPSIZ;
138 while (xlen > 0)
139 {
140 ((op_t *) dstp)[0] = cccc;
141 dstp += OPSIZ;
142 xlen -= 1;
143 }
144 len %= OPSIZ;
145 }
146
147 /* Write the last few bytes. */
148 while (len > 0)
149 {
150 ((unsigned char *) dstp)[0] = c;
151 dstp += 1;
152 len -= 1;
153 }
154
155 return dstpp;
156 }
157 #endif
158
159 #ifdef memcpy
160 #undef memcpy
161 #endif
162 void *memcpy(void *dstpp, const void *srcpp, size_t len) {
163 char *dstp = (char*)dstpp;
164 char *srcp = (char*) srcpp;
165 unsigned i;
166
167 for (i = 0; i < len; ++i)
168 dstp[i] = srcp[i];
169
170 return dstpp;
171 }
+0
-16
runtime/GCCLibraries/libgcc/Makefile less more
None ##===- runtime/GCCLibraries/libgcc/Makefile ----------------*- Makefile -*-===##
1 #
2 # The LLVM Compiler Infrastructure
3 #
4 # This file was developed by the LLVM research group and is distributed under
5 # the University of Illinois Open Source License. See LICENSE.TXT for details.
6 #
7 ##===----------------------------------------------------------------------===##
8
9 LEVEL = ../../..
10 BYTECODE_LIBRARY = 1
11 DONT_BUILD_RELINKED = 1
12 LIBRARYNAME = gcc
13 BYTECODE_DESTINATION = $(CFERuntimeLibDir)
14
15 include $(LEVEL)/Makefile.common
+0
-13
runtime/GCCLibraries/libgcc/eprintf.c less more
None #include
1 void abort(void);
2
3 /* This is used by the `assert' macro. */
4 void
5 __eprintf (const char *string, const char *expression,
6 unsigned int line, const char *filename)
7 {
8 fprintf (stderr, string, expression, line, filename);
9 fflush (stderr);
10 abort ();
11 }
12
+0
-16
runtime/GCCLibraries/libm/Makefile less more
None ##===- runtime/GCCLibraries/libm/Makefile ------------------*- Makefile -*-===##
1 #
2 # The LLVM Compiler Infrastructure
3 #
4 # This file was developed by the LLVM research group and is distributed under
5 # the University of Illinois Open Source License. See LICENSE.TXT for details.
6 #
7 ##===----------------------------------------------------------------------===##
8
9 LEVEL = ../../..
10 BYTECODE_LIBRARY = 1
11 DONT_BUILD_RELINKED = 1
12 LIBRARYNAME = m
13 BYTECODE_DESTINATION = $(CFERuntimeLibDir)
14
15 include $(LEVEL)/Makefile.common
+0
-1
runtime/GCCLibraries/libm/temp.c less more
None typedef int INTEGER;
+0
-43
runtime/Makefile less more
None ##===- runtime/Makefile ------------------------------------*- Makefile -*-===##
1 #
2 # The LLVM Compiler Infrastructure
3 #
4 # This file was developed by the LLVM research group and is distributed under
5 # the University of Illinois Open Source License. See LICENSE.TXT for details.
6 #
7 ##===----------------------------------------------------------------------===##
8
9 LEVEL = ..
10 include $(LEVEL)/Makefile.config
11
12 ifeq ($(LLVMGCC_MAJVERS),4)
13 PARALLEL_DIRS :=
14 install all::
15 $(Echo) "Warning: These runtime libraries only need to be built with"
16 $(Echo) "Warning: llvm-gcc version 3. They are automatically included"
17 $(Echo) "Warning: with llvm-gcc version 4 and beyond"
18 else
19 ifneq ($(wildcard $(LLVMGCC)),)
20 PARALLEL_DIRS := GCCLibraries libdummy libprofile libtrace GC
21 else
22 PARALLEL_DIRS :=
23 install all ::
24 @echo '********' Warning: Your LLVMGCCDIR is set incorrectly. Check
25 @echo '********' Warning: llvm/Makefile.config to make sure it matches
26 @echo '********' Warning: the directory where the C front-end is
27 @echo '********' Warning: installed,and re-run configure if it does not.
28 endif
29
30 # Disable libprofile: a faulty libtool is generated by autoconf which breaks the
31 # build on Sparc
32 ifeq ($(ARCH), Sparc)
33 PARALLEL_DIRS := $(filter-out libprofile, $(PARALLEL_DIRS))
34 endif
35 endif
36
37 include $(LEVEL)/Makefile.common
38
39 # Install target for libraries: Copy into $LLVMGCCDIR/bytecode-libs
40 #
41 install::
42
+0
-4
runtime/README.txt less more
None This directory contains the various runtime libraries used by components of
1 the LLVM compiler. For example, the automatic pool allocation transformation
2 inserts calls to an external pool allocator library. This runtime library is
3 an example of the type of library that lives in these directories.
+0
-19
runtime/libdummy/Makefile less more
None ##===- runtime/libdummy/Makefile ---------------------------*- Makefile -*-===##
1 #
2 # The LLVM Compiler Infrastructure
3 #
4 # This file was developed by the LLVM research group and is distributed under
5 # the University of Illinois Open Source License. See LICENSE.TXT for details.
6 #
7 ##===----------------------------------------------------------------------===##
8
9 LEVEL = ../..
10 BYTECODE_LIBRARY = 1
11 DONT_BUILD_RELINKED = 1
12 LIBRARYNAME = dummy
13 BYTECODE_DESTINATION = $(CFERuntimeLibDir)
14
15 include $(LEVEL)/Makefile.common
16
17 CompileCommonOpts := $(filter-out -pedantic,$(CompileCommonOpts))
18 CompileCommonOpts := $(filter-out -Wno-long-long,$(CompileCommonOpts))
+0
-2
runtime/libdummy/README.txt less more
None This directory contains stub routines which are occasionally useful when
1 performing alias analysis research.
+0
-144
runtime/libdummy/dummylib.c less more
None #include
1 #include
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8
9 #if 0
10 int stat(const char *file_name, struct stat *buf) { return 0; }
11 int fstat(int filedes, struct stat *buf) { return 0; }
12 int lstat(const char *file_name, struct stat *buf) { return 0; }
13
14 // Varargs function definitions
15 int ioctl(int d, int request, ...) {return 0; }
16 int printf(const char *X) {return 0; }
17 int sscanf(const char *X, const char *Y, ...) { return 0; }
18 int fprintf(FILE *stream, const char *format, ...) { return 0; }
19
20
21 int gettimeofday(struct timeval *tv, void *tz) { return 0; }
22 void *xmalloc(size_t X) { return malloc(X); }
23
24 void srand(unsigned x) {}
25 double exp(double x) { return 0; }
26 double log(double x) { return 0; }
27 double sqrt(double x) { return 0; }
28 void exit(int x) {}
29 int puts(const char *x) { return 0; }
30 void __main() {}
31 int atoi(const char*x) { return 1; }
32 char *fgets(char*Ptr, int x, FILE*F) { return Ptr; }
33 char *gets(char *C) { return C; }
34 int fclose(FILE*F) { return 0; }
35 FILE *fopen(const char *n, const char*x) { return malloc(sizeof(FILE)); }
36 FILE *freopen(const char *path, const char *mode, FILE *stream) { return 0; }
37 int fflush(FILE *F) { return 0; }
38 size_t fwrite(const void* str, size_t N, size_t n, FILE *F) { return N; }
39 void *memset(void *P, int X, size_t N) { return P; }
40 void *memcpy(void *P, void *S, size_t N) { return P; }
41 void *memmove(void *P, void *S, size_t N) { return P; }
42 char *strcpy(char*Str1, const char *Str) { return Str1; }
43 char *strcat(char*Str1, const char *Str) { return Str1; }
44 size_t strlen(char *X) { return 0; }
45 #undef putchar
46 int putchar(int N) { return N; }
47 int putc(int c, FILE *stream) { return c; }
48 int fputc(int c, FILE *stream) { return c; }
49 int fgetc(FILE *S) { return 0; }
50 long ftell(FILE *F) { return 0; }
51 int getc(FILE *S) { return 0; }
52 size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream) { return 0; }
53 int fseek(FILE *stream, long offset, int whence) { return 0; }
54 int feof(FILE *stream) { return 0; }
55 int fputs(const char *s, char *stream) { return 0; }
56 int ferror(FILE *F) { return 0; }
57 FILE *fdopen(int fildes, const char *mode) { return 0;}
58 FILE *popen(const char *command, const char *type) { return 0; }
59 int pclose(FILE *stream) { return 0; }
60
61 int ungetc(int c, FILE *stream) { return 0; }
62 int setvbuf(FILE *stream, char *buf, int mode , size_t size) { return 0; }
63 void rewind(FILE*F) { }
64 int fileno(FILE *stream) { return 1; }
65 char *ttyname(int desc) { return 0; }
66 long sysconf(int name) { return 0; }
67 char *tmpnam(char *s) { return s; }
68
69 void *calloc(size_t A, size_t B) { return malloc(A*B); }
70 void *realloc(void *ptr, size_t N) { return ptr; }
71 const char *strerror(int N) { return 0; }
72 int unlink(const char *path) { return 0; }
73 void perror(const char *err) {}
74 char *strrchr(const char *S, int C) { return (char*)S; }
75 int memcmp(const char *A, const char *B, size_t N) { return 0; }
76 ssize_t read(int fildes, void *buf, size_t nbyte) { return nbyte; }
77 int close(int FD) { return 0; }
78 int rename(const char *oldpath, const char *newpath) { return 0; }
79 ssize_t write(int fd, const void *buf, size_t count) { return 0; }
80 pid_t getpid(void) { return 0; }
81 pid_t getppid(void) { return 0; }
82 void setbuf(FILE *stream, char *buf) {}
83 int isatty(int desc) { return 0; }
84 int vsprintf(char *str, const char *format, va_list ap) { return 0; }
85 char *getcwd(char *buf, size_t size) { return buf; }
86
87 void qsort(void *base, size_t nmemb, size_t size,
88 int(*compar)(const void *, const void *)) {
89 compar(base, base);
90 }
91
92
93
94 #include
95 clock_t times(struct tms *buf) { return 0; }
96
97
98 #include
99 int setjmp(jmp_buf env) { return 0; }
100 void longjmp(jmp_buf env, int val) {}
101 int kill(pid_t pid, int sig) { return 0; }
102 int system(const char *string) { return 0; }
103 char *getenv(const char *name) { return 0; }
104 typedef void (*sighandler_t)(int);
105
106 sighandler_t signal(int signum, sighandler_t handler) { return handler; }
107
108
109
110
111 char *strchr(const char *s, int c) { return (char*)s; }
112 int strcmp(const char *s1, const char *s2) { return 0; }
113 int strncmp(const char *s1, const char *s2, size_t n) { return 0; }
114 char *strncpy(char *s1, const char *s2, size_t n) { return s1; }
115 char *strpbrk(const char *s, const char *accept) { return (char*)s; }
116 char *strncat(char *dest, const char *src, size_t n) { return dest; }
117
118 double atof(const char *C) { return 0; }
119
120
121 long clock() { return 0; }
122 char *ctime(const time_t *timep) { return 0; }
123 time_t time(time_t *t) { return *t = 0; }
124
125 double sin(double x) { return x; }
126 double cos(double x) { return x; }
127 double tan(double x) { return x; }
128 double asin(double x) { return x; }
129 double acos(double x) { return x; }
130 double atan(double x) { return x; }
131 double cosh(double x) { return x; }
132 double sinh(double x) { return x; }
133 double ceil(double x) { return x; }
134 double floor(double x) { return x; }
135
136 double atan2(double x, double y) { return x; }
137 double fmod(double x, double y) { return x; }
138 double pow(double x, double y) { return x; }
139
140 int tolower(int x) { return x; }
141 int toupper(int x) { return x; }
142
143 #endif
+0
-67
runtime/libprofile/BasicBlockTracing.c less more
None /*===-- BasicBlockTracing.c - Support library for basic block tracing -----===*\
1 |*
2 |* The LLVM Compiler Infrastructure
3 |*
4 |* This file was developed by the LLVM research group and is distributed under
5 |* the University of Illinois Open Source License. See LICENSE.TXT for details.
6 |*
7 |*===----------------------------------------------------------------------===*|
8 |*
9 |* This file implements the call back routines for the basic block tracing
10 |* instrumentation pass. This should be used with the -trace-basic-blocks
11 |* LLVM pass.
12 |*
13 \*===----------------------------------------------------------------------===*/
14
15 #include "Profiling.h"
16 #include
17 #include
18
19 static unsigned *ArrayStart, *ArrayEnd, *ArrayCursor;
20
21 /* WriteAndFlushBBTraceData - write out the currently accumulated trace data
22 * and reset the cursor to point to the beginning of the buffer.
23 */
24 static void WriteAndFlushBBTraceData () {
25 write_profiling_data(BBTraceInfo, ArrayStart, (ArrayCursor - ArrayStart));
26 ArrayCursor = ArrayStart;
27 }
28
29 /* BBTraceAtExitHandler - When the program exits, just write out any remaining
30 * data and free the trace buffer.
31 */
32 static void BBTraceAtExitHandler() {
33 WriteAndFlushBBTraceData ();
34 free (ArrayStart);
35 }
36
37 /* llvm_trace_basic_block - called upon hitting a new basic block. */
38 void llvm_trace_basic_block (unsigned BBNum) {
39 *ArrayCursor++ = BBNum;
40 if (ArrayCursor == ArrayEnd)
41 WriteAndFlushBBTraceData ();
42 }
43
44 /* llvm_start_basic_block_tracing - This is the main entry point of the basic
45 * block tracing library. It is responsible for setting up the atexit
46 * handler and allocating the trace buffer.
47 */
48 int llvm_start_basic_block_tracing(int argc, const char **argv,
49 unsigned *arrayStart, unsigned numElements) {
50 int Ret;
51 const unsigned BufferSize = 128 * 1024;
52 unsigned ArraySize;
53
54 Ret = save_arguments(argc, argv);
55
56 /* Allocate a buffer to contain BB tracing data */
57 ArraySize = BufferSize / sizeof (unsigned);
58 ArrayStart = malloc (ArraySize * sizeof (unsigned));
59 ArrayEnd = ArrayStart + ArraySize;
60 ArrayCursor = ArrayStart;
61
62 /* Set up the atexit handler. */
63 atexit (BBTraceAtExitHandler);
64
65 return Ret;
66 }
+0
-45
runtime/libprofile/BlockProfiling.c less more
None /*===-- BlockProfiling.c - Support library for block profiling ------------===*\
1 |*
2 |* The LLVM Compiler Infrastructure
3 |*
4 |* This file was developed by the LLVM research group and is distributed under
5 |* the University of Illinois Open Source License. See LICENSE.TXT for details.
6 |*
7 |*===----------------------------------------------------------------------===*|
8 |*
9 |* This file implements the call back routines for the block profiling
10 |* instrumentation pass. This should be used with the -insert-block-profiling
11 |* LLVM pass.
12 |*
13 \*===----------------------------------------------------------------------===*/
14
15 #include "Profiling.h"
16 #include
17
18 static unsigned *ArrayStart;
19 static unsigned NumElements;
20
21 /* BlockProfAtExitHandler - When the program exits, just write out the profiling
22 * data.
23 */
24 static void BlockProfAtExitHandler() {
25 /* Note that if this were doing something more intelligent with the
26 * instrumentation, we could do some computation here to expand what we
27 * collected into simple block profiles. (Or we could do it in llvm-prof.)
28 * Regardless, we directly count each block, so no expansion is necessary.
29 */
30 write_profiling_data(BlockInfo, ArrayStart, NumElements);
31 }
32
33
34 /* llvm_start_block_profiling - This is the main entry point of the block
35 * profiling library. It is responsible for setting up the atexit handler.
36 */
37 int llvm_start_block_profiling(int argc, const char **argv,
38 unsigned *arrayStart, unsigned numElements) {
39 int Ret = save_arguments(argc, argv);
40 ArrayStart = arrayStart;
41 NumElements = numElements;
42 atexit(BlockProfAtExitHandler);
43 return Ret;
44 }
+0
-117
runtime/libprofile/CommonProfiling.c less more
None /*===-- CommonProfiling.c - Profiling support library support -------------===*\
1 |*
2 |* The LLVM Compiler Infrastructure
3 |*
4 |* This file was developed by the LLVM research group and is distributed under
5 |* the University of Illinois Open Source License. See LICENSE.TXT for details.
6 |*
7 |*===----------------------------------------------------------------------===*|
8 |*
9 |* This file implements functions used by the various different types of
10 |* profiling implementations.
11 |*
12 \*===----------------------------------------------------------------------===*/
13
14 #include "Profiling.h"
15 #include
16 #include
17 #include
18 #include
19 #include
20 #include
21 #include
22
23 static char *SavedArgs = 0;
24 static unsigned SavedArgsLength = 0;
25
26 static const char *OutputFilename = "llvmprof.out";
27
28 /* save_arguments - Save argc and argv as passed into the program for the file
29 * we output.
30 */
31 int save_arguments(int argc, const char **argv) {
32 unsigned Length, i;
33 if (SavedArgs || !argv) return argc; /* This can be called multiple times */
34
35 /* Check to see if there are any arguments passed into the program for the
36 * profiler. If there are, strip them off and remember their settings.
37 */
38 while (argc > 1 && !strncmp(argv[1], "-llvmprof-", 10)) {
39 /* Ok, we have an llvmprof argument. Remove it from the arg list and decide
40 * what to do with it.
41 */
42 const char *Arg = argv[1];
43 memmove(&argv[1], &argv[2], (argc-1)*sizeof(char*));
44 --argc;
45
46 if (!strcmp(Arg, "-llvmprof-output")) {
47 if (argc == 1)
48 puts("-llvmprof-output requires a filename argument!");
49 else {
50 OutputFilename = strdup(argv[1]);
51 memmove(&argv[1], &argv[2], (argc-1)*sizeof(char*));
52 --argc;
53 }
54 } else {
55 printf("Unknown option to the profiler runtime: '%s' - ignored.\n", Arg);
56 }
57 }
58
59 for (Length = 0, i = 0; i != (unsigned)argc; ++i)
60 Length += strlen(argv[i])+1;
61
62 SavedArgs = (char*)malloc(Length);
63 for (Length = 0, i = 0; i != (unsigned)argc; ++i) {
64 unsigned Len = strlen(argv[i]);
65 memcpy(SavedArgs+Length, argv[i], Len);
66 Length += Len;
67 SavedArgs[Length++] = ' ';
68 }
69
70 SavedArgsLength = Length;
71
72 return argc;
73 }
74
75
76 /* write_profiling_data - Write a raw block of profiling counters out to the
77 * llvmprof.out file. Note that we allow programs to be instrumented with
78 * multiple different kinds of instrumentation. For this reason, this function
79 * may be called more than once.
80 */
81 void write_profiling_data(enum ProfilingType PT, unsigned *Start,
82 unsigned NumElements) {
83 static int OutFile = -1;
84 int PTy;
85
86 /* If this is the first time this function is called, open the output file for
87 * appending, creating it if it does not already exist.
88 */
89 if (OutFile == -1) {
90 OutFile = open(OutputFilename, O_CREAT | O_WRONLY | O_APPEND, 0666);
91 if (OutFile == -1) {
92 fprintf(stderr, "LLVM profiling runtime: while opening '%s': ",
93 OutputFilename);
94 perror("");
95 return;
96 }
97
98 /* Output the command line arguments to the file. */
99 {
100 int PTy = ArgumentInfo;
101 int Zeros = 0;
102 write(OutFile, &PTy, sizeof(int));
103 write(OutFile, &SavedArgsLength, sizeof(unsigned));
104 write(OutFile, SavedArgs, SavedArgsLength);
105 /* Pad out to a multiple of four bytes */
106 if (SavedArgsLength & 3)
107 write(OutFile, &Zeros, 4-(SavedArgsLength&3));
108 }
109 }
110
111 /* Write out this record! */
112 PTy = PT;
113 write(OutFile, &PTy, sizeof(int));
114 write(OutFile, &NumElements, sizeof(unsigned));
115 write(OutFile, Start, NumElements*sizeof(unsigned));
116 }
+0
-45
runtime/libprofile/EdgeProfiling.c less more
None /*===-- EdgeProfiling.c - Support library for edge profiling --------------===*\
1 |*
2 |* The LLVM Compiler Infrastructure
3 |*
4 |* This file was developed by the LLVM research group and is distributed under
5 |* the University of Illinois Open Source License. See LICENSE.TXT for details.
6 |*
7 |*===----------------------------------------------------------------------===*|
8 |*
9 |* This file implements the call back routines for the edge profiling
10 |* instrumentation pass. This should be used with the -insert-edge-profiling
11 |* LLVM pass.
12 |*
13 \*===----------------------------------------------------------------------===*/
14
15 #include "Profiling.h"
16 #include
17
18 static unsigned *ArrayStart;
19 static unsigned NumElements;
20
21 /* EdgeProfAtExitHandler - When the program exits, just write out the profiling
22 * data.
23 */
24 static void EdgeProfAtExitHandler() {
25 /* Note that if this were doing something more intelligent with the
26 * instrumentation, we could do some computation here to expand what we
27 * collected into simple edge profiles. Since we directly count each edge, we
28 * just write out all of the counters directly.
29 */
30 write_profiling_data(EdgeInfo, ArrayStart, NumElements);
31 }
32
33
34 /* llvm_start_edge_profiling - This is the main entry point of the edge
35 * profiling library. It is responsible for setting up the atexit handler.
36 */
37 int llvm_start_edge_profiling(int argc, const char **argv,
38 unsigned *arrayStart, unsigned numElements) {
39 int Ret = save_arguments(argc, argv);
40 ArrayStart = arrayStart;
41 NumElements = numElements;
42 atexit(EdgeProfAtExitHandler);
43 return Ret;
44 }
+0
-42
runtime/libprofile/FunctionProfiling.c less more
None /*===-- FunctionProfiling.c - Support library for function profiling ------===*\
1 |*
2 |* The LLVM Compiler Infrastructure
3 |*
4 |* This file was developed by the LLVM research group and is distributed under
5 |* the University of Illinois Open Source License. See LICENSE.TXT for details.
6 |*
7 |*===----------------------------------------------------------------------===*|
8 |*
9 |* This file implements the call back routines for the function profiling
10 |* instrumentation pass. This should be used with the
11 |* -insert-function-profiling LLVM pass.
12 |*
13 \*===----------------------------------------------------------------------===*/
14
15 #include "Profiling.h"
16 #include
17
18 static unsigned *ArrayStart;
19 static unsigned NumElements;
20
21 /* FuncProfAtExitHandler - When the program exits, just write out the profiling
22 * data.
23 */
24 static void FuncProfAtExitHandler() {
25 /* Just write out the data we collected.
26 */
27 write_profiling_data(FunctionInfo, ArrayStart, NumElements);
28 }
29
30
31 /* llvm_start_func_profiling - This is the main entry point of the function
32 * profiling library. It is responsible for setting up the atexit handler.
33 */
34 int llvm_start_func_profiling(int argc, const char **argv,
35 unsigned *arrayStart, unsigned numElements) {
36 int Ret = save_arguments(argc, argv);
37 ArrayStart = arrayStart;
38 NumElements = numElements;
39 atexit(FuncProfAtExitHandler);
40 return Ret;
41 }
+0
-19
runtime/libprofile/Makefile less more
None ##===- runtime/libprofile/Makefile -------------------------*- Makefile -*-===##
1 #
2 # The LLVM Compiler Infrastructure
3 #
4 # This file was developed by the LLVM research group and is distributed under
5 # the University of Illinois Open Source License. See LICENSE.TXT for details.
6 #
7 ##===----------------------------------------------------------------------===##
8
9 LEVEL = ../..
10 BYTECODE_LIBRARY = 1
11 SHARED_LIBRARY = 1
12 LOADABLE_MODULE = 1
13 LIBRARYNAME = profile_rt
14 EXTRA_DIST = exported_symbols.lst
15 EXPORTED_SYMBOL_FILE = $(PROJ_SRC_DIR)/exported_symbols.lst
16 BYTECODE_DESTINATION = $(CFERuntimeLibDir)
17
18 include $(LEVEL)/Makefile.common
+0
-31
runtime/libprofile/Profiling.h less more
None /*===-- Profiling.h - Profiling support library support routines --*- C -*-===*\
1 |*
2 |* The LLVM Compiler Infrastructure
3 |*
4 |* This file was developed by the LLVM research group and is distributed under
5 |* the University of Illinois Open Source License. See LICENSE.TXT for details.
6 |*
7 |*===----------------------------------------------------------------------===*|
8 |*
9 |* This file defines functions shared by the various different profiling
10 |* implementations.
11 |*
12 \*===----------------------------------------------------------------------===*/
13
14 #ifndef PROFILING_H
15 #define PROFILING_H
16
17 #include "llvm/Analysis/ProfileInfoTypes.h" /* for enum ProfilingType */
18
19 /* save_arguments - Save argc and argv as passed into the program for the file
20 * we output.
21 */
22 int save_arguments(int argc, const char **argv);
23
24 /* write_profiling_data - Write out a typed packet of profiling data to the
25 * current output file.
26 */
27 void write_profiling_data(enum ProfilingType PT, unsigned *Start,
28 unsigned NumElements);
29
30 #endif
+0
-5
runtime/libprofile/exported_symbols.lst less more
None
1 llvm_start_func_profiling
2 llvm_start_block_profiling
3 llvm_start_basic_block_tracing
4 llvm_trace_basic_block
+0
-18
runtime/libtrace/Makefile less more
None ##===- runtime/libtrace/Makefile ---------------------------*- Makefile -*-===##
1 #
2 # The LLVM Compiler Infrastructure
3 #
4 # This file was developed by the LLVM research group and is distributed under
5 # the University of Illinois Open Source License. See LICENSE.TXT for details.
6 #
7 ##===----------------------------------------------------------------------===##
8
9 LEVEL = ../..
10 BYTECODE_LIBRARY = 1
11 LIBRARYNAME = trace
12 BYTECODE_DESTINATION = $(CFERuntimeLibDir)
13
14 include $(LEVEL)/Makefile.common
15
16 CompileCommonOpts := $(filter-out -pedantic,$(CompileCommonOpts))
17 CompileCommonOpts := $(filter-out -Wno-long-long,$(CompileCommonOpts))
+0
-2
runtime/libtrace/README.txt less more
None These routines form the support library for the LLVM -trace and -tracem
1 instrumentation passes.
+0
-392
runtime/libtrace/tracelib.c less more
None /*===-- tracelib.c - Runtime routines for tracing ---------------*- C++ -*-===*
1 *
2 * Runtime routines for supporting tracing of execution for code generated by
3 * LLVM.
4 *
5 *===----------------------------------------------------------------------===*/
6
7 #include "tracelib.h"
8 #include
9 #include
10 #include
11 #include
12 #include "llvm/Support/DataTypes.h"
13
14 /*===---------------------------------------------------------------------=====
15 * HASH FUNCTIONS
16 *===---------------------------------------------------------------------===*/
17
18 /* use #defines until we have inlining */
19 typedef uintptr_t Index; /* type of keys, size for hash table */
20 typedef uint32_t Generic; /* type of values stored in table */
21
22 /* Index IntegerHashFunc(const Generic value, const Index size) */
23 #define IntegerHashFunc(value, size) \
24 ( ((((Index) value) << 3) ^ (((Index) value) >> 3)) % size )
25
26 /* Index IntegerRehashFunc(const Generic oldHashValue, const Index size) */
27 #define IntegerRehashFunc(oldHashValue, size) \
28 ((Index) ((oldHashValue+16) % size)) /* 16 is relatively prime to a Mersenne prime! */
29
30 /* Index PointerHashFunc(const void* value, const Index size) */
31 #define PointerHashFunc(value, size) \
32 IntegerHashFunc((Index) value, size)
33
34 /* Index PointerRehashFunc(const void* value, const Index size) */
35 #define PointerRehashFunc(value, size) \
36 IntegerRehashFunc((Index) value, size)
37
38 /*===---------------------------------------------------------------------=====
39 * POINTER-TO-GENERIC HASH TABLE.
40 * These should be moved to a separate location: HashTable.[ch]
41 *===---------------------------------------------------------------------===*/
42
43 typedef enum { FIND, ENTER } ACTION;
44 typedef char FULLEMPTY;
45 const FULLEMPTY EMPTY = '\0';
46 const FULLEMPTY FULL = '\1';
47
48 // List of primes closest to powers of 2 in [2^20 -- 2^30], obtained from
49 // http://www.utm.edu/research/primes/lists/2small/0bit.html.
50 // Use these as the successive sizes of the hash table.
51 #define NUMPRIMES 11
52 #define FIRSTENTRY 2
53 const unsigned PRIMES[NUMPRIMES] = { (1<<20)-3, (1<<21)-9, (1<<22)-3, (1<<23)-15,
54 (1<<24)-3, (1<<25)-39, (1<<26)-5, (1<<27)-39,
55 (1<<28)-57, (1<<29)-3, (1<<30)-35 };
56 unsigned CurrentSizeEntry = FIRSTENTRY;
57
58 const unsigned MAX_NUM_PROBES = 4;
59
60 typedef struct PtrValueHashEntry_struct {
61 void* key;
62 Generic value;
63 } PtrValueHashEntry;
64
65 typedef struct PtrValueHashTable_struct {
66 PtrValueHashEntry* table;
67 FULLEMPTY* fullEmptyFlags;
68 Index capacity;
69 Index size;
70 } PtrValueHashTable;
71
72
73 static Generic LookupOrInsertPtr(PtrValueHashTable* ptrTable, void* ptr,
74 ACTION action, Generic value);
75
76 static void Insert(PtrValueHashTable* ptrTable, void* ptr, Generic value);
77
78 static void Delete(PtrValueHashTable* ptrTable, void* ptr);
79
80 /* Returns 0 if the item is not found. */
81 /* void* LookupPtr(PtrValueHashTable* ptrTable, void* ptr) */
82 #define LookupPtr(ptrTable, ptr) \
83 LookupOrInsertPtr(ptrTable, ptr, FIND, (Generic) 0)
84
85 void
86 InitializeTable(PtrValueHashTable* ptrTable, Index newSize)
87 {
88 ptrTable->table = (PtrValueHashEntry*) calloc(newSize,
89 sizeof(PtrValueHashEntry));
90 ptrTable->fullEmptyFlags = (FULLEMPTY*) calloc(newSize, sizeof(FULLEMPTY));
91 ptrTable->capacity = newSize;
92 ptrTable->size = 0;
93 }
94
95 PtrValueHashTable*
96 CreateTable(Index initialSize)
97 {
98 PtrValueHashTable* ptrTable =
99 (PtrValueHashTable*) malloc(sizeof(PtrValueHashTable));
100 InitializeTable(ptrTable, initialSize);
101 return ptrTable;
102 }
103
104 void
105 ReallocTable(PtrValueHashTable* ptrTable, Index newSize)
106 {
107 if (newSize <= ptrTable->capacity)
108 return;
109
110 #ifndef NDEBUG
111 printf("\n***\n*** REALLOCATING SPACE FOR POINTER HASH TABLE.\n");
112 printf("*** oldSize = %ld, oldCapacity = %ld\n***\n\n",
113 (long) ptrTable->size, (long) ptrTable->capacity);
114 #endif
115
116 unsigned int i;
117 PtrValueHashEntry* oldTable = ptrTable->table;
118 FULLEMPTY* oldFlags = ptrTable->fullEmptyFlags;
119 Index oldSize = ptrTable->size;
120 Index oldCapacity = ptrTable->capacity;
121
122 /* allocate the new storage and flags and re-insert the old entries */
123 InitializeTable(ptrTable, newSize);
124 for (i=0; i < oldCapacity; ++i)
125 if (oldFlags[i] == FULL)
126 Insert(ptrTable, oldTable[i].key, oldTable[i].value);
127
128 assert(ptrTable->size == oldSize && "Incorrect number of entries copied?");
129
130 #ifndef NDEBUG
131 for (i=0; i < oldCapacity; ++i)
132 if (oldFlags[i] == FULL)
133 assert(LookupPtr(ptrTable, oldTable[i].key) == oldTable[i].value);
134 #endif
135
136 free(oldTable);
137 free(oldFlags);
138 }
139
140 void
141 DeleteTable(PtrValueHashTable* ptrTable)
142 {
143 free(ptrTable->table);
144 free(ptrTable->fullEmptyFlags);
145 memset(ptrTable, '\0', sizeof(PtrValueHashTable));
146 free(ptrTable);
147 }
148
149 void
150 InsertAtIndex(PtrValueHashTable* ptrTable, void* ptr, Generic value, Index index)
151 {
152 assert(ptrTable->fullEmptyFlags[index] == EMPTY && "Slot is in use!");
153 ptrTable->table[index].key = ptr;
154 ptrTable->table[index].value = value;
155 ptrTable->fullEmptyFlags[index] = FULL;
156 ptrTable->size++;
157 }
158
159 void
160 DeleteAtIndex(PtrValueHashTable* ptrTable, Index index)
161 {
162 assert(ptrTable->fullEmptyFlags[index] == FULL && "Deleting empty slot!");
163 ptrTable->table[index].key = 0;
164 ptrTable->table[index].value = (Generic) 0;
165 ptrTable->fullEmptyFlags[index] = EMPTY;
166 ptrTable->size--;
167 }
168
169 Index
170 FindIndex(PtrValueHashTable* ptrTable, void* ptr)
171 {
172 unsigned numProbes = 1;
173 Index index = PointerHashFunc(ptr, ptrTable->capacity);
174 if (ptrTable->fullEmptyFlags[index] == FULL)
175 {
176 if (ptrTable->table[index].key == ptr)
177 return index;
178
179 /* First lookup failed on non-empty slot: probe further */
180 while (numProbes < MAX_NUM_PROBES)
181 {
182 index = PointerRehashFunc(index, ptrTable->capacity);
183 if (ptrTable->fullEmptyFlags[index] == EMPTY)
184 break;
185 else if (ptrTable->table[index].key == ptr)
186 return index;
187 ++numProbes;
188 }
189 }
190
191 /* Lookup failed: item is not in the table. */
192 /* If last slot is empty, use that slot. */
193 /* Otherwise, table must have been reallocated, so search again. */
194
195 if (numProbes == MAX_NUM_PROBES)
196 { /* table is too full: reallocate and search again */
197 if (CurrentSizeEntry >= NUMPRIMES-1) {
198 fprintf(stderr, "Out of PRIME Numbers!!!");
199 abort();
200 }
201 ReallocTable(ptrTable, PRIMES[++CurrentSizeEntry]);
202 return FindIndex(ptrTable, ptr);
203 }
204 else
205 {
206 assert(ptrTable->fullEmptyFlags[index] == EMPTY &&
207 "Stopped before finding an empty slot and before MAX probes!");
208 return index;
209 }
210 }
211
212 /* Look up hash table using 'ptr' as the key. If an entry exists, return
213 * the value mapped to 'ptr'. If not, and if action==ENTER is specified,
214 * create a new entry with value 'value', but return 0 in any case.
215 */
216 Generic
217 LookupOrInsertPtr(PtrValueHashTable* ptrTable, void* ptr, ACTION action,
218 Generic value)
219 {
220 Index index = FindIndex(ptrTable, ptr);
221 if (ptrTable->fullEmptyFlags[index] == FULL &&
222 ptrTable->table[index].key == ptr)
223 return ptrTable->table[index].value;
224
225 /* Lookup failed: item is not in the table */
226 /* If action is ENTER, insert item into the table. Return 0 in any case. */
227 if (action == ENTER)
228 InsertAtIndex(ptrTable, ptr, value, index);
229
230 return (Generic) 0;
231 }
232
233 void
234 Insert(PtrValueHashTable* ptrTable, void* ptr, Generic value)
235 {
236 Index index = FindIndex(ptrTable, ptr);
237 assert(ptrTable->fullEmptyFlags[index] == EMPTY &&
238 "ptr is already in the table: delete it first!");
239 InsertAtIndex(ptrTable, ptr, value, index);
240 }
241
242 void
243 Delete(PtrValueHashTable* ptrTable, void* ptr)
244 {
245 Index index = FindIndex(ptrTable, ptr);
246 if (ptrTable->fullEmptyFlags[index] == FULL &&
247 ptrTable->table[index].key == ptr)
248 {
249 DeleteAtIndex(ptrTable, index);
250 }
251 }
252
253 /*===---------------------------------------------------------------------=====
254 * RUNTIME ROUTINES TO MAP POINTERS TO SEQUENCE NUMBERS
255 *===---------------------------------------------------------------------===*/
256
257 PtrValueHashTable* SequenceNumberTable = NULL;
258 #define INITIAL_SIZE (PRIMES[FIRSTENTRY])
259
260 #define MAX_NUM_SAVED 1024
261
262 typedef struct PointerSet_struct {
263 char* savedPointers[MAX_NUM_SAVED]; /* 1024 alloca'd ptrs shd suffice */
264 unsigned int numSaved;
265 struct PointerSet_struct* nextOnStack; /* implement a cheap stack */
266 } PointerSet;
267
268 PointerSet* topOfStack = NULL;
269
270 SequenceNumber
271 HashPointerToSeqNum(char* ptr)
272 {
273 static SequenceNumber count = 0;
274 SequenceNumber seqnum;
275 if (SequenceNumberTable == NULL) {
276 assert(MAX_NUM_PROBES < INITIAL_SIZE+1 && "Initial size too small");
277 SequenceNumberTable = CreateTable(INITIAL_SIZE);
278 }
279 seqnum = (SequenceNumber)
280 LookupOrInsertPtr(SequenceNumberTable, ptr, ENTER, count+1);
281
282 if (seqnum == 0) /* new entry was created with value count+1 */
283 seqnum = ++count; /* so increment counter */
284
285 assert(seqnum <= count && "Invalid sequence number in table!");
286 return seqnum;
287 }
288
289 void
290 ReleasePointerSeqNum(char* ptr)
291 { /* if a sequence number was assigned to this ptr, release it */
292 if (SequenceNumberTable != NULL)
293 Delete(SequenceNumberTable, ptr);
294 }
295
296 void
297 PushPointerSet()
298 {
299 PointerSet* newSet = (PointerSet*) malloc(sizeof(PointerSet));
300 newSet->numSaved = 0;
301 newSet->nextOnStack = topOfStack;
302 topOfStack = newSet;
303 }
304
305 void
306 PopPointerSet()
307 {
308 PointerSet* oldSet;
309 assert(topOfStack != NULL && "popping from empty stack!");
310 oldSet = topOfStack;
311 topOfStack = oldSet->nextOnStack;
312 assert(oldSet->numSaved == 0);
313 free(oldSet);
314 }
315
316 /* free the pointers! */
317 static void
318 ReleaseRecordedPointers(char* savedPointers[MAX_NUM_SAVED],
319 unsigned int numSaved)
320 {
321 unsigned int i;
322 for (i=0; i < topOfStack->numSaved; ++i)
323 ReleasePointerSeqNum(topOfStack->savedPointers[i]);
324 }
325
326 void
327 ReleasePointersPopSet()
328 {
329 ReleaseRecordedPointers(topOfStack->savedPointers, topOfStack->numSaved);
330 topOfStack->numSaved = 0;
331 PopPointerSet();
332 }
333
334 void
335 RecordPointer(char* ptr)
336 { /* record pointers for release later */
337 if (topOfStack->numSaved == MAX_NUM_SAVED) {
338 printf("***\n*** WARNING: OUT OF ROOM FOR SAVED POINTERS."
339 " ALL POINTERS ARE BEING FREED.\n"
340 "*** THE SEQUENCE NUMBERS OF SAVED POINTERS WILL CHANGE!\n*** \n");
341 ReleaseRecordedPointers(topOfStack->savedPointers, topOfStack->numSaved);
342 topOfStack->numSaved = 0;
343 }
344 topOfStack->savedPointers[topOfStack->numSaved++] = ptr;
345 }
346
347 /*===---------------------------------------------------------------------=====
348 * TEST DRIVER FOR INSTRUMENTATION LIBRARY
349 *===---------------------------------------------------------------------===*/
350
351 #ifndef TEST_INSTRLIB
352 #undef TEST_INSTRLIB /* #define this to turn on by default */
353 #endif
354
355 #ifdef TEST_INSTRLIB
356 int
357 main(int argc, char** argv)
358 {
359 int i, j;
360 int doRelease = 0;
361
362 INITIAL_SIZE = 5; /* start with small table to test realloc's*/
363
364 if (argc > 1 && ! strcmp(argv[1], "-r"))
365 {
366 PushPointerSet();
367 <