source: trunk/third/gstreamer/testsuite/elements/struct_size.c @ 21005

Revision 21005, 1.4 KB checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r21004, which included commits to RCS files with non-trunk default branches.
Line 
1
2#ifdef HAVE_CONFIG_H
3#include "config.h"
4#endif
5
6#include <gst/gst.h>
7#include <gst/gstqueue.h>
8#include <gst/gsttrashstack.h>
9#include <stdlib.h>
10
11typedef struct
12{
13  char *name;
14  int size;
15  int abi_size;
16}
17Struct;
18
19#ifdef HAVE_CPU_I386
20#include "struct_i386.h"
21#define HAVE_ABI_SIZES
22#else
23/* in case someone wants to generate a new arch */
24#include "struct_i386.h"
25#endif
26
27int
28main (int argc, char *argv[])
29{
30  int i;
31
32  if (argc > 1) {
33    g_print ("/* Generated by GStreamer-%s */\n", GST_VERSION);
34    g_print ("Struct list[] = {\n");
35    for (i = 0; list[i].name; i++) {
36      g_print ("  { \"%s\", sizeof (%s), %d },\n",
37          list[i].name, list[i].name, list[i].size);
38    }
39    g_print ("  { NULL, 0, 0}\n");
40    g_print ("};\n");
41  } else {
42    g_print ("Run './struct_size regen' to regenerate structs.h\n");
43
44#ifdef HAVE_ABI_SIZES
45    {
46      gboolean ok = TRUE;
47
48      for (i = 0; list[i].name; i++) {
49        if (list[i].size != list[i].abi_size) {
50          ok = FALSE;
51          g_print ("sizeof(%s) is %d, expected %d\n",
52              list[i].name, list[i].size, list[i].abi_size);
53        }
54      }
55      if (ok) {
56        g_print ("All structures expected size\n");
57      } else {
58        g_print ("failed\n");
59        exit (1);
60      }
61    }
62#else
63    g_print ("No structure size list was generated for this architecture\n");
64    g_print ("ignoring\n");
65#endif
66  }
67
68  exit (0);
69}
Note: See TracBrowser for help on using the repository browser.