File: longdouble.c

package info (click to toggle)
libffi-platypus-perl 2.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,860 kB
  • sloc: perl: 7,388; ansic: 6,862; cpp: 53; sh: 19; makefile: 14
file content (37 lines) | stat: -rw-r--r-- 691 bytes parent folder | download | duplicates (4)
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
#include "ffi_platypus.h"

long double
my_long_double(long double a, long double b)
{
  if(a != 1.0L || b != 3.0L)
    exit(2);
  return a+b;
}

int
dlmain(int argc, char *argv[])
{
  ffi_cif cif;
  ffi_type *args[2];
  void *values[2];

  if(&ffi_type_longdouble == &ffi_type_double)
    return 2;

  args[0] = &ffi_type_longdouble;
  args[1] = &ffi_type_longdouble;

  if(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &ffi_type_longdouble, args) == FFI_OK)
  {
    long double answer;
    long double a = 1.0L;
    long double b = 3.0L;
    values[0] = &a;
    values[1] = &b;
    ffi_call(&cif, (void*) my_long_double, &answer, values);
    if(answer == 4.0L)
      return 0;
  }

  return 2;
}