ref: 13524eb51bcdd4ee9316a00b8ad6c1e6ee490ab6
parent: 2218aceab862c6d0305162e306620b71ca7caf0e
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Fri Mar 10 11:55:08 EST 2023
eradicate windows and mac os x support
--- a/builtins.c
+++ b/builtins.c
@@ -374,9 +374,6 @@
return FL_T;
}
-#ifdef WIN32
-#define stat _stat
-#endif
static value_t fl_path_exists(value_t *args, uint32_t nargs)
{
argcount("path.exists?", nargs, 1);
--- a/flisp.boot
+++ b/flisp.boot
@@ -71,9 +71,15 @@
<= #fn("7000r2}|X17B02e0|3116802e0}31@;" [nan?] <=) >
#fn("7000r2}|X;" [] >) >= #fn("7000r2|}X17B02e0|3116802e0}31@;" [nan?] >=)
Instructions #table(not 16 vargc 67 load1 49 = 39 setc.l 64 sub2 72 brne.l 83 largc 74 brnn 85 loadc.l 58 loadi8 50 < 40 nop 0 set-cdr! 32 loada 55 bound? 21 / 37 neg 73 brn.l 88 lvargc 75 brt 7 trycatch 68 null? 17 load0 48 jmp.l 8 loadv 51 seta 61 keyargs 91 * 36 function? 26 builtin? 23 aref 43 optargs 89 vector? 24 loadt 45 brf 6 symbol? 19 cdr 30 for 69 loadc00 78 pop 2 pair? 22 cadr 84 closure 65 loadf 46 compare 41 loadv.l 52 setg.l 60 brn 87 eqv? 13 aset! 44 eq? 12 atom? 15 boolean? 18 brt.l 10 tapply 70 dummy_nil 94 loada0 76 brbound 90 list 28 dup 1 apply 33 loadc 57 loadc01 79 dummy_t 92 setg 59 loada1 77 tcall.l 81 jmp 5 fixnum? 25 cons 27 loadg.l 54 tcall 4 call 3 - 35 brf.l 9 + 34 dummy_f 93 add2 71 seta.l 62 loadnil 47 brnn.l 86 setc 63 set-car! 31 vector 42 loadg 53 loada.l 56 argc 66 div0 38 ret 11 number? 20 equal? 14 car 29 call.l 80 brne 82)
- __init_globals #fn("7000r0e0c1<17B02e0c2<17802e0c3<6>0c4k52c6k75;0c8k52c9k72e:k;2e<k=2e>k?;" [*os-name*
- win32 win64 windows "\\" *directory-separator* "\r\n" *linefeed* "/" "\n"
- *stdout* *output-stream* *stdin* *input-stream* *stderr* *error-stream*] __init_globals)
+ __init_globals #fn("6000r0c0k12c2k32e4k52e6k72e8k9;" ["/"
+ *directory-separator*
+ "\n" *linefeed*
+ *stdout*
+ *output-stream*
+ *stdin*
+ *input-stream*
+ *stderr*
+ *error-stream*] __init_globals)
__script #fn("7000r1c0qc1t;" [#fn("7000r0e0~41;" [load])
#fn("7000r1e0|312c1a41;" [top-level-exception-handler
#fn(exit)])] __script)
@@ -157,7 +163,7 @@
largc lvargc vargc argc compile-in ret values #fn(function) encode-byte-code
bcode:code const-to-idx-vec]) filter keyword-arg?])
#fn(length)]) #fn(length)]) make-code-emitter lastcdr lambda-vars filter #.pair?
- lambda])] #0=[#:g718 ()])
+ lambda])] #0=[#:g714 ()])
compile-for #fn(":000r5e0g4316X0e1|}^g2342e1|}^g3342e1|}^g4342e2|c342;e4c541;" [1arg-lambda?
compile-in emit for error "for: third form must be a 1-argument lambda"] compile-for)
compile-if #fn("<000r4c0qe1|31e1|31g3\x84e2g331e3g331F6;0e4g331560e53045;" [#fn(";000r5g2]\x82>0e0~\x7fi02g344;g2^\x82>0e0~\x7fi02g444;e0~\x7f^g2342e1~c2|332e0~\x7fi02g3342i026<0e1~c3325:0e1~c4}332e5~|322e0~\x7fi02g4342e5~}42;" [compile-in
@@ -278,7 +284,7 @@
#fn("7000r1|c0>16:02c1i1031670c240;|;" ["" #fn(io.eof?)
#fn(eof-object)])
#fn(io.tostring!)]) #fn(buffer)] io.readall)
- io.readline #fn("8000r1c0|c142;" [#fn(io.readuntil) #\linefeed] io.readline)
+ io.readline #fn("8000r1c0|c142;" [#fn(io.readuntil) #\newline] io.readline)
io.readlines #fn("8000r1e0e1|42;" [read-all-of io.readline] io.readlines)
iota #fn("8000r1e0e1|42;" [map-int identity] iota) keyword->symbol
#fn("9000r1c0|316@0c1c2c3|313141;|;" [#fn(keyword?)
--- a/flisp.c
+++ b/flisp.c
@@ -2325,10 +2325,6 @@
#ifdef LINUX
set(symbol("*os-name*"), symbol("linux"));
-#elif defined(WIN32) || defined(WIN64)
- set(symbol("*os-name*"), symbol("win32"));
-#elif defined(MACOSX)
- set(symbol("*os-name*"), symbol("macos"));
#elif defined(OPENBSD)
set(symbol("*os-name*"), symbol("openbsd"));
#elif defined(FREEBSD)
--- a/llt/bitvector-ops.c
+++ b/llt/bitvector-ops.c
@@ -10,11 +10,6 @@
#include "dtypes.h"
#include "bitvector.h"
-#ifdef WIN32
-#include <malloc.h>
-#define alloca _alloca
-#endif
-
// greater than this # of words we use malloc instead of alloca
#define MALLOC_CUTOFF 2000
--- a/llt/bitvector.c
+++ b/llt/bitvector.c
@@ -41,10 +41,6 @@
#include "dtypes.h"
#include "bitvector.h"
-#ifdef WIN32
-#include <malloc.h>
-#endif
-
u_int32_t *bitvector_resize(u_int32_t *b, uint64_t oldsz, uint64_t newsz,
int initzero)
{
--- a/llt/dirpath.c
+++ b/llt/dirpath.c
@@ -1,6 +1,7 @@
#ifdef PLAN9
#include <u.h>
#include <libc.h>
+#define getcwd getwd
#else
#include <stdlib.h>
#include <stdio.h>
@@ -11,21 +12,10 @@
#include <limits.h>
#include <sys/stat.h>
#include <sys/types.h>
-#ifdef WIN32
-#include <malloc.h>
-#include <sys/timeb.h>
-#include <windows.h>
-#undef NO_ERROR
-#undef MOD_SHIFT
-#undef TRUE
-#undef FALSE
-#undef VOID
-#else
#include <sys/time.h>
#include <sys/poll.h>
#include <unistd.h>
#endif
-#endif
#include "dtypes.h"
#include "dirpath.h"
@@ -32,25 +22,12 @@
void get_cwd(char *buf, size_t size)
{
-#ifdef PLAN9
- getwd(buf, size);
-#elif !defined(WIN32)
getcwd(buf, size);
-#else
- GetCurrentDirectory(size, buf);
-#endif
}
int set_cwd(char *buf)
{
-#ifndef WIN32
- if (chdir(buf) == -1)
- return 1;
-#else
- if (SetCurrentDirectory(buf) == 0)
- return 1;
-#endif
- return 0;
+ return chdir(buf);
}
// destructively convert path to directory part
@@ -223,22 +200,5 @@
sysctl(mib, 4, buf, &size, NULL, 0);
return buf;
-}
-#elif defined(WIN32)
-char *get_exename(char *buf, size_t size)
-{
- if (GetModuleFileName(NULL, buf, size) == 0)
- return NULL;
-
- return buf;
-}
-#elif defined(MACOSX)
-#include <mach-o/dyld.h>
-char *get_exename(char *buf, size_t size)
-{
- uint32_t bufsize = (uint32_t)size;
- if (_NSGetExecutablePath(buf, &bufsize))
- return NULL;
- return buf;
}
#endif
--- a/llt/dirpath.h
+++ b/llt/dirpath.h
@@ -1,20 +1,11 @@
#ifndef __DIRPATH_H_
#define __DIRPATH_H_
-#ifdef WIN32
-#define PATHSEP '\\'
-#define PATHSEPSTRING "\\"
-#define PATHLISTSEP ';'
-#define PATHLISTSEPSTRING ";"
-#define ISPATHSEP(c) ((c)=='/' || (c)=='\\')
-#define MAXPATHLEN 1024
-#else
#define PATHSEP '/'
#define PATHSEPSTRING "/"
#define PATHLISTSEP ':'
#define PATHLISTSEPSTRING ":"
#define ISPATHSEP(c) ((c)=='/')
-#endif
void get_cwd(char *buf, size_t size);
int set_cwd(char *buf);
--- a/llt/dtypes.h
+++ b/llt/dtypes.h
@@ -19,8 +19,6 @@
#if defined(__gnu_linux__)
# define LINUX
-#elif defined(__APPLE__) && defined(__MACH__)
-# define MACOSX
#elif defined(__OpenBSD__)
# define OPENBSD
#elif defined(__FreeBSD__)
@@ -27,8 +25,6 @@
# define FREEBSD
#elif defined(__NetBSD__)
# define NETBSD
-#elif defined(_WIN32)
-# define WIN32
#elif !defined(PLAN9)
# error "unknown platform"
#endif
@@ -55,14 +51,7 @@
#endif
-#if defined(WIN32)
-# define STDCALL __stdcall
-# if defined(IMPORT_EXPORTS)
-# define DLLEXPORT __declspec(dllimport)
-# else
-# define DLLEXPORT __declspec(dllexport)
-# endif
-#elif defined(PLAN9)
+#if defined(PLAN9)
#define STDCALL
#define DLLEXPORT
#else
@@ -70,20 +59,9 @@
# define DLLEXPORT __attribute__ ((visibility("default")))
#endif
-#if defined(LINUX)
-# include <features.h>
+#if defined(LINUX) || defined(OPENBSD) || defined(FREEBSD) || defined(NETBSD)
# include <endian.h>
-# define LITTLE_ENDIAN __LITTLE_ENDIAN
-# define BIG_ENDIAN __BIG_ENDIAN
-# define PDP_ENDIAN __PDP_ENDIAN
-# define BYTE_ORDER __BYTE_ORDER
-#elif defined(MACOSX) || defined(OPENBSD) || defined(FREEBSD) || defined(NETBSD)
-# include <machine/endian.h>
-# define __LITTLE_ENDIAN LITTLE_ENDIAN
-# define __BIG_ENDIAN BIG_ENDIAN
-# define __PDP_ENDIAN PDP_ENDIAN
-# define __BYTE_ORDER BYTE_ORDER
-#elif defined(WIN32) || defined(PLAN9)
+#elif defined(PLAN9)
# define __LITTLE_ENDIAN 1234
# define __BIG_ENDIAN 4321
# define __PDP_ENDIAN 3412
@@ -134,14 +112,6 @@
#ifndef NULL
#define NULL nil
#endif
-#elif defined(__INTEL_COMPILER) && defined(WIN32)
-# define STATIC_INLINE static
-# define INLINE
-# ifdef BITS64
-typedef unsigned long size_t;
-# else
-typedef unsigned int size_t;
-# endif
#else
# define STATIC_INLINE static inline
# define INLINE inline
@@ -163,19 +133,6 @@
typedef vlong off_t;
typedef intptr intptr_t;
typedef uintptr uintptr_t;
-#elif defined(WIN32)
-typedef short int16_t;
-typedef int int32_t;
-typedef long long int64_t;
-typedef unsigned char u_int8_t;
-typedef unsigned short u_int16_t;
-typedef unsigned int u_int32_t;
-typedef unsigned long long u_int64_t;
-#ifdef __INTEL_COMPILER
-typedef signed char int8_t;
-typedef short int16_t;
-typedef int int32_t;
-#endif
#else
#include <sys/types.h>
#include <stdint.h>
@@ -213,6 +170,10 @@
#define __likely(x) (x)
#endif
+#ifndef PLAN9
+#include <float.h>
+#endif
+
#define DBL_MAXINT 9007199254740992LL
#define FLT_MAXINT 16777216
#define U64_MAX 18446744073709551615ULL
@@ -223,17 +184,6 @@
#define S32_MAX 2147483647L
#define S32_MIN (-S32_MAX - 1L)
#define BIT31 0x80000000UL
-
-#ifndef DBL_EPSILON
-#define DBL_EPSILON 2.2204460492503131e-16
-#define FLT_EPSILON 1.192092896e-7
-#if !defined(NETBSD)
-#define DBL_MAX 1.7976931348623157e+308
-#define DBL_MIN 2.2250738585072014e-308
-#define FLT_MAX 3.402823466e+38
-#define FLT_MIN 1.175494351e-38
-#endif
-#endif
#define LOG2_10 3.3219280948873626
#define rel_zero(a, b) (fabs((a)/(b)) < DBL_EPSILON)
--- a/llt/ios.c
+++ b/llt/ios.c
@@ -25,12 +25,6 @@
#include <errno.h>
#include <wchar.h>
#include <stdio.h> // for printf
-#ifdef WIN32
-#include <malloc.h>
-#include <io.h>
-#include <fcntl.h>
-#define fileno _fileno
-#else
#include <unistd.h>
#include <sys/time.h>
#include <sys/select.h>
@@ -37,7 +31,6 @@
#include <sys/stat.h>
#include <fcntl.h>
#endif
-#endif
#include "dtypes.h"
#include "utils.h"
@@ -49,7 +42,7 @@
/* OS-level primitive wrappers */
-#if defined(MACOSX) || defined(PLAN9)
+#if defined(PLAN9)
void *memrchr(const void *s, int c, size_t n)
{
const unsigned char *src = (const unsigned char*)s + n;
@@ -67,7 +60,6 @@
// poll for read, unless forwrite!=0
static void _fd_poll(long fd, int forwrite)
{
-#ifndef WIN32
fd_set set;
FD_ZERO(&set);
@@ -76,8 +68,6 @@
select(fd+1, NULL, &set, NULL, NULL);
else
select(fd+1, &set, NULL, NULL, NULL);
-#else
-#endif
}
#endif
--- a/llt/lookup3.c
+++ b/llt/lookup3.c
@@ -37,18 +37,9 @@
#ifndef PLAN9
#include <stdio.h> /* defines printf for tests */
-#include <time.h> /* defines time_t for timings in the test */
-#ifndef WIN32
#include <stdint.h> /* defines uint32_t etc */
#include <sys/param.h> /* attempt to define endianness */
-#else
-typedef unsigned int uint32_t;
-typedef unsigned char uint8_t;
-typedef unsigned short uint16_t;
-#endif
-#ifdef LINUX
-# include <endian.h> /* attempt to define endianness */
-#endif
+#include <endian.h> /* attempt to define endianness */
#endif
/*
--- a/llt/socket.c
+++ b/llt/socket.c
@@ -4,15 +4,11 @@
#include <unistd.h>
#include <assert.h>
#include <errno.h>
-
-#include "dtypes.h"
-
-#if !defined(WIN32) && !defined(PLAN9)
#include <sys/time.h>
#include <sys/select.h>
#include <sys/types.h>
-#endif
+#include "dtypes.h"
#include "socket.h"
int mysocket(int domain, int type, int protocol)
@@ -39,13 +35,6 @@
fcntl(socket, F_SETFL, flags & ~O_NONBLOCK);
}
-#ifdef WIN32
-void bzero(void *s, size_t n)
-{
- memset(s, 0, n);
-}
-#endif
-
/* returns a socket on which to accept() connections */
int open_tcp_port(short portno)
{
@@ -113,12 +102,10 @@
return sockfd;
}
-#ifndef WIN32
void closesocket(int fd)
{
close(fd);
}
-#endif
/* returns a socket to use to send data to the given address */
int connect_to_host(char *hostname, short portno)
--- a/llt/socket.h
+++ b/llt/socket.h
@@ -2,9 +2,6 @@
#define __LLTSOCKET_H_
#ifndef PLAN9
-#ifdef WIN32
-#include <winsock2.h>
-#else
#include <netinet/in.h>
#include <netdb.h>
#include <sys/types.h>
@@ -11,7 +8,6 @@
#include <sys/socket.h>
#include <fcntl.h>
#endif
-#endif
int open_tcp_port(short portno);
int open_any_tcp_port(short *portno);
@@ -22,12 +18,6 @@
int readall(int sockfd, char *buffer, int bufLen, int flags);
int addr_eq(struct sockaddr_in *a, struct sockaddr_in *b);
int socket_ready(int sock);
-
-#ifdef WIN32
-void bzero(void *s, size_t n);
-#endif
-#ifndef WIN32
void closesocket(int fd);
-#endif
#endif
--- a/llt/timefuncs.c
+++ b/llt/timefuncs.c
@@ -11,38 +11,17 @@
#include <limits.h>
#include <sys/stat.h>
#include <sys/types.h>
-#ifdef WIN32
-#include <malloc.h>
-#include <sys/timeb.h>
-#include <windows.h>
-#else
#include <sys/time.h>
#include <sys/poll.h>
#include <unistd.h>
#endif
-#endif
#include "dtypes.h"
#include "timefuncs.h"
-#ifdef WIN32
-/*
-double tvals2float(struct tm *t, struct timeb *tstruct)
-{
- return (double)t->tm_hour * 3600 + (double)t->tm_min * 60 +
- (double)t->tm_sec + (double)tstruct->millitm/1.0e3;
-}
-*/
+#if defined(PLAN9)
double floattime(void)
{
- struct timeb tstruct;
-
- ftime(&tstruct);
- return (double)tstruct.time + (double)tstruct.millitm/1.0e3;
-}
-#elif defined(PLAN9)
-double floattime(void)
-{
return (double)nsec() / 1.0e9;
}
#else
@@ -61,11 +40,7 @@
u_int64_t i64time(void)
{
u_int64_t a;
-#ifdef WIN32
- struct timeb tstruct;
- ftime(&tstruct);
- a = (((u_int64_t)tstruct.time)<<32) + (u_int64_t)tstruct.millitm;
-#elif defined(PLAN9)
+#if defined(PLAN9)
a = nsec();
#else
struct timeval now;
@@ -78,7 +53,7 @@
double clock_now(void)
{
-#if defined(WIN32) || defined(PLAN9)
+#if defined(PLAN9)
return floattime();
#else
struct timeval now;
@@ -93,7 +68,7 @@
#ifdef PLAN9
Tm tm;
snprint(buffer, len, "%τ", tmfmt(tmtime(&tm, seconds, tzload("local")), nil));
-#elif defined(LINUX) || defined(MACOSX) || defined(OPENBSD) || defined(FREEBSD) || defined(NETBSD)
+#elif defined(LINUX) || defined(OPENBSD) || defined(FREEBSD) || defined(NETBSD)
time_t tme = (time_t)seconds;
char *fmt = "%c"; /* needed to suppress GCC warning */
@@ -121,7 +96,7 @@
#endif
}
-#if defined(LINUX) || defined(MACOSX) || defined(OPENBSD) || defined(FREEBSD) || defined(NETBSD)
+#if defined(LINUX) || defined(OPENBSD) || defined(FREEBSD) || defined(NETBSD)
extern char *strptime(const char *s, const char *format, struct tm *tm);
double parsetime(const char *str)
{
@@ -160,9 +135,7 @@
if (ms == 0)
return;
-#ifdef WIN32
- Sleep(ms);
-#elif defined(PLAN9)
+#if defined(PLAN9)
sleep(ms);
#else
struct timeval timeout;
--- a/llt/utf8.c
+++ b/llt/utf8.c
@@ -36,15 +36,6 @@
#include <stdarg.h>
#include <wchar.h>
#include <wctype.h>
-
-#ifdef WIN32
-#include <malloc.h>
-#define snprintf _snprintf
-#else
-#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__)
-#include <alloca.h>
-#endif /* __FreeBSD__ && __OpenBSD__ && __NetBSD__ */
-#endif
#include <assert.h>
#endif
@@ -260,7 +251,7 @@
return count;
}
-#if defined(__WIN32__) || defined(PLAN9)
+#if defined(PLAN9)
#include "wcwidth.c"
#endif
--- a/llt/utf8.h
+++ b/llt/utf8.h
@@ -1,7 +1,6 @@
#ifndef __UTF8_H_
#define __UTF8_H_
-#if !defined(MACOSX)
#if !defined(__DTYPES_H_) && !defined(_SYS_TYPES_H)
typedef char int8_t;
typedef short int16_t;
@@ -11,11 +10,6 @@
typedef unsigned short u_int16_t;
typedef unsigned int u_int32_t;
typedef unsigned long long u_int64_t;
-#endif
-#endif
-
-#if defined(__WIN32__)
-extern int wcwidth(uint32_t);
#endif
/* is c the start of a utf8 sequence? */
--- a/system.lsp
+++ b/system.lsp
@@ -1056,13 +1056,8 @@
; initialize globals that need to be set at load time
(define (__init_globals)
- (if (or (eq? *os-name* 'win32)
- (eq? *os-name* 'win64)
- (eq? *os-name* 'windows))
- (begin (set! *directory-separator* "\\")
- (set! *linefeed* "\r\n"))
- (begin (set! *directory-separator* "/")
- (set! *linefeed* "\n")))
+ (set! *directory-separator* "/")
+ (set! *linefeed* "\n")
(set! *output-stream* *stdout*)
(set! *input-stream* *stdin*)
(set! *error-stream* *stderr*))