Thu, 19 Nov 1998 22:20:31 +0000
changeset 324 df0c936ae18716268c28f27461a45aeb55e5da90
parent 295 5ad9e12128289cda7609b6f05e2e6f7cf87b97ad
child 325 02caf72026bcb7893414dbcffc073c7b7253fb58
permissions -rw-r--r--
Enable OS/2 builds with IBM's compiler (Visualage) and gcc port of OS/2 (emx). Checkin for Eric Olson <Eric.Olson@Sympatico.CA> and Henry <>.

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 * The contents of this file are subject to the Netscape Public License
 * Version 1.0 (the "NPL"); you may not use this file except in
 * compliance with the NPL.  You may obtain a copy of the NPL at
 * Software distributed under the NPL is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
 * for the specific language governing rights and limitations under the
 * NPL.
 * The Initial Developer of this code under the NPL is Netscape
 * Communications Corporation.  Portions created by Netscape are
 * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
 * Reserved.

#include <stdio.h>
#include <stdlib.h>

#if defined(XP_UNIX) || defined(XP_OS2_EMX)
#include <sys/time.h>
#elif defined(WIN32) || defined(XP_OS2_VACPP)
#include <sys/timeb.h>
#error "Architecture not supported"

int main(int argc, char **argv)
#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) || defined(XP_OS2_EMX)
    long long now;
    struct timeval tv;
    gettimeofday(&tv, NULL);
    now = ((1000000LL) * tv.tv_sec) + (long long)tv.tv_usec;
#if defined(OSF1)
    fprintf(stdout, "%ld", now);
    fprintf(stdout, "%lld", now);

#elif defined(WIN32)
    __int64 now;
    long long now;
    struct timeb b;
    now = b.time;
    now *= 1000000;
    now += (1000 * b.millitm);
    fprintf(stdout, "%I64d", now);

#elif defined(XP_OS2_VACPP)
/* no long long or i64 so we use a string */
#include <string.h>
  char buf[24];
  char tbuf[7];
  time_t now;
  long mtime;
  int i;

  struct timeb b;
  now = b.time;
  _ltoa(now, buf, 10);

  mtime = b.millitm * 1000;
  if (mtime == 0){
    strcat(buf, "000000");
  } else {
     _ltoa(mtime, tbuf, 10);
     for (i = strlen(tbuf); i < 6; ++i)
       strcat(buf, "0");
     strcat(buf, tbuf);
  fprintf(stdout, "%s", buf);

#error "Architecture not supported"

    return 0;
}  /* main */

/* now.c */