This file is indexed.

/usr/share/frama-c/machdep.c is in frama-c-base 20151002+magnesium+dfsg-1build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
/****************************************************************************/
/*                                                                          */
/*  Copyright (C) 2001-2003                                                 */
/*   George C. Necula    <necula@cs.berkeley.edu>                           */
/*   Scott McPeak        <smcpeak@cs.berkeley.edu>                          */
/*   Wes Weimer          <weimer@cs.berkeley.edu>                           */
/*   Ben Liblit          <liblit@cs.berkeley.edu>                           */
/*  All rights reserved.                                                    */
/*                                                                          */
/*  Redistribution and use in source and binary forms, with or without      */
/*  modification, are permitted provided that the following conditions      */
/*  are met:                                                                */
/*                                                                          */
/*  1. Redistributions of source code must retain the above copyright       */
/*  notice, this list of conditions and the following disclaimer.           */
/*                                                                          */
/*  2. Redistributions in binary form must reproduce the above copyright    */
/*  notice, this list of conditions and the following disclaimer in the     */
/*  documentation and/or other materials provided with the distribution.    */
/*                                                                          */
/*  3. The names of the contributors may not be used to endorse or          */
/*  promote products derived from this software without specific prior      */
/*  written permission.                                                     */
/*                                                                          */
/*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS     */
/*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT       */
/*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS       */
/*  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE          */
/*  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,     */
/*  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,    */
/*  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;        */
/*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER        */
/*  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT      */
/*  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN       */
/*  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         */
/*  POSSIBILITY OF SUCH DAMAGE.                                             */
/*                                                                          */
/*  File modified by CEA (Commissariat à l'énergie atomique et aux          */
/*                        énergies alternatives)                            */
/*               and INRIA (Institut National de Recherche en Informatique  */
/*                          et Automatique).                                */
/****************************************************************************/

#include "../config.h"
#include <stdio.h>

#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif

#ifdef HAVE_WCHAR_H
#include <wchar.h>
#endif

#define COMPILER "other"

#ifdef __TURBOC__
#define LONGLONG long long
#define CONST_STRING_LITERALS "false"
#define VERSION __TURBOC__
#define VERSION_MAJOR 0
#define VERSION_MINOR 0
#endif

#ifdef __GNUC__
#define LONGLONG long long
#define CONST_STRING_LITERALS "true"
#define VERSION __VERSION__
#define VERSION_MAJOR __GNUC__
#define VERSION_MINOR __GNUC_MINOR__
#undef COMPILER
#define COMPILER "gcc"
#endif

#ifdef _MSVC
#define LONGLONG __int64
#define CONST_STRING_LITERALS "false"
#define VERSION "Microsoft C"
#define VERSION_MAJOR (_MSC_VER / 100)
#define VERSION_MINOR (_MSC_VER % 100)
#undef COMPILER
#define COMPILER "msvc"
#endif

#ifndef __TURBOC__
#ifndef __GNUC__
#ifndef _MSVC
#error "Please define one of __TURBOC__ __GNUC__ _MSVC."
#endif
#endif
#endif

/* The type for the machine dependency structure is generated from the
   Makefile */
int main() {
  fprintf(stderr, "Generating machine dependency information for CIL\n");

  printf("(* Generated by code in %s *)\n", __FILE__);
  printf("open Cil_types\n");
  printf("let mach = {\n");
  //  printf("\t version_major    = %d;\n", VERSION_MAJOR);
  //  printf("\t version_minor    = %d;\n", VERSION_MINOR);
#ifdef __TURBOC__
  printf("\t version          = \"%d\";\n", VERSION);
#else
  printf("\t version          = \"%s\";\n", VERSION);
#endif
  // Size of certain types
  printf("\t sizeof_short     = %lu;\n", sizeof(short));
  printf("\t sizeof_int       = %lu;\n", sizeof(int));
  printf("\t sizeof_long      = %lu;\n", sizeof(long));
  printf("\t sizeof_longlong  = %lu;\n", sizeof(LONGLONG));
  printf("\t sizeof_ptr       = %lu;\n", sizeof(int *));
  printf("\t sizeof_float     = %lu;\n", sizeof(float));
  printf("\t sizeof_double    = %lu;\n", sizeof(double));
  printf("\t sizeof_longdouble  = %lu;\n", sizeof(long double));
  printf("\t sizeof_void      = %lu;\n",
#ifdef __TURBOC__
         0
#else
         sizeof(void)
#endif
);
  printf("\t sizeof_fun       = %lu;\n",
#ifdef __GNUC__
         sizeof(main)
#else
         0
#endif
           );
  // definition of size_t
  {
    printf("\t size_t = \"%s\";\n", TYPE_SIZE_T);
    printf("\t wchar_t = \"%s\";\n", TYPE_WCHAR_T);
    printf("\t ptrdiff_t = \"%s\";\n", TYPE_PTRDIFF_T);
  }

  // The alignment of a short
  {
    struct shortstruct {
      char c;
      short s;
    };
    printf("\t alignof_short = %z;\n",
           (size_t)(&((struct shortstruct*)0)->s));
  }

  // The alignment of an int
  {
    struct intstruct {
      char c;
      int i;
    };
    printf("\t alignof_int = %z;\n",
           (size_t)(&((struct intstruct*)0)->i));
  }
  
  // The alignment of a long
  {
    struct longstruct {
      char c;
      long l;
    };
    printf("\t alignof_long = %z;\n",
           (size_t)(&((struct longstruct*)0)->l));
  }

  // The alignment of long long
  {
    struct longlong {
      char c;
      LONGLONG ll;
    };
    printf("\t alignof_longlong = %z;\n",
           (size_t)(&((struct longlong*)0)->ll));
  }

  // The alignment of a ptr
  {
    struct ptrstruct {
      char c; 
      int * p;
    };
    printf("\t alignof_ptr = %z;\n",
           (size_t)(&((struct ptrstruct*)0)->p));
  }

  // Unnamed members
  {
    struct S0
    {
      int;
      // If you are reading this, it's probably because your C compiler
      // rejected the above. Good for you! It is not allowed by C99.
      // See discussion thread at:
      // http://lists.cs.uiuc.edu/pipermail/c-semantics/2011-August/thread.html
      // You can comment out this block.
      int f1;
    };
    if (sizeof(struct S0) != 2*sizeof(int))
      {
	printf("(* WARNING: This compiler handles unnamed struct members\n");
	printf("   differently from Frama-C.\n");
	printf("   To be analyzed correctly, your programs must *NOT* use\n");
	printf("   this language extension. *)\n");
      }
   }

  // long long bit-fields
  {
    struct LLS
    {
      long long int f:2;
      // If you are reading this, it's probably because your C compiler
      // rejected the above. Good for you! It is only allowed by C99
      // as an extension.
      // You can comment out this block.
    } lls;
    if (sizeof(1 + lls.f) != sizeof(int))
      {
	printf("(* WARNING: This compiler handles long long bit-fields\n");
	printf("   differently from Frama-C.\n");
	printf("   To be analyzed correctly, your programs must *NOT* use\n");
	printf("   this language extension. *)\n");
      }
   }

  // The alignment of a float
  {
    struct floatstruct {
      char c;
      float f;
    };
    printf("\t alignof_float = %z;\n",
           (size_t)(&((struct floatstruct*)0)->f));
  }
  
  // The alignment of double
  {
    struct s1 {
      char c;
      double d;
    };
    printf("\t alignof_double = %z;\n",
           (size_t)(&((struct s1*)0)->d));
  }    

  // The alignment of long  double
  {
    struct s1 {
      char c;
      long double ld;
    };
    printf("\t alignof_longdouble = %z;\n",
           (size_t)(&((struct s1*)0)->ld));
  }    

  printf("\t alignof_str = %lu;\n",
#ifdef __GNUC__
         __alignof("a string")
#else
         0
#endif
         );

  printf("\t alignof_fun = %lu;\n",
#ifdef __GNUC__
         __alignof(main)
#else
         0
#endif
         );

  // The alignment of char array
  {
    struct s1 {
      char c;
      char ca[2];
    };
    //    printf("\t alignof_char_array = %lu;\n",
    //           (int)(&((struct s1*)0)->ca));
  }

  /* The alignement of an __aligned__ type */
  {
#ifdef __TURBOC__
    printf("\t alignof_aligned = 8;\n");
#else
    char __attribute__((aligned)) c;
    long double  __attribute__((aligned)) ld;
    if (__alignof(c) != __alignof(ld)) {
      printf("(*__attribute__((aligned)) has a different effect \
              on different types.  alignments may be computed \
              incorrectly.*)\n");
      };
    printf("\t alignof_aligned = %lu;\n",__alignof(c));
#endif
    }


   // Whether char is unsigned
  printf("\t char_is_unsigned = %s;\n", 
         ((char)0xff) > 0 ? "true" : "false");

  // Whether int bit-field is unsigned
  { 
    union { 
      signed int init ;
      struct { 
	int width8 : 8; 
      } sign ;
    } bitfield;

    bitfield.init=-1;
    printf("\t (* int_bitfield_is_unsigned = %s; *)\n", 
	   (bitfield.sign.width8 > 0 ? "true" : "false"));
    if (bitfield.sign.width8 > 0) {
      // 'int width8 : 8' is an unsigned bit-field.
      printf("(* WARNING: This compiler handles int bit-fields\n");
      printf("   differently from Frama-C.\n");
      printf("   To be analyzed correctly, your programs must *NOT* use\n");
      printf("   'int' bit-fields, but 'unsigned int' bit-fields. *)\n");
    }
  }

  // Whether string literals contain constant characters
  puts("\t const_string_literals = " CONST_STRING_LITERALS ";");

  // endianity
  {
    int e = 0x11223344;
    printf("\t little_endian = %s;\n",
           (0x44 == *(char*)&e) ? "true" :
           ((0x11 == *(char*)&e) ? "false" : (exit(1), "false")));
  }

  // __builtin_val_list
  {
#ifdef HAVE_BUILTIN_VA_LIST
    printf("\t has__builtin_va_list = true;\n");
#else
    printf("\t has__builtin_va_list = false;\n");
#endif
  }

  // __thread_is_keyword
  {
#ifdef THREAD_IS_KEYWORD
    printf("\t __thread_is_keyword = true;\n");
#else
    printf("\t __thread_is_keyword = false;\n");
#endif
  }

  // underscore_name
  {
#ifdef UNDERSCORE_NAME
    printf("\t underscore_name = true;\n");
#else
    printf("\t underscore_name = false;\n");
#endif
  }

  // compiler
  {
    printf("\t compiler = \"" COMPILER "\"");
  }


  printf("}\n");

  exit(0);
}