mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-18 18:44:06 +08:00
Briefly,
* configure + Makefile changes * shared memory attaching in EXEC_BACKEND case (+ minor fix for apparent cygwin bug under cygwin/EXEC_BACKEND case only) * PATH env var separator differences * missing win32 rand functions added * placeholder replacements for sync etc under port.h To those who are really interested, and there are a few of you: the attached patch + file will allow the source base to be compiled (and, for some definition, "run") under MingW, with the following caveats (I wanted to first properly fix all but the last of these, but y'all won't quit asking for a patch :-): * child death: SIGCHLD not yet sent, so as a minimum, you'll need to put in some sort of delay after StartupDatabase, and handle setting StartupPID to 0 etc (ie. the stuff the reaper() signal function is supposed to do) * dirmod.c: comment out the elog calls * dfmgr.c: some hackage required to substitute_libpath_macro * slru/xact.c: comment out the errno checking after the readdir (fixed by next version of MingW) Again, this is only if you *really* want to see postgres compile and start, and is a nice leg-up for working on the other Win32 TODO list items. Just don't expect too much else from it at this point... Claudio Natoli
This commit is contained in:
parent
10bb17e334
commit
e5e5a323ca
3
configure
vendored
3
configure
vendored
@ -2502,7 +2502,7 @@ echo "$as_me: using CFLAGS=$CFLAGS" >&6;}
|
||||
|
||||
# We already have this in Makefile.win32, but configure needs it too
|
||||
if test "$PORTNAME" = "win32"; then
|
||||
CPPFLAGS="$CPPFLAGS -I$srcdir/src/include/port/win32"
|
||||
CPPFLAGS="$CPPFLAGS -I$srcdir/src/include/port/win32 -DEXEC_BACKEND"
|
||||
fi
|
||||
|
||||
# Check if the compiler still works with the template settings
|
||||
@ -12079,6 +12079,7 @@ esac
|
||||
case $host_os in mingw*)
|
||||
LIBOBJS="$LIBOBJS dirmod.$ac_objext"
|
||||
LIBOBJS="$LIBOBJS copydir.$ac_objext"
|
||||
LIBOBJS="$LIBOBJS rand.$ac_objext"
|
||||
LIBOBJS="$LIBOBJS gettimeofday.$ac_objext"
|
||||
LIBOBJS="$LIBOBJS pipe.$ac_objext" ;;
|
||||
esac
|
||||
|
@ -1,5 +1,5 @@
|
||||
# -*-makefile-*-
|
||||
# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.173 2004/01/19 21:20:06 tgl Exp $
|
||||
# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.174 2004/02/02 00:11:30 momjian Exp $
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# All PostgreSQL makefiles include this file and use the variables it sets,
|
||||
@ -346,6 +346,11 @@ LIBS += -lpgport
|
||||
LDFLAGS := -L$(top_builddir)/src/port $(LDFLAGS)
|
||||
endif
|
||||
|
||||
# to make ws2_32.lib the last library
|
||||
ifeq ($(PORTNAME),win32)
|
||||
LIBS += -lws2_32
|
||||
endif
|
||||
|
||||
# Not really standard libc functions, used by the backend.
|
||||
TAS = @TAS@
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
#
|
||||
# Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
# $PostgreSQL: pgsql/src/backend/Makefile,v 1.97 2003/11/29 19:51:39 pgsql Exp $
|
||||
# $PostgreSQL: pgsql/src/backend/Makefile,v 1.98 2004/02/02 00:11:30 momjian Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
@ -32,12 +32,15 @@ endif
|
||||
all: submake-libpgport postgres $(POSTGRES_IMP)
|
||||
|
||||
ifneq ($(PORTNAME), cygwin)
|
||||
ifneq ($(PORTNAME), win32)
|
||||
|
||||
postgres: $(OBJS)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $^ $(LIBS) -o $@
|
||||
|
||||
else # cygwin
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(PORTNAME), cygwin)
|
||||
postgres: $(OBJS) $(DLLINIT) postgres.def libpostgres.a
|
||||
$(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(OBJS) $(LIBS)
|
||||
@ -53,6 +56,24 @@ libpostgres.a: postgres.def
|
||||
|
||||
endif # cygwin
|
||||
|
||||
ifeq ($(PORTNAME), win32)
|
||||
|
||||
postgres: $(OBJS) $(DLLINIT) postgres.def libpostgres.a
|
||||
$(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(OBJS) $(LIBS)
|
||||
$(DLLTOOL) --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) $@.exp $(OBJS) $(LIBS)
|
||||
rm -f $@.exp $@.base
|
||||
|
||||
postgres.def: $(OBJS)
|
||||
$(DLLTOOL) --export-all --output-def $@ $^
|
||||
|
||||
libpostgres.a: postgres.def
|
||||
$(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@
|
||||
|
||||
endif # win32
|
||||
|
||||
|
||||
ifeq ($(PORTNAME), aix)
|
||||
|
||||
postgres: $(POSTGRES_IMP)
|
||||
@ -130,6 +151,11 @@ ifeq ($(PORTNAME), cygwin)
|
||||
ifeq ($(MAKE_DLL), true)
|
||||
$(INSTALL_DATA) libpostgres.a $(DESTDIR)$(libdir)/libpostgres.a
|
||||
endif
|
||||
endif
|
||||
ifeq ($(PORTNAME), win32)
|
||||
ifeq ($(MAKE_DLL), true)
|
||||
$(INSTALL_DATA) libpostgres.a $(DESTDIR)$(libdir)/libpostgres.a
|
||||
endif
|
||||
endif
|
||||
$(MAKE) -C catalog install-data
|
||||
$(INSTALL_DATA) $(srcdir)/libpq/pg_hba.conf.sample $(DESTDIR)$(datadir)/pg_hba.conf.sample
|
||||
@ -157,6 +183,11 @@ ifeq ($(MAKE_DLL), true)
|
||||
$(mkinstalldirs) $(DESTDIR)$(libdir)
|
||||
endif
|
||||
endif
|
||||
ifeq ($(PORTNAME), win32)
|
||||
ifeq ($(MAKE_DLL), true)
|
||||
$(mkinstalldirs) $(DESTDIR)$(libdir)
|
||||
endif
|
||||
endif
|
||||
ifeq ($(MAKE_EXPORTS), true)
|
||||
$(mkinstalldirs) $(DESTDIR)$(pkglibdir)
|
||||
endif
|
||||
@ -173,6 +204,11 @@ ifeq ($(PORTNAME), cygwin)
|
||||
ifeq ($(MAKE_DLL), true)
|
||||
rm -f $(DESTDIR)$(libdir)/libpostgres.a
|
||||
endif
|
||||
endif
|
||||
ifeq ($(PORTNAME), win32)
|
||||
ifeq ($(MAKE_DLL), true)
|
||||
rm -f $(DESTDIR)$(libdir)/libpostgres.a
|
||||
endif
|
||||
endif
|
||||
$(MAKE) -C catalog uninstall-data
|
||||
rm -f $(DESTDIR)$(datadir)/pg_hba.conf.sample \
|
||||
@ -189,6 +225,9 @@ clean:
|
||||
$(top_builddir)/src/include/utils/fmgroids.h
|
||||
ifeq ($(PORTNAME), cygwin)
|
||||
rm -f postgres.dll postgres.def libpostgres.a
|
||||
endif
|
||||
ifeq ($(PORTNAME), win32)
|
||||
rm -f postgres.dll postgres.def libpostgres.a
|
||||
endif
|
||||
for i in $(DIRS); do $(MAKE) -C $$i clean || exit; done
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.72 2004/01/27 00:45:26 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.73 2004/02/02 00:11:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -227,7 +227,11 @@ main(int argc, char *argv[])
|
||||
*/
|
||||
len = strlen(new_argv[0]);
|
||||
|
||||
if (len >= 10 && strcmp(new_argv[0] + len - 10, "postmaster") == 0)
|
||||
if ((len >= 10 && strcmp(new_argv[0] + len - 10, "postmaster") == 0)
|
||||
#ifdef WIN32
|
||||
|| (len >= 14 && strcmp(new_argv[0] + len - 14, "postmaster.exe") == 0)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
/* Called as "postmaster" */
|
||||
exit(PostmasterMain(argc, new_argv));
|
||||
|
@ -10,7 +10,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.29 2004/01/27 00:45:26 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.30 2004/02/02 00:11:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -140,7 +140,12 @@ InternalIpcMemoryCreate(IpcMemoryKey memKey, uint32 size)
|
||||
/* use intimate shared memory on Solaris */
|
||||
memAddress = shmat(shmid, 0, SHM_SHARE_MMU);
|
||||
#else
|
||||
|
||||
#ifdef EXEC_BACKEND
|
||||
memAddress = shmat(shmid, UsedShmemSegAddr, 0);
|
||||
#else
|
||||
memAddress = shmat(shmid, 0, 0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (memAddress == (void *) -1)
|
||||
@ -244,18 +249,32 @@ PGSharedMemoryCreate(uint32 size, bool makePrivate, int port)
|
||||
PGShmemHeader *hdr;
|
||||
IpcMemoryId shmid;
|
||||
|
||||
/* Room for a header? */
|
||||
Assert(size > MAXALIGN(sizeof(PGShmemHeader)));
|
||||
|
||||
#ifdef EXEC_BACKEND
|
||||
/* If Exec case, just attach and return the pointer */
|
||||
if (ExecBackend && UsedShmemSegAddr != NULL && !makePrivate)
|
||||
if (UsedShmemSegAddr != NULL && !makePrivate)
|
||||
{
|
||||
void* origUsedShmemSegAddr = UsedShmemSegAddr;
|
||||
|
||||
#ifdef CYGWIN
|
||||
/* cygipc (currently) appears to not detach on exec. */
|
||||
PGSharedMemoryDetach();
|
||||
UsedShmemSegAddr = origUsedShmemSegAddr;
|
||||
#endif
|
||||
elog(DEBUG3,"Attaching to %x",UsedShmemSegAddr);
|
||||
hdr = PGSharedMemoryAttach((IpcMemoryKey) UsedShmemSegID, &shmid);
|
||||
if (hdr == NULL)
|
||||
elog(FATAL, "could not attach to proper memory at fixed address: shmget(key=%lu, addr=%p) failed: %m",
|
||||
UsedShmemSegID, UsedShmemSegAddr);
|
||||
elog(FATAL, "could not attach to proper memory at fixed address: shmget(key=%d, addr=%p) failed: %m",
|
||||
(int) UsedShmemSegID, UsedShmemSegAddr);
|
||||
if (hdr != origUsedShmemSegAddr)
|
||||
elog(FATAL,"attaching to shared mem returned unexpected address (got %p, expected %p)",
|
||||
hdr,UsedShmemSegAddr);
|
||||
UsedShmemSegAddr = hdr;
|
||||
return hdr;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Room for a header? */
|
||||
Assert(size > MAXALIGN(sizeof(PGShmemHeader)));
|
||||
|
||||
/* Make sure PGSharedMemoryAttach doesn't fail without need */
|
||||
UsedShmemSegAddr = NULL;
|
||||
@ -354,12 +373,18 @@ PGSharedMemoryDetach(void)
|
||||
{
|
||||
if (UsedShmemSegAddr != NULL)
|
||||
{
|
||||
if (shmdt(UsedShmemSegAddr) < 0)
|
||||
if ((shmdt(UsedShmemSegAddr) < 0)
|
||||
#if (defined(EXEC_BACKEND) && defined(CYGWIN))
|
||||
/* Work-around for cygipc exec bug */
|
||||
&& shmdt(NULL) < 0
|
||||
#endif
|
||||
)
|
||||
elog(LOG, "shmdt(%p) failed: %m", UsedShmemSegAddr);
|
||||
UsedShmemSegAddr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Attach to shared memory and make sure it has a Postgres header
|
||||
*
|
||||
|
@ -32,7 +32,7 @@ shmat(int memId, void *shmaddr, int flag)
|
||||
/* TODO -- shmat needs to count # attached to shared mem */
|
||||
void *lpmem = MapViewOfFileEx((HANDLE) memId,
|
||||
FILE_MAP_WRITE | FILE_MAP_READ,
|
||||
0, 0, /* (DWORD)pshmdsc->segsize */ s_segsize, shmaddr);
|
||||
0, 0, /* (DWORD)pshmdsc->segsize */ 0 /* s_segsize */, shmaddr);
|
||||
|
||||
if (lpmem == NULL)
|
||||
{
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/init/findbe.c,v 1.40 2003/11/29 19:52:01 pgsql Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/init/findbe.c,v 1.41 2004/02/02 00:11:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -205,9 +205,9 @@ FindExec(char *full_path, const char *argv0, const char *binary_name)
|
||||
{
|
||||
elog(DEBUG2, "searching PATH for executable");
|
||||
path = strdup(p); /* make a modifiable copy */
|
||||
for (startp = path, endp = strchr(path, ':');
|
||||
for (startp = path, endp = strchr(path, PATHSEP);
|
||||
startp && *startp;
|
||||
startp = endp + 1, endp = strchr(startp, ':'))
|
||||
startp = endp + 1, endp = strchr(startp, PATHSEP))
|
||||
{
|
||||
if (startp == endp) /* it's a "::" */
|
||||
continue;
|
||||
|
@ -43,7 +43,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
* Portions taken from FreeBSD.
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.21 2004/01/31 22:10:00 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.22 2004/02/02 00:11:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -144,11 +144,6 @@ static const char *backend_options = "-F -O -c search_path=pg_catalog -c exit_on
|
||||
#define DEVNULL "/dev/null"
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#define PATHSEP ';'
|
||||
#else
|
||||
#define PATHSEP ':'
|
||||
#endif
|
||||
|
||||
/* detected path to postgres and (we assume) friends */
|
||||
char *pgpath;
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/port.h,v 1.15 2003/11/29 22:40:53 pgsql Exp $
|
||||
* $PostgreSQL: pgsql/src/include/port.h,v 1.16 2004/02/02 00:11:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -44,6 +44,10 @@ extern int pgunlink(const char *path);
|
||||
|
||||
extern int copydir(char *fromdir, char *todir);
|
||||
|
||||
/* Missing rand functions */
|
||||
extern long lrand48(void);
|
||||
extern void srand48(long seed);
|
||||
|
||||
/* Last parameter not used */
|
||||
extern int gettimeofday(struct timeval * tp, struct timezone * tzp);
|
||||
|
||||
@ -122,3 +126,20 @@ extern int pqGethostbyname(const char *name,
|
||||
char *buffer, size_t buflen,
|
||||
struct hostent **result,
|
||||
int *herrno);
|
||||
|
||||
/* $PATH (or %PATH%) path separator */
|
||||
#ifdef WIN32
|
||||
#define PATHSEP ';'
|
||||
#else
|
||||
#define PATHSEP ':'
|
||||
#endif
|
||||
|
||||
/* FIXME: [win32] Placeholder win32 replacements, to allow continued development */
|
||||
#ifdef WIN32
|
||||
#define fsync(a) _commit(a)
|
||||
#define sync() _flushall()
|
||||
#define WEXITSTATUS(w) (((w) >> 8) & 0xff)
|
||||
#define WIFEXITED(w) (((w) & 0xff) == 0)
|
||||
#define WIFSIGNALED(w) (((w) & 0x7f) > 0 && (((w) & 0x7f) < 0x7f))
|
||||
#define WTERMSIG(w) ((w) & 0x7f)
|
||||
#endif
|
||||
|
@ -4,7 +4,7 @@
|
||||
#
|
||||
# Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.96 2003/11/30 06:09:50 momjian Exp $
|
||||
# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.97 2004/02/02 00:11:31 momjian Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
@ -33,6 +33,9 @@ endif
|
||||
# shared library link. (The order in which you list them here doesn't
|
||||
# matter.)
|
||||
SHLIB_LINK += $(filter -lcrypt -ldes -lkrb -lcom_err -lcrypto -lk5crypto -lkrb5 -lssl -lsocket -lnsl -lresolv -lintl, $(LIBS)) $(THREAD_LIBS)
|
||||
ifeq ($(PORTNAME), win32)
|
||||
SHLIB_LINK += -lwsock32 -lws2_32
|
||||
endif
|
||||
|
||||
|
||||
all: all-lib
|
||||
|
@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/pqsignal.c,v 1.19 2004/01/09 02:02:43 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/pqsignal.c,v 1.20 2004/02/02 00:11:31 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* This shouldn't be in libpq, but the monitor and some other
|
||||
@ -44,6 +44,7 @@ pqsignal(int signo, pqsigfunc func)
|
||||
pqsigfunc
|
||||
pqsignalinquire(int signo)
|
||||
{
|
||||
#ifndef WIN32
|
||||
#if !defined(HAVE_POSIX_SIGNALS)
|
||||
pqsigfunc old_sigfunc;
|
||||
int old_sigmask;
|
||||
@ -61,4 +62,7 @@ pqsignalinquire(int signo)
|
||||
return SIG_ERR;
|
||||
return oact.sa_handler;
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
#else
|
||||
return SIG_DFL;
|
||||
#endif
|
||||
}
|
||||
|
@ -22,7 +22,9 @@
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_EXTRA_LEAN
|
||||
#define VC_EXTRALEAN
|
||||
#ifndef __MINGW32__
|
||||
#define NOGDI
|
||||
#endif
|
||||
#define NOCRYPT
|
||||
|
||||
#include <windows.h>
|
||||
|
78
src/port/rand.c
Normal file
78
src/port/rand.c
Normal file
@ -0,0 +1,78 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* rand.c
|
||||
* Missing rand implementations for Win32
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Martin Birgmeier
|
||||
* All rights reserved.
|
||||
*
|
||||
* You may redistribute unmodified or modified versions of this source
|
||||
* code provided that the above copyright notice and this and the
|
||||
* following conditions are retained.
|
||||
*
|
||||
* This software is provided ``as is'', and comes with no warranties
|
||||
* of any kind. I shall in no event be liable for anything that happens
|
||||
* to anyone/anything when using this software.
|
||||
*/
|
||||
#define RAND48_SEED_0 (0x330e)
|
||||
#define RAND48_SEED_1 (0xabcd)
|
||||
#define RAND48_SEED_2 (0x1234)
|
||||
#define RAND48_MULT_0 (0xe66d)
|
||||
#define RAND48_MULT_1 (0xdeec)
|
||||
#define RAND48_MULT_2 (0x0005)
|
||||
#define RAND48_ADD (0x000b)
|
||||
|
||||
unsigned short _rand48_seed[3] = {
|
||||
RAND48_SEED_0,
|
||||
RAND48_SEED_1,
|
||||
RAND48_SEED_2
|
||||
};
|
||||
unsigned short _rand48_mult[3] = {
|
||||
RAND48_MULT_0,
|
||||
RAND48_MULT_1,
|
||||
RAND48_MULT_2
|
||||
};
|
||||
unsigned short _rand48_add = RAND48_ADD;
|
||||
|
||||
void
|
||||
_dorand48(unsigned short xseed[3])
|
||||
{
|
||||
unsigned long accu;
|
||||
unsigned short temp[2];
|
||||
|
||||
accu = (unsigned long) _rand48_mult[0] * (unsigned long) xseed[0] +
|
||||
(unsigned long) _rand48_add;
|
||||
temp[0] = (unsigned short) accu; /* lower 16 bits */
|
||||
accu >>= sizeof(unsigned short) * 8;
|
||||
accu += (unsigned long) _rand48_mult[0] * (unsigned long) xseed[1] +
|
||||
(unsigned long) _rand48_mult[1] * (unsigned long) xseed[0];
|
||||
temp[1] = (unsigned short) accu; /* middle 16 bits */
|
||||
accu >>= sizeof(unsigned short) * 8;
|
||||
accu += _rand48_mult[0] * xseed[2] + _rand48_mult[1] * xseed[1] + _rand48_mult[2] * xseed[0];
|
||||
xseed[0] = temp[0];
|
||||
xseed[1] = temp[1];
|
||||
xseed[2] = (unsigned short) accu;
|
||||
}
|
||||
|
||||
long
|
||||
lrand48(void)
|
||||
{
|
||||
_dorand48(_rand48_seed);
|
||||
return ((long) _rand48_seed[2] << 15) + ((long) _rand48_seed[1] >1);
|
||||
}
|
||||
|
||||
void
|
||||
srand48(long seed)
|
||||
{
|
||||
_rand48_seed[0] = RAND48_SEED_0;
|
||||
_rand48_seed[1] = (unsigned short) seed;
|
||||
_rand48_seed[2] = (unsigned short) (seed >16);
|
||||
_rand48_mult[0] = RAND48_MULT_0;
|
||||
_rand48_mult[1] = RAND48_MULT_1;
|
||||
_rand48_mult[2] = RAND48_MULT_2;
|
||||
_rand48_add = RAND48_ADD;
|
||||
}
|
Loading…
Reference in New Issue
Block a user