[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: why not use more functionality from the posix standardd libc ?
- From: Jim <djvaios@...>
- Date: Thu, 9 May 2019 04:15:24 +0200
On 10/3/18, Sean Conner <sean@conman.org> wrote:
> it was not about using in the first place. it was just an example of what other
> small embedding languages can do/provide. the point here was that such
> functionality could be added to Lua aswell without too much work
> (in that case it was Squirrel's builtin regex lib wich provides pattern alternatives
> using the '|' OR regex operator).
in this case Suirrel's author provides such a lib that could be used
directly by Lua
if adding such a regex operator is turns out to be too much work.
another solution would be using the builtin Squirrel regex lib's code directly,
it is written in C++ though, but i a very procedural style that does
not use much
(if any) OO features, so translating it to C should be not much work
(i don't know why C++ is used here at all, seems like a Windows thing, where
C++ was promoted since plain C was declared "obsolote" by M$.).
the code can directly work on unicode strings.
> In some respects yes. In other respects no.
> On Linux you need to link with pthreads of you use that;
> not so on other systems. On Solaris you need
> to link with nt if you want to use the network API
> (socket(), bind(), accept(), etc) but no so with other Unix systems.
i was merely talking about basic functionality (mostly found in <unistd.h>)
like get(ugp)id, chdir (!!!!!), chmod, chown and the like which are wrappers
around kernel syscalls in the libc and require no libs other than libc
(which is used by lua anyway, so way not exploiting that a bit more ?).
but as we are at it:
if Lua is build on Linux, BSD, Solaris etc the platform is know at build time
(via feature test macros and makefile rules, see below), so one could indeed
build in socket/thread support and use other platform specifics which are
provided by default vendor libs.
> On Windows, POSIX isn't part of the C library
> (although I could be wrong, but I would find it surprising).
but even M$ provides some limited POSIX functionality.
but this is not much of a problem, see below.
sounds a bit like you don't use their nice products anyway. :D
maybe even if you were paid for doing so, who knows ? ;-)
> Okay, round two. If I have a program that makes use of pthreads, on
> Solaris it comes "for free" (your terms) in libc. On Linux, the pthreads
> API is NOT in libc, so it's not "for free" in that reguard
> -- you have to link with libpthread.
> if I have a program that uses socket(), bind(), accept(), listen(), etc.
> (the Berkeley sockets API), those calls come "for free" on
> Linux --they're part of libc.
> On Solaris, they are not "for free" --they are not part of
> libc and you are required to link against libnt.
but we can easily figure out where we are compiling and react accordingly.
> On Windows, you don't even get get*id(), umask(), fork() or wait() AT ALL!
> Windows does not natively support POSIX.
dunno, don't use it. but i am sure it can be detected by feature test macros
(OS and compiler ("Visual Sudio" ?)).
in the case of POSIX functionality POSIX macros HAVE to be #defined.
when building the OS information is provided by the make call as in
"make linux", "make solaris" etc. so we know the OS without such preprocessor
macros anyway.
> I don't know which Unix you are using, but the ones I've had
> experience with never came with regex "for free" (as part of libc).
Linux with glibc and musl (the latter uses the TRE lib.
i am sure ulibc has that as well). ever used that ?
when trying it out have a look at /usr/include/regex*.h and man 3 regex.
same for the BSDs and of course macOS, Solaris, AIX, and HP-UX since they are
certified (and marketed) as conforming to POSIX standards.
>> well posix requires regex to be found in <regex.h>, so every unix has
>> them, from aix to the bsds, its in the libc that one has to use anyway.
>> so its there for FREE on all relevant unix platforms.
> Again, not always so in my exerience.
what non POSIX OS do you use ?
the major one is Windows and even that provides some limited POSIX support.