/* feature.h - arch specific defines resulting from some tests */


#ifndef PARROT_FEATURE_H_GUARD
#define PARROT_FEATURE_H_GUARD

#perl - all below here gets evaled by perl, OUT is the filehandle

print OUT <<'END_PRINT';

/* from config/auto/memalign */
END_PRINT
if (@memalign@ eq 'posix_memalign') {
    print OUT <<'END_PRINT'
#define PARROT_HAS_POSIX_MEMALIGN
#define PARROT_HAS_SOME_MEMALIGN
END_PRINT
}
elsif (@memalign@ eq 'memalign') {
    print OUT <<'END_PRINT'
#define PARROT_HAS_MEMALIGN
#define PARROT_HAS_SOME_MEMALIGN
END_PRINT
}
elsif (@memalign@ eq 'some_memalign') {
    print OUT <<'END_PRINT'
#define PARROT_HAS_SOME_MEMALIGN
END_PRINT
}

print OUT <<'END_PRINT';

/* from config/auto/isreg */
END_PRINT
unless (@isreg@) {
    print OUT <<'END_PRINT';
#define PARROT_HAS_BROKEN_ISREG 1
END_PRINT
}

print OUT <<'END_PRINT';

/* from config/auto/jit */
END_PRINT
if ( @has_exec_protect@ )
{
    print OUT <<'END_PRINT';
#define PARROT_HAS_EXEC_PROTECT
END_PRINT
}
if (@jit_i386@ && @jit_i386@ eq 'fcomip') {
    print OUT <<'END_PRINT';
#ifdef I386
#  define PARROT_HAS_JIT_FCOMIP
#endif
END_PRINT
}

my $va_result = @va_ptr_type@;
print OUT <<"END_PRINT";

/* from config/auto/va_ptr.pm: va_ptr_type => $va_result */
END_PRINT
if (@va_ptr_type@ eq 'register') {
    print OUT <<'END_PRINT';
/* if defined __powerpc__ || defined __x86_64__ || defined __s390__ */
#  define PARROT_VA_TO_VAPTR(x) (x)
END_PRINT
}
if (@va_ptr_type@ eq 'stack') {
    print OUT <<'END_PRINT';
#  define PARROT_VA_TO_VAPTR(x) (&(x))
END_PRINT
}

print OUT <<'END_PRINT';

/* signal stuff from config/auto/signal */
END_PRINT

if (@has_sigaction@) {
    print OUT <<'END_PRINT';
#define PARROT_HAS_SIGACTION 1
END_PRINT
}
if (@has___sighandler_t@) {
    print OUT <<'END_PRINT';
#define PARROT_HAS___SIGHANDLER_T 1
END_PRINT
}
if (@has_setitimer@) {
    print OUT <<'END_PRINT';
#define PARROT_HAS_SETITIMER 1
#define PARROT_HAS_SOME_SYS_TIMER 1
END_PRINT
}

print OUT <<'END_PRINT';

/* from config/auto/env */
END_PRINT
if (@setenv@) {
    print OUT <<'END_PRINT';
#define PARROT_HAS_SETENV 1
END_PRINT
}
if (@unsetenv@) {
    print OUT <<'END_PRINT';
#define PARROT_HAS_UNSETENV 1
END_PRINT
}

print OUT <<'END_PRINT';

/* from config/auto/inline */
END_PRINT
if (@inline@ ne '') {
    my $inl = @inline@;
    print OUT <<"END_PRINT";
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#  define PARROT_INLINE inline
#  define PARROT_HAS_INLINE
#else
#  define PARROT_INLINE
#endif
END_PRINT
}
else {
    print OUT <<'END_PRINT';
#define PARROT_INLINE
END_PRINT
}

my $has_socklen_t = @has_socklen_t@;
    print OUT <<"END_PRINT";

/* from config/auto/socklen_t */
#define PARROT_HAS_SOCKLEN_T $has_socklen_t
END_PRINT

print OUT <<'END_PRINT';

/* from config/auto/backtrace */
END_PRINT
if (defined @backtrace@) {
    print OUT <<"END_PRINT";
#define PARROT_HAS_BACKTRACE
#include <execinfo.h>
/* __USE_GNU seems to mess up stdio.h on Linux; only define it for dlfcn.h if
it's not already defined */
#ifndef __USE_GNU
#  define __USE_GNU
#  include <dlfcn.h>
#  undef __USE_GNU
#else
#  include <dlfcn.h>
#endif
END_PRINT
}

print OUT <<'END_PRINT';

/* from config/auto/neg_0 */
END_PRINT
if (@has_negative_zero@) {
    print OUT <<'END_PRINT';
#define PARROT_HAS_NEGATIVE_ZERO 1
END_PRINT
}
else {
    print OUT <<'END_PRINT';
#undef PARROT_HAS_NEGATIVE_ZERO
END_PRINT
}

print OUT <<'END_PRINT';

#endif /* PARROT_FEATURE_H_GUARD */
END_PRINT

print OUT <<"END_PRINT";

/*
 * Local variables:
 *   c-file-style: "parrot"
 * End:
 * vim: expandtab shiftwidth=4:
 */
END_PRINT
