[PATCH 3/5] libfreebsd: FreeBSD porting helper header

Christian Mauderer oss at c-mauderer.de
Sat Jun 6 11:57:31 UTC 2020


On 04/06/2020 19:43, G S Niteesh Babu wrote:
> This file serve the purpose as rtems-bsd-kernel-space.h in the
> rtems-libbsd.
> This file is intended to be included in every source file that
> is to imported from FreeBSD. This is to reduce the number of
> redefinitions for commonly used functions like malloc, free
> and KASSERT.
> ---
>  cpukit/libfreebsd/rtems-freebsd-helper.h | 45 ++++++++++++++++++++++++
>  1 file changed, 45 insertions(+)
>  create mode 100644 cpukit/libfreebsd/rtems-freebsd-helper.h
> 
> diff --git a/cpukit/libfreebsd/rtems-freebsd-helper.h b/cpukit/libfreebsd/rtems-freebsd-helper.h

How do you plan to include it? Currently you would need a

#include "../../../rtems-freebsd-helper.h"

right? Can become a bit hard to count the .. with a deep directory tree.

> new file mode 100644
> index 0000000000..1b9b7609f9
> --- /dev/null
> +++ b/cpukit/libfreebsd/rtems-freebsd-helper.h
> @@ -0,0 +1,45 @@
> +
> +/* SPDX-License-Identifier: BSD-2-Clause
> +
> + *
> + * @file
> + *
> + * @ingroup LIBFREEBSD

You have a group LIBFREEBSD here. Earlier you had a LIBFREEBSDOFW. Do
you really want multiple groups? I would suggest to start with one for
the new libfreebsd subsystem.

> + *
> + * @brief
> + */
> +
> +/*
> + * Copyright (C) <2020> Niteesh Babu <niteesh.gs at gmail.com>
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + * 1. Redistributions of source code must retain the above copyright
> + *    notice, this list of conditions and the following disclaimer.
> + * 2. Redistributions in binary form must reproduce the above copyright
> + *    notice, this list of conditions and the following disclaimer in the
> + *    documentation and/or other materials provided with the distribution.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
> + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
> + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
> + * POSSIBILITY OF SUCH DAMAGE.
> + */
> +
> +#ifndef _LIBFREEBSD_RTEMS_FREEBSD_HELPER_H
> +#define _LIBFREEBSD_RTEMS_FREEBSD_HELPER_H
> +
> +#define _KERNEL						1
> +#define KASSERT(cnd, msg)			assert(cnd)
> +#define malloc(size, type, flags)	malloc(size)
> +#define free(addr, type)			free(addr)

The tabs between the define name and the value seem a bit random here.
Please try to use FreeBSD style (I really hope I don't start a
discussion now whether we should use RTEMS style instead for new files).

https://www.freebsd.org/cgi/man.cgi?query=style&apropos=0&sektion=9

If it's not clear there: Take a look at some FreeBSD files.

> +
> +#endif /* _LIBFREEBSD_RTEMS_FREEBSD_HELPER_H */
> \ No newline at end of file
> 


More information about the devel mailing list