summaryrefslogtreecommitdiff
path: root/tests/src/JIT/jit64/mcc/interop/native_i0c.cpp
blob: 9c4c966f729b7eea19da10412f1745d532dc2d89 (plain)
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
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#include <stdarg.h>
#include "native.h"


MCC_API VType0 __cdecl sum(unsigned __int64 first, ...) {
    VType0 result;

    unsigned int count = 0;
    unsigned __int64 sum = 0;
    unsigned __int64 val = first;
    va_list args;

    // initialize variable arguments.
    va_start(args, first);
    while (val != (unsigned __int64)-1) {
        sum += val;
        count++;
        val = va_arg(args, unsigned __int64);
    }
    // reset variable arguments.
    va_end(args);

    result.sum = sum;
    result.count = count;
    result.average = (double)sum / count;
    result.dummy1 = result.sum;
    result.dummy2 = result.average;

    return result;
}