modified: SpatialOmicsCoord.py
[GalaxyCodeBases.git] / c_cpp / etc / calc / align32.c
blob3031aee21eaf7430c96612bc782b08aca4fc5a8b
1 /*
2 * align32 - determine if 32 bit accesses must be aligned
4 * Copyright (C) 1999 Landon Curt Noll
6 * Calc is open software; you can redistribute it and/or modify it under
7 * the terms of the version 2.1 of the GNU Lesser General Public License
8 * as published by the Free Software Foundation.
10 * Calc is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
13 * Public License for more details.
15 * A copy of version 2.1 of the GNU Lesser General Public License is
16 * distributed with calc under the filename COPYING-LGPL. You should have
17 * received a copy with calc; if not, write to Free Software Foundation, Inc.
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * @(#) $Revision: 30.1 $
21 * @(#) $Id: align32.c,v 30.1 2007/03/16 11:09:46 chongo Exp $
22 * @(#) $Source: /usr/local/src/bin/calc/RCS/align32.c,v $
24 * Under source code control: 1995/11/23 05:18:06
25 * File existed as early as: 1995
27 * chongo <was here> /\oo/\ http://www.isthe.com/chongo/
28 * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
32 #include <stdio.h>
33 #include <signal.h>
34 #include "longbits.h"
36 #include "have_unistd.h"
37 #if defined(HAVE_UNISTD_H)
38 #include <unistd.h>
39 #endif
41 static void buserr(void); /* catch alignment errors */
44 int
45 main(void)
47 char byte[2*sizeof(USB32)]; /* mis-alignment buffer */
48 USB32 *p; /* mis-alignment pointer */
49 int i;
51 #if defined(MUST_ALIGN32)
52 /* force alignment */
53 printf("#define MUST_ALIGN32\t%c* forced to align 32 bit values *%c\n",
54 '/', '/');
55 #else
56 /* setup to catch alignment bus errors */
57 signal(SIGBUS, buserr);
58 signal(SIGSEGV, buserr); /* some systems will generate SEGV instead! */
60 /* mis-align our long fetches */
61 for (i=0; i < sizeof(USB32); ++i) {
62 p = (USB32 *)(byte+i);
63 *p = i;
64 *p += 1;
67 /* if we got here, then we can mis-align longs */
68 printf("#undef MUST_ALIGN32\t%c* can mis-align 32 bit values *%c\n",
69 '/', '/');
71 #endif
72 /* exit(0); */
73 return 0;
78 * buserr - catch an alignment error
80 * given:
81 * arg to keep ANSI C happy
83 /*ARGSUSED*/
84 static void
85 buserr(int arg)
87 /* alignment is required */
88 printf("#define MUST_ALIGN32\t%c* must align 32 bit values *%c\n",
89 '/', '/');
90 exit(0);