- 所有 tcc 文件/内容/宏改名为 pcc (tcc.c->pcc.c, tccelf.c->pccelf.c, libtcc.c->libpcc.c 等) - 支持架构: i386, x86_64, ARM, ARM64, RISC-V, C67 - 支持格式: PE, ELF, Mach-O, COFF - 完整预处理、代码生成、链接器、调试信息 - 构建成功: pcc.exe (x86_64 Windows) - 功能测试通过: 递归/结构体/浮点/switch/循环 - 自编译测试通过: pcc 可以编译自身
70 行
1020 B
C
70 行
1020 B
C
#include <stdio.h>
|
|
|
|
#if (defined _WIN32 || defined __APPLE__) && (!defined __TINYC__ || defined __leading_underscore)
|
|
# define _ "_"
|
|
#else
|
|
# define _
|
|
#endif
|
|
|
|
#ifdef __clang__
|
|
/* clang needs some help tp not throw functions away even at -O0 */
|
|
#define __USED __attribute__((__used__))
|
|
#else
|
|
#define __USED
|
|
#endif
|
|
|
|
static int __USED x1_c (void)
|
|
{
|
|
printf(" x1");
|
|
return 1;
|
|
}
|
|
|
|
#if __i386__
|
|
asm(".text;"_"x1: call "_"x1_c; ret");
|
|
#else
|
|
/* Keep stack aligned */
|
|
asm(".text;"_"x1: sub $8,%rsp; call "_"x1_c; add $8,%rsp; ret");
|
|
#endif
|
|
|
|
void callx4(void);
|
|
void callx5_again(void);
|
|
|
|
void x6()
|
|
{
|
|
printf(" x6-1");
|
|
}
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
printf("*");
|
|
asm("call "_"x1");
|
|
asm("call "_"x2");
|
|
asm("call "_"x3");
|
|
callx4();
|
|
asm("call "_"x5");
|
|
callx5_again();
|
|
x6();
|
|
printf(" *\n");
|
|
return 0;
|
|
}
|
|
|
|
static
|
|
int __USED x2(void)
|
|
{
|
|
printf(" x2");
|
|
return 2;
|
|
}
|
|
|
|
extern int x3(void);
|
|
|
|
void x4(void)
|
|
{
|
|
printf(" x4");
|
|
}
|
|
|
|
void x5(void);
|
|
void x5(void)
|
|
{
|
|
printf(" x5");
|
|
}
|