FreeBSD Bugzilla – Attachment 216332 Details for
Bug 233057
emulators/rtc: Fix build with stable/12
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch to clean up emulators/rtc port
patch-emulators_rtc.patch (text/plain), 12.39 KB, created by
Jamie Landeg-Jones
on 2020-07-09 00:22:59 UTC
(
hide
)
Description:
patch to clean up emulators/rtc port
Filename:
MIME Type:
Creator:
Jamie Landeg-Jones
Created:
2020-07-09 00:22:59 UTC
Size:
12.39 KB
patch
obsolete
>diff -ruN ../rtc.orig/Makefile ./Makefile >--- ../rtc.orig/Makefile 2019-10-09 15:14:17.000000000 +0100 >+++ ./Makefile 2020-07-08 21:36:10.012054000 +0100 >@@ -1,44 +1,30 @@ > # Created by: Akinori MUSHA aka knu <knu@idaemons.org> >-# $FreeBSD: head/emulators/rtc/Makefile 514157 2019-10-09 14:14:17Z tobik $ >+# $FreeBSD: head/emulators/rtc/Makefile 482846 2018-10-23 16:34:43Z jbeich $ > > PORTNAME= rtc >-PORTVERSION= 2004.02.24.1 >-PORTREVISION= 8 >+PORTVERSION= 2020.07.07.1 > CATEGORIES= emulators linux > MASTER_SITES= # none > DISTFILES= # none > >-MAINTAINER= emulation@FreeBSD.org >+MAINTAINER= jamie@catflap.org > COMMENT= Kernel module which provides /dev/rtc device support > >-BROKEN_FreeBSD_12= fails to compile: rtc.c:166:2: implicit declaration of function 'MALLOC' is invalid in C99 >-BROKEN_FreeBSD_13= fails to compile: rtc.c:166:2: implicit declaration of function 'MALLOC' is invalid in C99 >+LICENSE= BSD2CLAUSE > >+USES= kmod >+ > WRKSRC= ${WRKDIR}/files > >-KMODDIR= ${PREFIX}/modules >+MAKE_ARGS= KMODDIR="${KMODDIR}" > >-CDEV_MAJOR= 202 >-DEVDIR= ${LINUXBASE}/dev >- >-STARTUP= rtc.sh >-MAKE_ARGS= KMODDIR="${KMODDIR}" CDEV_MAJOR="${CDEV_MAJOR}" >-PLIST_SUB= DEVDIR="${DEVDIR}" CDEV_MAJOR="${CDEV_MAJOR}" \ >- RTC_H_DIR="${RTC_H_DIR}" >- >-USES= kmod linux uidfix >- > do-extract: > @${MKDIR} ${WRKSRC} >- @${SED} -e 's,@@PREFIX@@,${PREFIX},' \ >- ${FILESDIR}/${STARTUP} > ${WRKDIR}/${STARTUP} > @cd ${FILESDIR} && ${CP} Makefile *.[ch] ${WRKSRC}/ > > post-install: > ${INSTALL_DATA} ${WRKSRC}/rtc.h ${STAGEDIR}${PREFIX}/include > ${MKDIR} ${STAGEDIR}${EXAMPLESDIR} > ${INSTALL_DATA} ${WRKSRC}/test.c ${STAGEDIR}${EXAMPLESDIR} >- @${ECHO} "Installing ${PREFIX}/etc/rc.d/${STARTUP} startup file."; >- ${INSTALL_SCRIPT} ${WRKDIR}/${STARTUP} ${STAGEDIR}${PREFIX}/etc/rc.d > > .include <bsd.port.mk> >diff -ruN ../rtc.orig/files/Makefile ./files/Makefile >--- ../rtc.orig/files/Makefile 2019-11-07 16:30:12.000000000 +0000 >+++ ./files/Makefile 2020-07-08 21:36:10.012183000 +0100 >@@ -22,27 +22,17 @@ > # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > # SUCH DAMAGE. > # >-# $FreeBSD: head/emulators/rtc/files/Makefile 516983 2019-11-07 16:30:12Z rene $ >+# $FreeBSD: head/emulators/rtc/files/Makefile 458755 2018-01-11 16:53:44Z danfe $ > # > > SYS?= /sys >-NOMAN= YES > KMOD= rtc >-MODULE_DEPEND= linux >-CDEV_MAJOR?= 202 >-DEVNAME= ${KMOD} > SRCS= rtc.c rtc_linux.c vnode_if.h > > INCLUDE= -I${.CURDIR} -I${SYS} > >-CFLAGS+= ${INCLUDE} -DCDEV_MAJOR_=${CDEV_MAJOR} >+CFLAGS+= ${INCLUDE} > > all: vnode_if.h >- >-#afterinstall: device >- >-device: >- rm -f /dev/${DEVNAME} >- mknod /dev/${DEVNAME} c ${CDEV_MAJOR} 0 > > .include <bsd.kmod.mk> >diff -ruN ../rtc.orig/files/rtc.c ./files/rtc.c >--- ../rtc.orig/files/rtc.c 2014-01-24 00:14:07.000000000 +0000 >+++ ./files/rtc.c 2020-07-08 21:36:10.012493000 +0100 >@@ -50,11 +50,6 @@ > MODULE_DEPEND(rtc, linux, 1, 1, 1); > #endif > >-#define CDEV_MAJOR 202 >-#if defined(CDEV_MAJOR_) && CDEV_MAJOR != CDEV_MAJOR_ >-#error "CDEV_MAJOR != CDEV_MAJOR_" >-#endif >- > #define DEVICE_NAME "rtc" > > enum rtc_log_level {Lenter=0, Lexit=1, Linfo, Lwarning, Lfail}; >@@ -68,11 +63,7 @@ > #endif /* DEBUG */ > > struct rtc_softc { >-#if __FreeBSD_version >= 502117 > struct cdev *dev; /* Back reference to device */ >-#else >- dev_t dev; /* Back reference to device */ >-#endif > struct { > int freq; > struct { >@@ -97,40 +88,14 @@ > static int rtc_modeevent(module_t mod, int cmd, void *arg); > > static struct cdevsw rtc_cdevsw = { >-#if __FreeBSD_version >= 500104 >-#if __FreeBSD_version >= 502103 > .d_version = D_VERSION, > .d_flags = D_NEEDGIANT, >-#else >- .d_maj = CDEV_MAJOR, >-#endif > .d_open = rtc_open, > .d_close = rtc_close, > .d_ioctl = rtc_ioctl, > .d_poll = rtc_poll, > .d_read = rtc_read, > .d_name = DEVICE_NAME, >-#else >- /* open */ rtc_open, >- /* close */ rtc_close, >- /* read */ rtc_read, >- /* write */ nowrite, >- /* ioctl */ rtc_ioctl, >- /* poll */ rtc_poll, >- /* mmap */ nommap, >- /* strategy */ nostrategy, >- /* name */ DEVICE_NAME, >- /* maj */ CDEV_MAJOR, >- /* dump */ nodump, >- /* psize */ nopsize, >- /* flags */ 0, >-#if __FreeBSD_version <= 500018 >- /* bmaj */ -1, >-#endif >-#if __FreeBSD_version >= 500018 || __FreeBSD_version >= 430000 >- /* kqfilter */ nokqfilter, >-#endif >-#endif > }; > > /* >@@ -139,31 +104,22 @@ > */ > DEV_MODULE(rtc, rtc_modeevent, 0); > >- > /* -=-=-=-=-=-=-=-=-= attach/detach device stuff -=-=-=-=-=-=-=-=-= */ > > static struct rtc_softc * >-#if __FreeBSD_version >= 502017 > rtc_attach(struct cdev *dev) >-#else >-rtc_attach(dev_t dev) >-#endif > { > struct rtc_softc *sc; > int unit; > >-#if __FreeBSD_version >= 500014 > unit = dev2unit(dev); >-#else >- unit = lminor(dev); >-#endif > DLog(Lenter, "%d %p", unit, dev); > if (dev->si_drv1) { > DLog(Lexit, "old %p, %p", dev, dev->si_drv1); > return dev->si_drv1; > } > >- MALLOC(sc, struct rtc_softc*, sizeof(*sc), M_DEVBUF, M_WAITOK); >+ sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK); > if (sc==NULL) > return NULL; > >@@ -172,22 +128,14 @@ > sc->dev = dev; > sc->var.freq = 1; > >-#if __FreeBSD_version >= 500000 > callout_init(&sc->var.rtc_handle, 1); >-#else >- callout_init(&sc->var.rtc_handle); >-#endif > > DLog(Lexit, "new %p,%p", dev, sc); > return sc; > } > > static int >-#if __FreeBSD_version >= 502017 > rtc_detach(struct cdev *dev, struct rtc_softc *sc) >-#else >-rtc_detach(dev_t dev, struct rtc_softc *sc) >-#endif > { > int error=0; > >@@ -196,7 +144,7 @@ > } > > callout_stop(&sc->var.rtc_handle); >- FREE(sc, M_DEVBUF); >+ free(sc, M_DEVBUF); > dev->si_drv1 = NULL; > return error; > } >@@ -204,13 +152,7 @@ > /* -=-=-=-=-=-=-=-=-= character device stuff -=-=-=-=-=-=-=-=-= */ > > static int >-#if __FreeBSD_version >= 502017 > rtc_open(struct cdev *dev, int oflag, int otyp, struct thread *p) >-#elif __FreeBSD_version >= 500023 >-rtc_open(dev_t dev, int oflag, int otyp, struct thread *p) >-#else >-rtc_open(dev_t dev, int oflag, int otyp, struct proc *p) >-#endif > { > struct rtc_softc *sc; > >@@ -228,13 +170,7 @@ > } > > int >-#if __FreeBSD_version >= 502017 > rtc_close(struct cdev *dev, int fflag, int otyp, struct thread *p) >-#elif __FreeBSD_version >= 500023 >-rtc_close(dev_t dev, int fflag, int otyp, struct thread *p) >-#else >-rtc_close(dev_t dev, int fflag, int otyp, struct proc *p) >-#endif > { > struct rtc_softc *sc = (struct rtc_softc *) dev->si_drv1; > >@@ -244,13 +180,7 @@ > } > > int >-#if __FreeBSD_version >= 502017 > rtc_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int mode, struct thread *p) >-#elif __FreeBSD_version >= 500023 >-rtc_ioctl(dev_t dev, u_long cmd, caddr_t arg, int mode, struct thread *p) >-#else >-rtc_ioctl(dev_t dev, u_long cmd, caddr_t arg, int mode, struct proc *p) >-#endif > { > struct rtc_softc *sc = (struct rtc_softc *) dev->si_drv1; > int error=0, freq, sleep; >@@ -292,13 +222,7 @@ > } > > int >-#if __FreeBSD_version >= 502017 > rtc_poll(struct cdev *dev, int events, struct thread *p) >-#elif __FreeBSD_version >= 500023 >-rtc_poll(dev_t dev, int events, struct thread *p) >-#else >-rtc_poll(dev_t dev, int events, struct proc *p) >-#endif > { > struct rtc_softc *sc = (struct rtc_softc *) dev->si_drv1; > int revents = 0; >@@ -318,11 +242,7 @@ > } > > int >-#if __FreeBSD_version >= 502017 > rtc_read(struct cdev *dev, struct uio *uio, int flags __unused) >-#else >-rtc_read(dev_t dev, struct uio *uio, int flags __unused) >-#endif > { > struct rtc_softc *sc = (struct rtc_softc *) dev->si_drv1; > int error = 0; >@@ -351,23 +271,13 @@ > } > > /* -=-=-=-=-=-=-=-=-= module load/unload stuff -=-=-=-=-=-=-=-=-= */ >-#if __FreeBSD_version >= 502017 > static struct cdev *rtc_dev = NULL; >-#else >-static dev_t rtc_dev = NULL; >-#endif > > static int > init_module(void) > { > int error = 0; > >-#if __FreeBSD_version < 500104 >- error = cdevsw_add(&rtc_cdevsw); >- if (error) >- return error; >-#endif >- > rtc_dev = make_dev(&rtc_cdevsw, 0, UID_ROOT, GID_WHEEL, 0644, DEVICE_NAME); > if (rtc_dev==NULL) > error = ENOMEM; >@@ -375,17 +285,12 @@ > return error; > } > >- >- > static int > cleanup_module(void) > { > int error = 0; > > destroy_dev(rtc_dev); >-#if __FreeBSD_version < 500104 >- error = cdevsw_remove(&rtc_cdevsw); >-#endif > DLog(Linfo, "return %d", error); > return error; > } >@@ -433,23 +338,37 @@ > restart: > increment.tv_sec = 0; > increment.tv_nsec = 1000000000 / sc->var.freq; >+#if P_OSREL_MAJOR(__FreeBSD_version) >= 12 >+ timespecadd(&sc->var.lasttime, &increment, &sc->var.lasttime); >+ timespecadd(&sc->var.lasttime, &increment, &nexttime); >+#else > timespecadd(&sc->var.lasttime, &increment); > nexttime.tv_sec = sc->var.lasttime.tv_sec; > nexttime.tv_nsec = sc->var.lasttime.tv_nsec; > timespecadd(&nexttime, &increment); >+#endif > if (timespeccmp(&nexttime, &curtime, <)) { > /* Catch up if we lag curtime */ >- sc->var.lasttime.tv_sec = curtime.tv_sec; >- sc->var.lasttime.tv_nsec = curtime.tv_nsec; >- timespecsub(&sc->var.lasttime, &increment); >- timespecsub(&nexttime, &curtime); >+#if P_OSREL_MAJOR(__FreeBSD_version) >= 12 >+ timespecsub(&curtime, &increment, &sc->var.lasttime); >+ timespecsub(&nexttime, &curtime, &nexttime); >+#else >+ sc->var.lasttime.tv_sec = curtime.tv_sec; >+ sc->var.lasttime.tv_nsec = curtime.tv_nsec; >+ timespecsub(&sc->var.lasttime, &increment); >+ timespecsub(&nexttime, &curtime); >+#endif > #if 0 > printf("lagging curtime by %d.%ld\n", nexttime.tv_sec, nexttime.tv_nsec); > #endif > goto restart; > } else { >+#if P_OSREL_MAJOR(__FreeBSD_version) >= 12 >+ timespecsub(&nexttime, &curtime, &nexttime); >+#else > timespecsub(&nexttime, &curtime); >- sleep = nexttime.tv_nsec / (1000000000 / hz); >- } >- callout_reset(&sc->var.rtc_handle, sleep, &rtc_callback, xtp); >+#endif >+ sleep = nexttime.tv_nsec / (1000000000 / hz); >+ } >+ callout_reset(&sc->var.rtc_handle, sleep, &rtc_callback, xtp); > } >diff -ruN ../rtc.orig/files/rtc.sh ./files/rtc.sh >--- ../rtc.orig/files/rtc.sh 2014-01-24 00:14:07.000000000 +0000 >+++ ./files/rtc.sh 1970-01-01 01:00:00.000000000 +0100 >@@ -1,20 +0,0 @@ >-#!/bin/sh >- >-kmoddir=@@PREFIX@@/modules >-kmod=rtc.ko >- >-case "$1" in >-start) >- if [ -x $kmoddir/$kmod ]; then >- echo -n ' rtc' >- /sbin/kldload $kmoddir/$kmod >- fi >- ;; >-stop) >- /sbin/kldunload $kmod && echo -n ' rtc' >- ;; >-*) >- echo "Usage: `basename $0` {start|stop}" >&2 >- exit 64 >- ;; >-esac >diff -ruN ../rtc.orig/files/rtc_linux.c ./files/rtc_linux.c >--- ../rtc.orig/files/rtc_linux.c 2014-01-24 00:14:07.000000000 +0000 >+++ ./files/rtc_linux.c 2020-07-08 21:36:10.012726000 +0100 >@@ -35,11 +35,7 @@ > > #include <i386/linux/linux.h> > #include <i386/linux/linux_proto.h> >-#if __FreeBSD_version >= 500012 || __FreeBSD_version >= 430000 > #include <compat/linux/linux_ioctl.h> >-#else >-#include <i386/linux/linux_ioctl.h> >-#endif > > #include "rtc.h" > >@@ -62,27 +58,15 @@ > LINUX_IOCTL_SET(rtc, 0x7000, 0x70ff); > > static int >-#if __FreeBSD_version >= 500023 > linux_ioctl_rtc(struct thread *p, struct linux_ioctl_args *args) >-#else >-linux_ioctl_rtc(struct proc *p, struct linux_ioctl_args *args) >-#endif > { > switch (args->cmd & 0xffff) { > case LINUX_RTC_PIE_ON: > args->cmd=RTCIO_PIE_ON; >-#if __FreeBSD_version >= 900044 > return sys_ioctl(p, (struct ioctl_args*)args); >-#else >- return ioctl(p, (struct ioctl_args*)args); >-#endif > case LINUX_RTC_IRQP_SET: > args->cmd=RTCIO_IRQP_SET; >-#if __FreeBSD_version >= 900044 > return sys_ioctl(p, (struct ioctl_args*)args); >-#else >- return ioctl(p, (struct ioctl_args*)args); >-#endif > } > return (ENOIOCTL); > } >diff -ruN ../rtc.orig/files/test.c ./files/test.c >--- ../rtc.orig/files/test.c 2014-01-24 00:14:07.000000000 +0000 >+++ ./files/test.c 2020-07-08 21:40:49.209355000 +0100 >@@ -6,7 +6,7 @@ > #include <string.h> > #include <sys/ioccom.h> > >-#include "rtc.h" >+#include <rtc.h> > > > int main(void) >@@ -21,7 +21,7 @@ > > rtc = open("/dev/rtc", O_RDONLY); > if (rtc<0) { >- perror("/dec/rtc"); >+ perror("/dev/rtc"); > return 1; > } > >diff -ruN ../rtc.orig/pkg-message ./pkg-message >--- ../rtc.orig/pkg-message 1970-01-01 01:00:00.000000000 +0100 >+++ ./pkg-message 2020-07-08 21:36:10.012955000 +0100 >@@ -0,0 +1,19 @@ >+[ >+{ type: install >+ message: <<EOM >+This module can be enabled with: >+ >+ # kldload rtc >+ >+and disabled with: >+ >+ # kldunload rtc >+ >+For it to be loaded automatically at boottime, add "rtc" to your >+kld_list entry in /etc/rc.conf . One way to do this is with the >+one-off command: >+ >+ # sysrc kld_list+="rtc" >+EOM >+} >+] >diff -ruN ../rtc.orig/pkg-plist ./pkg-plist >--- ../rtc.orig/pkg-plist 2019-08-26 12:12:49.000000000 +0100 >+++ ./pkg-plist 2020-07-08 21:36:10.013045000 +0100 >@@ -1,6 +1,3 @@ >-etc/rc.d/rtc.sh > include/rtc.h >-modules/rtc.ko >+/%%KMODDIR%%/rtc.ko > %%EXAMPLESDIR%%/test.c >-@postexec rm -f %%DEVDIR%%/rtc >-@postunexec rm -f /dev/rtc
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 233057
:
199049
| 216332