Initial import of tcc:

DESCR:
======
Tiny C Compiler - C Scripting Everywhere - The Smallest ANSI C compiler
-----------------------------------------------------------------------
Features:
--------
- SMALL! You can compile and execute C code everywhere, for example on
  rescue disks.
- FAST! tcc generates optimized x86 code. No byte code
  overhead. Compile, assemble and link about 7 times faster than 'gcc
  -O0'.
- UNLIMITED! Any C dynamic library can be used directly. TCC is
  heading torward full ISOC99 compliance. TCC can of course compile
  itself.
- SAFE! tcc includes an optional memory and bound checker. Bound
  checked code can be mixed freely with standard code.
- Compile and execute C source directly. No linking or assembly
  necessary. Full C preprocessor included. 
- C script supported : just add '#!/usr/local/bin/tcc -run' at the first
  line of your C source, and execute it directly from the command
  line.


** TODO **

* Original pkg seems to work under Linux and FreeBSD
  I patch a little bit FreeBSD #ifs and compiles under
  NetBSD, but doesn't works fine.
* Could be a freebsd bug also, I doesn't test it :/
This commit is contained in:
pancake ;) 2003-07-27 02:41:02 +00:00
parent 0d69159255
commit 0a81804500
9 changed files with 202 additions and 0 deletions

19
tcc/DESCR Normal file
View file

@ -0,0 +1,19 @@
Tiny C Compiler - C Scripting Everywhere - The Smallest ANSI C compiler
-----------------------------------------------------------------------
Features:
--------
- SMALL! You can compile and execute C code everywhere, for example on
rescue disks.
- FAST! tcc generates optimized x86 code. No byte code
overhead. Compile, assemble and link about 7 times faster than 'gcc
-O0'.
- UNLIMITED! Any C dynamic library can be used directly. TCC is
heading torward full ISOC99 compliance. TCC can of course compile
itself.
- SAFE! tcc includes an optional memory and bound checker. Bound
checked code can be mixed freely with standard code.
- Compile and execute C source directly. No linking or assembly
necessary. Full C preprocessor included.
- C script supported : just add '#!/usr/local/bin/tcc -run' at the first
line of your C source, and execute it directly from the command
line.

18
tcc/Makefile Normal file
View file

@ -0,0 +1,18 @@
# $NetBSD: Makefile,v 1.1.1.1 2003/07/27 02:41:02 poppnk Exp $
#
DISTNAME= tcc-0.9.19
CATEGORIES= lang
MASTER_SITES= http://fabrice.bellard.free.fr/tcc/
MAINTAINER= pancake@phreaker.net
HOMEPAGE= http://www.tinycc.org
COMMENT= The Smallest ANSI C compiler
USE_GMAKE= yes
GNU_CONFIGURE= yes
USE_BUILDLINK2= yes
ONLY_FOR_PLATFORM= *-*-i386
.include "../../mk/bsd.pkg.mk"

15
tcc/PLIST Normal file
View file

@ -0,0 +1,15 @@
@comment $NetBSD: PLIST,v 1.1.1.1 2003/07/27 02:41:03 poppnk Exp $
bin/tcc
include/libtcc.h
lib/libtcc.a
lib/tcc/bcheck.o
lib/tcc/include/float.h
lib/tcc/include/stdarg.h
lib/tcc/include/stdbool.h
lib/tcc/include/stddef.h
lib/tcc/include/tcclib.h
lib/tcc/include/varargs.h
lib/tcc/libtcc1.a
man/man1/tcc.1
@dirrm lib/tcc/include
@dirrm lib/tcc

4
tcc/TODO Normal file
View file

@ -0,0 +1,4 @@
* Original pkg seems to work under Linux and FreeBSD
I patch a little bit FreeBSD #ifs and compiles under
NetBSD, but doesn't works fine.
* Could be a freebsd bug also, I doesn't test it :/

8
tcc/distinfo Normal file
View file

@ -0,0 +1,8 @@
$NetBSD: distinfo,v 1.1.1.1 2003/07/27 02:41:03 poppnk Exp $
SHA1 (tcc-0.9.19.tar.gz) = b0eeff0059253bb5f447c7c146978d9cdff368dd
Size (tcc-0.9.19.tar.gz) = 197848 bytes
SHA1 (patch-aa) = 3f2383c1764c5b2694849cdfc18f53ea17c3c7d6
SHA1 (patch-ab) = eef3c23a19f195f8bfea1f6b4b1c9f2a789fa2a5
SHA1 (patch-ac) = fd553aee2bdd172903bf35da5a387765d637326e
SHA1 (patch-ad) = 8c6c97bacffe9374a9e33d3566f8f37430120af0

69
tcc/patches/patch-aa Normal file
View file

@ -0,0 +1,69 @@
$NetBSD: patch-aa,v 1.1.1.1 2003/07/27 02:41:03 poppnk Exp $
--- tcc.c.orig 2003-05-24 18:30:29.000000000 +0000
+++ tcc.c 2003-07-26 21:58:09.000000000 +0000
@@ -2926,6 +2926,22 @@
}
}
+#if __NetBSD__
+float strtof(const char *nptr, char **endptr)
+{
+ float n=0;
+ sscanf(nptr,"%f",&n);
+ return n;
+}
+
+long double strtold(const char *nptr, char **endptr)
+{
+ long double n=0;
+ sscanf(nptr,"%Lf",&n);
+ return n;
+}
+#endif
+
/* parse number in null terminated string 'p' and return it in the
current token */
void parse_number(const char *p)
@@ -8954,9 +8970,15 @@
/* fix for glibc 2.1 */
#ifndef REG_EIP
+#include <sys/param.h>
+#if BSD
+#define REG_EIP _REG_EIP
+#define REG_EBP _REG_EBP
+#else
#define REG_EIP EIP
#define REG_EBP EBP
#endif
+#endif
/* return the PC at frame level 'level'. Return non zero if not found */
static int rt_get_caller_pc(unsigned long *paddr,
@@ -8969,14 +8991,14 @@
#ifdef __FreeBSD__
*paddr = uc->uc_mcontext.mc_eip;
#else
- *paddr = uc->uc_mcontext.gregs[REG_EIP];
+ *paddr = uc->uc_mcontext.__gregs[REG_EIP];
#endif
return 0;
} else {
#ifdef __FreeBSD__
fp = uc->uc_mcontext.mc_ebp;
#else
- fp = uc->uc_mcontext.gregs[REG_EBP];
+ fp = uc->uc_mcontext.__gregs[REG_EBP];
#endif
for(i=1;i<level;i++) {
/* XXX: check address validity with program info */
@@ -9108,7 +9130,7 @@
struct sigaction sigact;
/* install TCC signal handlers to print debug info on fatal
runtime errors */
- sigact.sa_flags = SA_SIGINFO | SA_RESETHAND;
+ sigact.sa_flags = SA_RESETHAND;
sigact.sa_sigaction = sig_error;
sigemptyset(&sigact.sa_mask);
sigaction(SIGFPE, &sigact, NULL);

13
tcc/patches/patch-ab Normal file
View file

@ -0,0 +1,13 @@
$NetBSD: patch-ab,v 1.1.1.1 2003/07/27 02:41:03 poppnk Exp $
--- tccelf.c.orig 2003-07-26 21:40:06.000000000 +0000
+++ tccelf.c 2003-07-26 21:40:16.000000000 +0000
@@ -378,7 +378,7 @@
static void *resolve_sym(const char *sym)
{
- return dlsym(RTLD_DEFAULT, sym);
+ return dlsym(RTLD_LAZY, sym);
}
/* relocate symbol table, resolve undefined symbols if do_resolve is

26
tcc/patches/patch-ac Normal file
View file

@ -0,0 +1,26 @@
$NetBSD: patch-ac,v 1.1.1.1 2003/07/27 02:41:04 poppnk Exp $
--- Makefile.orig 2003-05-24 18:30:29.000000000 +0000
+++ Makefile 2003-07-27 04:32:14.000000000 +0000
@@ -2,9 +2,11 @@
# Tiny C Compiler Makefile
#
include config.mak
+OS=\`uname\`
CFLAGS=-O2 -g -Wall
-LIBS=-ldl
+LIBS=`if [ ! "$(OS)" = "NetBSD" ]; then echo "-ldl"; fi`
+
CFLAGS_P=$(CFLAGS) -pg -static -DCONFIG_TCC_STATIC
LIBS_P=
@@ -167,7 +169,7 @@
$(AR) rcs $@ $^
libtcc_test: libtcc_test.c libtcc.a
- $(CC) $(CFLAGS) -I. -o $@ $< -L. -ltcc -ldl
+ $(CC) $(CFLAGS) -I. -o $@ $< -L. -ltcc $(LIBS)
libtest: libtcc_test
./libtcc_test

30
tcc/patches/patch-ad Normal file
View file

@ -0,0 +1,30 @@
$NetBSD: patch-ad,v 1.1.1.1 2003/07/27 02:41:04 poppnk Exp $
--- bcheck.c.orig 2003-07-27 04:13:21.000000000 +0000
+++ bcheck.c 2003-07-27 04:14:34.000000000 +0000
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
+#include <sys/param.h>
#ifndef __FreeBSD__
#include <malloc.h>
#endif
@@ -36,7 +37,7 @@
#define HAVE_MEMALIGN
-#ifdef __FreeBSD__
+#ifdef BSD
#warning Bound checking not fully supported on FreeBSD
#undef CONFIG_TCC_MALLOC_HOOKS
#undef HAVE_MEMALIGN
@@ -782,7 +783,7 @@
{
void *ptr;
size = size * nmemb;
- ptr = __bound_malloc(size);
+ ptr = __bound_malloc(size,0);
if (!ptr)
return NULL;
memset(ptr, 0, size);