1 /*
2  * SPDX-License-Identifier: BSD-3-Clause
3  *
4  * Copyright (c) 2022 Tomohiro Kusumi <tkusumi@netbsd.org>
5  * Copyright (c) 2011-2022 The DragonFly Project.  All rights reserved.
6  *
7  * This code is derived from software contributed to The DragonFly Project
8  * by Matthew Dillon <dillon@dragonflybsd.org>
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in
18  *    the documentation and/or other materials provided with the
19  *    distribution.
20  * 3. Neither the name of The DragonFly Project nor the names of its
21  *    contributors may be used to endorse or promote products derived
22  *    from this software without specific, prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
28  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29  * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
30  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
32  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
34  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35  * SUCH DAMAGE.
36  */
37 
38 #ifndef _HAMMER2_HAMMER2_COMPAT_H
39 #define _HAMMER2_HAMMER2_COMPAT_H
40 
41 #include <sys/statvfs.h>
42 #include <sys/spinlock.h>
43 #include <sys/uio.h> /* struct iovec */
44 
45 #include <stdio.h>
46 #include <stdlib.h>
47 #include <string.h>
48 #include <util.h> /* ecalloc */
49 #include <assert.h>
50 #include <err.h>
51 
52 #include "ffs/buf.h"
53 
54 #define INVARIANTS
55 
56 #define MALLOC_DECLARE(type)				struct __hack
57 #define MALLOC_DEFINE(type, shortdesc, longdesc)	struct __hack
58 
59 #define SYSCTL_NODE(parent, nbr, name, access, handler, descr)	struct __hack
60 #define SYSCTL_INT(parent, nbr, name, access, ptr, val, descr)	struct __hack
61 #define SYSCTL_LONG(parent, nbr, name, access, ptr, val, descr)	struct __hack
62 
63 #define VFS_SET(vfsops, fsname, flags)	struct __hack
64 
65 #define MODULE_VERSION(module, version)	struct __hack
66 
67 #define VOP_FSYNC(vp, waitfor, flags)	(0)
68 
69 #define kprintf(s, ...)		printf(s, ## __VA_ARGS__)
70 #define krateprintf(r, X, ...)	kprintf(X, ## __VA_ARGS__)
71 #define ksnprintf(s, n, ...)	snprintf(s, n, ## __VA_ARGS__)
72 #define kstrdup(str, type)	strdup(str)
73 
74 #define kmalloc_create(typep, descr)	do{}while(0)
75 #define kmalloc_destroy(typep)		do{}while(0)
76 #define kmalloc(size, type, flags)	ecalloc(1, size)
77 #define kfree(addr, type)		free(addr)
78 
79 #define kmalloc_create_obj(typep, descr, objsize)	do{}while(0)
80 #define kmalloc_destroy_obj(type)			do{}while(0)
81 #define kmalloc_obj(size, type, flags)			ecalloc(1, size)
82 #define kfree_obj(addr, type)				free(addr)
83 
84 #define kmalloc_raise_limit(typep, bytes)		do{}while(0)
85 
86 #define KASSERT(exp, msg)	do { if (!(exp)) panic msg; } while(0)
87 //#define KASSERT(exp, msg)	assert(exp)
88 #define KKASSERT(exp)		assert(exp)
89 
90 #define panic(s, ...)		errx(1, s, ## __VA_ARGS__)
91 
92 #define ERESTART	(-1)
93 
94 #define LK_SHARED	0x00000001
95 #define LK_EXCLUSIVE	0x00000002
96 #define LK_RELEASE	0x00000006
97 #define LK_NOWAIT	0x00000010
98 #define LK_RETRY	0x00020000
99 
100 #define MTX_EXCLUSIVE	0x80000000
101 #define MTX_MASK	0x0FFFFFFF
102 
103 #define IO_APPEND	0x0002
104 #define IO_SYNC		0x0004
105 #define IO_ASYNC	0x0080
106 #define IO_DIRECT	0x0100
107 #define IO_RECURSE	0x0200
108 
109 #define IO_SEQMAX	0x7F
110 #define IO_SEQSHIFT	16
111 
112 #define VROOT		0x00000001
113 #define VKVABIO		0x00000040
114 #define VLASTWRITETS	0x00080000
115 
116 #define VNOVAL		(-1)
117 
118 #define FORCECLOSE	0x0002
119 
120 #define GETBLK_BHEAVY	0x0002
121 #define GETBLK_KVABIO	0x0010
122 
123 #define NOOFFSET	(-1LL)
124 
125 #define KNOTE(list, hint)
126 
127 #define NOTE_DELETE	0x0001
128 #define NOTE_WRITE	0x0002
129 #define NOTE_EXTEND	0x0004
130 #define NOTE_LINK	0x0010
131 
132 extern int hz;
133 extern int ticks;
134 extern int64_t vnode_count;
135 
136 struct thread {
137 	void *td_proc;
138 };
139 
140 typedef struct thread *thread_t;
141 extern struct thread *curthread;
142 
143 struct lwkt_token {
144 };
145 
146 typedef struct lwkt_token *lwkt_token_t;
147 
148 struct mount {
149 	int mnt_flag;
150 	int mnt_kern_flag;
151 	struct statfs mnt_stat;
152 	struct statvfs mnt_vstat;
153 	qaddr_t mnt_data;
154 	unsigned int mnt_iosize_max;
155 };
156 
157 struct bio {
158 	struct buf *bio_buf;
159 	off_t bio_offset;
160 };
161 
162 struct bio_track {
163 };
164 
165 struct namecache {
166 	u_char nc_nlen;
167 	char *nc_name;
168 };
169 
170 struct nchandle {
171 	struct namecache *ncp;
172 };
173 
174 struct vop_generic_args {
175 	int a_reserved[4];
176 };
177 
178 struct vop_open_args {
179 	struct vnode *a_vp;
180 	int a_mode;
181 	struct ucred *a_cred;
182 	struct file **a_fpp;
183 };
184 
185 struct vop_close_args {
186 	struct vnode *a_vp;
187 	int a_fflag;
188 	struct file *a_fp;
189 };
190 
191 struct vop_access_args {
192 	struct vnode *a_vp;
193 	int a_mode;
194 	int a_flags;
195 	struct ucred *a_cred;
196 };
197 
198 struct vop_getattr_args {
199 	struct vnode *a_vp;
200 	struct vattr *a_vap;
201 };
202 
203 struct vop_getattr_lite_args {
204 	struct vnode *a_vp;
205 	struct vattr_lite *a_lvap;
206 };
207 
208 struct vop_setattr_args {
209 	struct vnode *a_vp;
210 	struct vattr *a_vap;
211 	struct ucred *a_cred;
212 };
213 
214 struct vop_read_args {
215 	struct vnode *a_vp;
216 	struct uio *a_uio;
217 	int a_ioflag;
218 	struct ucred *a_cred;
219 };
220 
221 struct vop_write_args {
222 	struct vnode *a_vp;
223 	struct uio *a_uio;
224 	int a_ioflag;
225 	struct ucred *a_cred;
226 };
227 
228 struct vop_ioctl_args {
229 	struct vnode *a_vp;
230 	u_long a_command;
231 	caddr_t a_data;
232 	int a_fflag;
233 	struct ucred *a_cred;
234 	struct sysmsg *a_sysmsg;
235 };
236 
237 struct vop_kqfilter_args {
238 	struct vnode *a_vp;
239 	struct knote *a_kn;
240 };
241 
242 struct vop_fsync_args {
243 	struct vnode *a_vp;
244 	int a_waitfor;
245 	int a_flags;
246 };
247 
248 struct vop_readdir_args {
249 	struct vnode *a_vp;
250 	struct uio *a_uio;
251 	struct ucred *a_cred;
252 	int *a_eofflag;
253 	int *a_ncookies;
254 	off_t **a_cookies;
255 };
256 
257 struct vop_readlink_args {
258 	struct vnode *a_vp;
259 	struct uio *a_uio;
260 	struct ucred *a_cred;
261 };
262 
263 struct vop_inactive_args {
264 	struct vnode *a_vp;
265 };
266 
267 struct vop_reclaim_args {
268 	struct vnode *a_vp;
269 };
270 
271 struct vop_bmap_args {
272 	struct vnode *a_vp;
273 	off_t a_loffset;
274 	off_t *a_doffsetp;
275 	int *a_runp;
276 	int *a_runb;
277 	buf_cmd_t a_cmd;
278 };
279 
280 struct vop_strategy_args {
281 	struct vnode *a_vp;
282 	struct bio *a_bio;
283 };
284 
285 struct vop_advlock_args {
286 	struct vnode *a_vp;
287 	caddr_t a_id;
288 	int a_op;
289 	struct flock *a_fl;
290 	int a_flags;
291 };
292 
293 struct vop_getpages_args {
294 	struct vnode *a_vp;
295 	int a_count;
296 	int a_reqpage;
297 	//vm_ooffset_t a_offset;
298 	int a_seqaccess;
299 };
300 
301 struct vop_putpages_args {
302 	struct vnode *a_vp;
303 	int a_count;
304 	int a_flags;
305 	int *a_rtvals;
306 	//vm_ooffset_t a_offset;
307 };
308 
309 struct vop_mountctl_args {
310 	int a_op;
311 	struct file *a_fp;
312 	const void *a_ctl;
313 	int a_ctllen;
314 	void *a_buf;
315 	int a_buflen;
316 	int *a_res;
317 	struct vnode *a_vp;
318 };
319 
320 struct vop_markatime_args {
321 	int a_op;
322 	struct vnode *a_vp;
323 	struct ucred *a_cred;
324 };
325 
326 struct vop_nresolve_args {
327 	struct nchandle *a_nch;
328 	struct vnode *a_dvp;
329 	struct ucred *a_cred;
330 	struct vnode **a_vpp; /* makefs */
331 };
332 
333 struct vop_nlookupdotdot_args {
334 	struct vnode *a_dvp;
335 	struct vnode **a_vpp;
336 	struct ucred *a_cred;
337 	char **a_fakename;
338 };
339 
340 struct vop_ncreate_args {
341 	struct nchandle *a_nch;
342 	struct vnode *a_dvp;
343 	struct vnode **a_vpp;
344 	struct ucred *a_cred;
345 	struct vattr *a_vap;
346 };
347 
348 struct vop_nmkdir_args {
349 	struct nchandle *a_nch;
350 	struct vnode *a_dvp;
351 	struct vnode **a_vpp;
352 	struct ucred *a_cred;
353 	struct vattr *a_vap;
354 };
355 
356 struct vop_nmknod_args {
357 	struct nchandle *a_nch;
358 	struct vnode *a_dvp;
359 	struct vnode **a_vpp;
360 	struct ucred *a_cred;
361 	struct vattr *a_vap;
362 };
363 
364 struct vop_nlink_args {
365 	struct nchandle *a_nch;
366 	struct vnode *a_dvp;
367 	struct vnode *a_vp;
368 	struct ucred *a_cred;
369 };
370 
371 struct vop_nsymlink_args {
372 	struct nchandle *a_nch;
373 	struct vnode *a_dvp;
374 	struct vnode **a_vpp;
375 	struct ucred *a_cred;
376 	struct vattr *a_vap;
377 	char *a_target;
378 };
379 
380 struct vop_nremove_args {
381 	struct nchandle *a_nch;
382 	struct vnode *a_dvp;
383 	struct ucred *a_cred;
384 };
385 
386 struct vop_nrmdir_args {
387 	struct nchandle *a_nch;
388 	struct vnode *a_dvp;
389 	struct ucred *a_cred;
390 };
391 
392 struct vop_nrename_args {
393 	struct nchandle *a_fnch;
394 	struct nchandle *a_tnch;
395 	struct vnode *a_fdvp;
396 	struct vnode *a_tdvp;
397 	struct ucred *a_cred;
398 };
399 
400 #define vop_defaultop	NULL
401 #define vop_stdgetpages	NULL
402 #define vop_stdputpages	NULL
403 #define vop_stdnoread	NULL
404 #define vop_stdnowrite	NULL
405 #define fifo_vnoperate	NULL
406 
407 struct vop_ops {
408 	int (*vop_default)(struct vop_generic_args *);
409 	int (*vop_open)(struct vop_open_args *);
410 	int (*vop_close)(struct vop_close_args *);
411 	int (*vop_access)(struct vop_access_args *);
412 	int (*vop_getattr)(struct vop_getattr_args *);
413 	int (*vop_getattr_lite)(struct vop_getattr_lite_args *);
414 	int (*vop_setattr)(struct vop_setattr_args *);
415 	int (*vop_read)(struct vop_read_args *);
416 	int (*vop_write)(struct vop_write_args *);
417 	int (*vop_ioctl)(struct vop_ioctl_args *);
418 	int (*vop_kqfilter)(struct vop_kqfilter_args *);
419 	int (*vop_fsync)(struct vop_fsync_args *);
420 	int (*vop_readdir)(struct vop_readdir_args *);
421 	int (*vop_readlink)(struct vop_readlink_args *);
422 	int (*vop_inactive)(struct vop_inactive_args *);
423 	int (*vop_reclaim)(struct vop_reclaim_args *);
424 	int (*vop_bmap)(struct vop_bmap_args *);
425 	int (*vop_strategy)(struct vop_strategy_args *);
426 	int (*vop_advlock)(struct vop_advlock_args *);
427 	int (*vop_getpages)(struct vop_getpages_args *);
428 	int (*vop_putpages)(struct vop_putpages_args *);
429 	int (*vop_mountctl)(struct vop_mountctl_args *);
430 	int (*vop_markatime)(struct vop_markatime_args *);
431 	int (*vop_nresolve)(struct vop_nresolve_args *);
432 	int (*vop_nlookupdotdot)(struct vop_nlookupdotdot_args *);
433 	int (*vop_ncreate)(struct vop_ncreate_args *);
434 	int (*vop_nmkdir)(struct vop_nmkdir_args *);
435 	int (*vop_nmknod)(struct vop_nmknod_args *);
436 	int (*vop_nlink)(struct vop_nlink_args *);
437 	int (*vop_nsymlink)(struct vop_nsymlink_args *);
438 	int (*vop_nremove)(struct vop_nremove_args *);
439 	int (*vop_nrmdir)(struct vop_nrmdir_args *);
440 	int (*vop_nrename)(struct vop_nrename_args *);
441 };
442 
443 enum uio_seg {
444 	UIO_USERSPACE,
445 	UIO_SYSSPACE,
446 	UIO_NOCOPY,
447 };
448 
449 enum uio_rw {
450 	UIO_READ,
451 	UIO_WRITE
452 };
453 
454 struct uio {
455 	struct iovec *uio_iov;
456 	int uio_iovcnt;
457 	off_t uio_offset;
458 	size_t uio_resid;
459 	enum uio_seg uio_segflg;
460 	enum uio_rw uio_rw;
461 	struct thread *uio_td;
462 };
463 
464 /*
465  * Since makefs(8) is a single thread program, there should never be any
466  * lock contention.  Therefore, lock(9)/mutex(9)/spinlock(9) emulation always
467  * succeed.  Similarly, tsleep(9) should never be called.
468  */
469 struct lock {
470 	int reserved;
471 };
472 
473 typedef struct {
474 	unsigned int mtx_lock;
475 } mtx_t;
476 
477 typedef mtx_t hammer2_mtx_t;
478 
479 typedef u_int mtx_state_t;
480 typedef mtx_state_t hammer2_mtx_state_t;
481 
482 typedef struct spinlock hammer2_spin_t;
483 
484 static __inline
485 void
486 cpu_pause(void)
487 {
488 }
489 
490 static __inline
491 void
492 cpu_mfence(void)
493 {
494 }
495 
496 static __inline
497 void
498 cpu_lfence(void)
499 {
500 }
501 
502 static __inline
503 void
504 cpu_sfence(void)
505 {
506 }
507 
508 static __inline
509 void
510 cpu_ccfence(void)
511 {
512 }
513 
514 static __inline
515 void
516 trigger_syncer(struct mount *mp)
517 {
518 }
519 
520 static __inline
521 int
522 vfs_mountedon(struct vnode *vp)
523 {
524 	return (0);
525 }
526 
527 static __inline
528 uid_t
529 vop_helper_create_uid(struct mount *mp, mode_t dmode, uid_t duid,
530 			struct ucred *cred, mode_t *modep)
531 {
532 	return (getuid());
533 }
534 
535 static __inline
536 int
537 vinitvmio(struct vnode *vp, off_t filesize, int blksize, int boff)
538 {
539 	return (0);
540 }
541 
542 static __inline
543 int
544 getnewvnode(enum vtagtype tag, struct mount *mp, struct vnode **vpp,
545 		int lktimeout, int lkflags)
546 {
547 	struct vnode *vp;
548 
549 	vp = ecalloc(1, sizeof(*vp));
550 	vp->v_logical = 1;
551 	vp->v_malloced = 1;
552 	*vpp = vp;
553 
554 	vnode_count++;
555 
556 	return (0);
557 }
558 
559 /* not freesomevnodes() */
560 static __inline
561 void
562 freevnode(struct vnode *vp)
563 {
564 	assert(vp->v_malloced);
565 	free(vp);
566 
567 	vnode_count--;
568 }
569 
570 static __inline
571 int
572 vn_lock(struct vnode *vp, int flags)
573 {
574 	return (0);
575 }
576 
577 static __inline
578 void
579 vn_unlock(struct vnode *vp)
580 {
581 }
582 
583 static __inline
584 int
585 vget(struct vnode *vp, int flags)
586 {
587 	return (0);
588 }
589 
590 static __inline
591 void
592 vput(struct vnode *vp)
593 {
594 }
595 
596 static __inline
597 void
598 vrele(struct vnode *vp)
599 {
600 }
601 
602 static __inline
603 void
604 vhold(struct vnode *vp)
605 {
606 }
607 
608 static __inline
609 void
610 vdrop(struct vnode *vp)
611 {
612 }
613 
614 static __inline
615 void
616 vx_put(struct vnode *vp)
617 {
618 }
619 
620 static __inline
621 void
622 vx_downgrade(struct vnode *vp)
623 {
624 }
625 
626 static __inline
627 void
628 vfinalize(struct vnode *vp)
629 {
630 }
631 
632 static __inline
633 void
634 vsetflags(struct vnode *vp, int flags)
635 {
636 }
637 
638 static __inline
639 void
640 vclrflags(struct vnode *vp, int flags)
641 {
642 }
643 
644 static __inline
645 void
646 vsetisdirty(struct vnode *vp)
647 {
648 }
649 
650 static __inline
651 void
652 vclrisdirty(struct vnode *vp)
653 {
654 }
655 
656 static __inline
657 int
658 vfsync(struct vnode *vp, int waitfor, int passes,
659 	int (*checkdef)(struct buf *),
660 	int (*waitoutput)(struct vnode *, struct thread *))
661 {
662 	return (0);
663 }
664 
665 static __inline
666 int
667 nvtruncbuf(struct vnode *vp, off_t length, int blksize, int boff, int flags)
668 {
669 	return (0);
670 }
671 
672 static __inline
673 int
674 nvextendbuf(struct vnode *vp, off_t olength, off_t nlength, int oblksize,
675 		int nblksize, int oboff, int nboff, int flags)
676 {
677 	return (0);
678 }
679 
680 static __inline
681 void
682 addaliasu(struct vnode *vp, int x, int y)
683 {
684 }
685 
686 static __inline
687 void
688 bheavy(struct buf *bp)
689 {
690 }
691 
692 static __inline
693 void
694 bkvasync(struct buf *bp)
695 {
696 }
697 
698 static __inline
699 void
700 bwillwrite(int bytes)
701 {
702 }
703 
704 static __inline
705 void
706 BUF_KERNPROC(struct buf *bp)
707 {
708 }
709 
710 static __inline
711 int
712 bio_track_wait(struct bio_track *track, int slp_flags, int slp_timo)
713 {
714 	return (0);
715 }
716 
717 static __inline
718 void
719 cache_setvp(struct nchandle *nch, struct vnode *vp)
720 {
721 }
722 
723 static __inline
724 void
725 cache_setunresolved(struct nchandle *nch)
726 {
727 }
728 
729 static __inline
730 void
731 lockinit(struct lock *lkp, const char *wmesg, int timo, int flags)
732 {
733 }
734 
735 static __inline
736 int
737 lockmgr(struct lock *lkp, uint32_t flags)
738 {
739 	return (0);
740 }
741 
742 static __inline
743 int
744 hammer2_mtx_ex(hammer2_mtx_t *mtx)
745 {
746 	mtx->mtx_lock |= MTX_EXCLUSIVE;
747 	mtx->mtx_lock++;
748 	return (0);
749 }
750 
751 static __inline
752 int
753 hammer2_mtx_ex_try(hammer2_mtx_t *mtx)
754 {
755 	mtx->mtx_lock |= MTX_EXCLUSIVE;
756 	mtx->mtx_lock++;
757 	return (0);
758 }
759 
760 static __inline
761 int
762 hammer2_mtx_sh(hammer2_mtx_t *mtx)
763 {
764 	mtx->mtx_lock |= MTX_EXCLUSIVE;
765 	mtx->mtx_lock++;
766 	return (0);
767 }
768 
769 static __inline
770 void
771 hammer2_mtx_sh_again(hammer2_mtx_t *mtx)
772 {
773 	mtx->mtx_lock |= MTX_EXCLUSIVE;
774 	mtx->mtx_lock++;
775 }
776 
777 static __inline
778 int
779 hammer2_mtx_sh_try(hammer2_mtx_t *mtx)
780 {
781 	mtx->mtx_lock |= MTX_EXCLUSIVE;
782 	mtx->mtx_lock++;
783 	return (0);
784 }
785 
786 static __inline
787 void
788 hammer2_mtx_unlock(hammer2_mtx_t *mtx)
789 {
790 	mtx->mtx_lock &= ~MTX_EXCLUSIVE;
791 	mtx->mtx_lock--;
792 }
793 
794 static __inline
795 int
796 hammer2_mtx_upgrade_try(hammer2_mtx_t *mtx)
797 {
798 	return (0);
799 }
800 
801 static __inline
802 int
803 hammer2_mtx_downgrade(hammer2_mtx_t *mtx)
804 {
805 	return (0);
806 }
807 
808 static __inline
809 int
810 hammer2_mtx_owned(hammer2_mtx_t *mtx)
811 {
812 	return (1); /* XXX for asserts */
813 }
814 
815 static __inline
816 void
817 hammer2_mtx_init(hammer2_mtx_t *mtx, const char *ident)
818 {
819 	mtx->mtx_lock = 0;
820 }
821 
822 static __inline
823 hammer2_mtx_state_t
824 hammer2_mtx_temp_release(hammer2_mtx_t *mtx)
825 {
826 	return (0);
827 }
828 
829 static __inline
830 void
831 hammer2_mtx_temp_restore(hammer2_mtx_t *mtx, hammer2_mtx_state_t state)
832 {
833 }
834 
835 static __inline
836 int
837 hammer2_mtx_refs(hammer2_mtx_t *mtx)
838 {
839 	return (mtx->mtx_lock & MTX_MASK);
840 }
841 
842 static __inline
843 void
844 hammer2_spin_init(hammer2_spin_t *mtx, const char *ident)
845 {
846 	mtx->lock = 0;
847 }
848 
849 static __inline
850 void
851 hammer2_spin_sh(hammer2_spin_t *mtx)
852 {
853 	mtx->lock++;
854 }
855 
856 static __inline
857 void
858 hammer2_spin_ex(hammer2_spin_t *mtx)
859 {
860 	mtx->lock++;
861 }
862 
863 static __inline
864 void
865 hammer2_spin_unsh(hammer2_spin_t *mtx)
866 {
867 	mtx->lock--;
868 }
869 
870 static __inline
871 void
872 hammer2_spin_unex(hammer2_spin_t *mtx)
873 {
874 	mtx->lock--;
875 }
876 
877 static __inline
878 void
879 lwkt_gettoken(lwkt_token_t tok)
880 {
881 }
882 
883 static __inline
884 void
885 lwkt_reltoken(lwkt_token_t tok)
886 {
887 }
888 
889 static __inline
890 void
891 lwkt_yield(void)
892 {
893 }
894 
895 static __inline
896 int
897 tsleep(const volatile void *ident, int flags, const char *wmesg, int timo)
898 {
899 	assert(0);
900 }
901 
902 static __inline
903 void
904 tsleep_interlock(const volatile void *ident, int flags)
905 {
906 	assert(0);
907 }
908 
909 static __inline
910 void
911 wakeup(const volatile void *ident)
912 {
913 	assert(0);
914 }
915 
916 static __inline
917 void
918 print_backtrace(int count)
919 {
920 }
921 
922 static __inline
923 void
924 Debugger(const char *msg)
925 {
926 	panic("%s: %s", __func__, msg);
927 }
928 
929 #endif /* _HAMMER2_HAMMER2_COMPAT_H */
930