#3765 new defect

FreeBSD and Newlib qsort_r do not match

Reported by: Chris Johns Owned by:
Priority: normal Milestone: 5.1
Component: network/libbsd Version: 5
Severity: normal Keywords:
Cc: Blocked By:
Blocking:

Description

The FreeBSD and Newlib qsort_r calls are different. This breaks LibBSD.

FreeBSD is ..

void qsort_r(void *base, size_t nmemb, size_t size, void *thunk,
             int (*compar)(void *, const void *, const void *));

Newlib (which follows Linux) is ...

void qsort_r(void *base, size_t nmemb, size_t size,
             int (*compar)(const void *, const void *, void *),
                           void *arg);

The FreeBSD stdlib.h and sys/libkern.h decls match which means you can include sys/libkern.h with _KERNEL defined without generating an error if stdlib.h is included. RTEMS with LibBSD cannot do this.

We sometime need to define _KERNEL to access a kernel's structure. This happens in special cases where we need to examine exported kernel data. An example is net-snmp-5.8. It's agent/mibgroup/mibII/mibII_common.h with NETSNMP_IFNET_NEEDS_KERNEL is defined to 1 has ..

#if HAVE_STDLIB_H
#include <stdlib.h>
#endif
  [ snip ]
#if defined(NETSNMP_IFNET_NEEDS_KERNEL) && !defined(_KERNEL)
#define _KERNEL 1
#define _I_DEFINED_KERNEL
#endif
  [ snip ]
#if HAVE_NET_IF_VAR_H
#include <net/if_var.h>
#endif

The net/if_var.h file includes sys/libkern.h.

Change History (2)

comment:1 Changed on Jul 6, 2019 at 3:35:00 AM by Joel Sherrill

http://austingroupbugs.net/view.php?id=900

Read that. Can we push a but on FreeBSD?

comment:2 in reply to:  1 Changed on Jul 7, 2019 at 10:21:33 PM by Chris Johns

Replying to Joel Sherrill:

http://austingroupbugs.net/view.php?id=900

Read that. Can we push a but on FreeBSD?

I am not sure. FreeBSD uses user space labels for calls with different signatures in the kernel and that is a pain for us so where do we start.

After a number of hours of playing around with NetSNMP and LibBSD I have had to park it. There are other places where things are even harder to resolve, for example NetSNMP in mibII's ip.c has a line struct ipstats ipstats where the struct is a kernel one and we have remapped the name in a macro.

I am sure NetSMP can be made to build however I do not have the time at the moment.

Last edited on Jul 7, 2019 at 10:53:10 PM by Chris Johns (previous) (diff)
Note: See TracTickets for help on using tickets.