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