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

Christian Mauderer oss at c-mauderer.de
Wed Jun 10 16:48:52 UTC 2020


On 10/06/2020 15:56, Niteesh G. S. wrote:
> 
> On Sat, Jun 6, 2020 at 5:27 PM Christian Mauderer <contact at c-mauderer.de
> <mailto:contact at c-mauderer.de>> wrote:
> 
>     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.
> 
> 
> The right place for this file would be the standard include path. Since
> we haven't decided
> on this, I placed it temporarily here.
> If we can add libfreebsd to the include path that will be really nice
> because this will allow
> us to have the same include path as in FreeBSD.
> i.e.
> The openfirm.h is included in FreeBSD sources as
> #include <dev/ofw/openfirm.h>
> Including libfreebsd to include path will let us do the same.

Hm. I'm not sure whether the current build system allows adding that to
the include path. Definitively not for installed headers. If you see a
simple way to add it: Do it. But don't put much effort into it
(<30Minutes). It's not worth it.

> 
>  
> 
>     > 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.
> 
> 
> I changed everything to LIBFREEBSD.

OK

> 
>  
> 
>     > + *
>     > + * @brief
>     > + */
>     > +
>     > +/*
>     > + * Copyright (C) <2020> Niteesh Babu <niteesh.gs at gmail.com
>     <mailto: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.
> 
> I'll fix this.

Thanks.

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


More information about the devel mailing list