spinn_common 7.2.2
Support code for SpiNNaker applications.
Loading...
Searching...
No Matches
pair.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014 The University of Manchester
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
43#ifndef __PAIR_H__
44#define __PAIR_H__
45
46#include "stdint.h"
47
49typedef uint64_t pair_t;
50
52typedef union {
55 struct {
57 void *lo;
59 void *hi;
60 };
62
67static inline pair_t __pair(
68 void *x,
69 void *y)
70{
71 register pair_union_t tmp;
72
73 tmp.lo = x;
74 tmp.hi = y;
75 return tmp.pair;
76}
77
81static inline void *fst(
82 pair_t p)
83{
84 register pair_union_t tmp;
85
86 tmp.pair = p;
87 return tmp.lo;
88}
89
93static inline void *snd(
94 pair_t p)
95{
96 register pair_union_t tmp;
97
98 tmp.pair = p;
99 return tmp.hi;
100}
101
103#define pair(x, y) __pair((void*)(x), (void*)(y))
104
105#endif /*__PAIR_H__*/
static pair_t __pair(void *x, void *y)
Create a pair from two generic 32-bit objects.
Definition pair.h:67
pair_t pair
The paired value.
Definition pair.h:54
static void * snd(pair_t p)
Return the second component of a pair.
Definition pair.h:93
static void * fst(pair_t p)
Return the first component of a pair.
Definition pair.h:81
uint64_t pair_t
Give a useful name to the return type, indicating it's use.
Definition pair.h:49
The implementation of a pair.
Definition pair.h:52