[RTEMS Project] #3765: FreeBSD and Newlib qsort_r do not match

RTEMS trac trac at rtems.org
Sat Jul 6 03:17:45 UTC 2019


#3765: FreeBSD and Newlib qsort_r do not match
-----------------------------+--------------------
  Reporter:  Chris Johns     |      Owner:  (none)
      Type:  defect          |     Status:  new
  Priority:  normal          |  Milestone:  5.1
 Component:  network/libbsd  |    Version:  5
  Severity:  normal          |   Keywords:
Blocked By:                  |   Blocking:
-----------------------------+--------------------
 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`.

--
Ticket URL: <http://devel.rtems.org/ticket/3765>
RTEMS Project <http://www.rtems.org/>
RTEMS Project


More information about the bugs mailing list