From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2913 Path: news.gmane.org!not-for-mail From: Zvi Gilboa Newsgroups: gmane.linux.lib.musl.general Subject: Re: question: hard-coded file descriptors in stdin/stdout/stderr Date: Thu, 14 Mar 2013 13:51:19 -0400 Message-ID: <51420E17.9030305@eservices.virginia.edu> References: <5141F86D.8010000@eservices.virginia.edu> <20130314171752.GB19010@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1363283500 2796 80.91.229.3 (14 Mar 2013 17:51:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 14 Mar 2013 17:51:40 +0000 (UTC) To: Original-X-From: musl-return-2914-gllmg-musl=m.gmane.org@lists.openwall.com Thu Mar 14 18:52:01 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1UGCJn-0005sG-Bc for gllmg-musl@plane.gmane.org; Thu, 14 Mar 2013 18:51:55 +0100 Original-Received: (qmail 32018 invoked by uid 550); 14 Mar 2013 17:51:32 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 32010 invoked from network); 14 Mar 2013 17:51:32 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4 In-Reply-To: <20130314171752.GB19010@port70.net> X-Originating-IP: [68.229.98.213] Xref: news.gmane.org gmane.linux.lib.musl.general:2913 Archived-At: >> which ones? ... since you are asking... inspired by musl-libc, I am currently writing a win32/win64 open-source library that implements/provides POSIX system calls (see note below). I believe that having a powerful libc with an MIT license available on Windows would actually be of great value to the open source community for all possible reasons, but that is of course irrelevant to my question:) The main issue here is that the standard file descriptors on Windows are -10 (STD_INPUT_HANDLE), -11 (STD_OUTPUT_HANDLE), and -12 (STD_ERROR_HANDLE). I could of course compensate for that in my code and "translate" the POSIX special file descriptor numbers to the Windows ones, however it would be more elegant if musl-libc used the descriptors defined in instead of hard-coded numbers. * as for psxcalls: this is a C library, that exclusively uses the Native API. It attaches to ntdll.dll during run-time, and can thus be compiled as a "native" static library with no external dependencies. While it is currently in its very initial stage (and not yet online), the major "obstacle" features -- including fork() -- have already been implemented. To remove all doubts, I am aware of Cygwin's existence, yet am looking for a high-performance solution that would be both "clean" (psxcalls-->libc-->user-library-or-application), and flexibly licensed. Best regards, Zvi On 03/14/2013 01:17 PM, Szabolcs Nagy wrote: > * Zvi Gilboa [2013-03-14 12:18:53 -0400]: >> I just noticed that the file descriptors in stdin.c, stdout.c, and >> stderr.c do not use the #defines from (namely >> STDIN_FILENO, STDOUT_FILENO, and STDERR_FILENO), but are rather >> hard-coded (as 0, 1, and 2 respectively). I was therefore wondering > these numbers are fixed on posix (and linux and all historical unices) > > the macro definitions are there for conformance reasons > > it's like using 0 instead of NULL or -1U instead of UINT_MAX > > >> this would normally not be an issue, however there are still some >> systems out there with standard file descriptor numbers which are >> different... > which ones? > >> On that same note: wouldn't it make sense to slightly modify >> unistd.h so that it first checks whether STDIN_FILENO, etc. have > i dont think it makes sense for a linux libc > to have these numbers configurable