C-sparse

 view release on metacpan or  search on metacpan

src/sparse-0.4.4/lib.c  view on Meta::CPAN

	 * Ignore unknown command line options:
	 * they're probably gcc switches
	 */
	return next;
}

void declare_builtin_functions(SCTX)
{
	/* Gaah. gcc knows tons of builtin <string.h> functions */
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern void *__builtin_memcpy(void *, const void *, __SIZE_TYPE__);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern void *__builtin_mempcpy(void *, const void *, __SIZE_TYPE__);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern void *__builtin_memset(void *, int, __SIZE_TYPE__);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern int __builtin_memcmp(const void *, const void *, __SIZE_TYPE__);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern char *__builtin_strcat(char *, const char *);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern char *__builtin_strncat(char *, const char *, __SIZE_TYPE__);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern int __builtin_strcmp(const char *, const char *);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern char *__builtin_strchr(const char *, int);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern char *__builtin_strcpy(char *, const char *);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern char *__builtin_strncpy(char *, const char *, __SIZE_TYPE__);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern __SIZE_TYPE__ __builtin_strspn(const char *, const char *);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern __SIZE_TYPE__ __builtin_strcspn(const char *, const char *);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern char * __builtin_strpbrk(const char *, const char *);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern char* __builtin_stpcpy(const char *, const char*);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern __SIZE_TYPE__ __builtin_strlen(const char *);\n");

	/* And bitwise operations.. */
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern int __builtin_clz(int);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern int __builtin_clzl(long);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern int __builtin_clzll(long long);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern int __builtin_ctz(int);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern int __builtin_ctzl(long);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern int __builtin_ctzll(long long);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern int __builtin_ffs(int);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern int __builtin_ffsl(long);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern int __builtin_ffsll(long long);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern int __builtin_popcount(unsigned int);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern int __builtin_popcountl(unsigned long);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern int __builtin_popcountll(unsigned long long);\n");

	/* And byte swaps.. */
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern unsigned short __builtin_bswap16(unsigned short);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern unsigned int __builtin_bswap32(unsigned int);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern unsigned long long __builtin_bswap64(unsigned long long);\n");

	/* And some random ones.. */
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern void *__builtin_return_address(unsigned int);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern void *__builtin_extract_return_addr(void *);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern void *__builtin_frame_address(unsigned int);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern void __builtin_trap(void);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern void *__builtin_alloca(__SIZE_TYPE__);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern void __builtin_prefetch (const void *, ...);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern long __builtin_alpha_extbl(long, long);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern long __builtin_alpha_extwl(long, long);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern long __builtin_alpha_insbl(long, long);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern long __builtin_alpha_inswl(long, long);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern long __builtin_alpha_insql(long, long);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern long __builtin_alpha_inslh(long, long);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern long __builtin_alpha_cmpbge(long, long);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern long __builtin_labs(long);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern double __builtin_fabs(double);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern void __sync_synchronize();\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern int __sync_bool_compare_and_swap(void *, ...);\n");

	/* Add Blackfin-specific stuff */
	add_pre_buffer(sctx_ sctxp stream_sb->id, 
		"#ifdef __bfin__\n"
		"extern void __builtin_bfin_csync(void);\n"
		"extern void __builtin_bfin_ssync(void);\n"
		"extern int __builtin_bfin_norm_fr1x32(int);\n"
		"#endif\n"
	);

	/* And some floating point stuff.. */
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern int __builtin_isgreater(float, float);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern int __builtin_isgreaterequal(float, float);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern int __builtin_isless(float, float);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern int __builtin_islessequal(float, float);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern int __builtin_islessgreater(float, float);\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "extern int __builtin_isunordered(float, float);\n");

	/* And some __FORTIFY_SOURCE ones.. */
	add_pre_buffer (sctx_ sctxp stream_sb->id, "extern __SIZE_TYPE__ __builtin_object_size(void *, int);\n");
	add_pre_buffer (sctx_ sctxp stream_sb->id, "extern void * __builtin___memcpy_chk(void *, const void *, __SIZE_TYPE__, __SIZE_TYPE__);\n");
	add_pre_buffer (sctx_ sctxp stream_sb->id, "extern void * __builtin___memmove_chk(void *, const void *, __SIZE_TYPE__, __SIZE_TYPE__);\n");
	add_pre_buffer (sctx_ sctxp stream_sb->id, "extern void * __builtin___mempcpy_chk(void *, const void *, __SIZE_TYPE__, __SIZE_TYPE__);\n");
	add_pre_buffer (sctx_ sctxp stream_sb->id, "extern void * __builtin___memset_chk(void *, int, __SIZE_TYPE__, __SIZE_TYPE__);\n");
	add_pre_buffer (sctx_ sctxp stream_sb->id, "extern int __builtin___sprintf_chk(char *, int, __SIZE_TYPE__, const char *, ...);\n");
	add_pre_buffer (sctx_ sctxp stream_sb->id, "extern int __builtin___snprintf_chk(char *, __SIZE_TYPE__, int , __SIZE_TYPE__, const char *, ...);\n");
	add_pre_buffer (sctx_ sctxp stream_sb->id, "extern char * __builtin___stpcpy_chk(char *, const char *, __SIZE_TYPE__);\n");
	add_pre_buffer (sctx_ sctxp stream_sb->id, "extern char * __builtin___strcat_chk(char *, const char *, __SIZE_TYPE__);\n");
	add_pre_buffer (sctx_ sctxp stream_sb->id, "extern char * __builtin___strcpy_chk(char *, const char *, __SIZE_TYPE__);\n");
	add_pre_buffer (sctx_ sctxp stream_sb->id, "extern char * __builtin___strncat_chk(char *, const char *, __SIZE_TYPE__, __SIZE_TYPE__);\n");
	add_pre_buffer (sctx_ sctxp stream_sb->id, "extern char * __builtin___strncpy_chk(char *, const char *, __SIZE_TYPE__, __SIZE_TYPE__);\n");
	add_pre_buffer (sctx_ sctxp stream_sb->id, "extern int __builtin___vsprintf_chk(char *, int, __SIZE_TYPE__, const char *, __builtin_va_list);\n");
	add_pre_buffer (sctx_ sctxp stream_sb->id, "extern int __builtin___vsnprintf_chk(char *, __SIZE_TYPE__, int, __SIZE_TYPE__, const char *, __builtin_va_list ap);\n");
	add_pre_buffer (sctx_ sctxp stream_sb->id, "extern void __builtin_unreachable(void);\n");
}

void create_builtin_stream(SCTX)
{
	add_pre_buffer(sctx_ sctxp stream_sb->id, "#weak_define __GNUC__ %d\n", sctxp gcc_major);
	add_pre_buffer(sctx_ sctxp stream_sb->id, "#weak_define __GNUC_MINOR__ %d\n", sctxp gcc_minor);
	add_pre_buffer(sctx_ sctxp stream_sb->id, "#weak_define __GNUC_PATCHLEVEL__ %d\n", sctxp gcc_patchlevel);

	/* We add compiler headers path here because we have to parse
	 * the arguments to get it, falling back to default. */
	add_pre_buffer(sctx_ sctxp stream_sb->id, "#add_system \"%s/include\"\n", sctxp gcc_base_dir);
	add_pre_buffer(sctx_ sctxp stream_sb->id, "#add_system \"%s/include-fixed\"\n", sctxp gcc_base_dir);

	add_pre_buffer(sctx_ sctxp stream_sb->id, "#define __extension__\n");
	add_pre_buffer(sctx_ sctxp stream_sb->id, "#define __pragma__\n");

	// gcc defines __SIZE_TYPE__ to be size_t.  For linux/i86 and
	// solaris/sparc that is really "unsigned int" and for linux/x86_64
	// it is "long unsigned int".  In either case we can probably
	// get away with this.  We need the #weak_define as cgcc will define
	// the right __SIZE_TYPE__.
	if (sctxp size_t_ctype == &sctxp ulong_ctype)
		add_pre_buffer(sctx_ sctxp stream_sb->id, "#weak_define __SIZE_TYPE__ long unsigned int\n");
	else
		add_pre_buffer(sctx_ sctxp stream_sb->id, "#weak_define __SIZE_TYPE__ unsigned int\n");



( run in 1.304 second using v1.01-cache-2.11-cpan-39bf76dae61 )