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