summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2024-02-02Accept non-canonical cross-compilersHEADmasterSamuel Thibault
to let people use gnu 32bit compilers from e.g. Linux
2023-12-29Use char* for inlined arrays of char in user headersFlavio Cruz
This changes how we declare RPC user prototypes for device_read_inband to use "char *data" rather than "io_buf_ptr_inband_t data". It is more standard to pass a pointer to represent arrays compared to "char [128]". This fixes a warning in console-client since GCC won't complain we are not passing an exact char [128]. Also updated code to use const_io_buf_ptr_inband_t for device_write_inband. This is a pointer to const data rather than a const pointer. Message-ID: <ZY7u7noOnHlyJi24@jupiter.tail36e24.ts.net>
2023-12-17x86_64: adapt MiG generated stubs to use mach_port_name_inlined_t for ↵Flavio Cruz
inlined port rights. For i686, we just change the code to use mach_port_name_inlined_t when defining the types. This is a no-op. For x86_64, there's a few things that are different: - In the server code, the server handler can get inlined ports and the array will be resized and cast as an array of mach_port_name_t. Output parameters have a similar treatment where the inlined array in the output is used as an array of mach_port_name_t but resized to look like a mach_port_name_inlined_t. - In the user side, we follow the same approach. Input ports as arrays of mach_port_name_t are expanded into an array of mach_port_name_inlined_t. Output ports are then converted back into an array of mach_port_name_inlined_t so that they fit into the expected message format. Essentially, regardless of whether port rights are inline or out of line, user interfaces and server stubs always receive an array of port rights, not mach_port_name_inlined_t. However, inlined port rights will be exchanged using mach_port_name_inlined_t.
2023-12-03Revert "x86_64: adapt MiG generated stubs to use mach_port_name_inlined_t ↵Samuel Thibault
for inlined port rights." This reverts commit c40604042bd6e9f80e4f5fe6bc9deefb29c4b94a.
2023-12-03x86_64: adapt MiG generated stubs to use mach_port_name_inlined_t for ↵Flavio Cruz
inlined port rights. For i686, we just change the code to use mach_port_name_inlined_t when defining the types. This is a no-op. For x86_64, there's a few things that are different: - In the server code, the server handler can get inlined ports and the array will be resized and cast as an array of mach_port_name_t. Output parameters have a similar treatment where the inlined array in the output is used as an array of mach_port_name_t but resized to look like a mach_port_name_inlined_t. - In the user side, we follow the same approach. Input ports as arrays of mach_port_name_t are expanded into an array of mach_port_name_inlined_t. Output ports are then converted back into an array of mach_port_name_inlined_t so that they fit into the expected message format. Essentially, regardless of whether port rights are inline or out of line, user interfaces and server stubs always receive an array of port rights, not mach_port_name_inlined_t. However, inlined port rights will be exchanged using mach_port_name_inlined_t. Message-ID: <20231124213041.952886-4-flaviocruz@gmail.com>
2023-09-24Update code generation to handle the new 64 bit ABIFlavio Cruz
Mostly, we don't set the fields that do not exist and avoid type mismatching (like casting unsigned short to unsigned char for msgt_name). We also revamp type checking to compare mach_msg_type_t to uint64_t instead of just uint32_t as we now use the whole structure. Message-Id: <ZGREMgn19Zptc/Pf@jupiter.tail36e24.ts.net>
2023-06-17Remove error procedure directivesSergey Bugaev
Back in the wonderful old days of Mach 2, when there were no send-once rights, dead names, or port reference counts, MIG used to have more kinds of operations: there were functions, procedures, simpleprocedures, routines, and simpleroutines. Routines returned an error code as their C function return value, functions had real return values, procedures and simpleprocedures returned void. Functions, procedures, and simpleprocedures signalled errors by invoking a global function. By default, a function named MsgError was invoked, but a subsystem could specify a different function using the 'error' directive: error CustomErrorHandler; In Mach 3, functions, procedures, and simpleprocedures are gone. Routines and simpleroutines are the only remaining kinds of operations. Some 26 years later, most of the code for generating functions, procedures, and simpleprocedures was removed from GNU MIG in commit 7f10b4ed6a557b7a1fd1083939156a3dcf8b377e. Error directives remained, seemingly due to an oversight. So remove them too. Found while trying to use the word 'error' as an identifier and receiving a cryptic syntax error from MIG. Message-Id: <20230617203953.622120-1-bugaevc@gmail.com>
2023-05-20Fix printing size_tv1.8+git20230520Samuel Thibault
2023-05-11Check that msgt_name is always smaller than 255.Flavio Cruz
For the x86_64 ABI we want this to always fit into 1 byte. Even for regular i686, msgt_name is always smaller than 25 (MACH_MSG_TYPE_LAST) and we don't have plans to have more names. Also throw an error if we deemed an RPC to be "TooLong" as that won't work or work badly. Tested by cross-compiling a basic Hurd system. Message-Id: <ZFsuKtiLdwNpD6b1@jupiter.tail36e24.ts.net>
2023-03-08Use designated initializers for mach_msg_type_t and mach_msg_type_long_t.v1.8+git20230502Flavio Cruz
Message-Id: <ZAbgdBuKlIIiF6zA@jupiter.tail36e24.ts.net>
2023-02-27Change complex_align_of to be sizeof(uintptr_t)Flavio Cruz
By using uintptr_t, we ensure that all 64 bit stubs are free of undefined behavior since we support up to 8-byte alignment. This works fine given that Mig will type check types that have higher alignment requirements through the use of _Static_assert. This even works for a 64 bit kernel / 32 bit user land since we can use mig64 to build stubs for the 8-byte aligned kernel stubs and existing 32 bit mig to build the old user side stubs. Pragma is no longer required as we take advantage of the compiler to drive the alignment and avoid undefined behavior. Message-Id: <Y/KsiXZKkq1q/D+3@jupiter.tail36e24.ts.net>
2023-02-27Also align mach_msg_type_long_t to complex_alignofFlavio Cruz
This was a miss in the previous patch given that mach_msg_type_long_t is 12 bytes long so won't neatly align to 8 bytes. Message-Id: <Y+8VyADQ8+bRRUcp@jupiter.tail36e24.ts.net>
2023-02-20Stop including mach/msg_type.h in generated code.Flavio Cruz
File is not needed. Message-Id: <Y/K1bKVZXhYM7X9W@jupiter.tail36e24.ts.net>
2023-02-13Introduce complex_alignof to replace word_sizeFlavio Cruz
Remove the concept of word_size since it is meaningless in some architectures. This is also done in preparation to possibly introduce 8-byte aligned messages. Message-Id: <Y+lkv0uMo/3+hbCb@jupiter.tail36e24.ts.net>
2023-02-12Drop -undef -ansi from cpp flagsSergey Bugaev
Since GNU Mach commit d30481122a5d24ad6b921062f93b9172ef922fc3, i386/machine_types.defs defines types based on defined(__x86_64__). Supressing the built-in macro definitions will now result in the wrong type being silently selected. -undef was initially introduced in commit 78b6a7665db7b2eae367e17102821cbdca231d19 without much of an explanation. -ansi was introduced in commit 6940fb91859e46b2e96a331a029f2dc2a0ee51c9 "to avoid -Di386=1 and the like". Since glibc has been using MIG with CPP set to a custom GCC invocation which did *not* use either flag, it appears that everything works well enough even without them. On the other hand, not having __x86_64__ defined most definetely causes issues for anything that does not set a custom CPP when invoking MIG (i.e., most users). Other built-in definitions could be used in the future in a similar way (e.g. on other architectures); it's really more of a coincidence that they have not been used until now, and things kept working with -undef. Message-Id: <20230212111044.610942-8-bugaevc@gmail.com>
2023-02-02Do not generate the server routine for kernel servers.Flavio Cruz
The kernel does not use these functions so we can avoid a few compiler warnings. I think we could make the hurd servers not use these also but currently these are still needed. Message-Id: <Y9tpQNDG/mx84kV+@jupiter.tail36e24.ts.net>
2023-02-02Avoid passing NULL to memcpySamuel Thibault
2022-12-21Fix make checkv1.8+git20221221Samuel Thibault
c7654756ee19 ("Provide intptr_t and uintptr_t as default types") added intptr_t and uintptr_t, but missed updating the testsuite.
2022-12-21Fix make distSamuel Thibault
7063f0aefd8a ("mig: replace boolean.h with stdbool.h") dropped boolean.h, but missed dropping its installation.
2022-12-21Provide intptr_t and uintptr_t as default typesFlavio Cruz
Message-Id: <Y6CAwaY0IRqihOjU@mars>
2022-12-18Generate cpu.h with -ffreestandingFlavio Cruz
During a system bootstrap, it is preferable that we don't require a full hosted environment. For all other cases, we also do not need libc since mach headers are self contained. Message-Id: <Y5+WXzOwGkyvcDI0@mars>
2022-11-25mig: replace boolean.h with stdbool.hFlavio Cruz
Message-Id: <Y3/Z1CGL8D4OwT66@viriathus>
2022-11-15Initialize basic types once and print errors for duplicate definitionsFlavio Cruz
For kernel server or user subsystems we would initialize basic types twice, once in main() and again for the subsystem declaration. Instead, initialize basic types when the subsystem is declared and then throw errors when types are defined multiple times. Message-Id: <Y3HUt/YAKaqMMTi3@viriathus>
2022-11-05Add support to define structures in mig.v1.8+git20221111Flavio Cruz
Basic syntax is presented below and allows users to define nested structured types by using simpler or structure types as members. Mig will use the C padding and alignment rules to produce the same size as the corresponding C structures. type timespec_t = struct { uint32_t tv_sec; uint32_t tv_nsec; }; This allows us to build stubs that are more easily adaptable to other architectures. Message-Id: <Y2SjQSMOINY8I5Dy@viriathus>
2022-08-27fill msg size in the header for user stubsv1.8+git20220827Luca Dariz
* user.c: - adjust comment in generated file - set msgh_size with the same value passed to mach_msg() Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220628094927.442907-4-luca@orpolo.org>
2022-08-27add check for whole message sizeLuca Dariz
* user.c: ensure fixed-length messages have the correct size. In addition to the single-fields check, this also include padding. Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220628094927.442907-3-luca@orpolo.org>
2022-08-27fix message fields alignment for 64 bitLuca Dariz
On x86_64 alignment of structures is different, as the pointer size is different. For simplicity we keep the same 4-byte alignment as used on 32-bit. This simplifies the support for 32-bit rpc on 64-bit kernels, and also it seems not worth as an optimization, as we would need to add more code in the ipc_kmsg* routines. * routine.c: align both short and long descriptors * utils.c: use a fixed alignment for data fields in structures representing messages. Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220628094927.442907-2-luca@orpolo.org>
2022-08-27improve error messageLuca Dariz
* parser.y: add information about type names Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220403150020.120799-3-luca@orpolo.org>
2022-08-27add separate port_size and mach_port_name_size definitionsLuca Dariz
* cpu.sym: retrieve size of vm_offset_t and mach_port_name_t from gnumach headers at compile type. * global.{c,h}: add port size as a variable and initialize it to the port name size. * lexxer.l: apply port or port name size to the corresponding types, instead of using the word size. * parser.y: update port size if we're generating for kernel-space (server or client). Also re-initialize default port types to account for this change. * type.c: use port size instead of word size in default port types and runtime checks. There are many assumptions about mach_port_t: - on kernel side, its size is the same as a pointer. This allows to replace the port name with the address of the corresponding data structure during copyin in mach_msg() - in mig, this is also the "word size", which is derived from gnumach headers as the size of integer_t - its size is also the same as natural_t, so it's possible to model structures like mach_port_status_t as an array of integer_t in mig. This is convenient since arrays and structures can't have mixed types. - its size is always the same as the port name size This patch does not change the current behaviour on 32-bit kernels, but allows for some of these assumptions to be broken on 64-bit kernels. This is needed to have 32-bit port names on 64-bit kernels and be able to support a 32-bit userspace. It still leaves the choice for a 64-bit userspace, if all integer_t and natural_t are to be extended to 64 bit. However keeping 32-bit port names seems to be the right thing, based on previous discussions [1], even for a 64-bit kernel. The only assumption kept is that in kernel-space ports are always the size of a pointer, as they refer to a data structure and not to a specific port name. To ensure this is true for various user/kernel combinations, we dynamically change the port size if we're generating code for kernel-space server or clients, and keep the size of a port the same of a port name for user-space servers and clients. [1] https://lists.gnu.org/archive/html/bug-hurd/2012-04/msg00000.html Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220403150020.120799-2-luca@orpolo.org>
2022-05-02mig: remove local definition of 'vprintf'Guy-Fleury Iteriteka
autoconf consider that 'AC_FUNC_VPRINTF' is obsolescent. see 'info autoconf AC_FUNC_VPRINTF' * Makefile.am: remove 'vprint.c' on src files. configure.ac: remove 'AC_FUNC_VPRINTF' macro. vprint.c: delete file. Message-Id: <Ym+H/OM0PnucKO4w@debian>
2022-01-21Add _Static_assert when compiling server and user stubs.Flavio Cruz
This is only done when data is inlined with a concrete size. It ensures the C and Mig types have the same size in the target arch. Tested by building the hurd package. No assertions were triggered. Message-Id: <YekIQaxvs+4FrHyw@viriathus>
2022-01-16Also add const qualifiers on server sideSamuel Thibault
Although in practice the buffers can be modified since they are from the message, it leads to missing const where it would otherwise make sense.
2022-01-16Make dev_name_t also use const_dev_name_tSamuel Thibault
to avoid forcing the caller to respect the definite string size.
2021-02-11Add noyywrap optionPaul Dufresne
We do not actually use yywrap, and this allows to avoid requiring libflex, making cross-compilations simpler. * lexxer.l: Add noyywrap option.
2020-11-30Make string_t always use const_string_tSamuel Thibault
This will allow to relieve constraints in callers, e.g. dir_lookup("") would otherwise produce a warning with gcc-11 since char[1024] would mean that dir_lookup would read all 1024 characters while it is not. * utils.c (UserVarQualifier): Also use const_ qualifier when type is string_t. * tests/includes/types.h (const_string_t): New type.
2020-06-18cpu.sym: Add more C typesv1.8+git20200618Samuel Thibault
* cpu.sym: Add sizeof_long, sizeof_float, sizeof_double.
2020-06-18cpu.sym: Replace implementation from Utah with implementation from CMUSamuel Thibault
This replaces the implementation from the University of Utah, covered by the advertising clause, with the implementation from CMU, picked up from the GNU Mach source, which is free from the advertising clause. This includes the addition of the sizeof as seen used by mig with git grep word_size git grep sizeof_
2020-06-18message.h: Replace implementation from Utah with implementation from CMUSamuel Thibault
This replaces the implementation from the University of Utah, covered by the advertising clause, with the implementation from CMU, picked up from the GNU Mach source, which is free from the advertising clause.
2020-06-18boolean.h: Replace implementation from Utah with implementation from CMUSamuel Thibault
This replaces the implementation from the University of Utah, covered by the advertising clause, with the implementation from CMU, picked up from the GNU Mach source, which is free from the advertising clause.
2020-01-28Make MIG recognize the basic C integral types.Flavio Cruz
Also removed itMakeIntType which was not used anymore. Users can use char, int, and short types without having to define them. These types are defined using the builtin MACH_MSG_TYPE_* types and are architecture independent since they have the same size as the C char, short and int. If these basic types are redefined, MIG will still produce stub code but will produce a warning. * cpu.sym: Define sizeof_int, char, short. * tests/base_types.defs: Remove int. * tests/good/complex-types.defs: Use byte instead of char. * tests/good/directions: Remove char and int. * tests/good/types.defs: Remove char and also use short as a parameter in 'alltypes'. * type.c: Define itCIntTypeDecl. Remove itMakeIntType. Call itInsert for char, short and int. Message-Id: <20160419070513.GA12642@debian>
2018-11-06build: Distribute tarball compressed with xz instead of bzip2Guillem Jover
* configure.ac (AM_INIT_AUTOMAKE): Change dist-bzip2 to dist-xz.
2018-03-04Fix c89 compilation of mig headersSamuel Thibault
* header.c (WriteServerHeader): Print __inline instead of inline.
2018-01-28Fix RPC build warningsSamuel Thibault
Users of RPCs want to be able to pass pointers to const data, so add const qualifiers to RPCs as appropriate. * utils.c (UserVarConst, UserVarQualifier): New functions. (WriteUserVarDecl): Use UserVarQualifier to qualify function parameter. (WriteFieldDeclPrim): Use UserVarConst to qualify pointer to user variable.
2018-01-28Fix compilation warningsSamuel Thibault
Nowadays' compilers are able to recognize memcpy and replace it appropriately without having to tell them so through a structure assignment. That also avoids warnings about type puning. * utils.c (WriteCopyType): Emit memcpy call instead of type-puned assignement.
2017-01-02Fix spurious warning on MACH_MSG_TYPE_POLYMORPHIC valueSamuel Thibault
* utils.c (WriteStaticLongDecl): Explicitly cast name to unsigned short to ignore truncation of MACH_MSG_TYPE_POLYMORPHIC i.e. -1.
2016-12-19Fix compiler warningSamuel Thibault
2016-12-18GNU MIG 1.8v1.8Thomas Schwinge
* configure.ac (AC_INIT): Set version to 1.8. * NEWS: Finalize for 1.8.
2016-12-13Remove bullet points from NEWS fileThomas Schwinge
... to match the GNU Mach and Hurd NEWS files. * NEWS: Remove bullet points.
2016-12-09Update the NEWS fileJustus Winter
2016-10-10Fix spurious warning on MACH_MSG_TYPE_POLYMORPHIC valueSamuel Thibault
* utils.c (WriteCheckDecl, WriteStaticShortDecl): Explicitly cast name to unsigned char to ignore truncation of MACH_MSG_TYPE_POLYMORPHIC i.e. -1.