[comp.windows.x] Berklib.o needs to be split

tml@HEMULI.TIK.VTT.FI (Tor Lillqvist) (11/27/90)

			  X Window System Bug Report
			    xbugs@expo.lcs.mit.edu
			    [ also sent to xpert ]

VERSION:
    R4

CLIENT MACHINE and OPERATING SYSTEM:
    HP9000 running HP-UX 7.0

DISPLAY TYPE:
    Irrelevant

WINDOW MANAGER:
    Irrelevant

AREA:
    mit/lib/X/sysV/Berklib.c

SYNOPSIS:
    Berklib.o in libX11 needs to be split into smaller pieces.

DESCRIPTION:
    The Berklib.o module contains replacements for various BSD
    functions not found on SYSV style systems.  They are all in one
    source file, and thus if the linker needs one entry from the
    resulting object module, it pulls in the whole module.

    For example, say you want to use a special malloc library for
    debugging that includes an error-checking version of bcopy.  If
    you also link with -lX11, and the X library calls ffs, Berklib.o
    gets pulled in, and you get multiply defined symbols.

SAMPLE FIX:
    Split Berklib.o into several files.  I have kept Berklib.c, but
    partitioned it into conditionally compiled pieces, and added
    several two-line sources that #define a symbol telling which piece
    to compile, and #include Berklib.c.  The config/Project.tmpl file
    needs updating in the BandAidLibrary section.

    Here is a shar and a diff:

# This is a shell archive.  Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by Tor Lillqvist <tml@hemuli> on Tue Nov 27 12:35:32 1990
#
# This archive contains:
#	BerkB.c		BerkFfs.c	BerkI.c		BerkOth.c	
#	BerkQ.c		BerkR.c		
#

LANG=""; export LANG
PATH=/bin:/usr/bin:$PATH; export PATH

echo x - BerkB.c
cat >BerkB.c <<'@EOF'
#define BSTRING
#include "sysV/Berklib.c"
@EOF

chmod 644 BerkB.c

echo x - BerkFfs.c
cat >BerkFfs.c <<'@EOF'
#define FFS
#include "sysV/Berklib.c"
@EOF

chmod 644 BerkFfs.c

echo x - BerkI.c
cat >BerkI.c <<'@EOF'
#define INDEX
#include "sysV/Berklib.c"
@EOF

chmod 644 BerkI.c

echo x - BerkOth.c
cat >BerkOth.c <<'@EOF'
#define OTHERS
#include "sysV/Berklib.c"
@EOF

chmod 644 BerkOth.c

echo x - BerkQ.c
cat >BerkQ.c <<'@EOF'
#define QUEUE
#include "sysV/Berklib.c"
@EOF

chmod 644 BerkQ.c

echo x - BerkR.c
cat >BerkR.c <<'@EOF'
#define RANDOM
#include "sysV/Berklib.c"
@EOF

chmod 644 BerkR.c

exit 0


*** config/Project.tmpl.ORIG	Mon Dec 18 23:46:46 1989
--- config/Project.tmpl	Tue Nov 27 12:20:12 1990
***************
*** 314,325 ****
  
  #if NeedBerklibInXlib		/* what about regular Berklib */
  #define BandAidLibraryNeeded		YES
! #define BandAidLibrarySources		Berklib.c
! #define BandAidLibraryObjects		Berklib.o
  #define BandAidLibraryMake()					@@\
! Berklib.c: sysV/Berklib.c					@@\
! 	-$(RM) Berklib.c					@@\
! 	-$(LN) sysV/Berklib.c .
  #endif /* NeedBerklibInXlib */
  
  
--- 314,337 ----
  
  #if NeedBerklibInXlib		/* what about regular Berklib */
  #define BandAidLibraryNeeded		YES
! #define BandAidLibrarySources		BerkB.c BerkI.c BerkFfs.c BerkQ.c BerkR.c BerkOth.c
! #define BandAidLibraryObjects		BerkB.o BerkI.o BerkFfs.o BerkQ.o BerkR.o BerkOth.o
  #define BandAidLibraryMake()					@@\
! BerkB.c: sysV/BerkB.c						@@\
! 	-$(RM) BerkB.c						@@\
! 	-$(LN) sysV/BerkB.c .					@@\
! BerkI.c: sysV/BerkI.c						@@\
! 	-$(RM) BerkI.c						@@\
! 	-$(LN) sysV/BerkI.c .					@@\
! BerkFfs.c: sysV/BerkFfs.c					@@\
! 	-$(RM) BerkFfs.c					@@\
! 	-$(LN) sysV/BerkFfs.c .					@@\
! BerkQ.c: sysV/BerkQ.c						@@\
! 	-$(RM) BerkQ.c						@@\
! 	-$(LN) sysV/BerkQ.c .					@@\
! BerkOth.c: sysV/BerkOth.c					@@\
! 	-$(RM) BerkOth.c					@@\
! 	-$(LN) sysV/BerkOth.c .
  #endif /* NeedBerklibInXlib */
  
  
*** lib/X/sysV/Berklib.c.ORIG	Mon Oct  1 12:03:13 1990
--- lib/X/sysV/Berklib.c	Tue Nov 27 12:22:22 1990
***************
*** 6,11 ****
--- 6,13 ----
  
  #include <sys/types.h>
  
+ #ifdef BSTRING
+ 
  /*
   * These are routines found in BSD and not found in many SysV's.  They are
   * included so that some clients can compile.
***************
*** 48,53 ****
--- 50,58 ----
      }
  }
  
+ #endif
+ 
+ #ifdef FFS
  
  /* Find the first set bit
   * i.e. least signifigant 1 bit:
***************
*** 73,78 ****
--- 78,87 ----
      return i;
  }
  
+ #endif
+ 
+ #ifdef INDEX
+ 
  char * 
  index (s, c)
  char *s, c;
***************
*** 87,92 ****
--- 96,105 ----
      return ((char *) strrchr (s, c));
  }
  
+ #endif
+ 
+ #ifdef QUEUE
+ 
  /*
   * insque, remque - insert/remove element from a queue
   *
***************
*** 132,137 ****
--- 145,154 ----
  }
  
  
+ #endif
+ 
+ #ifdef RANDOM
+ 
  /*
   * Berkeley random()
   *
***************
*** 158,163 ****
--- 175,183 ----
  }
  
  
+ #endif
+ 
+ #ifdef OTHERS
  #ifdef hpux
  
  /** on hpux 5.n, readv/writev don't work on sockets;
***************
*** 221,224 ****
--- 241,245 ----
  		);
      }
  }
+ #endif
  #endif