view release on metacpan or search on metacpan
src/tests/tests2/79_vla_continue.c
src/tests/tests2/79_vla_continue.expect
src/tests/tests2/80_flexarray.c
src/tests/tests2/80_flexarray.expect
src/tests/tests2/81_types.c
src/tests/tests2/81_types.expect
src/tests/tests2/82_attribs_position.c
src/tests/tests2/82_attribs_position.expect
src/tests/tests2/82_nocode_wanted.c
src/tests/tests2/82_nocode_wanted.expect
src/tests/tests2/83_utf8_in_identifiers.c
src/tests/tests2/83_utf8_in_identifiers.expect
src/tests/tests2/84-hex-float.c
src/tests/tests2/84-hex-float.expect
src/tests/tests2/85-asm-outside-function.c
src/tests/tests2/85-asm-outside-function.expect
src/tests/tests2/LICENSE
src/tests/vla_test.c
src/texi2pod.pl
src/TODO
src/VERSION
src/win32/build-tcc.bat
src/il-gen.c view on Meta::CPAN
#define OP(name, str, n) [n] = str,
#include "il-opcodes.h"
#undef OP
};
/******************************************************/
/* arguments variable numbers start from there */
#define ARG_BASE 0x70000000
static FILE *il_outfile;
static void out_byte(int c)
{
*(char *)ind++ = c;
}
static void out_le32(int c)
{
out_byte(c);
out_byte(c >> 8);
out_byte(c >> 16);
out_byte(c >> 24);
}
static void init_outfile(void)
{
if (!il_outfile) {
il_outfile = stdout;
fprintf(il_outfile,
".assembly extern mscorlib\n"
"{\n"
".ver 1:0:2411:0\n"
"}\n\n");
}
}
static void out_op1(int op)
{
if (op & 0x100)
out_byte(IL_OP_PREFIX);
out_byte(op & 0xff);
}
/* output an opcode with prefix */
static void out_op(int op)
{
out_op1(op);
fprintf(il_outfile, " %s\n", il_opcodes_str[op]);
}
static void out_opb(int op, int c)
{
out_op1(op);
out_byte(c);
fprintf(il_outfile, " %s %d\n", il_opcodes_str[op], c);
}
static void out_opi(int op, int c)
{
out_op1(op);
out_le32(c);
fprintf(il_outfile, " %s 0x%x\n", il_opcodes_str[op], c);
}
/* XXX: not complete */
static void il_type_to_str(char *buf, int buf_size,
int t, const char *varstr)
{
int bt;
Sym *s, *sa;
char buf1[256];
const char *tstr;
src/il-gen.c view on Meta::CPAN
}
/* output jump and return symbol */
static int out_opj(int op, int c)
{
out_op1(op);
out_le32(0);
if (c == 0) {
c = ind - (int)cur_text_section->data;
}
fprintf(il_outfile, " %s L%d\n", il_opcodes_str[op], c);
return c;
}
void gsym(int t)
{
fprintf(il_outfile, "L%d:\n", t);
}
/* load 'r' from value 'sv' */
void load(int r, SValue *sv)
{
int v, fc, ft;
v = sv->r & VT_VALMASK;
fc = sv->c.i;
ft = sv->t;
src/il-gen.c view on Meta::CPAN
/* generate function call with address in (vtop->t, vtop->c) and free function
context. Stack entry is popped */
void gfunc_call(GFuncContext *c)
{
char buf[1024];
if ((vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
/* XXX: more info needed from tcc */
il_type_to_str(buf, sizeof(buf), vtop->t, "xxx");
fprintf(il_outfile, " call %s\n", buf);
} else {
/* indirect call */
gv(RC_INT);
il_type_to_str(buf, sizeof(buf), vtop->t, NULL);
fprintf(il_outfile, " calli %s\n", buf);
}
vtop--;
}
/* generate function prolog of type 't' */
void gfunc_prolog(int t)
{
int addr, u, func_call;
Sym *sym;
char buf[1024];
init_outfile();
/* XXX: pass function name to gfunc_prolog */
il_type_to_str(buf, sizeof(buf), t, funcname);
fprintf(il_outfile, ".method static %s il managed\n", buf);
fprintf(il_outfile, "{\n");
/* XXX: cannot do better now */
fprintf(il_outfile, " .maxstack %d\n", NB_REGS);
fprintf(il_outfile, " .locals (int32, int32, int32, int32, int32, int32, int32, int32)\n");
if (!strcmp(funcname, "main"))
fprintf(il_outfile, " .entrypoint\n");
sym = sym_find((unsigned)t >> VT_STRUCT_SHIFT);
func_call = sym->r;
addr = ARG_BASE;
/* if the function returns a structure, then add an
implicit pointer parameter */
func_vt = sym->t;
func_var = (sym->c == FUNC_ELLIPSIS);
if ((func_vt & VT_BTYPE) == VT_STRUCT) {
src/il-gen.c view on Meta::CPAN
sym_push(sym->v & ~SYM_FIELD, u,
VT_LOCAL | lvalue_type(sym->type.t), addr);
addr++;
}
}
/* generate function epilog */
void gfunc_epilog(void)
{
out_op(IL_OP_RET);
fprintf(il_outfile, "}\n\n");
}
/* generate a jump to a label */
int gjmp(int t)
{
return out_opj(IL_OP_BR, t);
}
/* generate a jump to a fixed address */
void gjmp_addr(int a)
src/libtcc.c view on Meta::CPAN
tccgen_end(s1);
}
s1->error_set_jmp_enabled = 0;
/* #ifdef CONFIG_TCC_EXSYMTAB */
/* Make an extended copy of the symbol table, if requested */
if (s1->nb_errors == 0 && s1->exsymtab == (extended_symtab*)1)
{
copy_extended_symtab(s1, define_start, tok_start);
/* Output the symbol table to a cache if requested */
if (s1->symtab_serialize_outfile)
tcc_serialize_extended_symtab(s1->exsymtab, s1->symtab_serialize_outfile);
/* Output the symbol names */
if (s1->dump_identifier_names_outfile)
tcc_dump_identifier_names(s1->exsymtab, s1->dump_identifier_names_outfile);
}
/* #endif */
free_inline_functions(s1);
/* reset define stack, but keep -D and built-ins */
free_defines(define_start);
sym_pop(&global_stack, NULL);
sym_pop(&local_stack, NULL);
return s1->nb_errors != 0 ? -1 : 0;
}
src/libtcc.c view on Meta::CPAN
"name proto __asm__ (#alias) __THROW");
# endif
#endif /* ndef TCC_TARGET_PE */
/* #ifdef CONFIG_TCC_EXSYMTAB */
/* Extended symbol table API */
s->symtab_name_callback = NULL;
s->symtab_sym_used_callback = NULL;
s->symtab_prep_callback = NULL;
s->symtab_callback_data = NULL;
s->symtab_serialize_outfile = NULL;
s->dump_identifier_names_outfile = NULL;
/* #endif */
return s;
}
LIBTCCAPI void tcc_delete(TCCState *s1)
{
int bench = s1->do_bench;
tcc_cleanup();
/* #ifdef CONFIG_TCC_EXSYMTAB */
/* Clean up the extended symbol table if it was never copied. */
if (s1->exsymtab > (extended_symtab*)1)
tcc_delete_extended_symbol_table(s1->exsymtab);
/* free file paths related to caching */
tcc_free(s1->symtab_serialize_outfile);
tcc_free(s1->dump_identifier_names_outfile);
/* #endif */
/* free sections */
tccelf_delete(s1);
/* free library paths */
dynarray_reset(&s1->library_paths, &s1->nb_library_paths);
dynarray_reset(&s1->crt_paths, &s1->nb_crt_paths);
/* free include paths */
dynarray_reset(&s1->cached_includes, &s1->nb_cached_includes);
dynarray_reset(&s1->include_paths, &s1->nb_include_paths);
dynarray_reset(&s1->sysinclude_paths, &s1->nb_sysinclude_paths);
tcc_free(s1->tcc_lib_path);
tcc_free(s1->soname);
tcc_free(s1->rpath);
tcc_free(s1->init_symbol);
tcc_free(s1->fini_symbol);
tcc_free(s1->outfile);
tcc_free(s1->deps_outfile);
dynarray_reset(&s1->files, &s1->nb_files);
dynarray_reset(&s1->target_deps, &s1->nb_target_deps);
dynarray_reset(&s1->pragma_libs, &s1->nb_pragma_libs);
#ifdef TCC_IS_NATIVE
/* free runtime memory */
tcc_run_free(s1);
#endif
tcc_free(s1->sym_attrs);
src/libtcc.c view on Meta::CPAN
case TCC_OPTION_shared:
x = TCC_OUTPUT_DLL;
goto set_output_type;
case TCC_OPTION_soname:
s->soname = tcc_strdup(optarg);
break;
case TCC_OPTION_m:
s->option_m = tcc_strdup(optarg);
break;
case TCC_OPTION_o:
if (s->outfile) {
tcc_warning("multiple -o option");
tcc_free(s->outfile);
}
s->outfile = tcc_strdup(optarg);
break;
case TCC_OPTION_r:
/* generate a .o merging several output files */
s->option_r = 1;
x = TCC_OUTPUT_OBJ;
goto set_output_type;
case TCC_OPTION_isystem:
tcc_add_sysinclude_path(s, optarg);
break;
case TCC_OPTION_iwithprefix:
src/libtcc.c view on Meta::CPAN
case TCC_OPTION_E:
x = TCC_OUTPUT_PREPROCESS;
goto set_output_type;
case TCC_OPTION_P:
s->Pflag = atoi(optarg) + 1;
break;
case TCC_OPTION_MD:
s->gen_deps = 1;
break;
case TCC_OPTION_MF:
s->deps_outfile = tcc_strdup(optarg);
break;
/* #ifdef CONFIG_TCC_EXSYMTAB */
case TCC_OPTION_serialize_symtab:
s->symtab_serialize_outfile = tcc_strdup(optarg + 1);
s->exsymtab = (extended_symtab*)1;
break;
case TCC_OPTION_dump_identifier_names:
s->dump_identifier_names_outfile = tcc_strdup(optarg + 1);
s->exsymtab = (extended_symtab*)1;
break;
/* #endif */
case TCC_OPTION_dumpversion:
printf ("%s\n", TCC_VERSION);
exit(0);
break;
case TCC_OPTION_x:
if (*optarg == 'c')
s->filetype = AFF_TYPE_C;
src/libtcc.h view on Meta::CPAN
TCCState * compiler_state,
extended_symtab_lookup_by_name_callback new_name_callback,
extended_symtab_sym_used_callback new_sym_used_callback,
extended_symtab_prep_callback new_prep_callback,
void * data
);
/*** For symbol table caching ***/
LIBTCCAPI extended_symtab_p tcc_deserialize_extended_symtab(const char * input_filename);
LIBTCCAPI int tcc_serialize_extended_symtab(extended_symtab_p symtab, const char * output_filename);
LIBTCCAPI void tcc_dump_identifier_names(extended_symtab_p symtab, char * outfile);
/* Testing functions, not really for general use */
LIBTCCAPI int tcc_extended_symtab_test(extended_symtab_p, int to_test, const char * name);
LIBTCCAPI char* tcc_get_next_extended_symbol_name(extended_symtab_p symtab, int * poffset);
#ifndef SYM_EXTENDED
#define SYM_EXTENDED 0x40000000 /* extended symbol space */
#endif
/* #endif CONFIG_TCC_EXSYMTAB */
src/tcc-doc.texi view on Meta::CPAN
@section Option summary
General Options:
@c man begin OPTIONS
@table @option
@item -c
Generate an object file.
@item -o outfile
Put object file, executable, or dll into output file @file{outfile}.
@item -run source [args...]
Compile file @var{source} and run it with the command line arguments
@var{args}. In order to be able to give more than one argument to a
script, several TCC options can be given @emph{after} the
@option{-run} option, separated by spaces:
@example
tcc "-run -L/usr/X11R6/lib -lX11" ex4.c
@end example
In a script, it gives the following header:
}
}
static void help(void)
{
printf("Tiny C Compiler "TCC_VERSION" - Copyright (C) 2001-2006 Fabrice Bellard\n"
/* #ifdef CONFIG_TCC_EXSYMTAB */
"compiled with the exsymtab extension by David Mertens\n"
"\n"
/* #endif */
"Usage: tcc [options...] [-o outfile] [-c] infile(s)...\n"
" tcc [options...] -run infile [arguments...]\n"
"General options:\n"
" -c compile only - generate an object file\n"
" -o outfile set output filename\n"
" -run run compiled source\n"
" -fflag set or reset (with 'no-' prefix) 'flag' (see man page)\n"
" -mms-bitfields use bitfield alignment consistent with MSVC\n"
" -Wwarning set or reset (with 'no-' prefix) 'warning' (see man page)\n"
" -w disable all warnings\n"
" -v show version\n"
" -vv show included files (as sole argument: show search paths)\n"
" -dumpversion\n"
" -bench show compilation statistics\n"
" -xc -xa specify type of the next infile\n"
if (!depout)
tcc_error("could not open '%s'", filename);
fprintf(depout, "%s : \\\n", target);
for (i=0; i<s->nb_target_deps; ++i)
fprintf(depout, " %s \\\n", s->target_deps[i]);
fprintf(depout, "\n");
fclose(depout);
}
static char *default_outputfile(TCCState *s, const char *first_file)
{
char buf[1024];
char *ext;
const char *name = "a";
if (first_file && strcmp(first_file, "-"))
name = tcc_basename(first_file);
pstrcpy(buf, sizeof(buf), name);
ext = tcc_fileextension(buf);
#ifdef TCC_TARGET_PE
/* accepts only a single input file */
if (s->nb_files != 1)
tcc_error("cannot specify multiple files with -c");
}
if (s->output_type == 0)
s->output_type = TCC_OUTPUT_EXE;
tcc_set_output_type(s, s->output_type);
if (s->output_type == TCC_OUTPUT_PREPROCESS) {
if (!s->outfile) {
s->ppfp = stdout;
} else {
s->ppfp = fopen(s->outfile, "w");
if (!s->ppfp)
tcc_error("could not write '%s'", s->outfile);
}
} else if (s->output_type != TCC_OUTPUT_OBJ) {
if (s->option_pthread)
tcc_set_options(s, "-lpthread");
}
if (s->do_bench)
start_time = getclock_ms();
/* compile or add each files or library */
if (tcc_add_file(s, f->name) < 0)
ret = 1;
if (!first_file)
first_file = f->name;
}
s->filetype = AFF_TYPE_NONE;
s->alacarte_link = 1;
}
if (s->output_type == TCC_OUTPUT_PREPROCESS) {
if (s->outfile)
fclose(s->ppfp);
} else if (0 == ret) {
if (s->output_type == TCC_OUTPUT_MEMORY) {
#ifdef TCC_IS_NATIVE
ret = tcc_run(s, argc - 1 - optind, argv + 1 + optind);
#endif
} else
/* #ifdef CONFIG_TCC_EXSYMTAB */
if (!s->outfile
&& (s->symtab_serialize_outfile || s->dump_identifier_names_outfile))
{
/* do nothing */
} else
/* #endif */
{
if (!s->outfile)
s->outfile = default_outputfile(s, first_file);
ret = !!tcc_output_file(s, s->outfile);
if (s->gen_deps && !ret)
gen_makedeps(s, s->outfile, s->deps_outfile);
}
}
if (s->do_bench)
tcc_print_stats(s, getclock_ms() - start_time);
tcc_delete(s);
return ret;
}
const char *runtime_main;
void **runtime_mem;
int nb_runtime_mem;
#endif
/* used by main and tcc_parse_args only */
struct filespec **files; /* files seen on command line */
int nb_files; /* number thereof */
int nb_libraries; /* number of libs thereof */
int filetype;
char *outfile; /* output filename */
char *option_m; /* only -m32/-m64 handled */
int print_search_dirs; /* option */
int option_r; /* option -r */
int do_bench; /* option -bench */
int gen_deps; /* option -MD */
char *deps_outfile; /* option -MF */
/* #ifdef CONFIG_TCC_EXSYMTAB */
/* ---- Extended symbol table handling ---- */
struct extended_symtab * exsymtab;
extended_symtab_lookup_by_name_callback symtab_name_callback;
extended_symtab_sym_used_callback symtab_sym_used_callback;
extended_symtab_prep_callback symtab_prep_callback;
void * symtab_callback_data;
char * symtab_serialize_outfile; /* option -serialize-symtab */
char * dump_identifier_names_outfile; /* option -dump-identifier-names */
/* #endif */
int option_pthread; /* -pthread option */
};
struct filespec {
char type, name[1];
};
/* The current value can be: */
src/tccexsymtab.c view on Meta::CPAN
}
}
char * type_lookup_table[16] = {
"int", "char", "short", "void",
"pointer", "enum", "func", "struct",
"float", "double", "long double", "bool",
"long long", "long", "qlong", "qfloat"
};
void tcc_dump_identifier_names(extended_symtab * symtab, char * outfile)
{
int i;
FILE * out_fh = fopen(outfile, "w");
/* report error? I think a lack of file will probably be sufficient */
if (!out_fh) return;
for (i = 0; symtab->tokenSym_list + i < symtab->tokenSym_last; i++) {
int btype;
TokenSym * ts;
Sym * curr_sym;
ts = symtab->tokenSym_list[i];
src/tccpp.c view on Meta::CPAN
case ';':
case ':':
case '?':
case '~':
case '@': /* only used in assembler */
parse_simple:
tok = c;
p++;
break;
default:
if (c >= 0x80 && c <= 0xFF) /* utf8 identifiers */
goto parse_ident_fast;
if (parse_flags & PARSE_FLAG_ASM_FILE)
goto parse_simple;
tcc_error("unrecognized character \\x%02x", c);
break;
}
tok_flags = 0;
keep_tok_flags:
file->buf_ptr = p;
#if defined(PARSE_DEBUG)
src/texi2pod.pl view on Meta::CPAN
$head = $sect;
$head =~ s/SEEALSO/SEE ALSO/;
print "=head1 $head\n\n";
print scalar unmunge ($sects{$sect});
print "\n";
}
}
sub usage
{
die "usage: $0 [-D toggle...] [infile [outfile]]\n";
}
sub postprocess
{
local $_ = $_[0];
# @value{foo} is replaced by whatever 'foo' is defined as.
while (m/(\@value\{([a-zA-Z0-9_-]+)\})/g) {
if (! exists $defs{$2}) {
print STDERR "Option $2 not defined\n";
src/win32/tools/tiny_impdef.c view on Meta::CPAN
/* -------------------------------------------------------------- */
/*
* tiny_impdef creates an export definition file (.def) from a dll
* on MS-Windows. Usage: tiny_impdef library.dll [-o outputfile]"
*
* Copyright (c) 2005,2007 grischka
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
src/win32/tools/tiny_impdef.c view on Meta::CPAN
&& p[-1] != '\\'
)
--p;
return (char*)p;
}
int main(int argc, char **argv)
{
int ret, v, i;
char infile[MAX_PATH];
char outfile[MAX_PATH];
static const char *ext[] = { ".dll", ".exe", NULL };
const char *file, **pp;
char path[MAX_PATH], *p, *q;
FILE *fp, *op;
infile[0] = 0;
outfile[0] = 0;
fp = op = NULL;
v = 0;
ret = 1;
p = NULL;
for (i = 1; i < argc; ++i) {
const char *a = argv[i];
if ('-' == a[0]) {
if (0 == strcmp(a, "-v")) {
v = 1;
} else if (0 == strcmp(a, "-o")) {
if (++i == argc)
goto usage;
strcpy(outfile, argv[i]);
} else
goto usage;
} else if (0 == infile[0])
strcpy(infile, a);
else
goto usage;
}
if (0 == infile[0]) {
usage:
fprintf(stderr,
"tiny_impdef: create export definition file (.def) from a dll\n"
"Usage: tiny_impdef library.dll [-o outputfile]\n"
);
goto the_end;
}
if (0 == outfile[0])
{
strcpy(outfile, file_basename(infile));
q = strrchr(outfile, '.');
if (NULL == q)
q = strchr(outfile, 0);
strcpy(q, ".def");
}
file = infile;
#ifdef _WIN32
pp = ext;
do if (SearchPath(NULL, file, *pp, sizeof path, path, NULL)) {
file = path;
break;
src/win32/tools/tiny_impdef.c view on Meta::CPAN
}
if (v)
printf("--> %s\n", file);
p = get_export_names(fileno(fp));
if (NULL == p) {
fprintf(stderr, "tiny_impdef: could not get exported function names.\n");
goto the_end;
}
op = fopen(outfile, "w");
if (NULL == op) {
fprintf(stderr, "tiny_impdef: could not create output file: %s\n", outfile);
goto the_end;
}
fprintf(op, "LIBRARY %s\n\nEXPORTS\n", file_basename(file));
for (q = p, i = 0; *q; ++i) {
fprintf(op, "%s\n", q);
q += strlen(q) + 1;
}
if (v) {
printf("<-- %s\n", outfile);
printf("%d symbol(s) found\n", i);
}
ret = 0;
the_end:
if (p)
free(p);
if (fp)
fclose(fp);
src/win32/vs2015/libtcc.vcxproj view on Meta::CPAN
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
src/win32/vs2015/tcc.vcxproj view on Meta::CPAN
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>