Subversion Repositories shark

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
/*
2
 code "borrowed" from JPEG-5 config code
3
*/
4
 
5
#include <stdio.h>
6
 
7
int is_shifting_signed (arg)
8
     long arg;
9
/* See whether right-shift on a long is signed or not. */
10
{
11
  long res = arg >> 4;
12
 
13
  if (res == -0x7F7E80CL) {     /* expected result for signed shift */
14
    return 1;                   /* right shift is signed */
15
  }
16
 
17
  /* see if unsigned-shift hack will fix it. */
18
  /* we can't just test exact value since it depends on width of long... */
19
  res |= (~0L) << (32-4);
20
 
21
  if (res == -0x7F7E80CL) {     /* expected result now? */
22
    return 0;                   /* right shift is unsigned */
23
  }
24
 
25
  fprintf(stderr, "Right shift isn't acting as I expect it to.\n");
26
  fprintf(stderr, "I fear the DCT software will not work at all.\n\n");
27
  exit(1);
28
}
29
 
30
main()
31
{
32
 
33
  if (is_shifting_signed(-0x7F7E80B1L)) {
34
    printf("do not define RIGHT_SHIFT_IS_UNSIGNED\n");
35
  }
36
  else {
37
    printf("define RIGHT_SHIFT_IS_UNSIGNED\n");
38
  }
39
 
40
}