spinn_common 7.3.1
Support code for SpiNNaker applications.
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions
pair.h File Reference

It is sometimes useful to return two values from a function. By exploiting the EABI for 64-bit integer values, we can efficiently return two 32-bit values, in ‘C’. More...

#include "stdint.h"

Go to the source code of this file.

Data Structures

union  pair_union_t
 The implementation of a pair. More...
 
struct  pair_union_t.__unnamed1__
 

Macros

#define pair(x, y)   __pair((void*)(x), (void*)(y))
 Create a pair, with automatic casting.
 

Typedefs

typedef uint64_t pair_t
 Give a useful name to the return type, indicating it's use.
 

Functions

static pair_t __pair (void *x, void *y)
 Create a pair from two generic 32-bit objects.
 
static void * fst (pair_t p)
 Return the first component of a pair.
 
static void * snd (pair_t p)
 Return the second component of a pair.
 

Detailed Description

It is sometimes useful to return two values from a function. By exploiting the EABI for 64-bit integer values, we can efficiently return two 32-bit values, in ‘C’.

The returned values are in r0, and r1 respectively. This obviates the need to use pointers to return pairs of values.

Author
Dave Lester (david.nosp@m..r.l.nosp@m.ester.nosp@m.@man.nosp@m.chest.nosp@m.er.a.nosp@m.c.uk)
Date
27 April, 2014

Data Structure Documentation

◆ pair_union_t

union pair_union_t

The implementation of a pair.

Data Fields
pair_t pair The paired value.
struct pair_union_t.__unnamed1__ __unnamed__

◆ pair_union_t.__unnamed1__

struct pair_union_t.__unnamed1__
Data Fields
void * lo Low word of the pair.
void * hi High word of the pair.

Function Documentation

◆ __pair()

static pair_t __pair ( void *  x,
void *  y 
)
inlinestatic

Create a pair from two generic 32-bit objects.

Parameters
[in]xis a void* object
[in]yis a void* object
Returns
A pair of values as a 64-bit unsigned int (pair_t).

◆ fst()

static void * fst ( pair_t  p)
inlinestatic

Return the first component of a pair.

Parameters
[in]pis a pair_t object
Returns
The first component: n.b. this is void*, so will need casting.

◆ snd()

static void * snd ( pair_t  p)
inlinestatic

Return the second component of a pair.

Parameters
[in]pis a pair_t object
Returns
The second component: n.b. this is void*, so will need casting.