Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Still no dirent.h in C1X

Reply
Thread Tools

Still no dirent.h in C1X

 
 
Markus Wichmann
Guest
Posts: n/a
 
      11-25-2011
On 25.11.2011 21:38, Kaz Kylheku wrote:
> I haven't looked at the threads in C1X, but it would be ridiculous if it
> was just a copy of <pthread.h> stuff from POSIX.
>


It is. Basically, if you prefix every function with "pthread_" and spell
out the second part completely ("cnd" -> "cond", "mtx"->"mutex", etc.)
you get the complete POSIX threads library.

Which is funny, because that itself is a library on Linux, wrapping
around system calls. So, up until now the C library wrapped system
calls, and now the C libary wraps the thread library, which wraps the
system calls. Nice job!

CYA,
Markus
 
Reply With Quote
 
 
 
 
Ben Pfaff
Guest
Posts: n/a
 
      11-25-2011
David Demelier <(E-Mail Removed)> writes:

> I've seen the new standard of C called C1x.
> http://www.open-std.org/JTC1/SC22/wg...docs/n1250.pdf
>
> They added some great features like anonymous unions and threads. But
> there is still no directory management. I think that's very annoying.
> Why threads should be added and dirent.h should not ?


Threads strike right at the heart of the language. They require
compiler support to have any assurance that they will work
correctly.

In contrast, directory support is just a library.
--
Go not to Usenet for counsel, for they will say both no and yes.
 
Reply With Quote
 
 
 
 
Richard Damon
Guest
Posts: n/a
 
      11-26-2011
On 11/25/11 5:54 PM, Markus Wichmann wrote:
....

>
> Yeah, that appears to be quite stunning. To my knowledge, any OS out
> there with multitasking capabilities should have a file system. Or are
> there counter examples?
>

....

>
> HTH,
> Markus


The question comes, do they all support them is a close enough manner
that a usable portable definition could be defined if the standard
extended the current file primitives to directories.

We do already have a POSIX standard which defines this for one major
class of systems. It would NOT make sense to just adopt that for C, as
then suddenly OSes that are NOT POSIX compatible might have a hard time
implementing the standard.

There is nothing wrong in using standards beyond the C standard in
defining your program (as long as they are compatible with it, and you
environment supports it).

This currently means that if you want to use <dirent.h>, you just need
to document that you program requires C/POSIX not just C as the
environment. This also means that you have available everything that
POSIX supplies. If the C standard did adopt a directory library you
would probably be complaining that it doesn't provide enough capability,
as it would be less than what you get from POSIX, and likely to remain
backwards compatible, (avoiding gratuitous incompatibilities with the
POSIX standard), the include file would likely be given a different name
and the functions would have different names.
 
Reply With Quote
 
Malcolm McLean
Guest
Posts: n/a
 
      11-26-2011
On Nov 25, 10:01*pm, Quentin Pope <(E-Mail Removed)> wrote:
>
> You may not be aware that many, probably the majority, of C programs run
> on systems without any notion of directories. For example, embedded
> processors, but also many mainframe systems. It's only a few months ago
> that I was doing some maintenance work on a UNISYS A Series, which has a
> flat file system. This is not unusual for mainframes in current use.
>
> C should not be ladened with cruft that simply doesn't make sense on a
> large proportion of implementations.
>

A lot of my programs could be written in pure ANSI C, with the
exception of a couple of calls to directory functions. Or are written
in ANSI C and need the user to create an empty directory and pass a
commandline argument to it.



 
Reply With Quote
 
Seebs
Guest
Posts: n/a
 
      11-26-2011
On 2011-11-25, Markus Wichmann <(E-Mail Removed)> wrote:
> Yeah, that appears to be quite stunning. To my knowledge, any OS out
> there with multitasking capabilities should have a file system. Or are
> there counter examples?


File system is... well. Not all filesystems have directory structure as
such, or compatible directory structures. Some embedded systems have
filesystems optional, so whether or not you have anything like that is
variable.

Mostly, though... I think the <dirent.h> approach is probably wrong. Among
other things, consider the mandate of a 32-bit "fileno" which uniquely
identifies a file. There are filesystems on which that may be either very
expensive or impossible.

> If you think mandating the existence of directory listing facilities in
> the OS would lessen portability, I think you are wrong. That is because
> either there is _any_ kind of file system, then you can enumerate the
> files, or there isn't, then you can't. However, in a hosted environment
> C already mandates the existence of files. (As seen in <stdio.h>)


It doesn't mandate the existence of directories, though. Or indeed the
existence of any *specific* files. So far as I can tell, an implementation
where fopen() always returns NULL could be conforming.

-s
--
Copyright 2011, all wrongs reversed. Peter Seebach / http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
 
Reply With Quote
 
Kleuske
Guest
Posts: n/a
 
      11-26-2011
On Fri, 25 Nov 2011 23:54:01 +0100, Markus Wichmann saw fit to publish the
following:

> On 25.11.2011 21:01, Quentin Pope wrote:
>> On Thu, 24 Nov 2011 04:43:26 -0800, David Demelier wrote:
>>> Hello,
>>>
>>> I've seen the new standard of C called C1x.
>>> http://www.open-std.org/JTC1/SC22/wg...docs/n1250.pdf
>>>
>>> They added some great features like anonymous unions and threads. But
>>> there is still no directory management. I think that's very annoying.
>>> Why threads should be added and dirent.h should not ?

>>
>>

> Yeah, that appears to be quite stunning. To my knowledge, any OS out
> there with multitasking capabilities should have a file system. Or are
> there counter examples?


http://en.wikipedia.org/wiki/Ucos

There are more OS's like that, some proprietary.

<snip>

>> C should not be ladened with cruft that simply doesn't make sense on a
>> large proportion of implementations.
>>

> _Complex was already named. Apart from that, in my (little) experience,
> programming for embedded processors takes place in a freestanding
> environment, rendering the entire Section 7 useless there (OK, not
> entirely, but there isn't much left in a freestanding environment).


There's no requirement of using a freestanding implementation.

> What's more: The standard library already contains enough cruft to sink
> a cruiser, so I don't get where there should be harm in adding more
> stuff.


For one, it may be quite tricky to design/specify a common interface for
any number of file-system implementations without reverting to a gretest
common denominator and hence inhibiting native functionality and, again,
many systems don't have one.

Hence it's more convenient, all around, to leave it to the OS-designers
to provide system-specific functionality and interfaces. As does POSIX.

<snip>

--
Violence in reality is quite different from theory.
-- Spock, "The Cloud Minders", stardate 5818.4
 
Reply With Quote
 
Kaz Kylheku
Guest
Posts: n/a
 
      11-26-2011
On 2011-11-25, Markus Wichmann <(E-Mail Removed)> wrote:
> On 25.11.2011 21:38, Kaz Kylheku wrote:
>> I haven't looked at the threads in C1X, but it would be ridiculous if it
>> was just a copy of <pthread.h> stuff from POSIX.
>>

>
> It is. Basically, if you prefix every function with "pthread_" and spell
> out the second part completely ("cnd" -> "cond", "mtx"->"mutex", etc.)
> you get the complete POSIX threads library.


That is ****ing stupid, but it's what you expect from a committee working on
the N-th revision of a programming language.
 
Reply With Quote
 
James
Guest
Posts: n/a
 
      11-26-2011
"Markus Wichmann" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On 25.11.2011 21:38, Kaz Kylheku wrote:
>> I haven't looked at the threads in C1X, but it would be ridiculous if it
>> was just a copy of <pthread.h> stuff from POSIX.
>>

>
> It is. Basically, if you prefix every function with "pthread_" and spell
> out the second part completely ("cnd" -> "cond", "mtx"->"mutex", etc.)
> you get the complete POSIX threads library.


Pthreads does not provide atomic operations and memory barriers. However,
C1X does have them. FINALLY!

[...]


 
Reply With Quote
 
Stephen Sprunk
Guest
Posts: n/a
 
      11-26-2011
On 25-Nov-11 14:18, jacob navia wrote:
> Le 25/11/11 21:01, Quentin Pope a écrit :
>> You may not be aware that many, probably the majority, of C programs run
>> on systems without any notion of directories.

>
> Where is your data for such sweeping generalizations?
>
> According to several surveys, for instance this one:
>
> http://langpop.com/


The "data" there is completely useless.

> C is one of the most popular computer languages ever.


By pretty much any measure, yes. However, popularity is not the claim
in question.

> Applications like the linux kernel, many RDBMS like
> Sqlite, and a LONG etc disprove your supposition that
> C is used in embedded systems where there isn't a file
> system.


How does the fact C is used for one thing disprove that it is used for
another thing?

For many embedded systems, the _only_ language available is C, and there
is no OS to speak of. Many don't have file systems at all, and of those
that have file systems, some don't have a concept of directories because
they only need to manage a small (and fixed) set of files.

Embedded systems outnumber hosted systems by at least an order of magnitude.

S

--
Stephen Sprunk "God does not play dice." --Albert Einstein
CCIE #3723 "God is an inveterate gambler, and He throws the
K5SSS dice at every possible opportunity." --Stephen Hawking
 
Reply With Quote
 
Stefan Ram
Guest
Posts: n/a
 
      11-26-2011
Richard Damon <(E-Mail Removed)> writes:
>The question comes, do they all support them is a close enough manner
>that a usable portable definition could be defined if the standard
>extended the current file primitives to directories.


See also:

http://www.purl.org/stefan_ram/pub/c..._extensions_en

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
posting history -- wording of C1X sequencing Ersek, Laszlo C Programming 1 09-24-2010 12:43 AM
On alignment (final committee draft for C++0x and n1425 for C1X) Gennaro Prota C++ 2 08-25-2010 11:43 PM
On alignment (final committee draft for C++0x and n1425 for C1X) Gennaro Prota C++ 6 08-25-2010 04:37 PM
improved C1X security Robert Seacord C Programming 7 08-15-2008 10:18 AM
Who knows more information about the next ISO C standard "C1x" ? Royt C Programming 2 03-16-2008 01:05 PM



Advertisments