xref: /netbsd-src/external/bsd/tcpdump/dist/machdep.c (revision 26ba0b503b498a5194a71ac319838b7f5497f3fe)
10f74e101Schristos /*
20f74e101Schristos  * Copyright (c) 1996, 1997
30f74e101Schristos  *	The Regents of the University of California.  All rights reserved.
40f74e101Schristos  *
50f74e101Schristos  * Redistribution and use in source and binary forms, with or without
60f74e101Schristos  * modification, are permitted provided that: (1) source code distributions
70f74e101Schristos  * retain the above copyright notice and this paragraph in its entirety, (2)
80f74e101Schristos  * distributions including binary code include the above copyright notice and
90f74e101Schristos  * this paragraph in its entirety in the documentation or other materials
100f74e101Schristos  * provided with the distribution, and (3) all advertising materials mentioning
110f74e101Schristos  * features or use of this software display the following acknowledgement:
120f74e101Schristos  * ``This product includes software developed by the University of California,
130f74e101Schristos  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
140f74e101Schristos  * the University nor the names of its contributors may be used to endorse
150f74e101Schristos  * or promote products derived from this software without specific prior
160f74e101Schristos  * written permission.
170f74e101Schristos  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
180f74e101Schristos  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
190f74e101Schristos  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
200f74e101Schristos  */
210f74e101Schristos 
2211b3aaa1Schristos #include <sys/cdefs.h>
230f74e101Schristos #ifndef lint
24*26ba0b50Schristos __RCSID("$NetBSD: machdep.c,v 1.9 2024/09/02 16:15:30 christos Exp $");
250f74e101Schristos #endif
260f74e101Schristos 
27c74ad251Schristos #include <config.h>
280f74e101Schristos 
29c74ad251Schristos #include <stddef.h>
300f74e101Schristos 
310f74e101Schristos #ifdef __osf__
32c74ad251Schristos #include <stdio.h>
330f74e101Schristos #include <sys/sysinfo.h>
340f74e101Schristos #include <sys/proc.h>
350f74e101Schristos #endif /* __osf__ */
360f74e101Schristos 
37c74ad251Schristos #include "varattrs.h"
380f74e101Schristos #include "machdep.h"
390f74e101Schristos 
40ba2ff121Schristos /*
41ba2ff121Schristos  * On platforms where the CPU doesn't support unaligned loads, force
42ba2ff121Schristos  * unaligned accesses to abort with SIGBUS, rather than being fixed
43ba2ff121Schristos  * up (slowly) by the OS kernel; on those platforms, misaligned accesses
44ba2ff121Schristos  * are bugs, and we want tcpdump to crash so that the bugs are reported.
45ba2ff121Schristos  *
46ba2ff121Schristos  * The only OS on which this is necessary is DEC OSF/1^W^WDigital
47ba2ff121Schristos  * UNIX^W^WTru64 UNIX.
48ba2ff121Schristos  */
490f74e101Schristos int
500f74e101Schristos abort_on_misalignment(char *ebuf _U_, size_t ebufsiz _U_)
510f74e101Schristos {
520f74e101Schristos #ifdef __osf__
530f74e101Schristos 	static int buf[2] = { SSIN_UACPROC, UAC_SIGBUS };
540f74e101Schristos 
550f74e101Schristos 	if (setsysinfo(SSI_NVPAIRS, (caddr_t)buf, 1, 0, 0) < 0) {
560f74e101Schristos 		(void)snprintf(ebuf, ebufsiz, "setsysinfo: errno %d", errno);
570f74e101Schristos 		return (-1);
580f74e101Schristos 	}
590f74e101Schristos #endif
600f74e101Schristos 	return (0);
610f74e101Schristos }
62