Deutsch English Français Italiano |
<20240330112105.553@kylheku.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Kaz Kylheku <643-408-1753@kylheku.com> Newsgroups: comp.unix.shell,comp.unix.programmer,comp.lang.misc Subject: Re: Command Languages Versus Programming Languages Date: Sat, 30 Mar 2024 18:46:50 -0000 (UTC) Organization: A noiseless patient Spider Lines: 74 Message-ID: <20240330112105.553@kylheku.com> References: <uu54la$3su5b$6@dont-email.me> <uu636l$7haj$1@dont-email.me> <20240329084454.0000090f@gmail.com> <uu6om5$cmv8$1@dont-email.me> <20240329101248.556@kylheku.com> <uu6t9h$dq4d$1@dont-email.me> <20240329104716.777@kylheku.com> <uu8p02$uebm$1@dont-email.me> Injection-Date: Sat, 30 Mar 2024 18:46:50 +0100 (CET) Injection-Info: dont-email.me; posting-host="59a90be9cb8ca6b8cdebb54e344432f2"; logging-data="1230317"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/bw361GgctdzKMfy7l+/o2+zbY4Px5YZU=" User-Agent: slrn/pre1.0.4-9 (Linux) Cancel-Lock: sha1:NpyvzI2/VzxHejc/kPmlde85RMI= Bytes: 4680 On 2024-03-30, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote: > On Fri, 29 Mar 2024 17:58:41 -0000 (UTC) > Kaz Kylheku <643-408-1753@kylheku.com> wrote: >>On 2024-03-29, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote: >>> Were the mucky bits actually written in Lisp or was Lisp simply calling some >>> routines written in assembler? >> >>Sorry, could you demarcate where exactly the goalposts are? Which mucky >>bits? > > Oh I dunno, the parts that walk a kernel memory structure for example. Well, since the kernel is written in Lisp, of course Lisp walks its own data structures. In a kernel, there often occur externally imposed memory structures, like for instance lists of entries in a DMA buffer ring above an ethernet device. Or banks of registers. The kernel-writing Lisp dialect would have provisions for dealing with binary structures like that. The following example is not from a Lisp operating system, or a Lisp that is known for operating system work. It's from my own application. It shows how in CCL (Clozure Common Lisp) (note: note the Z, not Clojure with a J) we can obtain a linked list C data structure and walk it, using some CCL-specific concepts; CCL provides #> notations for C types, and offsets into C structures and such. The GetAdaptersInfo Win32 API is called, filling the list into a stack-allocated buffer, with the help of CCL's %stack-block operator. We get a list of adapters, each of which is a list consisting of a list of the mac bytes, IP address list, name and description. (The information is then encrypted, hashed and tied to a software license, along with other bits of system info.) (defun get-network-interface-list () (open-shared-library "iphlpapi.dll") (let ((blk-size 65536) ;; crude! (get-adapters-info (foreign-symbol-address "GetAdaptersInfo"))) (if get-adapters-info (%stack-block ((blk blk-size)) (rlet ((len-inout #>ULONG blk-size)) (if (zerop (ff-call get-adapters-info :address blk :address len-inout #>DWORD)) (loop for ptr = blk then (pref ptr #>IP_ADAPTER_INFO.Next) until (%null-ptr-p ptr) collecting (let ((alen (pref ptr #>IP_ADAPTER_INFO.AddressLength)) (addr (pref ptr #>IP_ADAPTER_INFO.Address)) (aname (pref ptr #>IP_ADAPTER_INFO.AdapterName)) (descr (pref ptr #>IP_ADAPTER_INFO.Description)) (iplist (pref ptr #>IP_ADAPTER_INFO.IpAddressList)) (type (pref ptr #>IP_ADAPTER_INFO.Type))) (list type (loop for i below alen collecting (%get-unsigned-byte addr i) into mac-bytes finally (return (mac-bytes-to-string mac-bytes))) (get-ip-address-list iplist) (%get-cstring aname) (%get-cstring descr)))))))))) CCL is compiled; this just turns into a machine language function poking at stack memory. -- TXR Programming Language: http://nongnu.org/txr Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal Mastodon: @Kazinator@mstdn.ca