paul@181 | 1 | /* |
paul@181 | 2 | * Factory-related data type macros. |
paul@181 | 3 | * |
paul@181 | 4 | * Copyright (C) 2019 Paul Boddie <paul@boddie.org.uk> |
paul@181 | 5 | * |
paul@181 | 6 | * This program is free software; you can redistribute it and/or |
paul@181 | 7 | * modify it under the terms of the GNU General Public License as |
paul@181 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@181 | 9 | * the License, or (at your option) any later version. |
paul@181 | 10 | * |
paul@181 | 11 | * This program is distributed in the hope that it will be useful, |
paul@181 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@181 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@181 | 14 | * GNU General Public License for more details. |
paul@181 | 15 | * |
paul@181 | 16 | * You should have received a copy of the GNU General Public License |
paul@181 | 17 | * along with this program; if not, write to the Free Software |
paul@181 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@181 | 19 | * Boston, MA 02110-1301, USA |
paul@181 | 20 | */ |
paul@181 | 21 | |
paul@181 | 22 | #pragma once |
paul@181 | 23 | |
paul@181 | 24 | #include <l4/sys/types.h> |
paul@181 | 25 | |
paul@181 | 26 | |
paul@181 | 27 | |
paul@181 | 28 | EXTERN_C_BEGIN |
paul@181 | 29 | |
paul@181 | 30 | /* Type and value constructor macros. */ |
paul@181 | 31 | |
paul@181 | 32 | #define ipc_varg_typedef(value_type, type) \ |
paul@181 | 33 | typedef struct { l4_umword_t tag; value_type value; } type; |
paul@181 | 34 | |
paul@181 | 35 | #define ipc_varg_mword(type, value) \ |
paul@181 | 36 | ((type) {L4_VARG_TYPE_MWORD | (sizeof(l4_mword_t) << 16), value}) |
paul@181 | 37 | |
paul@181 | 38 | #define ipc_varg_umword(type, value) \ |
paul@181 | 39 | ((type) {L4_VARG_TYPE_UMWORD | (sizeof(l4_umword_t) << 16), value}) |
paul@181 | 40 | |
paul@181 | 41 | /* Tag inspection macros. */ |
paul@181 | 42 | |
paul@181 | 43 | #define ipc_varg_size(tag) (tag >> 16) |
paul@181 | 44 | |
paul@181 | 45 | #define ipc_varg_type(tag) (tag & 0xff) |
paul@181 | 46 | |
paul@181 | 47 | #define ipc_varg_word(tag) \ |
paul@181 | 48 | ((ipc_varg_type(tag) == L4_VARG_TYPE_MWORD) || \ |
paul@181 | 49 | (ipc_varg_type(tag) == L4_VARG_TYPE_UMWORD)) |
paul@181 | 50 | |
paul@181 | 51 | /* Convenience macro for creating a type name, not necessarily employed by all |
paul@181 | 52 | types. */ |
paul@181 | 53 | |
paul@181 | 54 | #define ipc_varg(type) ipc_varg_##type##_t |
paul@181 | 55 | |
paul@181 | 56 | EXTERN_C_END |