Commit Graph

12 Commits

Author SHA1 Message Date
Kamil Rytarowski 48ff4764a4 Add NetBSD support
$ make test
cd tests && ../flisp unittest.lsp
all tests pass
2020-03-08 02:36:54 +02:00
Rick Hanson 6bc3fe5f11 get_exename() for OpenBSD. (#17)
get_exename() for OpenBSD.

Issue

`get_exename()` gets the pathname of the current process.  In
femtolisp, this is used to set the top-level `*install-dir*` which in
turn is used as the location of the system image, `flisp.boot`.

There is only a trivial implementation of `get_exename()` for OpenBSD
that simply returns `NULL`.  A minor consequence is that the unit test
will fail for the default build (make) because the system image cannot
be found.

Fix

This commit provides an implementation of `get_exename()` for OpenBSD,
so that the system image can be found.

Unlike, say, Linux or FreeBSD, OpenBSD doesn't have a system call to
get the path of the current (or any, for that matter) process.  The
present code contains some logic that was put together to emulate the
behavior of the Linux and FreeBSD variants of `get_exename()` as best
as possible.  It works as described by the following.

(1) Call `sysctl(3)` (with `CTL_KERN` -> `KERN_PROC_ARGS` ->
    `KERN_PROC_ARGV`) to get the "`argv[0]`" of the current process.
    If the program (flisp) was called in "`basename` form" (i.e. as
    "flisp"), then go to (2).  Otherwise, return the value from
    `sysctl(3)` which will be an absolute or relative pathname,
    e.g. "/usr/local/bin/flisp" or  "../flisp".

    The code for (1) was adapted from old OpenBSD-specific `tmux` code
    that has since been abandoned by the author only because he deemed
    it "too expensive".  For that code, see

    8c259f562b/tree/osdep-openbsd.c

(2) Since we now only have "flisp", we need to find out where it is
    located on the system.  We assume that a program like the shell
    had to crawl `PATH` to find "flisp"; hence we do the same.

    The code for (2) was adapted from the `which` utility in OpenBSD.
    See

    http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/usr.bin/which/which.c?rev=1.20&content-type=text/plain

Finally, any error condition returns `NULL`, which is the same
behavior of the other `get_exename()` variants.

* Resolve relative pathnames to absolute, for OpenBSD get_exename().
2016-11-15 15:12:14 -05:00
Mark Probst 49ec8cf379 get_exename() for OSX >= 10.9 2015-05-06 15:36:41 -07:00
Rick Hanson 74041edf56 Make FreeBSD a "first class citizen" among femtolisp's build OSes.
It looks like FreeBSD should do what OpenBSD does in femtolisp's code.
The biggest change here (I think) is that of determining the correct
value of CC in the Makefile(s).  As of version 10, FreeBSD's base
compiler is clang; so there is now some logic in the Makefile(s) to
determine if the build is occurring on a FreeBSD system >= 10.0.  If
so, then the value of CC will be "clang"; otherwise, it will be "gcc",
as before.
2015-04-11 15:21:02 -04:00
tycho luyben 54c441e29b Femtolisp works now on modern macs (fix from Julia) 2014-02-26 18:45:02 +01:00
James Turner 19a835847c Add support for OpenBSD 2013-06-03 21:40:14 -04:00
Jon Distad 3707cc21ab Updated carbon path and pointer size check 2013-05-08 19:41:21 -04:00
Jeff Bezanson c019b3bf2d portability improvements 2012-02-26 23:00:47 -05:00
JeffBezanson 7d652f9c5a some LLT cleanup:
making allocation functions customizable
  adding ios_vprintf
  simplifying config variables for mac
2010-02-25 04:37:33 +00:00
JeffBezanson be453f2ed5 improving portability to Mac OS
fixes for big endian architectures (PowerPC)
renaming exported symbol raise to fl_raise
fixing some bugs and oversights discovered in the process
2009-08-29 00:54:51 +00:00
JeffBezanson c8c59b1dfc added globals *install-dir* and *print-width*, parameterized
prettyprinter by screen width

decent accumulate-while and accumulate-for
2008-09-11 02:37:38 +00:00
JeffBezanson 1f81d56b89 import of llt library source 2008-07-01 01:53:51 +00:00