Ports to many Unix variants. Added the OMIT_LIB_BUILD_TIME workaround INCLUDE_SPRINGCLEANING_BASE MozillaClassicLayout_19981021 MozillaSourceClassic_19981026_BASE
authorwtc%netscape.com
Thu, 08 Oct 1998 21:31:09 +0000
changeset 295 5ad9e12128289cda7609b6f05e2e6f7cf87b97ad
parent 294 07754fe45b179f01c626ba731c83bf660af721df
child 296 8c91910a81f5a6c775f6718637514c4446a4ee1b
child 297 8c279cc8dce823b2b7fdcef0675874562535692f
child 298 3d4c11dc1f4b57f190c05e7df763c0b6b3136d98
child 299 df27d88905895d1e53895500f92cfe1c6541edda
child 300 05f912e9d2985b170ec52444052e35652ec63d93
push idunknown
push userunknown
push dateunknown
Ports to many Unix variants. Added the OMIT_LIB_BUILD_TIME workaround for platforms that don't have 'long long'. In pr/src/Makefile and lib/libc/src/Makefile, use single quotes so that we can avoid using backslashes in double quotes (that doesn't work under MKS shell).
config/Makefile
config/UNIXWARE.mk
config/now.c
lib/libc/src/Makefile
lib/libc/src/plvrsion.c
pr/include/md/_aix.h
pr/include/md/_ncr.h
pr/include/md/_nec.h
pr/include/md/_scoos.h
pr/include/md/_unixware.h
pr/src/Makefile
pr/src/md/unix/unix.c
pr/src/prvrsion.c
--- a/config/Makefile
+++ b/config/Makefile
@@ -26,16 +26,23 @@ CSRCS	= nsinstall.c now.c
 PLSRCS	= nfspwd.pl
 
 ifeq ($(OS_ARCH), WINNT)
 PROG_SUFFIX = .exe
 else
 PROG_SUFFIX =
 endif
 
+# Temporary workaround to disable the generation of
+# library build time because now.c uses the 'long long'
+# data type that's not available on some platforms.
+ifeq (,$(filter-out NEC SCOOS UNIXWARE,$(OS_ARCH)))
+DEFINES += -DOMIT_LIB_BUILD_TIME
+endif
+
 ifeq ($(OS_ARCH), IRIX)
     ifeq ($(basename $(OS_RELEASE)),6)
 	    ifeq ($(USE_N32),1)
 		    XLDOPTS += -n32 -Wl,-woff,85
 		    ifeq ($(OS_RELEASE), 6_2)
 			    XLDOPTS += -Wl,-woff,85
 		    endif
 	    else
--- a/config/UNIXWARE.mk
+++ b/config/UNIXWARE.mk
@@ -22,23 +22,34 @@
 # release.)
 # UnixWare 7 (codename Gemini) is based on what SCO calls SVR5.
 # The somewhat odd version number 7 was chosen to suggest that
 #     UnixWare 2 + OpenServer 5 = UnixWare 7
 #
 
 include $(MOD_DEPTH)/config/UNIX.mk
 
+ifeq ($(OS_RELEASE),7)
+CC		= cc
+CCC		= CC
+else
 CC		= $(NSDEPTH)/build/hcc
 CCC		= $(NSDEPTH)/build/hcpp
+endif
 
 RANLIB		= true
 
 DEFINES		+= -D_PR_LOCAL_THREADS_ONLY
 OS_CFLAGS	= -DSVR4 -DSYSV -DUNIXWARE
 
+ifeq ($(OS_RELEASE),7)
+OS_CFLAGS	+= -D_LARGEFILE64_SOURCE -D_PR_HAVE_OFF64_T -D_PR_HAVE_SOCKADDR_LEN
+else
+OS_CFLAGS	+= -D_PR_NO_LARGE_FILES
+endif
+
 MKSHLIB		= $(LD) $(DSO_LDOPTS)
 DSO_LDOPTS	= -G
 
 CPU_ARCH	= x86
 ARCH		= sco
 
 NOSUCHFILE	= /no-such-file
--- a/config/now.c
+++ b/config/now.c
@@ -25,33 +25,50 @@
 #include <sys/timeb.h>
 #else
 #error "Architecture not supported"
 #endif
 
 
 int main(int argc, char **argv)
 {
-#if defined(XP_UNIX)
-   long long now;
-   struct timeval tv;
+#if defined(OMIT_LIB_BUILD_TIME)
+    /*
+     * Some platforms don't have any 64-bit integer type
+     * such as 'long long'.  Because we can't use NSPR's
+     * PR_snprintf in this program, it is difficult to
+     * print a static initializer for PRInt64 (a struct).
+     * So we print nothing.  The makefiles that build the
+     * shared libraries will detect the empty output string
+     * of this program and omit the library build time
+     * in PRVersionDescription.
+     */
+#elif defined(XP_UNIX)
+    long long now;
+    struct timeval tv;
+#ifdef HAVE_SVID_GETTOD
+    gettimeofday(&tv);
+#else
     gettimeofday(&tv, NULL);
+#endif
     now = ((1000000LL) * tv.tv_sec) + (long long)tv.tv_usec;
 #if defined(OSF1)
-    return fprintf(stdout, "%ld", now);
+    fprintf(stdout, "%ld", now);
 #else
-    return fprintf(stdout, "%lld", now);
+    fprintf(stdout, "%lld", now);
 #endif
 
 #elif defined(WIN32)
     __int64 now;
     struct timeb b;
     ftime(&b);
     now = b.time;
     now *= 1000000;
     now += (1000 * b.millitm);
-    return fprintf(stdout, "%I64d", now);
+    fprintf(stdout, "%I64d", now);
 #else
 #error "Architecture not supported"
 #endif
+
+    return 0;
 }  /* main */
 
 /* now.c */
--- a/lib/libc/src/Makefile
+++ b/lib/libc/src/Makefile
@@ -94,38 +94,36 @@ ifeq ($(OS_ARCH),SCOOS)
 EXTRA_LIBS =
 endif
 
 include $(MOD_DEPTH)/config/rules.mk
 
 #
 # Version information generation (begin)
 #
-RM = rm
 ECHO = echo
-INCLUDES = -I$(DIST)/include
 TINC = $(OBJDIR)/_pl_bld.h
 PROD = libplc$(MOD_VERSION).$(DLL_SUFFIX)
 NOW = $(MOD_DEPTH)/config/$(OBJDIR)/now
 SH_DATE = $(shell date)
 SH_NOW = $(shell $(NOW))
 
 ifeq ($(OS_ARCH), WINNT)
 	SUF = i64
-	SH_QUOTE =
 else
 	SUF = LL
-	SH_QUOTE = "
 endif
 
 $(TINC):
 	@$(MAKE_OBJDIR)
-	@$(ECHO) $(SH_QUOTE)#define _BUILD_STRING \"$(SH_DATE)\"$(SH_QUOTE) > $(TINC)
-	@$(ECHO) $(SH_QUOTE)#define _BUILD_TIME $(SH_NOW)$(SUF)$(SH_QUOTE) >> $(TINC)
-	@$(ECHO) $(SH_QUOTE)#define _PRODUCTION \"$(PROD)\"$(SH_QUOTE) >> $(TINC)
+	@$(ECHO) '#define _BUILD_STRING "$(SH_DATE)"' > $(TINC)
+	@if test ! -z "$(SH_NOW)"; then \
+	    $(ECHO) '#define _BUILD_TIME $(SH_NOW)$(SUF)' >> $(TINC); \
+	fi
+	@$(ECHO) '#define _PRODUCTION "$(PROD)"' >> $(TINC)
 
 
 $(OBJDIR)/plvrsion.$(OBJ_SUFFIX): $(TINC)
 ifeq ($(OS_ARCH), WINNT)
 	$(CC) -Fo$@ -c $(CFLAGS) -I$(OBJDIR) plvrsion.c
 else
 	$(CC) -o $@ -c $(CFLAGS) -I$(OBJDIR) plvrsion.c
 endif
--- a/lib/libc/src/plvrsion.c
+++ b/lib/libc/src/plvrsion.c
@@ -19,17 +19,21 @@
 #include "prinit.h"
 #include "prvrsion.h"
 
 /************************************************************************/
 /**************************IDENTITY AND VERSIONING***********************/
 /************************************************************************/
 #include "_pl_bld.h"
 #if !defined(_BUILD_TIME)
+#ifdef HAVE_LONG_LONG
 #define _BUILD_TIME 0
+#else
+#define _BUILD_TIME {0, 0}
+#endif
 #endif
 #if !defined(_BUILD_STRING)
 #define _BUILD_STRING ""
 #endif
 #if !defined(_PRODUCTION)
 #define _PRODUCTION ""
 #endif
 
--- a/pr/include/md/_aix.h
+++ b/pr/include/md/_aix.h
@@ -20,23 +20,20 @@
 #define nspr_aix_defs_h___
 
 #include <sys/types.h>
 #if defined(_PR_PTHREADS) || defined(PTHREADS_USER)
 #include <pthread.h>
 #endif
 
 /*
- * To pick up fd_set.  In AIX 4.2, fd_set is defined in <sys/time.h>,
- * which is included by _unixos.h.
+ * To pick up fd_set and the poll events.
  */
-#ifdef AIX4_1
 #include <sys/select.h>
 #include <sys/poll.h>
-#endif
 
 /*
  * Internal configuration macros
  */
 
 #define PR_LINKER_ARCH          "aix"
 #define _PR_SI_SYSNAME		    "AIX"
 #define _PR_SI_ARCHITECTURE	    "rs6000"
--- a/pr/include/md/_ncr.h
+++ b/pr/include/md/_ncr.h
@@ -42,16 +42,18 @@
 #endif
 
 #ifndef	HAVE_WEAK_IO_SYMBOLS
 #define	HAVE_WEAK_IO_SYMBOLS
 #endif
 
 #define _PR_POLL_AVAILABLE
 #define _PR_USE_POLL
+#define _PR_NO_LARGE_FILES
+#define _PR_STAT_HAS_ST_ATIM_UNION
 
 #undef  HAVE_STACK_GROWING_UP
 #define HAVE_NETCONFIG
 #define NEED_STRFTIME_LOCK
 #define NEED_TIME_R
 #define NEED_LOCALTIME_R
 #define NEED_GMTIME_R  
 #define NEED_ASCTIME_R
--- a/pr/include/md/_nec.h
+++ b/pr/include/md/_nec.h
@@ -32,16 +32,20 @@
 #define _MD_DEFAULT_STACK_SIZE  65536L
 #define _MD_MMAP_FLAGS          MAP_PRIVATE
 
 #undef  HAVE_STACK_GROWING_UP
 #define HAVE_DLL
 #define USE_DLFCN
 #define NEED_TIME_R
 #define NEED_STRFTIME_LOCK
+#define _PR_POLL_AVAILABLE
+#define _PR_USE_POLL
+#define _PR_NO_LARGE_FILES
+#define _PR_STAT_HAS_ST_ATIM_UNION
  
 #include <ucontext.h>
 #include <sys/regset.h>
  
 #define PR_NUM_GCREGS   NGREG
 #define PR_CONTEXT_TYPE ucontext_t
  
 #define CONTEXT(_thread) (&(_thread)->md.context)
--- a/pr/include/md/_scoos.h
+++ b/pr/include/md/_scoos.h
@@ -42,16 +42,18 @@
 #endif
 
 #ifndef	HAVE_WEAK_IO_SYMBOLS
 #define	HAVE_WEAK_IO_SYMBOLS
 #endif
 
 #define _PR_POLL_AVAILABLE
 #define _PR_USE_POLL
+#define _PR_NO_LARGE_FILES
+#define _PR_STAT_HAS_ONLY_ST_ATIME
 
 #define NEED_STRFTIME_LOCK
 #define NEED_TIME_R
 #define _PR_RECV_BROKEN /* recv doesn't work on Unix Domain Sockets */
 
 #define USE_SETJMP
 
 #ifdef _PR_LOCAL_THREADS_ONLY
--- a/pr/include/md/_unixware.h
+++ b/pr/include/md/_unixware.h
@@ -33,16 +33,17 @@
 #define _MD_DEFAULT_STACK_SIZE	65536L
 #define _MD_MMAP_FLAGS          MAP_PRIVATE
 
 #ifndef	HAVE_WEAK_IO_SYMBOLS
 #define	HAVE_WEAK_IO_SYMBOLS
 #endif
 #define _PR_POLL_AVAILABLE
 #define _PR_USE_POLL
+#define _PR_STAT_HAS_ST_ATIM_UNION
 
 #undef  HAVE_STACK_GROWING_UP
 #define HAVE_NETCONFIG
 #define	HAVE_DLL
 #define	USE_DLFCN
 #define HAVE_STRERROR
 #define NEED_STRFTIME_LOCK
 #define NEED_TIME_R
--- a/pr/src/Makefile
+++ b/pr/src/Makefile
@@ -305,38 +305,37 @@ include $(MOD_DEPTH)/config/rules.mk
 ifeq ($(BUILD_AIX_RTL_LIBC),1)
 TARGETS		+= $(AIX_RTL_LIBC)
 # XXX is this a shared library?
 endif
 
 #
 # Version information generation (begin)
 #
-RM = rm
 ECHO = echo
 INCLUDES = -I$(DIST)/include
 TINC = $(OBJDIR)/_pr_bld.h
 PROD = libnspr$(MOD_VERSION).$(DLL_SUFFIX)
 NOW = $(MOD_DEPTH)/config/$(OBJDIR)/now
 SH_DATE = $(shell date)
 SH_NOW = $(shell $(NOW))
 
 ifeq ($(OS_ARCH), WINNT)
 	SUF = i64
-	SH_QUOTE =
 else
 	SUF = LL
-	SH_QUOTE = "
 endif
 
 $(TINC):
 	@$(MAKE_OBJDIR)
-	@$(ECHO) $(SH_QUOTE)#define _BUILD_STRING \"$(SH_DATE)\"$(SH_QUOTE) > $(TINC)
-	@$(ECHO) $(SH_QUOTE)#define _BUILD_TIME $(SH_NOW)$(SUF)$(SH_QUOTE) >> $(TINC)
-	@$(ECHO) $(SH_QUOTE)#define _PRODUCTION \"$(PROD)\"$(SH_QUOTE) >> $(TINC)
+	@$(ECHO) '#define _BUILD_STRING "$(SH_DATE)"' > $(TINC)
+	@if test ! -z "$(SH_NOW)"; then \
+	    $(ECHO) '#define _BUILD_TIME $(SH_NOW)$(SUF)' >> $(TINC); \
+	fi
+	@$(ECHO) '#define _PRODUCTION "$(PROD)"' >> $(TINC)
 
 
 $(OBJDIR)/prvrsion.$(OBJ_SUFFIX): $(TINC)
 ifeq ($(OS_ARCH), WINNT)
 	$(CC) -Fo$@ -c $(CFLAGS) -I$(OBJDIR) prvrsion.c
 else
 	$(CC) -o $@ -c $(CFLAGS) -I$(OBJDIR) prvrsion.c
 endif
--- a/pr/src/md/unix/unix.c
+++ b/pr/src/md/unix/unix.c
@@ -2255,16 +2255,54 @@ static void _MD_set_fileinfo64_times(
     const _MDStat64 *sb,
     PRFileInfo64 *info)
 {
     info->modifyTime = ((PRTime)sb->st_mtim.tv_sec * PR_USEC_PER_SEC);
     info->modifyTime += (sb->st_mtim.tv_nsec / 1000);
     info->creationTime = ((PRTime)sb->st_ctim.tv_sec * PR_USEC_PER_SEC);
     info->creationTime += (sb->st_ctim.tv_nsec / 1000);
 }
+#elif defined(_PR_STAT_HAS_ST_ATIM_UNION)
+/*
+** The st_atim, st_mtim, and st_ctim fields in struct stat are
+** unions with a st__tim union member of type timestruc_t.
+*/
+static void _MD_set_fileinfo_times(
+    const struct stat *sb,
+    PRFileInfo *info)
+{
+    PRInt64 us, s2us;
+
+    LL_I2L(s2us, PR_USEC_PER_SEC);
+    LL_I2L(info->modifyTime, sb->st_mtim.st__tim.tv_sec);
+    LL_MUL(info->modifyTime, info->modifyTime, s2us);
+    LL_I2L(us, sb->st_mtim.st__tim.tv_nsec / 1000);
+    LL_ADD(info->modifyTime, info->modifyTime, us);
+    LL_I2L(info->creationTime, sb->st_ctim.st__tim.tv_sec);
+    LL_MUL(info->creationTime, info->creationTime, s2us);
+    LL_I2L(us, sb->st_ctim.st__tim.tv_nsec / 1000);
+    LL_ADD(info->creationTime, info->creationTime, us);
+}
+
+static void _MD_set_fileinfo64_times(
+    const _MDStat64 *sb,
+    PRFileInfo64 *info)
+{
+    PRInt64 us, s2us;
+
+    LL_I2L(s2us, PR_USEC_PER_SEC);
+    LL_I2L(info->modifyTime, sb->st_mtim.st__tim.tv_sec);
+    LL_MUL(info->modifyTime, info->modifyTime, s2us);
+    LL_I2L(us, sb->st_mtim.st__tim.tv_nsec / 1000);
+    LL_ADD(info->modifyTime, info->modifyTime, us);
+    LL_I2L(info->creationTime, sb->st_ctim.st__tim.tv_sec);
+    LL_MUL(info->creationTime, info->creationTime, s2us);
+    LL_I2L(us, sb->st_ctim.st__tim.tv_nsec / 1000);
+    LL_ADD(info->creationTime, info->creationTime, us);
+}
 #elif defined(_PR_STAT_HAS_ST_ATIMESPEC)
 /*
 ** struct stat has st_atimespec, st_mtimespec, and st_ctimespec
 ** fields of type struct timespec.
 */
 #if defined(_PR_TIMESPEC_HAS_TS_SEC)
 static void _MD_set_fileinfo_times(
     const struct stat *sb,
@@ -2567,17 +2605,17 @@ static void* _MD_Unix_mmap64(
     void *addr, PRSize len, PRIntn prot, PRIntn flags,
     PRIntn fildes, PRInt64 offset)
 {
     PR_SetError(PR_FILE_TOO_BIG_ERROR, 0);
     return NULL;
 }  /* _MD_Unix_mmap64 */
 #endif /* defined(_PR_NO_LARGE_FILES) || defined(SOLARIS2_5) */
 
-#if defined(IRIX)
+#if defined(IRIX) || defined(UNIXWARE)
 
 /*
 ** This function emulates a lock64 for IRIX using fcntl calls. It is a true
 ** 64-bit operation, just a different system API to get it.
 */
 static PRIntn _MD_irix_lockf64(PRIntn osfd, PRIntn function, PRInt64 size)
 {
 #if 1
@@ -2637,17 +2675,17 @@ static void _PR_InitIOV(void)
     _md_iovector._mmap64 = mmap64;
     _md_iovector._fstat64 = fstat64;
     _md_iovector._stat64 = stat64;
 
 /*
 ** $$$ IRIX does not have a lockf64. One must fabricate it from fcntl
 ** calls with 64 bit arguments.
 */
-#if defined(IRIX)
+#if defined(IRIX) || defined(UNIXWARE)
     _md_iovector._lockf64 = _MD_irix_lockf64;
 #else
     _md_iovector._lockf64 = lockf64;
 #endif
     _md_iovector._lseek64 = lseek64;
 #elif defined(_PR_HAVE_LARGE_OFF_T)
     _md_iovector._open64 = open;
     _md_iovector._mmap64 = mmap;
--- a/pr/src/prvrsion.c
+++ b/pr/src/prvrsion.c
@@ -19,17 +19,21 @@
 #include "prinit.h"
 #include "prvrsion.h"
 
 /************************************************************************/
 /**************************IDENTITY AND VERSIONING***********************/
 /************************************************************************/
 #include "_pr_bld.h"
 #if !defined(_BUILD_TIME)
+#ifdef HAVE_LONG_LONG
 #define _BUILD_TIME 0
+#else
+#define _BUILD_TIME {0, 0}
+#endif
 #endif
 #if !defined(_BUILD_STRING)
 #define _BUILD_STRING ""
 #endif
 #if !defined(_PRODUCTION)
 #define _PRODUCTION ""
 #endif