Sha256: 18afb5d02f135897cfb71e974c57285b272dcfb136227cb79b92c97888c14a09

Contents?: true

Size: 1.42 KB

Versions: 13

Compression:

Stored size: 1.42 KB

Contents

/*
 * Copyright (c) 2007 Wayne Meissner. All rights reserved.
 * 
 * All rights reserved.
 *
 * This file is part of ruby-ffi.
 *
 * This code is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License version 3 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
 * version 3 for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with this work.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <stdio.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>

typedef char s8;
typedef short s16;
typedef int s32;
typedef long long s64;
typedef float f32;
typedef double f64;

typedef union union_test {
    char b;
    short s;
    int i;
    long long j;
    long l;
    float f;
    double d;
    s8 a[10];
} union_test_t;

#define T(x, type) \
  type union_align_##type(union_test_t* u) { return u->x; } \
  union_test_t* union_make_union_with_##type(type value) { static union_test_t u; u.x = value; return &u; }

T(b, s8);
T(s, s16);
T(i, s32);
T(j, s64);
T(f, f32);
T(d, f64);
T(l, long);

unsigned int union_size() { return sizeof(union_test_t); }

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/ffi-1.2.0/libtest/UnionTest.c
ffi-1.2.1-x86-mingw32 libtest/UnionTest.c
ffi-1.2.1 libtest/UnionTest.c
ffi-1.2.0-x86-mingw32 libtest/UnionTest.c
ffi-1.2.0 libtest/UnionTest.c
ffi-1.2.0.pre6-x86-mingw32 libtest/UnionTest.c
ffi-1.2.0.pre6 libtest/UnionTest.c
ffi-1.2.0.pre5 libtest/UnionTest.c
ffi-1.2.0.pre4 libtest/UnionTest.c
ffi-1.2.0.pre3-x86-mingw32 libtest/UnionTest.c
ffi-1.2.0.pre3 libtest/UnionTest.c
ffi-1.2.0.pre2-x86-mingw32 libtest/UnionTest.c
ffi-1.2.0.pre2 libtest/UnionTest.c