modified: SpatialOmicsCoord.py
[GalaxyCodeBases.git] / c_cpp / etc / md5_sha / must_align.c
blobe7fb3c42caadb07a904d687c04f8d35cc5fa4048
1 /*
2 * must_align - determine if longs must be aligned
4 * @(#) $Revision: 13.1 $
5 * @(#) $Id: must_align.c,v 13.1 2006/08/14 03:16:33 chongo Exp $
6 * @(#) $Source: /usr/local/src/cmd/hash/RCS/must_align.c,v $
8 * This file was written by Landon Curt Noll.
10 * This code has been placed in the public domain. Please do not
11 * copyright this code.
13 * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO
14 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER-
15 * CHANTABILITY AND FITNESS. IN NO EVENT SHALL LANDON CURT
16 * NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
17 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
18 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
19 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 * chongo (was here) /\oo/\
23 * http://www.isthe.com/chongo/index.html
25 * Share and enjoy! :-)
28 #include <stdio.h>
29 #include <signal.h>
30 #include <stdlib.h>
32 void buserr(int); /* catch alignment errors */
34 /*ARGSUSED*/
35 int
36 main(int argc, char *argv[])
38 char byte[2*sizeof(unsigned long)]; /* mis-alignment buffer */
39 unsigned long *p; /* mis-alignment pointer */
40 int i;
42 /* usage */
43 if (argc != 1) {
44 fprintf(stderr, "usage: %s\n", argv[0]);
45 exit(1);
48 #if !defined(MUST_ALIGN)
49 /* setup to catch alignment bus errors */
50 signal(SIGBUS, buserr);
51 signal(SIGSEGV, buserr); /* some systems will generate SEGV instead! */
53 /* mis-align our long fetches */
54 for (i=0; i < sizeof(long); ++i) {
55 p = (unsigned long *)(byte+i);
56 *((volatile unsigned long *) p) = i;
57 *((volatile unsigned long *) p) += 1;
60 /* if we got here, then we can mis-align longs */
61 printf("#undef MUST_ALIGN\n");
63 #else
64 /* force alignment */
65 printf("#define MUST_ALIGN\n");
66 #endif
67 exit(0);
72 * buserr - catch an alignment error
74 /*ARGSUSED*/
75 void
76 buserr(int sig)
78 /* alignment is required */
79 printf("#define MUST_ALIGN\n");
80 exit(0);