From owner-freebsd-questions@freebsd.org Tue Jan 15 12:51:47 2019 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DAD16148A13F for ; Tue, 15 Jan 2019 12:51:46 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mout.kundenserver.de (mout.kundenserver.de [217.72.192.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "mout.kundenserver.de", Issuer "TeleSec ServerPass DE-2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C7D2C86463 for ; Tue, 15 Jan 2019 12:51:45 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from r56.edvax.de ([92.193.226.69]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPA (Nemesis) id 1MvsMz-1hZ9HU3EJD-00suTx; Tue, 15 Jan 2019 13:46:23 +0100 Date: Tue, 15 Jan 2019 13:46:23 +0100 From: Polytropon To: iam@sdf.org Cc: freebsd-questions@freebsd.org Subject: Re: if userland in asm, no need for libc? Message-Id: <20190115134623.4a49687e.freebsd@edvax.de> In-Reply-To: <201901151224.x0FCOHbM016508@sdf.org> References: <201901151224.x0FCOHbM016508@sdf.org> Reply-To: Polytropon Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:0V9cSGP2dDKHO58vjqwPzZbj/nIZJb4qDsk1eUTgkywYFq+HPzT pp4I1u/3qt/pzT7vXhm8+9FK9pPoU3O89R7NSrOCnLdcxjJBm+xwqylcrQlQcPfPMMVoQDw o06/pizZ18CYrwX2Z2tNxtBjAojjXugiOwPuYmDBPEZZ2aJpv7jLIrg4IEVbA7oFW3vHOd+ 3x81ApUDp9MlE/BPkP6Xg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:ZqWQu4n8V+U=:HsrKWAok+DaGzhBNyEl3uQ e+R0K0QK3W1uqBWflLL6Hljk83hrhhHiGVi34pRJOe9kJnr3Ozyew6cNiisRL7KZ1AvF1AIBO uzmJLIe2s9QrJnuo3ZCQVAVwGNkJdEhV6l9y/BPxt4Fd7VLg7LRqEtGZMSXXf0r3ULCHFNrH5 DtiTh1XwQ7qmQEKnQvWsPO4sAOFQoa4kgWNAZAfb4ravF/hjs/nwmLD+JVLmtGaxjZis+NVE4 09sm7o4gDgFQkfX3aRAG6DHgoNUSEqeHeGyrO6wQrEm/VoZAOZtSI1atmla6PUJG6TN6eW4uE Mu4cZips+pQiW9S5IVug/+RiR8QGzSSP+kjjYyGvBNOpLJRD+LwqaSPjpwrV+L5/58/empeWK Fcl/xcwnG3iq1BTH/AJDbbekH8ppsyQt9CdWA8q33biHKufQ4pS5TCsgoUoPcdud5xoZgVAs3 /6ocnAOZ8zrQqg9vvbxUxQicS/3Hsiyo9RpYWcc2t9Q86aBn0u2XJYy9ZdR4eMdQOmgzrSxAr 1n/jRzRit6RoL3xi4hsddZGxpwYZ7R/OSCMAacvCM/mbollHzlu+0Qs72qImxezE9ZMgmT6PJ CUY8ScfWiIzWZ5+y0SKHNKJAlfOmOQZYnDKK1rovsiv1Tl9nDsEDNe69cfZQEll5sAWROOdzh 8qGEmVS92YOaufdjUuOLYH6pjaHxCuN+LlBY39ya6Ykys66yMV7pf+7F+GHc5G5Dw8koG9nrb TTvpPEpHlW6z/aKuCv18Vy4QfFPO3ft27ebaGOSFYCV6M8qr/Z3b9AjxBfY= X-Rspamd-Queue-Id: C7D2C86463 X-Spamd-Bar: ++++++ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [6.01 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; HAS_REPLYTO(0.00)[freebsd@edvax.de]; MV_CASE(0.50)[]; IP_SCORE(0.02)[ipnet: 217.72.192.0/20(-0.54), asn: 8560(0.65), country: DE(-0.01)]; TO_DN_NONE(0.00)[]; HAS_ORG_HEADER(0.00)[]; MX_GOOD(-0.01)[cached: mx01.schlund.de]; RCPT_COUNT_TWO(0.00)[2]; RECEIVED_SPAMHAUS_PBL(0.00)[69.226.193.92.zen.spamhaus.org : 127.0.0.10]; R_DKIM_NA(0.00)[]; SUBJECT_ENDS_QUESTION(1.00)[]; ASN(0.00)[asn:8560, ipnet:217.72.192.0/20, country:DE]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; ARC_NA(0.00)[]; REPLYTO_EQ_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; NEURAL_SPAM_SHORT(0.86)[0.856,0]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[edvax.de]; AUTH_NA(1.00)[]; NEURAL_SPAM_MEDIUM(0.75)[0.751,0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_SPAM_LONG(0.99)[0.988,0]; RCVD_IN_DNSWL_NONE(0.00)[73.192.72.217.list.dnswl.org : 127.0.5.0]; MID_CONTAINS_FROM(1.00)[]; R_SPF_NA(0.00)[]; RWL_MAILSPIKE_POSSIBLE(0.00)[73.192.72.217.rep.mailspike.net : 127.0.0.17]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_LAST(0.00)[] X-Spam: Yes X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Jan 2019 12:51:47 -0000 On Tue, 15 Jan 2019 12:24:17 GMT, iam@sdf.org wrote: > in continuum to my previous mail about libc; > if the whole of userland and various other toolkits were written > in assembly language, would there be no need for libc, that is > if "c" were not needed to be supported at all? Even a userland written in assembly _could_ interface with the C library, i. e., call functions that are defined in there. For this kind of interfacing, it doesn't really matter which language has been used to create the library. Keep in mind libc is "just a library", which is an archive of object code (machine code "snippets"). Given a specific calling convention, even assembly language can make use of it. However, to come back to your initial question: It would be possible to implement userland programs on the basis of kernel interfaces and system calls, not using libc at all. But that implies you'd have to implement a lot (!) of functionality yourself. Remember strcmp(), or fopen(), or signal()? All those facilities wouldn't be available. Now you could say: Well, I create a library myself with all those "subroutines" I permanently need to use. So what would you end up with? With a libc equivalent. ;-) > do assembly language programs have the capacity to make kernel > calls directly? i.e., without going through any libraries? Of course. There is a specific calling convetion that will enable you to perform system calls, and this is a common way to "relay" work to the kernel. The exact way to do this of course depends on the OS, and it is different between FreeBSD and Linux (e. g., "int 80h" vs. "syscall"), which makes this kind of programming nonportable. Early stages of the boot process as well as device drivers, being developed for _one_ OS in particular, don't have to care for being that portable... :-) -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...