/*
 * testalignptrs.in - figure out our minimum pointer alignment
 *
 * This file is automatically generated by Configure
 * from config/auto/alignptrs/test_c.in.
 */

#include <stdio.h>
#include <sys/types.h>
#include <signal.h>
/* Try to catch bus errors */
#ifdef SIGBUS
#include <stdlib.h>
void bletch(int s) { exit(1); }
#endif

int main(int argc, char **argv) {

    int i;
    char *c;

    long space[32];
    void **ptr;
    
    int align = 0;

    if(argc != 2) {
        printf("FAILED - single command-line parameter required!\n");
	return 1;
    }

#ifdef SIGBUS
    signal(SIGBUS, bletch);
#endif

    for (i = 0; i < 32; i ++) space[i] = 0;

    for (c = argv[1]; *c; c++) align = align * 10 + ((int)*c - '0');
    
#if defined(__alpha)
    if (align < 8) {
        printf("Soft failure hack for systems that simulate unaligned access\n");
        return 1;
    }
#endif
    
    ptr = (void **)((char *)space + align);
    
    if (*ptr == (void *)0)
        printf("%d OK\n", align);
    else
        printf("%d OK but didnt equal zero\n", align);

    return 0;
}
