Commit Graph

12 Commits

Author SHA1 Message Date
Lassi Kortela 6a6a7071a9 Run clang-format on all C code for the first time 2019-08-09 14:02:02 +03:00
Rick Hanson 130518cdc9 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().
2019-08-08 18:09:02 +03:00
Mark Probst 3c10ecc0be get_exename() for OSX >= 10.9 2019-08-08 18:09:02 +03:00
Rick Hanson fe6948e421 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.
2019-08-08 18:09:02 +03:00
tycho luyben 8dba83c8cd Femtolisp works now on modern macs (fix from Julia) 2019-08-08 18:09:02 +03:00
James Turner 088ea8f194 Add support for OpenBSD 2019-08-08 18:09:02 +03:00
Jon Distad c222226f43 Updated carbon path and pointer size check 2019-08-08 18:09:02 +03: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