File: config.align.c

package info (click to toggle)
gnustep-base 1.26.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 27,260 kB
  • sloc: objc: 204,878; ansic: 32,160; sh: 157; makefile: 128; cpp: 122; xml: 32
file content (44 lines) | stat: -rw-r--r-- 738 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* This program will most likely crash on systems that need shorts and ints
   to be word aligned
  Copyright (C) 2005 Free Software Foundation

  Copying and distribution of this file, with or without modification,
  are permitted in any medium without royalty provided the copyright
  notice and this notice are preserved.

*/
#include <stdlib.h>

int main ()
{
  char  *buf = malloc(30);
  void  *v;
  short *sp;
  short *sq;
  int   *ip;
  int   *iq;
  int   i;

  for (i = 0 ; i < 30; i++)
    {
      buf[i] = i;
    }
  v = buf;

  sp = (short*)(v + 1);
  sq = (short*)(v + 2);
  if (*sp == *sq)
    {
      return 1;
    }

  ip = (int*)(v + 1);
  iq = (int*)(v + 2);
  if (*ip == *iq)
    {
      return 1;
    }

  return 0;
}