Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Jan 1998 10:08:45 +0000 (GMT)
From:      Terry Lambert <tlambert@primenet.com>
To:        current@FreeBSD.ORG
Subject:   PATCH: if_de.c #ifdef based version encoding
Message-ID:  <199801271008.DAA04483@usr09.primenet.com>

next in thread | raw e-mail | index | archive | help
The value of the manifest constant __FreeBSD__ is derived from the
compiler tools and not from the kernel being built.

In other words, the value of __FreeBSD__ comes from the version of the
OS the tools were built on, not from the OS that's running or the one
that is being targeted.

This means that if I build a v3 kernel using a v2 system's tools, the
"#if __FreeBSD__ >= 3" and "#if defined(__FreeBSD__) && __FreeBSD__ >= 3"
will not test true, even though that is, in fact, what I am building.


Version information should not be encoded in #ifdef's; that is what
branch tags are for.  If I can check this code out, implicitly, I am
building a 3+ system.  The "#if" tests are bogus.

This patch allows people to compile v3 kernels containing if_de.c on v2
systems.

Please commit it.


					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.
=============================================================================
Index: pci/if_de.c
===================================================================
RCS file: /b/cvstree/ncvs/src/sys/pci/if_de.c,v
retrieving revision 1.74
diff -c -r1.74 if_de.c
*** 1.74	1997/11/08 14:46:53
--- if_de.c	1998/01/27 10:02:02
***************
*** 3024,3035 ****
  tulip_addr_filter(
      tulip_softc_t * const sc)
  {
! #if defined(__FreeBSD__) && __FreeBSD__ >= 3
      struct ifmultiaddr *ifma;
      u_char *addrp;
- #else
-     struct ether_multistep step;
-     struct ether_multi *enm;
  #endif
      int multicnt;
  
--- 3024,3032 ----
  tulip_addr_filter(
      tulip_softc_t * const sc)
  {
! #if defined(__FreeBSD__)
      struct ifmultiaddr *ifma;
      u_char *addrp;
  #endif
      int multicnt;
  
***************
*** 3041,3047 ****
      sc->tulip_if.if_flags &= ~IFF_ALLMULTI;
  #endif
  
! #if defined(__FreeBSD__) && __FreeBSD__ >= 3
      multicnt = 0;
      for (ifma = sc->tulip_if.if_multiaddrs.lh_first; ifma != NULL;
  	 ifma = ifma->ifma_link.le_next) {
--- 3038,3044 ----
      sc->tulip_if.if_flags &= ~IFF_ALLMULTI;
  #endif
  
! #if defined(__FreeBSD__)
      multicnt = 0;
      for (ifma = sc->tulip_if.if_multiaddrs.lh_first; ifma != NULL;
  	 ifma = ifma->ifma_link.le_next) {
***************
*** 3049,3056 ****
  	    if (ifma->ifma_addr->sa_family == AF_LINK)
  		multicnt++;
      }
- #else
-     multicnt = sc->tulip_multicnt;
  #endif
  
      sc->tulip_if.if_start = tulip_ifstart;	/* so the setup packet gets queued */
--- 3046,3051 ----
***************
*** 3075,3081 ****
  	 */
  	bzero(sc->tulip_setupdata, sizeof(sc->tulip_setupdata));
  
! #if defined(__FreeBSD__) && __FreeBSD__ >= 3
  	for (ifma = sc->tulip_if.if_multiaddrs.lh_first; ifma != NULL;
  	     ifma = ifma->ifma_link.le_next) {
  
--- 3070,3076 ----
  	 */
  	bzero(sc->tulip_setupdata, sizeof(sc->tulip_setupdata));
  
! #if defined(__FreeBSD__)
  	for (ifma = sc->tulip_if.if_multiaddrs.lh_first; ifma != NULL;
  	     ifma = ifma->ifma_link.le_next) {
  
***************
*** 3085,3103 ****
  		hash = tulip_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
  		sp[hash >> 4] |= 1 << (hash & 0xF);
  	}
- #else
- 	ETHER_FIRST_MULTI(step, TULIP_ETHERCOM(sc), enm);
- 	while (enm != NULL) {
- 		if (bcmp(enm->enm_addrlo, enm->enm_addrhi, 6) == 0) {
- 		    hash = tulip_mchash(enm->enm_addrlo);
- 		    sp[hash >> 4] |= 1 << (hash & 0xF);
- 		} else {
- 		    sc->tulip_flags |= TULIP_ALLMULTI;
- 		    sc->tulip_flags &= ~(TULIP_WANTHASHONLY|TULIP_WANTHASHPERFECT);
- 		    break;
- 		}
- 		ETHER_NEXT_MULTI(step, enm);
- 	}
  #endif
  	/*
  	 * No reason to use a hash if we are going to be
--- 3080,3085 ----
***************
*** 3123,3129 ****
  	    /*
  	     * Else can get perfect filtering for 16 addresses.
  	     */
! #if defined(__FreeBSD__) && __FreeBSD__ >= 3
  	    for (ifma = sc->tulip_if.if_multiaddrs.lh_first; ifma != NULL;
  		 ifma = ifma->ifma_link.le_next) {
  		    if (ifma->ifma_addr->sa_family != AF_LINK)
--- 3105,3111 ----
  	    /*
  	     * Else can get perfect filtering for 16 addresses.
  	     */
! #if defined(__FreeBSD__)
  	    for (ifma = sc->tulip_if.if_multiaddrs.lh_first; ifma != NULL;
  		 ifma = ifma->ifma_link.le_next) {
  		    if (ifma->ifma_addr->sa_family != AF_LINK)
***************
*** 3134,3152 ****
  		    *sp++ = ((u_int16_t *) addrp)[2];
  		    idx++;
  	    }
- #else
- 	    ETHER_FIRST_MULTI(step, TULIP_ETHERCOM(sc), enm);
- 	    for (; enm != NULL; idx++) {
- 		if (bcmp(enm->enm_addrlo, enm->enm_addrhi, 6) == 0) {
- 		    *sp++ = ((u_int16_t *) enm->enm_addrlo)[0]; 
- 		    *sp++ = ((u_int16_t *) enm->enm_addrlo)[1]; 
- 		    *sp++ = ((u_int16_t *) enm->enm_addrlo)[2];
- 		} else {
- 		    sc->tulip_flags |= TULIP_ALLMULTI;
- 		    break;
- 		}
- 		ETHER_NEXT_MULTI(step, enm);
- 	    }
  #endif
  	    /*
  	     * Add the broadcast address.
--- 3116,3121 ----
***************
*** 4459,4479 ****
  	    /*
  	     * Update multicast listeners
  	     */
! #if defined(__FreeBSD__) && __FreeBSD__ >= 3
  	    tulip_addr_filter(sc);		/* reset multicast filtering */
  	    tulip_init(sc);
  	    error = 0;
- #else
- 	    if (cmd == SIOCADDMULTI)
- 		error = ether_addmulti(ifr, TULIP_ETHERCOM(sc));
- 	    else
- 		error = ether_delmulti(ifr, TULIP_ETHERCOM(sc));
- 
- 	    if (error == ENETRESET) {
- 		tulip_addr_filter(sc);		/* reset multicast filtering */
- 		tulip_init(sc);
- 		error = 0;
- 	    }
  #endif
  	    break;
  	}
--- 4428,4437 ----
  	    /*
  	     * Update multicast listeners
  	     */
! #if defined(__FreeBSD__)
  	    tulip_addr_filter(sc);		/* reset multicast filtering */
  	    tulip_init(sc);
  	    error = 0;
  #endif
  	    break;
  	}
***************
*** 5112,5124 ****
      tulip_softc_t *sc;
  #define	PCI_CONF_WRITE(r, v)	pci_conf_write(config_id, (r), (v))
  #define	PCI_CONF_READ(r)	pci_conf_read(config_id, (r))
- #if __FreeBSD__ >= 3
  #define	PCI_GETBUSDEVINFO(sc)	((void)((sc)->tulip_pci_busno = (config_id->bus), /* XXX */ \
  					(sc)->tulip_pci_devno = (config_id->slot))) /* XXX */
- #else
- #define	PCI_GETBUSDEVINFO(sc)	((void)((sc)->tulip_pci_busno = ((config_id.cfg1 >> 16) & 0xFF), /* XXX */ \
- 					(sc)->tulip_pci_devno = ((config_id.cfg1 >> 11) & 0x1F))) /* XXX */
- #endif
  #endif
  #if defined(__bsdi__)
      tulip_softc_t * const sc = (tulip_softc_t *) self;
--- 5070,5077 ----
=============================================================================



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199801271008.DAA04483>