use uuid_generate on unix-like systems for S_unique_id

original commit: 2fd3db68230d094a0d396348a8140a4d3693b120
This commit is contained in:
Bob Burger 2018-09-18 16:42:51 -04:00
parent 59c055d91f
commit 75a70547f8
14 changed files with 45 additions and 57 deletions

View File

@ -11,8 +11,10 @@ matrix:
env: TARGET_MACHINE=ta6osx
- os: linux
env: TARGET_MACHINE=i3le
sudo: required
- os: linux
env: TARGET_MACHINE=ti3le
sudo: required
- os: linux
env: TARGET_MACHINE=a6le
- os: linux

View File

@ -1,5 +1,8 @@
#!/bin/bash
case $TARGET_MACHINE in
*i3le) sudo apt-get -yq --no-install-suggests --no-install-recommends install uuid-dev:i386 ;;
*)
esac
./configure -m=$TARGET_MACHINE
exitcode=$?
if [ $exitcode -ne 0 ] ; then

View File

@ -42,6 +42,7 @@ Prerequisites:
* gcc
* Header files and libraries for ncurses
* Header files and libraries for X windows
* Header files and libraries for uuid
Uninstalling on Unix-like systems is as simple as running:

2
LOG
View File

@ -1007,3 +1007,5 @@
Makefile.in, Makefile-workarea.in, Mf-install.in
- add PDB files for Windows
c/*nt, wininstall/*nt.wxs
- use uuid_generate on unix-like systems for S_unique_id
BUILDING, c/Mf-*le, stats.c, objects.stex, release_notes.stex

View File

@ -16,7 +16,7 @@
m = a6le
Cpu = X86_64
mdclib = -lm -ldl -lncurses -lrt
mdclib = -lm -ldl -lncurses -lrt -luuid
C = ${CC} ${CPPFLAGS} -m64 -msse2 -Wpointer-arith -Wall -Wextra -Werror -Wno-implicit-fallthrough -O2 ${CFLAGS}
o = o
mdsrc = i3le.c

View File

@ -16,7 +16,7 @@
m = arm32le
Cpu = ARMV6
mdclib = -lm -ldl -lncurses -lrt
mdclib = -lm -ldl -lncurses -lrt -luuid
C = ${CC} ${CPPFLAGS} -Wpointer-arith -Wextra -Werror -Wno-implicit-fallthrough -O2 ${CFLAGS}
o = o
mdsrc = arm32le.c

View File

@ -16,7 +16,7 @@
m = i3le
Cpu = I386
mdclib = -lm -ldl -lncurses -lrt
mdclib = -lm -ldl -lncurses -lrt -luuid
C = ${CC} ${CPPFLAGS} -m32 -msse2 -Wpointer-arith -Wall -Wextra -Werror -Wno-implicit-fallthrough -O2 -fno-stack-protector ${CFLAGS}
o = o
mdsrc = i3le.c

View File

@ -16,7 +16,7 @@
m = ppc32le
Cpu = PPC32
mdclib = -lm -ldl -lncurses -lrt
mdclib = -lm -ldl -lncurses -lrt -luuid
C = ${CC} ${CPPFLAGS} -m32 -Wpointer-arith -Wextra -Werror -Wno-implicit-fallthrough -O2 ${CFLAGS}
o = o
mdsrc = ppc32.c

View File

@ -16,7 +16,7 @@
m = ta6le
Cpu = X86_64
mdclib = -lm -ldl -lncurses -lpthread -lrt
mdclib = -lm -ldl -lncurses -lpthread -lrt -luuid
C = ${CC} ${CPPFLAGS} -m64 -msse2 -Wpointer-arith -Wall -Wextra -Werror -Wno-implicit-fallthrough -O2 -D_REENTRANT -pthread ${CFLAGS}
o = o
mdsrc = i3le.c

View File

@ -16,7 +16,7 @@
m = ti3le
Cpu = I386
mdclib = -lm -ldl -lncurses -lpthread -lrt
mdclib = -lm -ldl -lncurses -lpthread -lrt -luuid
C = ${CC} ${CPPFLAGS} -m32 -msse2 -Wpointer-arith -Wall -Wextra -Werror -Wno-implicit-fallthrough -O2 -D_REENTRANT -pthread ${CFLAGS}
o = o
mdsrc = i3le.c

View File

@ -16,7 +16,7 @@
m = tppc32le
Cpu = PPC32
mdclib = -lm -ldl -lncurses -lpthread -lrt
mdclib = -lm -ldl -lncurses -lpthread -lrt -luuid
C = ${CC} ${CPPFLAGS} -m32 -Wpointer-arith -Wextra -Werror -Wno-implicit-fallthrough -O2 -D_REENTRANT -pthread ${CFLAGS}
o = o
mdsrc = ppc32le.c

View File

@ -53,57 +53,33 @@ static long adjust_time_zone(ptr dtvec, struct tm *tmxp, ptr given_tzoff);
#include <rpc.h>
ptr S_unique_id() {
union {UUID uuid; INT foo[4];} u;
union {UUID uuid; U32 foo[4];} u;
u.foo[0] = 0;
u.foo[1] = 0;
u.foo[2] = 0;
u.foo[3] = 0;
UuidCreate(&u.uuid);
return S_add(S_ash(Sunsigned(u.foo[0]), Sinteger(8*3*sizeof(INT))),
S_add(S_ash(Sunsigned(u.foo[1]), Sinteger(8*2*sizeof(INT))),
S_add(S_ash(Sunsigned(u.foo[2]), Sinteger(8*sizeof(INT))),
Sunsigned(u.foo[3]))));
return S_add(S_ash(Sunsigned32(u.foo[0]), Sinteger(8*3*sizeof(U32))),
S_add(S_ash(Sunsigned32(u.foo[1]), Sinteger(8*2*sizeof(U32))),
S_add(S_ash(Sunsigned32(u.foo[2]), Sinteger(8*sizeof(U32))),
Sunsigned32(u.foo[3]))));
}
#else /* WIN32 */
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
static INT gethostip(void) {
char hostname[MAXHOSTNAMELEN+1];
struct hostent *h;
char **p;
struct in_addr in;
if (gethostname(hostname, MAXHOSTNAMELEN)) return 0;
if ((h = gethostbyname(hostname)) == NULL) return 0;
p = h->h_addr_list;
if (*p == NULL) return 0;
memcpy(&in.s_addr, *p, sizeof (in.s_addr));
return in.s_addr;
}
#include <uuid/uuid.h>
ptr S_unique_id() {
struct timeval tp;
time_t sec;
pid_t pid;
INT ip;
(void) gettimeofday(&tp,NULL);
pid = getpid();
ip = gethostip();
sec = tp.tv_sec;
return S_add(S_ash(Sunsigned(pid), Sinteger(8*(sizeof(sec)+sizeof(ip)))),
S_add(S_ash(Sunsigned(ip), Sinteger(8*(sizeof(sec)))),
Sunsigned(sec)));
union {uuid_t uuid; U32 foo[4];} u;
u.foo[0] = 0;
u.foo[1] = 0;
u.foo[2] = 0;
u.foo[3] = 0;
uuid_generate(u.uuid);
return S_add(S_ash(Sunsigned32(u.foo[0]), Sinteger(8*3*sizeof(U32))),
S_add(S_ash(Sunsigned32(u.foo[1]), Sinteger(8*2*sizeof(U32))),
S_add(S_ash(Sunsigned32(u.foo[2]), Sinteger(8*sizeof(U32))),
Sunsigned32(u.foo[3]))));
}
#endif /* WIN32 */

View File

@ -1418,10 +1418,8 @@ The pretty name of a gensym is returned by the procedure
In both the first and second forms, the unique name is an
automatically generated globally unique name.
Globally unique names are constructed (lazily---see below)
from some combination of a unique machine identifier (such as the
network address), the current process identifier (PID), and the
time at which the Scheme session began, along with an internal
Globally unique names are constructed (lazily---see below) from the
combination of a universally unique identifier and an internal
counter.
In the third form of gensym, the unique name of the new gensym is
\var{unique-name}, which must be a string.

View File

@ -1592,6 +1592,12 @@ in fasl files does not generally make sense.
%-----------------------------------------------------------------------------
\section{Bug Fixes}\label{section:bugfixes}
\subsection{Globally unique names on non-Windows systems no longer contain the IP address (9.5.1)}
The globally unique names of gensyms no longer contain the IP address
on non-Windows systems. Windows systems already used a universally
unique identifier.
\subsection{Invalid memory reference from \protect\scheme{fxvector} calls (9.5)}
A compiler bug that could result in an invalid memory reference or