Re: [PATCH] remove pthread_atfork issue
Guy-Fleury Iteriteka, le jeu. 24 nov. 2022 09:25:31 +0200, a ecrit: > * open_issues/pthread_atfork.mdwn: delete file Applied, thanks!
Re: [PATCH] mig: explicitly use -std=gnu11
On 24/11/2022 5:41 am, Flavio Cruz wrote: On Wed, Nov 23, 2022 at 11:51:36AM +0100, Samuel Thibault wrote: Flavio Cruz, le mer. 23 nov. 2022 00:10:10 -0500, a ecrit: Latest GCC will pick up gnu17 by default but gnu11 will be better supported with older compilers. Mmm, but why explicitly requesting gnu11 then? Latest GCC will be fine with using gnu17, and older GCC will be fine with using whatever it supports. I would like to modernize some parts of the mig code (for example, use stdbool.h instead of setting up our own boolean type). For this, gnu99 would be enough but I thought gnu11 would be fine since it has been around for some time. FWIW, From experience with other code using the -std=*11 options: This will not just downgrade the specification on latest compilers, but at times disable newer code safety checks. Making some types of bugs more difficult to detect. /2c HTH AYJ
[PATCH] mig: replace boolean.h with stdbool.h
--- Tested by bootstrapping the system from scratch. boolean.h| 60 --- global.c | 12 - global.h | 14 +- mig_string.h | 5 ++-- migcom.c | 14 +- parser.y | 12 - routine.c| 68 - routine.h| 38 +-- server.c | 38 +-- string.c | 6 ++--- type.c | 72 ++-- type.h | 34 - user.c | 4 +-- utils.c | 32 +++ utils.h | 8 +++--- 15 files changed, 178 insertions(+), 239 deletions(-) delete mode 100644 boolean.h diff --git a/boolean.h b/boolean.h deleted file mode 100644 index 823b404..000 --- a/boolean.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or software.distribut...@cs.cmu.edu - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ -/* - * Boolean data type. - * - */ - -#ifndef_MIG_BOOLEAN_H_ -#define_MIG_BOOLEAN_H_ - -/* - * Pick up "boolean_t" type definition - */ - -#ifndef__ASSEMBLER__ -typedef intboolean_t; -#endif /* __ASSEMBLER__ */ - -#endif /* _MIG_BOOLEAN_H_ */ - -/* - * Define TRUE and FALSE, only if they haven't been before, - * and not if they're explicitly refused. Note that we're - * outside the BOOLEAN_H_ conditional, to avoid ordering - * problems. - */ - -#if!defined(NOBOOL) - -#ifndefTRUE -#define TRUE ((boolean_t) 1) -#endif /* TRUE */ - -#ifndefFALSE -#define FALSE ((boolean_t) 0) -#endif /* FALSE */ - -#endif /* !defined(NOBOOL) */ diff --git a/global.c b/global.c index e2eb76e..bf3d10d 100644 --- a/global.c +++ b/global.c @@ -28,13 +28,13 @@ #include "error.h" #include "global.h" -boolean_t DefaultFiles = TRUE; -boolean_t BeQuiet = FALSE; -boolean_t BeVerbose = FALSE; -boolean_t GenSymTab = FALSE; +bool DefaultFiles = true; +bool BeQuiet = false; +bool BeVerbose = false; +bool GenSymTab = false; -boolean_t IsKernelUser = FALSE; -boolean_t IsKernelServer = FALSE; +bool IsKernelUser = false; +bool IsKernelServer = false; const_string_t RCSId = strNULL; diff --git a/global.h b/global.h index cadd7e7..8e57df2 100644 --- a/global.h +++ b/global.h @@ -27,18 +27,18 @@ #ifndef_GLOBAL_H #define_GLOBAL_H +#include #include -#include "boolean.h" #include "mig_string.h" -extern boolean_t DefaultFiles; /* default output file names if no arguments */ -extern boolean_t BeQuiet; /* no warning messages */ -extern boolean_t BeVerbose;/* summarize types, routines */ -extern boolean_t GenSymTab; +extern bool DefaultFiles; /* default output file names if no arguments */ +extern bool BeQuiet; /* no warning messages */ +extern bool BeVerbose; /* summarize types, routines */ +extern bool GenSymTab; -extern boolean_t IsKernelUser; -extern boolean_t IsKernelServer; +extern bool IsKernelUser; +extern bool IsKernelServer; extern const_string_t RCSId; diff --git a/mig_string.h b/mig_string.h index d6cef95..920171c 100644 --- a/mig_string.h +++ b/mig_string.h @@ -27,10 +27,9 @@ #ifndef_MIG_STRING_H #define_MIG_STRING_H +#include #include -#include "boolean.h" - typedef char *string_t; typedef const char *const_string_t; typedef const_string_t identifier_t; @@ -43,7 +42,7 @@ extern void strfree(string_t string); #definestreql(a, b)(strcmp((a), (b)) == 0) -extern const char *strbool(boolean_t bool); +extern const char *strbool(bool v); extern const char *strstring(const_string_t string); #endif /* _MIG_STRING_H */ diff --git a/migcom.c b/migcom.c index e61c79b..2174836 100644 --- a/migcom.c +++ b/migcom.c @@ -91,19 +91,19 @@ parseArgs(int argc, char **argv) switch (argv[0][1]) { case 'n': - DefaultFiles = FALSE; + DefaultFiles = false; break; case 'q': - BeQuiet = TRUE
Re: [PATCH] mig: explicitly use -std=gnu11
Amos Jeffries, le jeu. 24 nov. 2022 22:50:57 +1300, a ecrit: > On 24/11/2022 5:41 am, Flavio Cruz wrote: > > On Wed, Nov 23, 2022 at 11:51:36AM +0100, Samuel Thibault wrote: > > > Flavio Cruz, le mer. 23 nov. 2022 00:10:10 -0500, a ecrit: > > > > Latest GCC will pick up gnu17 by default but gnu11 will be > > > > better supported with older compilers. > > > > > > Mmm, but why explicitly requesting gnu11 then? Latest GCC will be fine > > > with using gnu17, and older GCC will be fine with using whatever it > > > supports. > > > > I would like to modernize some parts of the mig code (for example, use > > stdbool.h instead of setting up our own boolean type). For this, gnu99 > > would be enough but I thought gnu11 would be fine since it has been > > around > > for some time. > > FWIW, From experience with other code using the -std=*11 options: > This will not just downgrade the specification on latest compilers, but at > times disable newer code safety checks. Making some types of bugs more > difficult to detect. Indeed. We can just declare that our code requires at least gnu11, and let glibc etc. use gnu17 etc. features whenever the compiler can support them. Samuel
Re: [PATCH] mig: replace boolean.h with stdbool.h
Applied, thanks! Flavio Cruz, le jeu. 24 nov. 2022 15:53:40 -0500, a ecrit: > --- > Tested by bootstrapping the system from scratch. > > boolean.h| 60 --- > global.c | 12 - > global.h | 14 +- > mig_string.h | 5 ++-- > migcom.c | 14 +- > parser.y | 12 - > routine.c| 68 - > routine.h| 38 +-- > server.c | 38 +-- > string.c | 6 ++--- > type.c | 72 ++-- > type.h | 34 - > user.c | 4 +-- > utils.c | 32 +++ > utils.h | 8 +++--- > 15 files changed, 178 insertions(+), 239 deletions(-) > delete mode 100644 boolean.h > > diff --git a/boolean.h b/boolean.h > deleted file mode 100644 > index 823b404..000 > --- a/boolean.h > +++ /dev/null > @@ -1,60 +0,0 @@ > -/* > - * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University > - * All Rights Reserved. > - * > - * Permission to use, copy, modify and distribute this software and its > - * documentation is hereby granted, provided that both the copyright > - * notice and this permission notice appear in all copies of the > - * software, derivative works or modified versions, and any portions > - * thereof, and that both notices appear in supporting documentation. > - * > - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" > - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR > - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. > - * > - * Carnegie Mellon requests users of this software to return to > - * > - * Software Distribution Coordinator or software.distribut...@cs.cmu.edu > - * School of Computer Science > - * Carnegie Mellon University > - * Pittsburgh PA 15213-3890 > - * > - * any improvements or extensions that they make and grant Carnegie Mellon > - * the rights to redistribute these changes. > - */ > -/* > - * Boolean data type. > - * > - */ > - > -#ifndef _MIG_BOOLEAN_H_ > -#define _MIG_BOOLEAN_H_ > - > -/* > - * Pick up "boolean_t" type definition > - */ > - > -#ifndef __ASSEMBLER__ > -typedef int boolean_t; > -#endif /* __ASSEMBLER__ */ > - > -#endif /* _MIG_BOOLEAN_H_ */ > - > -/* > - * Define TRUE and FALSE, only if they haven't been before, > - * and not if they're explicitly refused. Note that we're > - * outside the BOOLEAN_H_ conditional, to avoid ordering > - * problems. > - */ > - > -#if !defined(NOBOOL) > - > -#ifndef TRUE > -#define TRUE ((boolean_t) 1) > -#endif /* TRUE */ > - > -#ifndef FALSE > -#define FALSE((boolean_t) 0) > -#endif /* FALSE */ > - > -#endif /* !defined(NOBOOL) */ > diff --git a/global.c b/global.c > index e2eb76e..bf3d10d 100644 > --- a/global.c > +++ b/global.c > @@ -28,13 +28,13 @@ > #include "error.h" > #include "global.h" > > -boolean_t DefaultFiles = TRUE; > -boolean_t BeQuiet = FALSE; > -boolean_t BeVerbose = FALSE; > -boolean_t GenSymTab = FALSE; > +bool DefaultFiles = true; > +bool BeQuiet = false; > +bool BeVerbose = false; > +bool GenSymTab = false; > > -boolean_t IsKernelUser = FALSE; > -boolean_t IsKernelServer = FALSE; > +bool IsKernelUser = false; > +bool IsKernelServer = false; > > const_string_t RCSId = strNULL; > > diff --git a/global.h b/global.h > index cadd7e7..8e57df2 100644 > --- a/global.h > +++ b/global.h > @@ -27,18 +27,18 @@ > #ifndef _GLOBAL_H > #define _GLOBAL_H > > +#include > #include > > -#include "boolean.h" > #include "mig_string.h" > > -extern boolean_t DefaultFiles; /* default output file names if no > arguments */ > -extern boolean_t BeQuiet;/* no warning messages */ > -extern boolean_t BeVerbose; /* summarize types, routines */ > -extern boolean_t GenSymTab; > +extern bool DefaultFiles;/* default output file names if no arguments */ > +extern bool BeQuiet; /* no warning messages */ > +extern bool BeVerbose; /* summarize types, routines */ > +extern bool GenSymTab; > > -extern boolean_t IsKernelUser; > -extern boolean_t IsKernelServer; > +extern bool IsKernelUser; > +extern bool IsKernelServer; > > extern const_string_t RCSId; > > diff --git a/mig_string.h b/mig_string.h > index d6cef95..920171c 100644 > --- a/mig_string.h > +++ b/mig_string.h > @@ -27,10 +27,9 @@ > #ifndef _MIG_STRING_H > #define _MIG_STRING_H > > +#include > #include > > -#include "boolean.h" > - > typedef char *string_t; > typedef const char *const_string_t; > typedef const_string_t identifier_t; > @@ -43,7 +42,7 @@ extern void strfree(string_t string); > > #define streql(a, b)(strcmp((a), (b)) == 0) > > -extern const char *strbool(boolean_t bool); > +extern const char *strbool(bool v); > extern const char *strstring(const_string_
Re: [PATCH] Delete ipc_info.h since it is not used
Applied, thanks! Flavio Cruz, le mer. 23 nov. 2022 11:49:34 -0500, a ecrit: > --- > We don't implement this interface and the types are not used anywhere. > > Makefrag.am | 1 - > include/mach_debug/ipc_info.h | 77 --- > include/mach_debug/mach_debug_types.h | 1 - > ipc/mach_debug.c | 1 - > 4 files changed, 80 deletions(-) > delete mode 100644 include/mach_debug/ipc_info.h > > diff --git a/Makefrag.am b/Makefrag.am > index 2a80abfa..0f9052e4 100644 > --- a/Makefrag.am > +++ b/Makefrag.am > @@ -444,7 +444,6 @@ include_mach_debugdir = $(includedir)/mach_debug > include_mach_debug_HEADERS = \ > $(addprefix include/mach_debug/, \ > hash_info.h \ > - ipc_info.h \ > mach_debug.defs \ > mach_debug_types.defs \ > mach_debug_types.h \ > diff --git a/include/mach_debug/ipc_info.h b/include/mach_debug/ipc_info.h > deleted file mode 100644 > index a47ae7b4.. > --- a/include/mach_debug/ipc_info.h > +++ /dev/null > @@ -1,77 +0,0 @@ > -/* > - * Mach Operating System > - * Copyright (c) 1991,1990 Carnegie Mellon University > - * All Rights Reserved. > - * > - * Permission to use, copy, modify and distribute this software and its > - * documentation is hereby granted, provided that both the copyright > - * notice and this permission notice appear in all copies of the > - * software, derivative works or modified versions, and any portions > - * thereof, and that both notices appear in supporting documentation. > - * > - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" > - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR > - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. > - * > - * Carnegie Mellon requests users of this software to return to > - * > - * Software Distribution Coordinator or software.distribut...@cs.cmu.edu > - * School of Computer Science > - * Carnegie Mellon University > - * Pittsburgh PA 15213-3890 > - * > - * any improvements or extensions that they make and grant Carnegie Mellon > - * the rights to redistribute these changes. > - */ > -/* > - * File: mach_debug/ipc_info.h > - * Author: Rich Draves > - * Date: March, 1990 > - * > - * Definitions for the IPC debugging interface. > - */ > - > -#ifndef _MACH_DEBUG_IPC_INFO_H_ > -#define _MACH_DEBUG_IPC_INFO_H_ > - > -#include > -#include > -#include > - > -/* > - * Remember to update the mig type definitions > - * in mach_debug_types.defs when adding/removing fields. > - */ > - > -typedef struct ipc_info_name { > - mach_port_t iin_name; /* port name, including gen number */ > -/*boolean_t*/integer_t iin_marequest;/* extant msg-accepted request? > */ > - mach_port_type_t iin_type; /* straight port type */ > - mach_port_urefs_t iin_urefs;/* user-references */ > - vm_offset_t iin_object; /* object pointer */ > - natural_t iin_next; /* marequest/next in free list */ > -} ipc_info_name_t; > - > -typedef ipc_info_name_t *ipc_info_name_array_t; > - > -/* > - * Type definitions for mach_port_kernel_object. > - * By remarkable coincidence, these closely resemble > - * the IKOT_* definitions in ipc/ipc_kobject.h. > - */ > - > -#define IPC_INFO_TYPE_NONE 0 > -#define IPC_INFO_TYPE_THREAD 1 > -#define IPC_INFO_TYPE_TASK 2 > -#define IPC_INFO_TYPE_HOST 3 > -#define IPC_INFO_TYPE_HOST_PRIV 4 > -#define IPC_INFO_TYPE_PROCESSOR 5 > -#define IPC_INFO_TYPE_PSET 6 > -#define IPC_INFO_TYPE_PSET_NAME 7 > -#define IPC_INFO_TYPE_PAGER 8 > -#define IPC_INFO_TYPE_PAGING_REQUEST9 > -#define IPC_INFO_TYPE_DEVICE10 > -#define IPC_INFO_TYPE_XMM_PAGER 11 > -#define IPC_INFO_TYPE_PAGING_NAME12 > - > -#endif /* _MACH_DEBUG_IPC_INFO_H_ */ > diff --git a/include/mach_debug/mach_debug_types.h > b/include/mach_debug/mach_debug_types.h > index 1c81ca34..98124adb 100644 > --- a/include/mach_debug/mach_debug_types.h > +++ b/include/mach_debug/mach_debug_types.h > @@ -30,7 +30,6 @@ > #ifndef _MACH_DEBUG_MACH_DEBUG_TYPES_H_ > #define _MACH_DEBUG_MACH_DEBUG_TYPES_H_ > > -#include > #include > #include > #include > diff --git a/ipc/mach_debug.c b/ipc/mach_debug.c > index 6ddc89b2..aadd9066 100644 > --- a/ipc/mach_debug.c > +++ b/ipc/mach_debug.c > @@ -39,7 +39,6 @@ > #include > #include > #include > -#include > #include > #include > #include > -- > 2.37.2 > > -- Samuel --- Pour une évaluation indépendante, transparente et rigoureuse ! Je soutiens la Commission d'Évaluation de l'Inria.
Re: [PATCH] Update mach_debug interfaces to use struct.
Applied, thanks! Flavio Cruz, le mar. 22 nov. 2022 23:46:31 -0500, a ecrit: > The new interfaces will be compatible both with a 64 bits kernel and > userland and 64 bits kernel and 32 bit userland. Also removed many > of the uses of natural_t where an unsigned int suffices. Ideally we > should replace natural_t with something more portable such as uintptr_t > or a basic int type for counters since for the most part we don't > need counters to have the same width as the pointer type. > > * i386/include/mach/i386/vm_types.h: Define rpc_unsigned_long. > * include/mach/mach_types.defs: Define type rpc_vm_offset_t. > * include/mach_debug/hash_info.h: Use unsigned int instead of natural_t. > * include/mach_debug/mach_debug_types.defs: Update cache_info_t, > hash_info_bucket_t, vm_region_info_t, vm_object_info_t and > vm_page_info_t to use struct. > * include/mach_debug/slab_info.h: Use rpc_vm_size_t and > rpc_unsigned_long for compatibility with 32 bits userland. > * include/mach_debug/vm_info.h: Update struct fields to use the correct > types and avoid natural_t whenever we just want to keep a count of > something. > --- > i386/include/mach/i386/machine_types.defs | 14 + > i386/include/mach/i386/vm_types.h | 2 + > include/mach/mach_types.defs | 4 +- > include/mach_debug/hash_info.h| 2 +- > include/mach_debug/mach_debug_types.defs | 65 +-- > include/mach_debug/slab_info.h| 20 +++ > include/mach_debug/vm_info.h | 38 ++--- > 7 files changed, 109 insertions(+), 36 deletions(-) > > diff --git a/i386/include/mach/i386/machine_types.defs > b/i386/include/mach/i386/machine_types.defs > index dfbc521e..0e94999b 100755 > --- a/i386/include/mach/i386/machine_types.defs > +++ b/i386/include/mach/i386/machine_types.defs > @@ -58,6 +58,20 @@ type natural_t = uint32_t; > */ > type integer_t = int32_t; > > +/* > + * unsigned long for kernel <-> userland interfaces size depends on the > architecture > + * of both kernel and userland. > + */ > +#if defined(KERNEL) && defined(USER32) > +type rpc_unsigned_long = uint32_t; > +#else /* KERNEL and USER32 */ > +#if defined(__x86_64__) > +type rpc_unsigned_long = uint64_t; > +#else /* __x86_64__ */ > +type rpc_unsigned_long = uint32_t; > +#endif /* __x86_64__ */ > +#endif /* KERNEL_SERVER and USER32 */ > + > /* > * Physical address size > */ > diff --git a/i386/include/mach/i386/vm_types.h > b/i386/include/mach/i386/vm_types.h > index 7a43d75d..9daaa15e 100644 > --- a/i386/include/mach/i386/vm_types.h > +++ b/i386/include/mach/i386/vm_types.h > @@ -116,12 +116,14 @@ static inline __mach_uint32_t > convert_vm_to_user(__mach_uint64_t kaddr) > assert(kaddr <= 0x); > return (__mach_uint32_t)kaddr; > } > +typedef __mach_uint32_t rpc_unsigned_long; > #else /* MACH_KERNEL */ > typedef vm_offset_t rpc_vm_address_t; > typedef vm_offset_t rpc_vm_offset_t; > typedef vm_size_trpc_vm_size_t; > #define convert_vm_to_user null_conversion > #define convert_vm_from_user null_conversion > +typedef unsigned long rpc_unsigned_long; > #endif /* MACH_KERNEL */ > > #endif /* __ASSEMBLER__ */ > diff --git a/include/mach/mach_types.defs b/include/mach/mach_types.defs > index 4412d726..f7106946 100644 > --- a/include/mach/mach_types.defs > +++ b/include/mach/mach_types.defs > @@ -120,6 +120,8 @@ type rpc_vm_size_t = uint32_t; > #endif /* __x86_64__ */ > #endif /* KERNEL_SERVER and USER32 */ > > +type rpc_vm_offset_t = rpc_vm_size_t; > + > type vm_address_t = rpc_vm_size_t > #if defined(KERNEL_SERVER) > intran: vm_address_t convert_vm_from_user(rpc_vm_address_t) > @@ -128,7 +130,7 @@ type vm_address_t = rpc_vm_size_t > ctype: rpc_vm_address_t > #endif > ; > -type vm_offset_t = rpc_vm_size_t > +type vm_offset_t = rpc_vm_offset_t > #if defined(KERNEL_SERVER) > intran: vm_offset_t convert_vm_from_user(rpc_vm_offset_t) > outtran: rpc_vm_offset_t convert_vm_to_user(vm_offset_t) > diff --git a/include/mach_debug/hash_info.h b/include/mach_debug/hash_info.h > index 6944277d..8e6f19cf 100644 > --- a/include/mach_debug/hash_info.h > +++ b/include/mach_debug/hash_info.h > @@ -33,7 +33,7 @@ > */ > > typedef struct hash_info_bucket { > - natural_t hib_count; /* number of records in bucket */ > + unsigned int hib_count; /* number of records in bucket */ > } hash_info_bucket_t; > > typedef hash_info_bucket_t *hash_info_bucket_array_t; > diff --git a/include/mach_debug/mach_debug_types.defs > b/include/mach_debug/mach_debug_types.defs > index 23c2026d..c138dc40 100644 > --- a/include/mach_debug/mach_debug_types.defs > +++ b/include/mach_debug/mach_debug_types.defs > @@ -32,19 +32,74 @@ > > #include > > -type cache_info_t = struct[19] of integer_t; > +#define CACHE_NAME_MAX_LEN 32 > +type cache_name_t = struct[CACHE_NAME_MAX_LEN] of char; > +#undef CACHE_NAME_MAX_LEN > +type cache_info_t =