Merge pull request #8 from Oichkatzelesfrettschen/40pmin-eirikr/replace-__netbsd__-with-minix-conditionals

Replace __NetBSD__ checks with MINIX-specific conditionals
This commit is contained in:
Eirikr Hinngart 2025-05-29 20:27:51 -07:00 committed by GitHub
commit d8c46b9ffb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 132 additions and 83 deletions

View File

@ -134,7 +134,7 @@ static const wchar_t char_shell[] = L"'`\";&<>()|{}]\\$!^~";
static const wchar_t char_glob[] = L"*?[#"; static const wchar_t char_glob[] = L"*?[#";
#if !HAVE_NBTOOL_CONFIG_H #if !HAVE_NBTOOL_CONFIG_H
#if !defined(__NetBSD__) && ! defined(__minix) #ifndef __minix
/* /*
* On NetBSD MB_LEN_MAX is currently 32 which does not fit on any integer * On NetBSD MB_LEN_MAX is currently 32 which does not fit on any integer
* integral type and it is probably wrong, since currently the maximum * integral type and it is probably wrong, since currently the maximum
@ -154,7 +154,7 @@ static const wchar_t char_glob[] = L"*?[#";
#endif #endif
#endif /* __FreeBSD__ */ #endif /* __FreeBSD__ */
CTASSERT(MB_LEN_MAX <= sizeof(uint64_t)); CTASSERT(MB_LEN_MAX <= sizeof(uint64_t));
#endif /* !__NetBSD__ */ #endif /* !__minix */
#endif #endif
/* /*

View File

@ -2,7 +2,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#define ISC_FORMAT_PRINTF(a,b) __attribute__((__format__(__printf__,a,b))) #define ISC_FORMAT_PRINTF(a,b) __attribute__((__format__(__printf__,a,b)))
#define ISC_SOCKLEN_T socklen_t #define ISC_SOCKLEN_T socklen_t
#ifdef __NetBSD__ #ifdef __minix
#define DE_CONST(c,v) v = __UNCONST(c) #define DE_CONST(c,v) v = __UNCONST(c)
#else #else
#define DE_CONST(c,v) v = ((c) ? \ #define DE_CONST(c,v) v = ((c) ? \

View File

@ -97,13 +97,13 @@
/* LINTLIBRARY */ /* LINTLIBRARY */
#if defined(__NetBSD__) || defined(__minix) #ifdef __minix
# define xutrace(a, b) utrace("malloc", (a), (b)) # define xutrace(a, b) utrace("malloc", (a), (b))
# define __DECONST(x, y) ((x)__UNCONST(y)) # define __DECONST(x, y) ((x)__UNCONST(y))
# define NO_TLS # define NO_TLS
#else #else
# define xutrace(a, b) utrace((a), (b)) # define xutrace(a, b) utrace((a), (b))
#endif /* __NetBSD__ */ #endif /* __minix */
/* /*
* MALLOC_PRODUCTION disables assertions and statistics gathering. It also * MALLOC_PRODUCTION disables assertions and statistics gathering. It also
@ -159,7 +159,7 @@ __RCSID("$NetBSD: jemalloc.c,v 1.38 2015/07/26 17:21:55 martin Exp $");
#include <strings.h> #include <strings.h>
#include <unistd.h> #include <unistd.h>
#ifdef __NetBSD__ #ifdef __minix
# include <reentrant.h> # include <reentrant.h>
# include "extern.h" # include "extern.h"
@ -184,7 +184,7 @@ __strerror_r(int e, char *s, size_t l)
} }
return slen >= l ? ERANGE : rval; return slen >= l ? ERANGE : rval;
} }
#endif #endif /* __minix */
#ifdef __FreeBSD__ #ifdef __FreeBSD__
#define STRERROR_R(a, b, c) strerror_r(a, b, c); #define STRERROR_R(a, b, c) strerror_r(a, b, c);
@ -941,11 +941,11 @@ static bool malloc_init_hard(void);
* Begin mutex. * Begin mutex.
*/ */
#ifdef __NetBSD__ #ifdef __minix
#define malloc_mutex_init(m) mutex_init(m, NULL) #define malloc_mutex_init(m) mutex_init(m, NULL)
#define malloc_mutex_lock(m) mutex_lock(m) #define malloc_mutex_lock(m) mutex_lock(m)
#define malloc_mutex_unlock(m) mutex_unlock(m) #define malloc_mutex_unlock(m) mutex_unlock(m)
#else /* __NetBSD__ */ #else /* __minix */
static inline void static inline void
malloc_mutex_init(malloc_mutex_t *a_mutex) malloc_mutex_init(malloc_mutex_t *a_mutex)
{ {
@ -969,7 +969,7 @@ malloc_mutex_unlock(malloc_mutex_t *a_mutex)
if (__isthreaded) if (__isthreaded)
_SPINUNLOCK(&a_mutex->lock); _SPINUNLOCK(&a_mutex->lock);
} }
#endif /* __NetBSD__ */ #endif /* __minix */
/* /*
* End mutex. * End mutex.
@ -3952,7 +3952,7 @@ free(void *ptr)
/* /*
* Begin non-standard functions. * Begin non-standard functions.
*/ */
#ifndef __NetBSD__ #ifndef __minix
size_t size_t
malloc_usable_size(const void *ptr) malloc_usable_size(const void *ptr)
{ {

View File

@ -104,27 +104,31 @@ void utrace(struct ut *, int);
#endif /* defined(__minix) */ #endif /* defined(__minix) */
#include <sys/types.h> #include <sys/types.h>
#if defined(__NetBSD__) #ifdef __minix /* MINIX-specific tracing and locking */
# define malloc_minsize 16U #define malloc_minsize 16U
# define HAS_UTRACE #define HAS_UTRACE
# define UTRACE_LABEL "malloc", #define UTRACE_LABEL "malloc",
#include <sys/cdefs.h> #include <sys/cdefs.h>
#include "extern.h" #include "extern.h"
#if defined(LIBC_SCCS) && !defined(lint) #if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: malloc.c,v 1.56 2014/09/18 13:58:20 christos Exp $"); __RCSID("$NetBSD: malloc.c,v 1.56 2014/09/18 13:58:20 christos Exp $");
#endif /* LIBC_SCCS and not lint */ #endif /* LIBC_SCCS and not lint */
int utrace(const char *, void *, size_t); int utrace(const char *, void *, size_t);
#include <reentrant.h> #include <reentrant.h>
extern int __isthreaded; extern int __isthreaded;
static mutex_t thread_lock = MUTEX_INITIALIZER; static mutex_t thread_lock = MUTEX_INITIALIZER;
#define _MALLOC_LOCK() if (__isthreaded) mutex_lock(&thread_lock); #define _MALLOC_LOCK() \
#define _MALLOC_UNLOCK() if (__isthreaded) mutex_unlock(&thread_lock); if (__isthreaded) \
#endif /* __NetBSD__ */ mutex_lock(&thread_lock);
#define _MALLOC_UNLOCK() \
if (__isthreaded) \
mutex_unlock(&thread_lock);
#endif /* __minix */
#if defined(__sparc__) && defined(sun) #if defined(__sparc__) && defined(sun)
# define malloc_minsize 16U #define malloc_minsize 16U
# define MAP_ANON (0) #define MAP_ANON (0)
static int fdzero; static int fdzero;
# define MMAP_FD fdzero # define MMAP_FD fdzero
# define INIT_MMAP() \ # define INIT_MMAP() \

View File

@ -36,10 +36,10 @@ __RCSID("$NetBSD: strfmon.c,v 1.10 2012/03/21 14:19:15 christos Exp $");
#endif #endif
#endif /* LIBC_SCCS and not lint */ #endif /* LIBC_SCCS and not lint */
#if defined(__NetBSD__) || defined(__minix) #ifdef __minix /* MINIX uses namespace wrappers */
#include "namespace.h" #include "namespace.h"
#include <monetary.h> #include <monetary.h>
#endif #endif /* __minix */
#include <sys/types.h> #include <sys/types.h>
#include <assert.h> #include <assert.h>

View File

@ -90,7 +90,7 @@
** Nested includes ** Nested includes
*/ */
#if !defined(__NetBSD__) && !defined(__minix) #ifndef __minix
/* Avoid clashes with NetBSD by renaming NetBSD's declarations. */ /* Avoid clashes with NetBSD by renaming NetBSD's declarations. */
#define localtime_rz sys_localtime_rz #define localtime_rz sys_localtime_rz
#define mktime_z sys_mktime_z #define mktime_z sys_mktime_z
@ -406,7 +406,7 @@ void tzset(void);
extern char * asctime_r(struct tm const *restrict, char *restrict); extern char * asctime_r(struct tm const *restrict, char *restrict);
#endif #endif
#if defined(USG_COMPAT) && !defined(__NetBSD__) && !defined(__minix) #if defined(USG_COMPAT) && !defined(__minix)
# ifndef timezone # ifndef timezone
extern long timezone; extern long timezone;
# endif # endif
@ -449,9 +449,8 @@ time_t posix2time(time_t);
/* Infer TM_ZONE on systems where this information is known, but suppress /* Infer TM_ZONE on systems where this information is known, but suppress
guessing if NO_TM_ZONE is defined. Similarly for TM_GMTOFF. */ guessing if NO_TM_ZONE is defined. Similarly for TM_GMTOFF. */
#if (defined __GLIBC__ \ #if (defined __GLIBC__ || defined __FreeBSD__ || defined __minix || \
|| defined __FreeBSD__ || defined __minix || defined __NetBSD__ || defined __OpenBSD__ \ defined __OpenBSD__ || (defined __APPLE__ && defined __MACH__))
|| (defined __APPLE__ && defined __MACH__))
# if !defined TM_GMTOFF && !defined NO_TM_GMTOFF # if !defined TM_GMTOFF && !defined NO_TM_GMTOFF
# define TM_GMTOFF tm_gmtoff # define TM_GMTOFF tm_gmtoff
# endif # endif
@ -468,7 +467,7 @@ time_t posix2time(time_t);
** is not done here. What we call 'struct state' NetBSD calls ** is not done here. What we call 'struct state' NetBSD calls
** 'struct __state', but this is a private name so it doesn't matter. ** 'struct __state', but this is a private name so it doesn't matter.
*/ */
#if !defined(__NetBSD__) && !defined(__minix) #ifndef __minix
#if NETBSD_INSPIRED #if NETBSD_INSPIRED
typedef struct state *timezone_t; typedef struct state *timezone_t;
struct tm *localtime_rz(timezone_t restrict, time_t const *restrict, struct tm *localtime_rz(timezone_t restrict, time_t const *restrict,

View File

@ -98,9 +98,8 @@ typedef long intmax_t;
/* Infer TM_ZONE on systems where this information is known, but suppress /* Infer TM_ZONE on systems where this information is known, but suppress
guessing if NO_TM_ZONE is defined. Similarly for TM_GMTOFF. */ guessing if NO_TM_ZONE is defined. Similarly for TM_GMTOFF. */
#if (defined __GLIBC__ \ #if (defined __GLIBC__ || defined __FreeBSD__ || defined __minix || \
|| defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ \ defined __OpenBSD__ || (defined __APPLE__ && defined __MACH__))
|| (defined __APPLE__ && defined __MACH__))
# if !defined TM_GMTOFF && !defined NO_TM_GMTOFF # if !defined TM_GMTOFF && !defined NO_TM_GMTOFF
# define TM_GMTOFF tm_gmtoff # define TM_GMTOFF tm_gmtoff
# endif # endif

View File

@ -45,7 +45,8 @@
* seems to actually advertise this properly, despite Unicode 3.1 having * seems to actually advertise this properly, despite Unicode 3.1 having
* been around since 2001... */ * been around since 2001... */
#if !defined(__minix) #if !defined(__minix)
#if !defined(__NetBSD__) && !defined(__sun) && !(defined(__APPLE__) && defined(__MACH__)) && !defined(__OpenBSD__) && !defined(__FreeBSD__) #if !defined(__sun) && !(defined(__APPLE__) && defined(__MACH__)) && \
!defined(__OpenBSD__) && !defined(__FreeBSD__)
#ifndef __STDC_ISO_10646__ #ifndef __STDC_ISO_10646__
/* In many places it is assumed that the first 127 code points are ASCII /* In many places it is assumed that the first 127 code points are ASCII
* compatible, so ensure wchar_t indeed does ISO 10646 and not some other * compatible, so ensure wchar_t indeed does ISO 10646 and not some other

View File

@ -238,60 +238,106 @@ static Shell shells[] = {
* non-portable features that might not be supplied by all * non-portable features that might not be supplied by all
* sh-compatible shells. * sh-compatible shells.
*/ */
{ {
DEFSHELL_CUSTOM, DEFSHELL_CUSTOM,
FALSE, "", "", "", 0, FALSE,
FALSE, "echo \"%s\"\n", "%s\n", "{ %s \n} || exit $?\n", "'\n'", '#',
"", "",
"", "",
}, "",
0,
FALSE,
"echo \"%s\"\n",
"%s\n",
"{ %s \n} || exit $?\n",
"'\n'",
'#',
"",
"",
},
#endif /* DEFSHELL_CUSTOM */ #endif /* DEFSHELL_CUSTOM */
/* /*
* SH description. Echo control is also possible and, under * SH description. Echo control is also possible and, under
* sun UNIX anyway, one can even control error checking. * sun UNIX anyway, one can even control error checking.
*/ */
{ {
"sh", "sh",
FALSE, "", "", "", 0, FALSE,
FALSE, "echo \"%s\"\n", "%s\n", "{ %s \n} || exit $?\n", "'\n'", '#', "",
#if defined(MAKE_NATIVE) && defined(__NetBSD__) "",
"",
0,
FALSE,
"echo \"%s\"\n",
"%s\n",
"{ %s \n} || exit $?\n",
"'\n'",
'#',
#if defined(MAKE_NATIVE) && defined(__minix)
"q", "q",
#else #else
"", "",
#endif #endif
"", "",
}, },
/* /*
* KSH description. * KSH description.
*/ */
{ {
"ksh", "ksh",
TRUE, "set +v", "set -v", "set +v", 6, TRUE,
FALSE, "echo \"%s\"\n", "%s\n", "{ %s \n} || exit $?\n", "'\n'", '#', "set +v",
"set -v",
"set +v",
6,
FALSE,
"echo \"%s\"\n",
"%s\n",
"{ %s \n} || exit $?\n",
"'\n'",
'#',
"v", "v",
"", "",
}, },
/* /*
* CSH description. The csh can do echo control by playing * CSH description. The csh can do echo control by playing
* with the setting of the 'echo' shell variable. Sadly, * with the setting of the 'echo' shell variable. Sadly,
* however, it is unable to do error control nicely. * however, it is unable to do error control nicely.
*/ */
{ {
"csh", "csh",
TRUE, "unset verbose", "set verbose", "unset verbose", 10, TRUE,
FALSE, "echo \"%s\"\n", "csh -c \"%s || exit 0\"\n", "", "'\\\n'", '#', "unset verbose",
"v", "e", "set verbose",
}, "unset verbose",
10,
FALSE,
"echo \"%s\"\n",
"csh -c \"%s || exit 0\"\n",
"",
"'\\\n'",
'#',
"v",
"e",
},
/* /*
* UNKNOWN. * UNKNOWN.
*/ */
{ {
NULL, NULL,
FALSE, NULL, NULL, NULL, 0, FALSE,
FALSE, NULL, NULL, NULL, NULL, 0, NULL,
NULL, NULL, NULL,
} NULL,
}; 0,
FALSE,
NULL,
NULL,
NULL,
NULL,
0,
NULL,
NULL,
}};
static Shell *commandShell = &shells[DEFSHELL_INDEX]; /* this is the shell to static Shell *commandShell = &shells[DEFSHELL_INDEX]; /* this is the shell to
* which we pass all * which we pass all
* commands in the Makefile. * commands in the Makefile.

View File

@ -61,7 +61,7 @@ void usage(void)
exit(1); exit(1);
} }
#if HAVE_NBTOOL_CONFIG_H && !defined(__NetBSD__) #if HAVE_NBTOOL_CONFIG_H && defined(__minix)
#define arc4random() rand() #define arc4random() rand()
#endif #endif

View File

@ -32,7 +32,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint #ifndef lint
#ifdef __NetBSD__ #ifdef __minix
__RCSID("$NetBSD: fast_ipsec.c,v 1.20 2013/04/15 21:20:39 christos Exp $"); __RCSID("$NetBSD: fast_ipsec.c,v 1.20 2013/04/15 21:20:39 christos Exp $");
#endif #endif
#endif /* not lint*/ #endif /* not lint*/

View File

@ -64,7 +64,7 @@
#if 0 #if 0
static char sccsid[] = "from: @(#)inet.c 8.4 (Berkeley) 4/20/94"; static char sccsid[] = "from: @(#)inet.c 8.4 (Berkeley) 4/20/94";
#else #else
#ifdef __NetBSD__ #ifdef __minix
__RCSID("$NetBSD: pfkey.c,v 1.1 2012/01/06 14:21:16 drochner Exp $"); __RCSID("$NetBSD: pfkey.c,v 1.1 2012/01/06 14:21:16 drochner Exp $");
#endif #endif
#endif #endif

View File

@ -54,7 +54,7 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <syslog.h> #include <syslog.h>
#if defined(__NetBSD__) || defined(__minix) #if defined(__minix)
#include <util.h> #include <util.h>
#endif #endif
#include <poll.h> #include <poll.h>
@ -255,7 +255,7 @@ main(int argc, char *argv[])
sock_open(); sock_open();
#if defined(__NetBSD__) || defined(__minix) #if defined(__minix)
/* record the current PID */ /* record the current PID */
if (pidfile(NULL) < 0) { if (pidfile(NULL) < 0) {
syslog(LOG_ERR, syslog(LOG_ERR,