Affix

 view release on metacpan or  search on metacpan

dyncall/test/call_suite_aggrs/globals.c  view on Meta::CPAN

#undef X

/* intentional misalignment of test aggregates (use only positive numbers);
 * crashes/exceptions (e.g. sigbus on some platforms) when using values > 0
 * might reveal missing aggr-by-val copies in the implementation */
#define AGGR_MISALIGN 1 /* @@@AGGR make configurable */

static double rand_d()      { return ( ( (double) rand() )  / ( (double) RAND_MAX ) ); }

/* fill mem with random values, make sure no float aligned memory location
 * results in a NaN, as they always compare to false; so avaid all ones in
 * exporent (for simplicity we just look at first 7 exponent bits and make sure
 * they aren't all set, which would work for all IEEE754 precision formats) */
static void rand_mem__fp_friendly(void* p, size_t s)
{
  int i;
  for(i = 0; i<s; ++i) {
    char* c = (char*)p;
    c[i] = (char)rand(); /* slowish, byte by byte, but whatev */
    if((c[i]&0x7f) == 0x7f)
      c[i] ^= 1;

dyncall/test/callback_suite_aggrs/globals.c  view on Meta::CPAN

#undef X

/* intentional misalignment of test aggregates (use only positive numbers);
 * crashes/exceptions (e.g. sigbus on some platforms) when using values > 0
 * might reveal missing aggr-by-val copies in the implementation */
#define AGGR_MISALIGN 1 /* @@@AGGR make configurable */

static double rand_d()      { return ( ( (double) rand() )  / ( (double) RAND_MAX ) ); }

/* fill mem with random values, make sure no float aligned memory location
 * results in a NaN, as they always compare to false; so avaid all ones in
 * exporent (for simplicity we just look at first 7 exponent bits and make sure
 * they aren't all set, which would work for all IEEE754 precision formats) */
static void rand_mem__fp_friendly(void* p, size_t s)
{
  int i;
  for(i = 0; i<s; ++i) {
    char* c = (char*)p;
    c[i] = (char)rand(); /* slowish, byte by byte, but whatev */
    if((c[i]&0x7f) == 0x7f)
      c[i] ^= 1;

t/42_affix_simple_args.t  view on Meta::CPAN

sub TakeTwoShorts : Native('t/src/42_simple_args') : Signature([Short, Short] => Long);
sub AssortedIntArgs : Native('t/src/42_simple_args') : Signature([Long, Short, Char]=>Long);
#
is TakeInt(42),                          1, 'passed int 42';
is TakeUInt(42),                         1, 'passed int 42';
is TakeTwoShorts( 10, 20 ),              2, 'passed two shorts';
is AssortedIntArgs( 101, 102, chr 103 ), 3, 'passed an int32, int16 and int8';

# Float related
sub TakeADouble : Native('t/src/42_simple_args') : Signature([Double]=>Int);
sub TakeADoubleNaN : Native('t/src/42_simple_args') : Signature([Double]=>Int);
sub TakeAFloat : Native('t/src/42_simple_args') : Signature([Float]=>Int);
sub TakeAFloatNaN : Native('t/src/42_simple_args') : Signature([Float]=>Int);
is TakeADouble(-6.9e0),   4, 'passed a double';
is TakeADoubleNaN('NaN'), 4, 'passed a NaN (double)';
is TakeAFloat(4.2e0),     5, 'passed a float';
is TakeAFloatNaN('NaN'),  5, 'passed a NaN (float)';

# String related
sub TakeAString : Native('t/src/42_simple_args') : Signature([Str]=>Int);
is TakeAString('ok 6 - passed a string'), 6, 'passed a string';

# Explicitly managing strings
sub SetString : Native('t/src/42_simple_args') : Signature([Str]=>Int);
sub CheckString : Native('t/src/42_simple_args') : Signature([]=>Int);
my $str = 'ok 7 - checked previously passed string';

t/src/42_simple_args.c  view on Meta::CPAN

DLLEXPORT long AssortedIntArgs(long x, short y, char z) {
    if (x == 101 && y == 102 && z == 103) return 3;
    return 0;
}

DLLEXPORT int TakeADouble(double x) {
    if (-6.9 - x < 0.001) return 4;
    return 0;
}

DLLEXPORT int TakeADoubleNaN(double x) {
    if (isnan(x)) return 4;
    return 0;
}

DLLEXPORT int TakeAFloat(float x) {
    if (4.2 - x < 0.001) return 5;
    return 0;
}

DLLEXPORT int TakeAFloatNaN(float x) {
    if (isnan(x)) return 5;
    return 0;
}

DLLEXPORT int TakeAString(char *pass_msg) {
    if (0 == strcmp(pass_msg, "ok 6 - passed a string")) return 6;
    return 0;
}

static char *cached_str = NULL;

t/src/44_affix_aggr_args.c  view on Meta::CPAN

  return sizeof(x);*/
    if (x.x == 101 && x.y == 102 && x.z == 103) return 3;
    return 0;
}

DLLEXPORT int TakeADouble(double x) {
    if (-6.9 - x < 0.001) return 4;
    return 0;
}

DLLEXPORT int TakeADoubleNaN(double x) {
    if (isnan(x)) return 4;
    return 0;
}

DLLEXPORT int TakeAFloat(float x) {
    if (4.2 - x < 0.001) return 5;
    return 0;
}

DLLEXPORT int TakeAFloatNaN(float x) {
    if (isnan(x)) return 5;
    return 0;
}

DLLEXPORT int TakeAString(char *pass_msg) {
    if (0 == strcmp(pass_msg, "ok 6 - passed a string")) return 6;
    return 0;
}

static char *cached_str = NULL;

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 5.855 seconds using v1.00-cache-2.02-grep-82fe00e-cpan-72ae3ad1e6da )